Skip to content

Commit 5415162

Browse files
fix(lane_change): filtering object ahead of terminal (#8093)
* employ lanelet based filtering before distance based filtering Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * use distance based to terminal check instead Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * remove RCLCPP INFO Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * update flow chart Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> --------- Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent 563faec commit 5415162

File tree

6 files changed

+153
-129
lines changed

6 files changed

+153
-129
lines changed

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/README.md

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ title NormalLaneChange::filterObjects Method Execution Flow
331331
start
332332
333333
group "Filter Objects by Class" {
334-
:Iterate through each object in objects list;
335-
while (has not finished iterating through object list) is (TRUE)
334+
while (has not finished iterating through predicted object list) is (TRUE)
336335
if (current object type != param.object_types_to_check?) then (TRUE)
337336
#LightPink:Remove current object;
338337
else (FALSE)
@@ -341,17 +340,15 @@ endif
341340
end while
342341
end group
343342
344-
if (object list is empty?) then (TRUE)
343+
if (predicted object list is empty?) then (TRUE)
345344
:Return empty result;
346345
stop
347346
else (FALSE)
348347
endif
349348
350349
group "Filter Oncoming Objects" #PowderBlue {
351-
:Iterate through each object in target lane objects list;
352-
while (has not finished iterating through object list?) is (TRUE)
353-
:check object's yaw with reference to ego's yaw.;
354-
if (yaw difference < 90 degree?) then (TRUE)
350+
while (has not finished iterating through predicted object list?) is (TRUE)
351+
if (object's yaw with reference to ego's yaw difference < 90 degree?) then (TRUE)
355352
:Keep current object;
356353
else (FALSE)
357354
if (object is stopping?) then (TRUE)
@@ -363,53 +360,35 @@ endif
363360
endwhile
364361
end group
365362
366-
if (object list is empty?) then (TRUE)
367-
:Return empty result;
368-
stop
369-
else (FALSE)
370-
endif
371-
372-
group "Filter Objects Ahead Terminal" #Beige {
373-
:Calculate lateral distance from ego to current lanes center;
374-
375-
:Iterate through each object in objects list;
376-
while (has not finished iterating through object list) is (TRUE)
377-
:Get current object's polygon;
378-
:Initialize distance to terminal from object to max;
379-
while (has not finished iterating through object polygon's vertices) is (TRUE)
380-
:Calculate object's lateral distance to end of lane;
381-
:Update minimum distance to terminal from object;
382-
end while
383-
if (Is object's distance to terminal exceeds minimum lane change length?) then (TRUE)
384-
#LightPink:Remove current object;
385-
else (FALSE)
386-
endif
387-
end while
388-
end group
389-
390-
if (object list is empty?) then (TRUE)
363+
if (predicted object list is empty?) then (TRUE)
391364
:Return empty result;
392365
stop
393366
else (FALSE)
394367
endif
395368
396369
group "Filter Objects By Lanelets" #LightGreen {
397370
398-
:Iterate through each object in objects list;
399-
while (has not finished iterating through object list) is (TRUE)
400-
:lateral distance diff = difference between object's lateral distance and ego's lateral distance to the current lanes' centerline.;
401-
if (Object in target lane polygon, and lateral distance diff is more than half of ego's width?) then (TRUE)
402-
:Add to target_lane_objects;
403-
else (FALSE)
404-
if (Object overlaps with backward target lanes?) then (TRUE)
371+
while (has not finished iterating through predicted object list) is (TRUE)
372+
:Calculate lateral distance diff;
373+
if (Object in target lane polygon?) then (TRUE)
374+
if (lateral distance diff > half of ego's width?) then (TRUE)
375+
if (Object's physical position is before terminal point?) then (TRUE)
405376
:Add to target_lane_objects;
406377
else (FALSE)
407-
if (Object in current lane polygon?) then (TRUE)
408-
:Add to current_lane_objects;
409-
else (FALSE)
410-
:Add to other_lane_objects;
411-
endif
412378
endif
379+
else (FALSE)
380+
endif
381+
else (FALSE)
382+
endif
383+
384+
if (Object overlaps with backward target lanes?) then (TRUE)
385+
:Add to target_lane_objects;
386+
else (FALSE)
387+
if (Object in current lane polygon?) then (TRUE)
388+
:Add to current_lane_objects;
389+
else (FALSE)
390+
:Add to other_lane_objects;
391+
endif
413392
endif
414393
end while
415394
@@ -426,13 +405,10 @@ endif
426405
427406
group "Filter Target Lanes' objects" #LightCyan {
428407
429-
:Iterate through each object in target lane objects list;
430-
while (has not finished iterating through object list) is (TRUE)
431-
:check object's velocity;
408+
while (has not finished iterating through target lanes' object list) is (TRUE)
432409
if(velocity is within threshold?) then (TRUE)
433410
:Keep current object;
434411
else (FALSE)
435-
:check whether object is ahead of ego;
436412
if(object is ahead of ego?) then (TRUE)
437413
:keep current object;
438414
else (FALSE)
@@ -444,11 +420,8 @@ end group
444420
445421
group "Filter Current Lanes' objects" #LightYellow {
446422
447-
:Iterate through each object in current lane objects list;
448-
while (has not finished iterating through object list) is (TRUE)
449-
:check object's velocity;
423+
while (has not finished iterating through current lanes' object list) is (TRUE)
450424
if(velocity is within threshold?) then (TRUE)
451-
:check whether object is ahead of ego;
452425
if(object is ahead of ego?) then (TRUE)
453426
:keep current object;
454427
else (FALSE)
@@ -462,11 +435,8 @@ end group
462435
463436
group "Filter Other Lanes' objects" #Lavender {
464437
465-
:Iterate through each object in other lane objects list;
466-
while (has not finished iterating through object list) is (TRUE)
467-
:check object's velocity;
438+
while (has not finished iterating through other lanes' object list) is (TRUE)
468439
if(velocity is within threshold?) then (TRUE)
469-
:check whether object is ahead of ego;
470440
if(object is ahead of ego?) then (TRUE)
471441
:keep current object;
472442
else (FALSE)
@@ -478,7 +448,7 @@ while (has not finished iterating through object list) is (TRUE)
478448
endwhile
479449
end group
480450
481-
:Trasform the objects into extended predicted object and return them as lane_change_target_objects;
451+
:Transform the objects into extended predicted object and return them as lane_change_target_objects;
482452
stop
483453
484454
@enduml

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/scene.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,8 @@ class NormalLaneChange : public LaneChangeBase
128128

129129
void filterOncomingObjects(PredictedObjects & objects) const;
130130

131-
void filterAheadTerminalObjects(
132-
PredictedObjects & objects, const lanelet::ConstLanelets & current_lanes) const;
133-
134131
void filterObjectsByLanelets(
135-
const PredictedObjects & objects, const lanelet::ConstLanelets & current_lanes,
136-
const lanelet::ConstLanelets & target_lanes,
132+
const PredictedObjects & objects, const PathWithLaneId & current_lanes_ref_path,
137133
std::vector<PredictedObject> & current_lane_objects,
138134
std::vector<PredictedObject> & target_lane_objects,
139135
std::vector<PredictedObject> & other_lane_objects) const;

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/data_structs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ struct PhaseInfo
185185

186186
struct Lanes
187187
{
188+
bool current_lane_in_goal_section{false};
188189
lanelet::ConstLanelets current;
189190
lanelet::ConstLanelets target;
190191
std::vector<lanelet::ConstLanelets> preceding_target;

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/utils.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,18 @@ LanesPolygon create_lanes_polygon(const CommonDataPtr & common_data_ptr);
302302
bool is_same_lane_with_prev_iteration(
303303
const CommonDataPtr & common_data_ptr, const lanelet::ConstLanelets & current_lanes,
304304
const lanelet::ConstLanelets & target_lanes);
305+
306+
Pose to_pose(
307+
const autoware::universe_utils::Point2d & point,
308+
const geometry_msgs::msg::Quaternion & orientation);
309+
310+
bool is_ahead_of_ego(
311+
const CommonDataPtr & common_data_ptr, const PathWithLaneId & path,
312+
const PredictedObject & object);
313+
314+
bool is_before_terminal(
315+
const CommonDataPtr & common_data_ptr, const PathWithLaneId & path,
316+
const PredictedObject & object);
305317
} // namespace autoware::behavior_path_planner::utils::lane_change
306318

307319
namespace autoware::behavior_path_planner::utils::lane_change::debug

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ void NormalLaneChange::update_lanes(const bool is_approved)
8383
common_data_ptr_->lanes_ptr->current = current_lanes;
8484
common_data_ptr_->lanes_ptr->target = target_lanes;
8585

86+
const auto & route_handler_ptr = common_data_ptr_->route_handler_ptr;
87+
common_data_ptr_->lanes_ptr->current_lane_in_goal_section =
88+
route_handler_ptr->isInGoalRouteSection(current_lanes.back());
8689
common_data_ptr_->lanes_ptr->preceding_target = utils::getPrecedingLanelets(
87-
*common_data_ptr_->route_handler_ptr, get_target_lanes(), common_data_ptr_->get_ego_pose(),
90+
*route_handler_ptr, get_target_lanes(), common_data_ptr_->get_ego_pose(),
8891
common_data_ptr_->lc_param_ptr->backward_lane_length);
8992

9093
*common_data_ptr_->lanes_polygon_ptr = create_lanes_polygon(common_data_ptr_);
@@ -983,7 +986,6 @@ ExtendedPredictedObjects NormalLaneChange::getTargetObjects(
983986

984987
LaneChangeLanesFilteredObjects NormalLaneChange::filterObjects() const
985988
{
986-
const auto & current_pose = getEgoPose();
987989
const auto & route_handler = getRouteHandler();
988990
const auto & common_parameters = planner_data_->parameters;
989991
auto objects = *planner_data_->dynamic_object;
@@ -1006,12 +1008,6 @@ LaneChangeLanesFilteredObjects NormalLaneChange::filterObjects() const
10061008
return {};
10071009
}
10081010

1009-
filterAheadTerminalObjects(objects, current_lanes);
1010-
1011-
if (objects.objects.empty()) {
1012-
return {};
1013-
}
1014-
10151011
std::vector<PredictedObject> target_lane_objects;
10161012
std::vector<PredictedObject> current_lane_objects;
10171013
std::vector<PredictedObject> other_lane_objects;
@@ -1022,48 +1018,37 @@ LaneChangeLanesFilteredObjects NormalLaneChange::filterObjects() const
10221018
return {};
10231019
}
10241020

1021+
const auto path =
1022+
route_handler->getCenterLinePath(current_lanes, 0.0, std::numeric_limits<double>::max());
1023+
10251024
filterObjectsByLanelets(
1026-
objects, current_lanes, target_lanes, current_lane_objects, target_lane_objects,
1027-
other_lane_objects);
1025+
objects, path, current_lane_objects, target_lane_objects, other_lane_objects);
10281026

10291027
const auto is_within_vel_th = [](const auto & object) -> bool {
10301028
constexpr double min_vel_th = 1.0;
10311029
constexpr double max_vel_th = std::numeric_limits<double>::max();
10321030
return utils::path_safety_checker::filter::velocity_filter(object, min_vel_th, max_vel_th);
10331031
};
10341032

1035-
const auto path =
1036-
route_handler->getCenterLinePath(current_lanes, 0.0, std::numeric_limits<double>::max());
1037-
1038-
if (path.points.empty()) {
1039-
return {};
1040-
}
1041-
1042-
const auto is_ahead_of_ego = [&path, &current_pose](const auto & object) {
1043-
const auto obj_polygon = autoware::universe_utils::toPolygon2d(object).outer();
1044-
1045-
double max_dist_ego_to_obj = std::numeric_limits<double>::lowest();
1046-
for (const auto & polygon_p : obj_polygon) {
1047-
const auto obj_p = autoware::universe_utils::createPoint(polygon_p.x(), polygon_p.y(), 0.0);
1048-
const auto dist_ego_to_obj = calcSignedArcLength(path.points, current_pose.position, obj_p);
1049-
max_dist_ego_to_obj = std::max(dist_ego_to_obj, max_dist_ego_to_obj);
1050-
}
1051-
return max_dist_ego_to_obj >= 0.0;
1052-
};
1053-
10541033
utils::path_safety_checker::filterObjects(
10551034
target_lane_objects, [&](const PredictedObject & object) {
1056-
return (is_within_vel_th(object) || is_ahead_of_ego(object));
1035+
const auto ahead_of_ego = utils::lane_change::is_ahead_of_ego(common_data_ptr_, path, object);
1036+
return is_within_vel_th(object) || ahead_of_ego;
10571037
});
10581038

1059-
utils::path_safety_checker::filterObjects(
1060-
other_lane_objects, [&](const PredictedObject & object) {
1061-
return is_within_vel_th(object) && is_ahead_of_ego(object);
1062-
});
1039+
if (lane_change_parameters_->check_objects_on_other_lanes) {
1040+
utils::path_safety_checker::filterObjects(
1041+
other_lane_objects, [&](const PredictedObject & object) {
1042+
const auto ahead_of_ego =
1043+
utils::lane_change::is_ahead_of_ego(common_data_ptr_, path, object);
1044+
return is_within_vel_th(object) && ahead_of_ego;
1045+
});
1046+
}
10631047

10641048
utils::path_safety_checker::filterObjects(
10651049
current_lane_objects, [&](const PredictedObject & object) {
1066-
return is_within_vel_th(object) && is_ahead_of_ego(object);
1050+
const auto ahead_of_ego = utils::lane_change::is_ahead_of_ego(common_data_ptr_, path, object);
1051+
return is_within_vel_th(object) && ahead_of_ego;
10671052
});
10681053

10691054
LaneChangeLanesFilteredObjects lane_change_target_objects;
@@ -1119,42 +1104,15 @@ void NormalLaneChange::filterOncomingObjects(PredictedObjects & objects) const
11191104
});
11201105
}
11211106

1122-
void NormalLaneChange::filterAheadTerminalObjects(
1123-
PredictedObjects & objects, const lanelet::ConstLanelets & current_lanes) const
1124-
{
1125-
const auto & current_pose = getEgoPose();
1126-
const auto & route_handler = getRouteHandler();
1127-
const auto minimum_lane_change_length = utils::lane_change::calcMinimumLaneChangeLength(
1128-
route_handler, current_lanes.back(), *lane_change_parameters_, direction_);
1129-
1130-
const auto dist_ego_to_current_lanes_center =
1131-
lanelet::utils::getLateralDistanceToClosestLanelet(current_lanes, current_pose);
1132-
1133-
// ignore object that are ahead of terminal lane change start
1134-
utils::path_safety_checker::filterObjects(objects, [&](const PredictedObject & object) {
1135-
const auto obj_polygon = autoware::universe_utils::toPolygon2d(object).outer();
1136-
// ignore object that are ahead of terminal lane change start
1137-
auto distance_to_terminal_from_object = std::numeric_limits<double>::max();
1138-
for (const auto & polygon_p : obj_polygon) {
1139-
const auto obj_p = autoware::universe_utils::createPoint(polygon_p.x(), polygon_p.y(), 0.0);
1140-
Pose polygon_pose;
1141-
polygon_pose.position = obj_p;
1142-
polygon_pose.orientation = object.kinematics.initial_pose_with_covariance.pose.orientation;
1143-
const auto dist = utils::getDistanceToEndOfLane(polygon_pose, current_lanes);
1144-
distance_to_terminal_from_object = std::min(dist_ego_to_current_lanes_center, dist);
1145-
}
1146-
1147-
return (minimum_lane_change_length > distance_to_terminal_from_object);
1148-
});
1149-
}
1150-
11511107
void NormalLaneChange::filterObjectsByLanelets(
1152-
const PredictedObjects & objects, const lanelet::ConstLanelets & current_lanes,
1153-
const lanelet::ConstLanelets & target_lanes, std::vector<PredictedObject> & current_lane_objects,
1108+
const PredictedObjects & objects, const PathWithLaneId & current_lanes_ref_path,
1109+
std::vector<PredictedObject> & current_lane_objects,
11541110
std::vector<PredictedObject> & target_lane_objects,
11551111
std::vector<PredictedObject> & other_lane_objects) const
11561112
{
11571113
const auto & current_pose = getEgoPose();
1114+
const auto & current_lanes = common_data_ptr_->lanes_ptr->current;
1115+
const auto & target_lanes = common_data_ptr_->lanes_ptr->target;
11581116
const auto & route_handler = getRouteHandler();
11591117
const auto & common_parameters = planner_data_->parameters;
11601118
const auto check_optional_polygon = [](const auto & object, const auto & polygon) {
@@ -1199,7 +1157,14 @@ void NormalLaneChange::filterObjectsByLanelets(
11991157
return std::abs(lateral) > (common_parameters.vehicle_width / 2);
12001158
});
12011159

1202-
if (check_optional_polygon(object, lanes_polygon.expanded_target) && is_lateral_far) {
1160+
const auto is_before_terminal = [&]() {
1161+
return utils::lane_change::is_before_terminal(
1162+
common_data_ptr_, current_lanes_ref_path, object);
1163+
};
1164+
1165+
if (
1166+
check_optional_polygon(object, lanes_polygon.expanded_target) && is_lateral_far &&
1167+
is_before_terminal()) {
12031168
target_lane_objects.push_back(object);
12041169
continue;
12051170
}

0 commit comments

Comments
 (0)