Apollo 10.0
自动驾驶开放平台
apollo::planning::PathAssessmentDeciderUtil类 参考

#include <path_assessment_decider_util.h>

apollo::planning::PathAssessmentDeciderUtil 的协作图:

静态 Public 成员函数

static bool IsValidRegularPath (const ReferenceLineInfo &reference_line_info, const PathData &path_data)
 Check if the generated path is valid
 
static bool IsGreatlyOffReferenceLine (const PathData &path_data)
 
static bool IsGreatlyOffRoad (const ReferenceLineInfo &reference_line_info, const PathData &path_data)
 
static bool IsCollidingWithStaticObstacles (const ReferenceLineInfo &reference_line_info, const PathData &path_data)
 
static bool IsStopOnReverseNeighborLane (const ReferenceLineInfo &reference_line_info, const PathData &path_data)
 
static void InitPathPointDecision (const PathData &path_data, const PathData::PathPointType type, std::vector< PathPointDecision > *const path_point_decision)
 Init path_point_decision as type
 
static void TrimTailingOutLanePoints (PathData *const path_data)
 Trim the points at tail of path which away from lane
 

详细描述

在文件 path_assessment_decider_util.h33 行定义.

成员函数说明

◆ InitPathPointDecision()

void apollo::planning::PathAssessmentDeciderUtil::InitPathPointDecision ( const PathData path_data,
const PathData::PathPointType  type,
std::vector< PathPointDecision > *const  path_point_decision 
)
static

Init path_point_decision as type

参数
path_datais input generated path
typeis input init type of point decision
path_point_decisionis output point decision which indicate each point decision in path

在文件 path_assessment_decider_util.cc245 行定义.

247 {
248 // Sanity checks.
249 CHECK_NOTNULL(path_point_decision);
250 path_point_decision->clear();
251
252 // Go through every path point in path data, and initialize a
253 // corresponding path point decision.
254 for (const auto& frenet_path_point : path_data.frenet_frame_path()) {
255 path_point_decision->emplace_back(frenet_path_point.s(), type,
256 std::numeric_limits<double>::max());
257 }
258}

◆ IsCollidingWithStaticObstacles()

bool apollo::planning::PathAssessmentDeciderUtil::IsCollidingWithStaticObstacles ( const ReferenceLineInfo reference_line_info,
const PathData path_data 
)
static

在文件 path_assessment_decider_util.cc97 行定义.

98 {
99 // Get all obstacles and convert them into frenet-frame polygons.
100 std::vector<const Obstacle*> obstacles;
101 const auto& indexed_obstacles =
102 reference_line_info.path_decision().obstacles();
103 const auto& vehicle_param =
105 double front_edge_to_center = vehicle_param.front_edge_to_center();
106 double back_edge_to_center = vehicle_param.back_edge_to_center();
107 double path_point_lateral_buffer =
108 std::max(vehicle_param.width() / 2.0, vehicle_param.length() / 2.0);
109 for (const auto* obstacle : indexed_obstacles.Items()) {
110 // Filter out unrelated obstacles.
112 continue;
113 }
114 // Ignore too small obstacles.
115 const auto& obstacle_sl = obstacle->PerceptionSLBoundary();
116 if ((obstacle_sl.end_s() - obstacle_sl.start_s()) *
117 (obstacle_sl.end_l() - obstacle_sl.start_l()) <
119 continue;
120 }
121 obstacles.push_back(obstacle);
122 }
123 // Go through all the four corner points at every path pt, check collision.
124 const auto& frenet_path = path_data.frenet_frame_path();
125 for (size_t i = 0; i < path_data.discretized_path().size(); ++i) {
126 // Skip the point after end point.
127 if (path_data.frenet_frame_path().back().s() -
128 path_data.frenet_frame_path()[i].s() <
129 (FLAGS_num_extra_tail_bound_point + 1) *
130 FLAGS_path_bounds_decider_resolution +
131 vehicle_param.length()) {
132 break;
133 }
134 double path_point_start_s = frenet_path[i].s() - back_edge_to_center;
135 double path_point_end_s = frenet_path[i].s() + front_edge_to_center;
136 double path_point_start_l = frenet_path[i].l() - path_point_lateral_buffer;
137 double path_point_end_l = frenet_path[i].l() + path_point_lateral_buffer;
138 // Check the points near the obstacles
139 for (const auto* obstacle : obstacles) {
140 const auto& obstacle_sl = obstacle->PerceptionSLBoundary();
141 // Filter the path points by s range.
142 if (obstacle_sl.start_s() > path_point_end_s ||
143 obstacle_sl.end_s() < path_point_start_s) {
144 continue;
145 }
146 if (obstacle_sl.start_l() > path_point_end_l ||
147 obstacle_sl.end_l() < path_point_start_l) {
148 continue;
149 }
150 const auto& path_point = path_data.discretized_path()[i];
151 const auto& vehicle_box =
152 common::VehicleConfigHelper::Instance()->GetBoundingBox(path_point);
153 const std::vector<Vec2d>& ABCDpoints = vehicle_box.GetAllCorners();
154 const common::math::Polygon2d& obstacle_polygon =
155 obstacle->PerceptionPolygon();
156 for (const auto& corner_point : ABCDpoints) {
157 if (obstacle_polygon.IsPointIn(corner_point)) {
158 AERROR << "ADC is colliding with obstacle at path s = "
159 << path_point.s() << ", with obstacle " << obstacle->Id();
160 return true;
161 }
162 }
163 }
164 }
165 return false;
166}
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
static bool IsWithinPathDeciderScopeObstacle(const Obstacle &obstacle)
Is obstacle should be considered in path decision
#define AERROR
Definition log.h:44
optional VehicleParam vehicle_param

◆ IsGreatlyOffReferenceLine()

bool apollo::planning::PathAssessmentDeciderUtil::IsGreatlyOffReferenceLine ( const PathData path_data)
static

在文件 path_assessment_decider_util.cc63 行定义.

64 {
65 static constexpr double kOffReferenceLineThreshold = 20.0;
66 const auto& frenet_path = path_data.frenet_frame_path();
67 for (const auto& frenet_path_point : frenet_path) {
68 if (std::fabs(frenet_path_point.l()) > kOffReferenceLineThreshold) {
69 AINFO << "Greatly off reference line at s = " << frenet_path_point.s()
70 << ", with l = " << frenet_path_point.l();
71 return true;
72 }
73 }
74 return false;
75}
#define AINFO
Definition log.h:42

◆ IsGreatlyOffRoad()

bool apollo::planning::PathAssessmentDeciderUtil::IsGreatlyOffRoad ( const ReferenceLineInfo reference_line_info,
const PathData path_data 
)
static

在文件 path_assessment_decider_util.cc77 行定义.

78 {
79 static constexpr double kOffRoadThreshold = 10.0;
80 const auto& frenet_path = path_data.frenet_frame_path();
81 for (const auto& frenet_path_point : frenet_path) {
82 double road_left_width = 0.0;
83 double road_right_width = 0.0;
84 if (reference_line_info.reference_line().GetRoadWidth(
85 frenet_path_point.s(), &road_left_width, &road_right_width)) {
86 if (frenet_path_point.l() > road_left_width + kOffRoadThreshold ||
87 frenet_path_point.l() < -road_right_width - kOffRoadThreshold) {
88 AINFO << "Greatly off-road at s = " << frenet_path_point.s()
89 << ", with l = " << frenet_path_point.l();
90 return true;
91 }
92 }
93 }
94 return false;
95}

◆ IsStopOnReverseNeighborLane()

bool apollo::planning::PathAssessmentDeciderUtil::IsStopOnReverseNeighborLane ( const ReferenceLineInfo reference_line_info,
const PathData path_data 
)
static

在文件 path_assessment_decider_util.cc168 行定义.

169 {
170 if (path_data.path_label().find("left") == std::string::npos &&
171 path_data.path_label().find("right") == std::string::npos) {
172 return false;
173 }
174
175 std::vector<common::SLPoint> all_stop_point_sl =
176 reference_line_info.GetAllStopDecisionSLPoint();
177 if (all_stop_point_sl.empty()) {
178 return false;
179 }
180
181 double check_s = 0.0;
182 // filter out sidepass stop fence
183 static constexpr double kLookForwardBuffer = 5.0;
184 const double adc_end_s = reference_line_info.AdcSlBoundary().end_s();
185 for (const auto& stop_point_sl : all_stop_point_sl) {
186 if (stop_point_sl.s() - adc_end_s < kLookForwardBuffer) {
187 continue;
188 }
189 check_s = stop_point_sl.s();
190 break;
191 }
192 if (check_s <= 0.0) {
193 return false;
194 }
195
196 double lane_left_width = 0.0;
197 double lane_right_width = 0.0;
198 if (!reference_line_info.reference_line().GetLaneWidth(
199 check_s, &lane_left_width, &lane_right_width)) {
200 return false;
201 }
202
203 static constexpr double kSDelta = 0.3;
204 common::SLPoint path_point_sl;
205 for (const auto& frenet_path_point : path_data.frenet_frame_path()) {
206 if (std::fabs(frenet_path_point.s() - check_s) < kSDelta) {
207 path_point_sl.set_s(frenet_path_point.s());
208 path_point_sl.set_l(frenet_path_point.l());
209 }
210 }
211 ADEBUG << "path_point_sl[" << path_point_sl.s() << ", " << path_point_sl.l()
212 << "] lane_left_width[" << lane_left_width << "] lane_right_width["
213 << lane_right_width << "]";
214
215 hdmap::Id neighbor_lane_id;
216 double neighbor_lane_width = 0.0;
217 if (path_data.path_label().find("left") != std::string::npos &&
218 path_point_sl.l() > lane_left_width) {
219 if (reference_line_info.GetNeighborLaneInfo(
221 &neighbor_lane_id, &neighbor_lane_width)) {
222 AINFO << "stop path point at LeftForward neighbor lane["
223 << neighbor_lane_id.id() << "]";
224 return false;
225 } else {
226 AINFO << "stop path point at LeftReverse neighbor lane";
227 return true;
228 }
229 } else if (path_data.path_label().find("right") != std::string::npos &&
230 path_point_sl.l() < -lane_right_width) {
231 if (reference_line_info.GetNeighborLaneInfo(
233 &neighbor_lane_id, &neighbor_lane_width)) {
234 AINFO << "stop path point at RightForward neighbor lane["
235 << neighbor_lane_id.id() << "]";
236 return false;
237 } else {
238 AINFO << "stop path point at RightReverse neighbor lane";
239 return true;
240 }
241 }
242 return false;
243}
#define ADEBUG
Definition log.h:41

◆ IsValidRegularPath()

bool apollo::planning::PathAssessmentDeciderUtil::IsValidRegularPath ( const ReferenceLineInfo reference_line_info,
const PathData path_data 
)
static

Check if the generated path is valid

参数
reference_line_infois input current reference_line_info
path_datais input generated path

在文件 path_assessment_decider_util.cc32 行定义.

33 {
34 // Basic sanity checks.
35 if (path_data.Empty()) {
36 AERROR << path_data.path_label() << ": path data is empty.";
37 return false;
38 }
39 // Check if the path is greatly off the reference line.
40 if (IsGreatlyOffReferenceLine(path_data)) {
41 AERROR << path_data.path_label() << ": ADC is greatly off reference line.";
42 return false;
43 }
44 // Check if the path is greatly off the road.
45 if (IsGreatlyOffRoad(reference_line_info, path_data)) {
46 AERROR << path_data.path_label() << ": ADC is greatly off road.";
47 return false;
48 }
49 // Check if there is any collision.
50 // if (IsCollidingWithStaticObstacles(reference_line_info, path_data)) {
51 // AINFO << path_data.path_label() << ": ADC has collision.";
52 // return false;
53 // }
54
55 if (IsStopOnReverseNeighborLane(reference_line_info, path_data)) {
56 AERROR << path_data.path_label() << ": stop at reverse neighbor lane";
57 return false;
58 }
59
60 return true;
61}
static bool IsGreatlyOffReferenceLine(const PathData &path_data)
static bool IsGreatlyOffRoad(const ReferenceLineInfo &reference_line_info, const PathData &path_data)
static bool IsStopOnReverseNeighborLane(const ReferenceLineInfo &reference_line_info, const PathData &path_data)

◆ TrimTailingOutLanePoints()

void apollo::planning::PathAssessmentDeciderUtil::TrimTailingOutLanePoints ( PathData *const  path_data)
static

Trim the points at tail of path which away from lane

参数
path_datais input generated path
typeis input init type of point decision
path_point_decisionis output point decision which indicate each point decision in path

在文件 path_assessment_decider_util.cc260 行定义.

261 {
262 // Don't trim self-lane path or fallback path.
263 if (path_data->path_label().find("fallback") != std::string::npos ||
264 path_data->path_label().find("self") != std::string::npos) {
265 return;
266 }
267
268 // Trim.
269 AINFO << "Trimming " << path_data->path_label();
270 auto frenet_path = path_data->frenet_frame_path();
271 auto path_point_decision = path_data->path_point_decision_guide();
272 while (!path_point_decision.empty() &&
273 std::get<1>(path_point_decision.back()) !=
275 if (std::get<1>(path_point_decision.back()) ==
277 AINFO << "Trimming out forward lane point";
278 } else if (std::get<1>(path_point_decision.back()) ==
280 AINFO << "Trimming out reverse lane point";
281 } else {
282 AINFO << "Trimming unknown lane point";
283 }
284 frenet_path.pop_back();
285 path_point_decision.pop_back();
286 }
287 path_data->SetFrenetPath(std::move(frenet_path));
288 path_data->SetPathPointDecisionGuide(std::move(path_point_decision));
289 AINFO << "After TrimTailingOutLanePoints: FrenetPath size: "
290 << path_data->frenet_frame_path().size();
291}

该类的文档由以下文件生成: