Apollo 11.0
自动驾驶开放平台
driving_state_generator.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
17
20
21namespace apollo {
22namespace planning {
23
25 const ReferenceLineInfo* reference_line_info, const EgoInfo* ego_info,
27 if (nullptr != ego_info->adc_waypoint().lane) {
28 state->set_lane_id(ego_info->adc_waypoint().lane->id().id());
29 state->set_s_in_lane(ego_info->adc_waypoint().s);
30 }
31
32 state->set_distance_to_destination(ego_info->distance_to_destination());
33 if (nullptr == reference_line_info) {
34 AERROR << "DriveReferenceLineInfo is nullptr";
35 return;
36 }
37
38 state->set_is_in_junction(
39 planning::util::CheckInsideJunction(*reference_line_info));
40
41 add_path_info(reference_line_info, state);
42 add_lane_info(reference_line_info, state);
43 add_nudge_info(reference_line_info, state);
44}
45
47 const ReferenceLineInfo* reference_line_info,
49 state->set_lane_change_type(planning_internal::NO_CHANGE);
50 state->set_lane_borrow_type(planning_internal::NO_BORROW);
51 const PathData current_path_data = reference_line_info->path_data();
52 if (reference_line_info->IsChangeLanePath() ||
53 current_path_data.path_label().find("lane_change") != std::string::npos) {
54 if (reference_line_info->Lanes().PreviousAction() ==
56 state->set_lane_change_type(planning_internal::LEFT_CHANGE);
57 } else if (reference_line_info->Lanes().PreviousAction() ==
59 state->set_lane_change_type(planning_internal::RIGHT_CHANGE);
60 }
61 } else {
62 if (current_path_data.path_label().find("left") != std::string::npos) {
63 state->set_lane_borrow_type(planning_internal::LEFT_BORROW);
64 } else if (current_path_data.path_label().find("right") !=
65 std::string::npos) {
66 state->set_lane_borrow_type(planning_internal::RIGHT_BORROW);
67 }
68 }
69 if (current_path_data.path_label().find("fallback") != std::string::npos) {
70 state->set_is_fallback(true);
71 }
72}
73
75 const ReferenceLineInfo* reference_line_info,
77 double adc_s = (reference_line_info->AdcSlBoundary().start_s() +
78 reference_line_info->AdcSlBoundary().end_s()) *
79 0.5;
80 double route_lane_start_s = 0.0;
81 double route_lane_end_s = 0.0;
82 for (const auto& seg : reference_line_info->Lanes()) {
83 const auto& turn_type = seg.lane->lane().turn();
84
85 route_lane_start_s = route_lane_end_s;
86 route_lane_end_s += seg.end_s - seg.start_s;
87
88 AINFO << "s: " << route_lane_start_s << ", " << route_lane_end_s
89 << ", ego s: " << adc_s;
90 AINFO << "turn_type: " << turn_type;
91
92 if (route_lane_end_s < adc_s) {
93 continue;
94 }
95 if (route_lane_start_s < adc_s + 0.01) {
96 state->set_cur_turn_info(seg.lane->lane().turn());
97 continue;
98 }
99 if (turn_type == hdmap::Lane::LEFT_TURN ||
100 turn_type == hdmap::Lane::RIGHT_TURN ||
101 turn_type == hdmap::Lane::U_TURN) {
102 state->mutable_next_turn_info()->set_turn_type(turn_type);
103 state->mutable_next_turn_info()->set_dis_to_turn(route_lane_start_s -
104 adc_s);
105 break;
106 }
107 }
108}
109
111 const ReferenceLineInfo* reference_line_info,
113 SLBoundary adc_sl_boundary = reference_line_info->AdcSlBoundary();
114 const auto path_decision = reference_line_info->path_decision();
115 double nearest_nudge_obs_dis = 1000.0;
116 for (auto sl_polygon : reference_line_info->obs_sl_polygons()) {
117 if (sl_polygon.NudgeInfo() == SLPolygon::IGNORE ||
118 sl_polygon.NudgeInfo() == SLPolygon::UNDEFINED ||
119 !sl_polygon.OverlapeWithReferCenter()) {
120 continue;
121 }
122
123 const Obstacle* perception_obs = path_decision.Find(sl_polygon.id());
124 if (!perception_obs) {
125 AERROR << "Failed to find obstacle : " << sl_polygon.id();
126 continue;
127 }
128
129 auto nudge_obstacle_debug = state->add_nudge_obstacle();
130 nudge_obstacle_debug->set_is_blocked(false);
131 if (sl_polygon.NudgeInfo() == SLPolygon::LEFT_NUDGE) {
132 nudge_obstacle_debug->set_type(
134 } else if (sl_polygon.NudgeInfo() == SLPolygon::RIGHT_NUDGE) {
135 nudge_obstacle_debug->set_type(
137 } else if (sl_polygon.NudgeInfo() == SLPolygon::BLOCKED) {
138 nudge_obstacle_debug->set_type(
140 nudge_obstacle_debug->set_is_blocked(true);
141 }
142
143 if (sl_polygon.MinS() - adc_sl_boundary.end_s() < nearest_nudge_obs_dis) {
144 nearest_nudge_obs_dis = sl_polygon.MinS() - adc_sl_boundary.end_s();
145 }
146
147 nudge_obstacle_debug->mutable_obstacle()->set_id(perception_obs->Id());
148 nudge_obstacle_debug->mutable_obstacle()->mutable_sl_boundary()->CopyFrom(
149 perception_obs->PerceptionSLBoundary());
150 }
151 const auto& reference_line_towing_l =
152 reference_line_info->reference_line_towing_l();
153 double towing_l = 0.0;
154 if (reference_line_towing_l.size() > 0) {
155 towing_l = reference_line_towing_l.at(0);
156 }
157 if (nearest_nudge_obs_dis < 6.0 &&
158 std::abs((adc_sl_boundary.start_l() + adc_sl_boundary.end_l()) * 0.5 -
159 towing_l) > FLAGS_driving_state_nudge_check_l) {
160 state->set_is_nudging(true);
161 } else {
162 state->set_is_nudging(false);
163 }
164}
165
166} // namespace planning
167} // namespace apollo
routing::ChangeLaneType PreviousAction() const
Get the previous change lane action need to take by the vehicle to reach current segment,...
void add_path_info(const ReferenceLineInfo *reference_line_info, planning_internal::ADCDrivingState *const state)
void add_lane_info(const ReferenceLineInfo *reference_line_info, planning_internal::ADCDrivingState *const state)
void add_nudge_info(const ReferenceLineInfo *reference_line_info, planning_internal::ADCDrivingState *const state)
void generate(const ReferenceLineInfo *reference_line_info, const EgoInfo *ego_info, planning_internal::ADCDrivingState *const state)
apollo::hdmap::LaneWaypoint adc_waypoint() const
Definition ego_info.h:67
double distance_to_destination() const
Definition ego_info.h:65
This is the class that associates an Obstacle with its path properties.
Definition obstacle.h:62
const std::string & Id() const
Definition obstacle.h:75
const SLBoundary & PerceptionSLBoundary() const
Definition obstacle.cc:694
const std::string & path_label() const
Definition path_data.cc:264
ReferenceLineInfo holds all data for one reference line.
const std::vector< SLPolygon > & obs_sl_polygons() const
const std::vector< double > & reference_line_towing_l() const
const hdmap::RouteSegments & Lanes() const
const SLBoundary & AdcSlBoundary() const
bool IsChangeLanePath() const
Check if the current reference line is a change lane reference line, i.e., ADC's current position is ...
Planning module main class.
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
bool CheckInsideJunction(const ReferenceLineInfo &reference_line_info)
Definition util.cc:115
class register implement
Definition arena_queue.h:37
LaneInfoConstPtr lane
Definition path.h:44