Skip to content

Commit 1ca97cf

Browse files
authored
feat(avoidance): wait and see ambiguous stopped vehicle (#6631)
* feat(avoidance): wait and see the ambiguous stopped vehicle Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix(avoidance): wait and see objects around ego straight lane Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * tmp Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * refactor(avoidance): filtering logic for vehicle type objects Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix(avoidance): wait with unsafe avoidance path Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix(avoidance): use getRightLanelet Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * refactor(avoidance): parameterize Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> --------- Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 3b53061 commit 1ca97cf

File tree

8 files changed

+186
-83
lines changed

8 files changed

+186
-83
lines changed

planning/behavior_path_avoidance_by_lane_change_module/src/manager.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,13 @@ void AvoidanceByLaneChangeModuleManager::init(rclcpp::Node * node)
133133

134134
{
135135
const std::string ns = "avoidance.target_filtering.avoidance_for_ambiguous_vehicle.";
136-
p.enable_force_avoidance_for_stopped_vehicle =
137-
getOrDeclareParameter<bool>(*node, ns + "enable");
138-
p.threshold_time_force_avoidance_for_stopped_vehicle =
139-
getOrDeclareParameter<double>(*node, ns + "time_threshold");
136+
p.enable_avoidance_for_ambiguous_vehicle = getOrDeclareParameter<bool>(*node, ns + "enable");
137+
p.closest_distance_to_wait_and_see_for_ambiguous_vehicle =
138+
getOrDeclareParameter<double>(*node, ns + "closest_distance_to_wait_and_see");
139+
p.time_threshold_for_ambiguous_vehicle =
140+
getOrDeclareParameter<double>(*node, ns + "condition.time_threshold");
141+
p.distance_threshold_for_ambiguous_vehicle =
142+
getOrDeclareParameter<double>(*node, ns + "condition.distance_threshold");
140143
p.object_ignore_section_traffic_light_in_front_distance =
141144
getOrDeclareParameter<double>(*node, ns + "ignore_area.traffic_light.front_distance");
142145
p.object_ignore_section_crosswalk_in_front_distance =

planning/behavior_path_avoidance_module/config/avoidance.param.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@
155155
# params for avoidance of vehicle type objects that are ambiguous as to whether they are parked.
156156
avoidance_for_ambiguous_vehicle:
157157
enable: false # [-]
158-
time_threshold: 1.0 # [s]
159-
distance_threshold: 1.0 # [m]
158+
closest_distance_to_wait_and_see: 10.0 # [m]
159+
condition:
160+
time_threshold: 1.0 # [s]
161+
distance_threshold: 1.0 # [m]
160162
ignore_area:
161163
traffic_light:
162164
front_distance: 100.0 # [m]

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/data_structs.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct AvoidanceParameters
100100
bool enable_cancel_maneuver{false};
101101

102102
// enable avoidance for all parking vehicle
103-
bool enable_force_avoidance_for_stopped_vehicle{false};
103+
bool enable_avoidance_for_ambiguous_vehicle{false};
104104

105105
// enable yield maneuver.
106106
bool enable_yield_maneuver{false};
@@ -184,8 +184,9 @@ struct AvoidanceParameters
184184
double object_check_min_road_shoulder_width{0.0};
185185

186186
// force avoidance
187-
double threshold_time_force_avoidance_for_stopped_vehicle{0.0};
188-
double force_avoidance_distance_threshold{0.0};
187+
double closest_distance_to_wait_and_see_for_ambiguous_vehicle{0.0};
188+
double time_threshold_for_ambiguous_vehicle{0.0};
189+
double distance_threshold_for_ambiguous_vehicle{0.0};
189190

190191
// when complete avoidance motion, there is a distance margin with the object
191192
// for longitudinal direction

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/helper.hpp

+29
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,35 @@ class AvoidanceHelper
289289
});
290290
}
291291

292+
bool isReady(const ObjectDataArray & objects) const
293+
{
294+
if (objects.empty()) {
295+
return true;
296+
}
297+
298+
const auto object = objects.front();
299+
300+
if (!object.is_ambiguous) {
301+
return true;
302+
}
303+
304+
if (!object.avoid_margin.has_value()) {
305+
return true;
306+
}
307+
308+
const auto is_object_on_right = utils::avoidance::isOnRight(object);
309+
const auto desire_shift_length =
310+
getShiftLength(object, is_object_on_right, object.avoid_margin.value());
311+
312+
const auto prepare_distance = getMinimumPrepareDistance();
313+
const auto constant_distance = getFrontConstantDistance(object);
314+
const auto avoidance_distance = getMinAvoidanceDistance(desire_shift_length);
315+
316+
return object.longitudinal <
317+
prepare_distance + constant_distance + avoidance_distance +
318+
parameters_->closest_distance_to_wait_and_see_for_ambiguous_vehicle;
319+
}
320+
292321
bool isReady(const AvoidLineArray & new_shift_lines, const double current_shift_length) const
293322
{
294323
if (std::abs(current_shift_length) < 1e-3) {

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/parameter_helper.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ AvoidanceParameters getParameter(rclcpp::Node * node)
141141

142142
{
143143
const std::string ns = "avoidance.target_filtering.avoidance_for_ambiguous_vehicle.";
144-
p.enable_force_avoidance_for_stopped_vehicle =
145-
getOrDeclareParameter<bool>(*node, ns + "enable");
146-
p.threshold_time_force_avoidance_for_stopped_vehicle =
147-
getOrDeclareParameter<double>(*node, ns + "time_threshold");
148-
p.force_avoidance_distance_threshold =
149-
getOrDeclareParameter<double>(*node, ns + "distance_threshold");
144+
p.enable_avoidance_for_ambiguous_vehicle = getOrDeclareParameter<bool>(*node, ns + "enable");
145+
p.closest_distance_to_wait_and_see_for_ambiguous_vehicle =
146+
getOrDeclareParameter<double>(*node, ns + "closest_distance_to_wait_and_see");
147+
p.time_threshold_for_ambiguous_vehicle =
148+
getOrDeclareParameter<double>(*node, ns + "condition.time_threshold");
149+
p.distance_threshold_for_ambiguous_vehicle =
150+
getOrDeclareParameter<double>(*node, ns + "condition.distance_threshold");
150151
p.object_ignore_section_traffic_light_in_front_distance =
151152
getOrDeclareParameter<double>(*node, ns + "ignore_area.traffic_light.front_distance");
152153
p.object_ignore_section_crosswalk_in_front_distance =

planning/behavior_path_avoidance_module/src/debug.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ MarkerArray createDebugMarkerArray(
579579
addObjects(data.other_objects, std::string("ParallelToEgoLane"));
580580
addObjects(data.other_objects, std::string("MergingToEgoLane"));
581581
addObjects(data.other_objects, std::string("UnstableObject"));
582+
addObjects(data.other_objects, std::string("AmbiguousStoppedVehicle"));
583+
addObjects(data.other_objects, std::string("AmbiguousStoppedVehicle(wait-and-see)"));
582584
}
583585

584586
// shift line pre-process

planning/behavior_path_avoidance_module/src/scene.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ void AvoidanceModule::fillShiftLine(AvoidancePlanningData & data, DebugData & de
522522
*/
523523
data.comfortable = helper_->isComfortable(data.new_shift_line);
524524
data.safe = isSafePath(data.candidate_path, debug);
525-
data.ready = helper_->isReady(data.new_shift_line, path_shifter_.getLastShiftLength());
525+
data.ready = helper_->isReady(data.new_shift_line, path_shifter_.getLastShiftLength()) &&
526+
helper_->isReady(data.target_objects);
526527
}
527528

528529
void AvoidanceModule::fillEgoStatus(

planning/behavior_path_avoidance_module/src/utils.cpp

+131-67
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ bool isMergingToEgoLane(const ObjectData & object)
399399
}
400400

401401
bool isParkedVehicle(
402-
ObjectData & object, const std::shared_ptr<RouteHandler> & route_handler,
402+
ObjectData & object, const AvoidancePlanningData & data,
403+
const std::shared_ptr<RouteHandler> & route_handler,
403404
const std::shared_ptr<AvoidanceParameters> & parameters)
404405
{
405406
using lanelet::geometry::distance2d;
@@ -496,57 +497,36 @@ bool isParkedVehicle(
496497
object.shiftable_ratio > parameters->object_check_shiftable_ratio;
497498
}
498499

499-
return is_left_side_parked_vehicle || is_right_side_parked_vehicle;
500-
}
501-
502-
bool isAmbiguousStoppedVehicle(
503-
ObjectData & object, const AvoidancePlanningData & data,
504-
const std::shared_ptr<const PlannerData> & planner_data,
505-
const std::shared_ptr<AvoidanceParameters> & parameters)
506-
{
507-
const auto stop_time_longer_than_threshold =
508-
object.stop_time > parameters->threshold_time_force_avoidance_for_stopped_vehicle;
509-
510-
if (!stop_time_longer_than_threshold) {
500+
if (!is_left_side_parked_vehicle && !is_right_side_parked_vehicle) {
511501
return false;
512502
}
513503

514504
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
515-
const auto is_moving_distance_longer_than_threshold =
516-
tier4_autoware_utils::calcDistance2d(object.init_pose, object_pose) >
517-
parameters->force_avoidance_distance_threshold;
518-
519-
if (is_moving_distance_longer_than_threshold) {
520-
return false;
521-
}
522-
523-
if (object.is_within_intersection) {
524-
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object is in the intersection area.");
525-
return false;
526-
}
527-
528-
const auto rh = planner_data->route_handler;
529-
530-
if (
531-
!!rh->getRoutingGraphPtr()->right(object.overhang_lanelet) &&
532-
!!rh->getRoutingGraphPtr()->left(object.overhang_lanelet)) {
533-
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object isn't on the edge lane.");
505+
object.to_centerline =
506+
lanelet::utils::getArcCoordinates(data.current_lanelets, object_pose).distance;
507+
if (std::abs(object.to_centerline) < parameters->threshold_distance_object_is_on_center) {
534508
return false;
535509
}
536510

537-
if (!object.is_on_ego_lane) {
538-
return true;
539-
}
511+
return true;
512+
}
540513

514+
bool isCloseToStopFactor(
515+
ObjectData & object, const AvoidancePlanningData & data,
516+
const std::shared_ptr<const PlannerData> & planner_data,
517+
const std::shared_ptr<AvoidanceParameters> & parameters)
518+
{
519+
const auto & rh = planner_data->route_handler;
541520
const auto & ego_pose = planner_data->self_odometry->pose.pose;
521+
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
542522

543523
// force avoidance for stopped vehicle
544-
bool not_parked_object = true;
524+
bool is_close_to_stop_factor = false;
545525

546526
// check traffic light
547527
const auto to_traffic_light = getDistanceToNextTrafficLight(object_pose, data.extend_lanelets);
548528
{
549-
not_parked_object =
529+
is_close_to_stop_factor =
550530
to_traffic_light < parameters->object_ignore_section_traffic_light_in_front_distance;
551531
}
552532

@@ -558,12 +538,89 @@ bool isAmbiguousStoppedVehicle(
558538
const auto stop_for_crosswalk =
559539
to_crosswalk < parameters->object_ignore_section_crosswalk_in_front_distance &&
560540
to_crosswalk > -1.0 * parameters->object_ignore_section_crosswalk_behind_distance;
561-
not_parked_object = not_parked_object || stop_for_crosswalk;
541+
is_close_to_stop_factor = is_close_to_stop_factor || stop_for_crosswalk;
562542
}
563543

564544
object.to_stop_factor_distance = std::min(to_traffic_light, to_crosswalk);
565545

566-
return !not_parked_object;
546+
return is_close_to_stop_factor;
547+
}
548+
549+
bool isNeverAvoidanceTarget(
550+
ObjectData & object, const AvoidancePlanningData & data,
551+
const std::shared_ptr<const PlannerData> & planner_data,
552+
const std::shared_ptr<AvoidanceParameters> & parameters)
553+
{
554+
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
555+
const auto is_moving_distance_longer_than_threshold =
556+
tier4_autoware_utils::calcDistance2d(object.init_pose, object_pose) >
557+
parameters->distance_threshold_for_ambiguous_vehicle;
558+
if (is_moving_distance_longer_than_threshold) {
559+
object.reason = AvoidanceDebugFactor::MOVING_OBJECT;
560+
return true;
561+
}
562+
563+
if (object.is_within_intersection) {
564+
if (object.behavior == ObjectData::Behavior::NONE) {
565+
object.reason = "ParallelToEgoLane";
566+
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object belongs to ego lane. never avoid it.");
567+
return true;
568+
}
569+
570+
if (object.behavior == ObjectData::Behavior::MERGING) {
571+
object.reason = "MergingToEgoLane";
572+
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object belongs to ego lane. never avoid it.");
573+
return true;
574+
}
575+
}
576+
577+
if (object.is_on_ego_lane) {
578+
if (
579+
planner_data->route_handler->getRightLanelet(object.overhang_lanelet).has_value() &&
580+
planner_data->route_handler->getLeftLanelet(object.overhang_lanelet).has_value()) {
581+
object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
582+
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object isn't on the edge lane. never avoid it.");
583+
return true;
584+
}
585+
}
586+
587+
if (isCloseToStopFactor(object, data, planner_data, parameters)) {
588+
if (object.is_on_ego_lane && !object.is_parked) {
589+
object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
590+
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object is close to stop factor. never avoid it.");
591+
return true;
592+
}
593+
}
594+
595+
return false;
596+
}
597+
598+
bool isObviousAvoidanceTarget(
599+
ObjectData & object, [[maybe_unused]] const AvoidancePlanningData & data,
600+
[[maybe_unused]] const std::shared_ptr<const PlannerData> & planner_data,
601+
[[maybe_unused]] const std::shared_ptr<AvoidanceParameters> & parameters)
602+
{
603+
if (!object.is_within_intersection) {
604+
if (object.is_parked && object.behavior == ObjectData::Behavior::NONE) {
605+
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object is obvious parked vehicle.");
606+
return true;
607+
}
608+
609+
if (!object.is_on_ego_lane && object.behavior == ObjectData::Behavior::NONE) {
610+
RCLCPP_DEBUG(rclcpp::get_logger(__func__), "object is adjacent vehicle.");
611+
return true;
612+
}
613+
}
614+
615+
if (!object.is_parked) {
616+
object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
617+
}
618+
619+
if (object.behavior == ObjectData::Behavior::MERGING) {
620+
object.reason = "MergingToEgoLane";
621+
}
622+
623+
return false;
567624
}
568625

569626
bool isSatisfiedWithCommonCondition(
@@ -666,50 +723,56 @@ bool isSatisfiedWithVehicleCondition(
666723
{
667724
object.behavior = getObjectBehavior(object, parameters);
668725
object.is_on_ego_lane = isOnEgoLane(object);
669-
object.is_ambiguous = isAmbiguousStoppedVehicle(object, data, planner_data, parameters);
670726

671-
// from here condition check for vehicle type objects.
672-
if (object.is_ambiguous && parameters->enable_force_avoidance_for_stopped_vehicle) {
727+
if (isNeverAvoidanceTarget(object, data, planner_data, parameters)) {
728+
return false;
729+
}
730+
731+
if (isObviousAvoidanceTarget(object, data, planner_data, parameters)) {
673732
return true;
674733
}
675734

676-
// check vehicle shift ratio
677-
if (object.is_on_ego_lane) {
678-
if (object.is_parked) {
679-
return true;
680-
} else {
681-
object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
682-
return false;
683-
}
735+
// from here, filtering for ambiguous vehicle.
736+
737+
if (!parameters->enable_avoidance_for_ambiguous_vehicle) {
738+
object.reason = "AmbiguousStoppedVehicle";
739+
return false;
684740
}
685741

686-
// Object is on center line -> ignore.
687-
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
688-
object.to_centerline =
689-
lanelet::utils::getArcCoordinates(data.current_lanelets, object_pose).distance;
690-
if (std::abs(object.to_centerline) < parameters->threshold_distance_object_is_on_center) {
691-
object.reason = AvoidanceDebugFactor::TOO_NEAR_TO_CENTERLINE;
742+
const auto stop_time_longer_than_threshold =
743+
object.stop_time > parameters->time_threshold_for_ambiguous_vehicle;
744+
if (!stop_time_longer_than_threshold) {
745+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
692746
return false;
693747
}
694748

695749
if (object.is_within_intersection) {
696-
std::string turn_direction = object.overhang_lanelet.attributeOr("turn_direction", "else");
697-
if (turn_direction == "straight") {
750+
if (object.behavior == ObjectData::Behavior::DEVIATING) {
751+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
752+
object.is_ambiguous = true;
753+
return true;
754+
}
755+
} else {
756+
if (object.behavior == ObjectData::Behavior::MERGING) {
757+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
758+
object.is_ambiguous = true;
698759
return true;
699760
}
700761

701-
if (object.behavior == ObjectData::Behavior::NONE) {
702-
object.reason = "ParallelToEgoLane";
703-
return false;
762+
if (object.behavior == ObjectData::Behavior::DEVIATING) {
763+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
764+
object.is_ambiguous = true;
765+
return true;
704766
}
705-
}
706767

707-
if (object.behavior == ObjectData::Behavior::MERGING) {
708-
object.reason = "MergingToEgoLane";
709-
return false;
768+
if (object.behavior == ObjectData::Behavior::NONE) {
769+
object.is_ambiguous = false;
770+
return true;
771+
}
710772
}
711773

712-
return true;
774+
object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
775+
return false;
713776
}
714777

715778
bool isNoNeedAvoidanceBehavior(
@@ -1636,7 +1699,8 @@ void filterTargetObjects(
16361699
if (filtering_utils::isVehicleTypeObject(o)) {
16371700
o.is_within_intersection =
16381701
filtering_utils::isWithinIntersection(o, planner_data->route_handler);
1639-
o.is_parked = filtering_utils::isParkedVehicle(o, planner_data->route_handler, parameters);
1702+
o.is_parked =
1703+
filtering_utils::isParkedVehicle(o, data, planner_data->route_handler, parameters);
16401704
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
16411705

16421706
if (filtering_utils::isNoNeedAvoidanceBehavior(o, parameters)) {

0 commit comments

Comments
 (0)