Skip to content

Commit c3093d2

Browse files
committed
feat(avoidance): check if it's parked vehicle
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 1b45a7e commit c3093d2

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/data_structs.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ struct ObjectData // avoidance target
415415
// is within intersection area
416416
bool is_within_intersection{false};
417417

418+
// is parked vehicle on road shoulder
419+
bool is_parked{false};
420+
418421
// object direction.
419422
Direction direction{Direction::NONE};
420423

planning/behavior_path_avoidance_module/src/debug.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ MarkerArray createObjectInfoMarkerArray(const ObjectDataArray & objects, std::st
176176
marker.id = uuidToInt32(object.object.object_id);
177177
marker.pose.position.z += 2.0;
178178
std::ostringstream string_stream;
179-
string_stream << object.reason;
179+
string_stream << object.reason << (object.is_parked ? "(PARKED)" : "");
180180
marker.text = string_stream.str();
181181
marker.color = createMarkerColor(1.0, 1.0, 1.0, 0.999);
182182
marker.scale = createMarkerScale(0.6, 0.6, 0.6);

planning/behavior_path_avoidance_module/src/utils.cpp

+22-29
Original file line numberDiff line numberDiff line change
@@ -516,35 +516,18 @@ bool isMergingToEgoLane(const ObjectData & object)
516516
return true;
517517
}
518518

519-
bool isObjectOnRoadShoulder(
519+
bool isParkedVehicle(
520520
ObjectData & object, const std::shared_ptr<RouteHandler> & route_handler,
521521
const std::shared_ptr<AvoidanceParameters> & parameters)
522522
{
523-
using boost::geometry::within;
524523
using lanelet::geometry::distance2d;
525524
using lanelet::geometry::toArcCoordinates;
526525
using lanelet::utils::to2D;
527526
using lanelet::utils::conversion::toLaneletPoint;
528527

529-
// assume that there are no parked vehicles in intersection.
530-
std::string turn_direction = object.overhang_lanelet.attributeOr("turn_direction", "else");
531-
if (turn_direction == "right" || turn_direction == "left" || turn_direction == "straight") {
532-
return false;
533-
}
534-
535-
// ============================================ <- most_left_lanelet.leftBound()
536-
// y road shoulder
537-
// ^ ------------------------------------------
538-
// | x +
539-
// +---> --- object closest lanelet --- o ----- <- object_closest_lanelet.centerline()
540-
//
541-
// --------------------------------------------
542-
// +: object position
543-
// o: nearest point on centerline
544-
545-
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
528+
const auto & object_pos = object.object.kinematics.initial_pose_with_covariance.pose.position;
546529
const auto centerline_pos =
547-
lanelet::utils::getClosestCenterPose(object.overhang_lanelet, object_pose.position).position;
530+
lanelet::utils::getClosestCenterPose(object.overhang_lanelet, object_pos).position;
548531

549532
bool is_left_side_parked_vehicle = false;
550533
if (!isOnRight(object)) {
@@ -580,7 +563,7 @@ bool isObjectOnRoadShoulder(
580563

581564
const auto arc_coordinates = toArcCoordinates(
582565
to2D(object.overhang_lanelet.centerline().basicLineString()),
583-
to2D(toLaneletPoint(object_pose.position)).basicPoint());
566+
to2D(toLaneletPoint(object_pos)).basicPoint());
584567
object.shiftable_ratio = arc_coordinates.distance / object_shiftable_distance;
585568

586569
is_left_side_parked_vehicle = object.shiftable_ratio > parameters->object_check_shiftable_ratio;
@@ -620,7 +603,7 @@ bool isObjectOnRoadShoulder(
620603

621604
const auto arc_coordinates = toArcCoordinates(
622605
to2D(object.overhang_lanelet.centerline().basicLineString()),
623-
to2D(toLaneletPoint(object_pose.position)).basicPoint());
606+
to2D(toLaneletPoint(object_pos)).basicPoint());
624607
object.shiftable_ratio = -1.0 * arc_coordinates.distance / object_shiftable_distance;
625608

626609
is_right_side_parked_vehicle =
@@ -813,7 +796,7 @@ bool isSatisfiedWithVehicleCondition(
813796
to2D(toLaneletPoint(object_pos)).basicPoint(),
814797
object.overhang_lanelet.polygon2d().basicPolygon());
815798
if (on_ego_driving_lane) {
816-
if (isObjectOnRoadShoulder(object, planner_data->route_handler, parameters)) {
799+
if (object.is_parked) {
817800
return true;
818801
} else {
819802
object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
@@ -1751,7 +1734,6 @@ void filterTargetObjects(
17511734
// Find the footprint point closest to the path, set to object_data.overhang_distance.
17521735
o.overhang_points = utils::avoidance::calcEnvelopeOverhangDistance(o, data.reference_path);
17531736
o.to_road_shoulder_distance = filtering_utils::getRoadShoulderDistance(o, data, planner_data);
1754-
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
17551737

17561738
// TODO(Satoshi Ota) parametrize stop time threshold if need.
17571739
constexpr double STOP_TIME_THRESHOLD = 3.0; // [s]
@@ -1763,17 +1745,28 @@ void filterTargetObjects(
17631745
}
17641746
}
17651747

1766-
if (filtering_utils::isNoNeedAvoidanceBehavior(o, parameters)) {
1767-
data.other_objects.push_back(o);
1768-
continue;
1769-
}
1770-
17711748
if (filtering_utils::isVehicleTypeObject(o)) {
1749+
o.is_parked = filtering_utils::isParkedVehicle(o, planner_data->route_handler, parameters);
1750+
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
1751+
1752+
if (filtering_utils::isNoNeedAvoidanceBehavior(o, parameters)) {
1753+
data.other_objects.push_back(o);
1754+
continue;
1755+
}
1756+
17721757
if (!filtering_utils::isSatisfiedWithVehicleCondition(o, data, planner_data, parameters)) {
17731758
data.other_objects.push_back(o);
17741759
continue;
17751760
}
17761761
} else {
1762+
o.is_parked = false;
1763+
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
1764+
1765+
if (filtering_utils::isNoNeedAvoidanceBehavior(o, parameters)) {
1766+
data.other_objects.push_back(o);
1767+
continue;
1768+
}
1769+
17771770
if (!filtering_utils::isSatisfiedWithNonVehicleCondition(o, data, planner_data, parameters)) {
17781771
data.other_objects.push_back(o);
17791772
continue;

0 commit comments

Comments
 (0)