35 if (path_data.
Empty()) {
65 static constexpr double kOffReferenceLineThreshold = 20.0;
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();
79 static constexpr double kOffRoadThreshold = 10.0;
81 for (
const auto& frenet_path_point : frenet_path) {
82 double road_left_width = 0.0;
83 double road_right_width = 0.0;
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();
100 std::vector<const Obstacle*> obstacles;
101 const auto& indexed_obstacles =
103 const auto& vehicle_param =
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()) {
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()) <
121 obstacles.push_back(obstacle);
129 (FLAGS_num_extra_tail_bound_point + 1) *
130 FLAGS_path_bounds_decider_resolution +
131 vehicle_param.length()) {
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;
139 for (
const auto* obstacle : obstacles) {
140 const auto& obstacle_sl = obstacle->PerceptionSLBoundary();
142 if (obstacle_sl.start_s() > path_point_end_s ||
143 obstacle_sl.end_s() < path_point_start_s) {
146 if (obstacle_sl.start_l() > path_point_end_l ||
147 obstacle_sl.end_l() < path_point_start_l) {
151 const auto& vehicle_box =
152 common::VehicleConfigHelper::Instance()->GetBoundingBox(path_point);
153 const std::vector<Vec2d>& ABCDpoints = vehicle_box.GetAllCorners();
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();
170 if (path_data.
path_label().find(
"left") == std::string::npos &&
171 path_data.
path_label().find(
"right") == std::string::npos) {
175 std::vector<common::SLPoint> all_stop_point_sl =
177 if (all_stop_point_sl.empty()) {
181 double check_s = 0.0;
183 static constexpr double kLookForwardBuffer = 5.0;
185 for (
const auto& stop_point_sl : all_stop_point_sl) {
186 if (stop_point_sl.s() - adc_end_s < kLookForwardBuffer) {
189 check_s = stop_point_sl.s();
192 if (check_s <= 0.0) {
196 double lane_left_width = 0.0;
197 double lane_right_width = 0.0;
199 check_s, &lane_left_width, &lane_right_width)) {
203 static constexpr double kSDelta = 0.3;
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());
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 <<
"]";
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) {
221 &neighbor_lane_id, &neighbor_lane_width)) {
222 AINFO <<
"stop path point at LeftForward neighbor lane["
223 << neighbor_lane_id.
id() <<
"]";
226 AINFO <<
"stop path point at LeftReverse neighbor lane";
229 }
else if (path_data.
path_label().find(
"right") != std::string::npos &&
230 path_point_sl.
l() < -lane_right_width) {
233 &neighbor_lane_id, &neighbor_lane_width)) {
234 AINFO <<
"stop path point at RightForward neighbor lane["
235 << neighbor_lane_id.
id() <<
"]";
238 AINFO <<
"stop path point at RightReverse neighbor lane";
247 std::vector<PathPointDecision>*
const path_point_decision) {
249 CHECK_NOTNULL(path_point_decision);
250 path_point_decision->clear();
255 path_point_decision->emplace_back(frenet_path_point.s(), type,
256 std::numeric_limits<double>::max());
263 if (path_data->
path_label().find(
"fallback") != std::string::npos ||
264 path_data->
path_label().find(
"self") != std::string::npos) {
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";
282 AINFO <<
"Trimming unknown lane point";
284 frenet_path.pop_back();
285 path_point_decision.pop_back();
289 AINFO <<
"After TrimTailingOutLanePoints: FrenetPath size: "
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
Rectangular (undirected) bounding box in 2-D.
The class of polygon in 2-D.
bool IsPointIn(const Vec2d &point) const
Check if a point is within the polygon.
Implements a class of 2-dimensional vectors.
static bool IsGreatlyOffReferenceLine(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 bool IsGreatlyOffRoad(const ReferenceLineInfo &reference_line_info, const PathData &path_data)
static bool IsCollidingWithStaticObstacles(const ReferenceLineInfo &reference_line_info, const PathData &path_data)
static void TrimTailingOutLanePoints(PathData *const path_data)
Trim the points at tail of path which away from lane
static bool IsStopOnReverseNeighborLane(const ReferenceLineInfo &reference_line_info, const PathData &path_data)
static bool IsValidRegularPath(const ReferenceLineInfo &reference_line_info, const PathData &path_data)
Check if the generated path is valid
static bool IsWithinPathDeciderScopeObstacle(const Obstacle &obstacle)
Is obstacle should be considered in path decision
const std::string & path_label() const
const FrenetFramePath & frenet_frame_path() const
bool SetPathPointDecisionGuide(std::vector< std::tuple< double, PathPointType, double > > path_point_decision_guide)
const DiscretizedPath & discretized_path() const
const std::vector< std::tuple< double, PathPointType, double > > & path_point_decision_guide() const
bool SetFrenetPath(FrenetFramePath frenet_path)
const IndexedList< std::string, Obstacle > & obstacles() const
ReferenceLineInfo holds all data for one reference line.
PathDecision * path_decision()
bool GetNeighborLaneInfo(const ReferenceLineInfo::LaneType lane_type, const double s, hdmap::Id *ptr_lane_id, double *ptr_lane_width) const
const ReferenceLine & reference_line() const
std::vector< common::SLPoint > GetAllStopDecisionSLPoint() const
const SLBoundary & AdcSlBoundary() const
bool GetRoadWidth(const double s, double *const road_left_width, double *const road_right_width) const
bool GetLaneWidth(const double s, double *const lane_left_width, double *const lane_right_width) const
Planning module main class.
constexpr double kMinObstacleArea
optional VehicleParam vehicle_param
optional double front_edge_to_center