Skip to content

Commit 27b5d1c

Browse files
committed
fix(avoidance): avoid merging vehicle if it's NOT on ego lane.
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 8be00ef commit 27b5d1c

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/data_structs.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ struct ObjectData // avoidance target
420420
// is parked vehicle on road shoulder
421421
bool is_parked{false};
422422

423+
// is driving on ego current lane
424+
bool is_on_ego_lane{false};
425+
423426
// object direction.
424427
Direction direction{Direction::NONE};
425428

planning/behavior_path_avoidance_module/src/utils.cpp

+20-10
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,14 @@ bool isWithinIntersection(
478478
object_polygon, utils::toPolygon2d(lanelet::utils::to2D(polygon.basicPolygon())));
479479
}
480480

481+
bool isOnEgoLane(const ObjectData & object)
482+
{
483+
const auto & object_pos = object.object.kinematics.initial_pose_with_covariance.pose.position;
484+
return boost::geometry::within(
485+
lanelet::utils::to2D(lanelet::utils::conversion::toLaneletPoint(object_pos)).basicPoint(),
486+
object.overhang_lanelet.polygon2d().basicPolygon());
487+
}
488+
481489
bool isParallelToEgoLane(const ObjectData & object, const double threshold)
482490
{
483491
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
@@ -525,6 +533,10 @@ bool isParkedVehicle(
525533
using lanelet::utils::to2D;
526534
using lanelet::utils::conversion::toLaneletPoint;
527535

536+
if (object.is_within_intersection) {
537+
return false;
538+
}
539+
528540
const auto & object_pos = object.object.kinematics.initial_pose_with_covariance.pose.position;
529541
const auto centerline_pos =
530542
lanelet::utils::getClosestCenterPose(object.overhang_lanelet, object_pos).position;
@@ -652,6 +664,10 @@ bool isForceAvoidanceTarget(
652664
return false;
653665
}
654666

667+
if (!object.is_on_ego_lane) {
668+
return true;
669+
}
670+
655671
const auto & ego_pose = planner_data->self_odometry->pose.pose;
656672

657673
// force avoidance for stopped vehicle
@@ -778,24 +794,16 @@ bool isSatisfiedWithVehicleCondition(
778794
const std::shared_ptr<const PlannerData> & planner_data,
779795
const std::shared_ptr<AvoidanceParameters> & parameters)
780796
{
781-
using boost::geometry::within;
782-
using lanelet::utils::to2D;
783-
using lanelet::utils::conversion::toLaneletPoint;
784-
785797
object.behavior = getObjectBehavior(object, parameters);
786-
object.is_within_intersection = isWithinIntersection(object, planner_data->route_handler);
798+
object.is_on_ego_lane = isOnEgoLane(object);
787799

788800
// from here condition check for vehicle type objects.
789801
if (isForceAvoidanceTarget(object, data, planner_data, parameters)) {
790802
return true;
791803
}
792804

793805
// check vehicle shift ratio
794-
const auto & object_pos = object.object.kinematics.initial_pose_with_covariance.pose.position;
795-
const auto on_ego_driving_lane = within(
796-
to2D(toLaneletPoint(object_pos)).basicPoint(),
797-
object.overhang_lanelet.polygon2d().basicPolygon());
798-
if (on_ego_driving_lane) {
806+
if (object.is_on_ego_lane) {
799807
if (object.is_parked) {
800808
return true;
801809
} else {
@@ -1755,6 +1763,8 @@ void filterTargetObjects(
17551763
}
17561764

17571765
if (filtering_utils::isVehicleTypeObject(o)) {
1766+
o.is_within_intersection =
1767+
filtering_utils::isWithinIntersection(o, planner_data->route_handler);
17581768
o.is_parked = filtering_utils::isParkedVehicle(o, planner_data->route_handler, parameters);
17591769
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
17601770

0 commit comments

Comments
 (0)