@@ -364,14 +364,14 @@ void DynamicAvoidanceModule::updateData()
364
364
365
365
// 1. Rough filtering of target objects with small computing cost
366
366
registerRegulatedObjects (prev_objects);
367
- registerPrioritizedObjects (prev_objects);
367
+ registerUnregulatedObjects (prev_objects);
368
368
369
369
const auto & ego_lat_feasible_paths = generateLateralFeasiblePaths (getEgoPose (), getEgoSpeed ());
370
370
target_objects_manager_.finalize (ego_lat_feasible_paths);
371
371
372
372
// 2. Precise filtering of target objects and check if they should be avoided
373
373
determineWhetherToAvoidAgainstRegulatedObjects (prev_objects);
374
- determineWhetherToAvoidAgainstPrioritizedObjects (prev_objects);
374
+ determineWhetherToAvoidAgainstUnregulatedObjects (prev_objects);
375
375
376
376
const auto target_objects_candidate = target_objects_manager_.getValidObjects ();
377
377
target_objects_.clear ();
@@ -407,8 +407,8 @@ BehaviorModuleOutput DynamicAvoidanceModule::plan()
407
407
std::vector<DrivableAreaInfo::Obstacle> obstacles_for_drivable_area;
408
408
for (const auto & object : target_objects_) {
409
409
const auto obstacle_poly = [&]() {
410
- if (getLabelAsTargetObstacle (object.label ) == ObjectBehaviorType::PRIORITIZED ) {
411
- return calcPrioritizedObstacleAvoidPolygon (object, ego_path_reserve_poly);
410
+ if (getLabelAsTargetObstacle (object.label ) == ObjectType::UNREGULATED ) {
411
+ return calcPredictedPathBasedDynamicObstaclePolygon (object, ego_path_reserve_poly);
412
412
}
413
413
414
414
if (parameters_->polygon_generation_method == PolygonGenerationMethod::EGO_PATH_BASE) {
@@ -463,35 +463,35 @@ BehaviorModuleOutput DynamicAvoidanceModule::planWaitingApproval()
463
463
return out;
464
464
}
465
465
466
- ObjectBehaviorType DynamicAvoidanceModule::getLabelAsTargetObstacle (const uint8_t label) const
466
+ ObjectType DynamicAvoidanceModule::getLabelAsTargetObstacle (const uint8_t label) const
467
467
{
468
468
using autoware_auto_perception_msgs::msg::ObjectClassification;
469
469
470
470
if (label == ObjectClassification::CAR && parameters_->avoid_car ) {
471
- return ObjectBehaviorType ::REGULATED;
471
+ return ObjectType ::REGULATED;
472
472
}
473
473
if (label == ObjectClassification::TRUCK && parameters_->avoid_truck ) {
474
- return ObjectBehaviorType ::REGULATED;
474
+ return ObjectType ::REGULATED;
475
475
}
476
476
if (label == ObjectClassification::BUS && parameters_->avoid_bus ) {
477
- return ObjectBehaviorType ::REGULATED;
477
+ return ObjectType ::REGULATED;
478
478
}
479
479
if (label == ObjectClassification::TRAILER && parameters_->avoid_trailer ) {
480
- return ObjectBehaviorType ::REGULATED;
480
+ return ObjectType ::REGULATED;
481
481
}
482
482
if (label == ObjectClassification::UNKNOWN && parameters_->avoid_unknown ) {
483
- return ObjectBehaviorType::PRIORITIZED ;
483
+ return ObjectType::UNREGULATED ;
484
484
}
485
485
if (label == ObjectClassification::BICYCLE && parameters_->avoid_bicycle ) {
486
- return ObjectBehaviorType::PRIORITIZED ;
486
+ return ObjectType::UNREGULATED ;
487
487
}
488
488
if (label == ObjectClassification::MOTORCYCLE && parameters_->avoid_motorcycle ) {
489
- return ObjectBehaviorType ::REGULATED;
489
+ return ObjectType ::REGULATED;
490
490
}
491
491
if (label == ObjectClassification::PEDESTRIAN && parameters_->avoid_pedestrian ) {
492
- return ObjectBehaviorType::PRIORITIZED ;
492
+ return ObjectType::UNREGULATED ;
493
493
}
494
- return ObjectBehaviorType::IGNORE ;
494
+ return ObjectType::OUT_OF_SCOPE ;
495
495
}
496
496
497
497
void DynamicAvoidanceModule::registerRegulatedObjects (
@@ -519,7 +519,7 @@ void DynamicAvoidanceModule::registerRegulatedObjects(
519
519
// 1.a. check label
520
520
if (
521
521
getLabelAsTargetObstacle (predicted_object.classification .front ().label ) !=
522
- ObjectBehaviorType ::REGULATED) {
522
+ ObjectType ::REGULATED) {
523
523
continue ;
524
524
}
525
525
@@ -588,7 +588,7 @@ void DynamicAvoidanceModule::registerRegulatedObjects(
588
588
}
589
589
}
590
590
591
- void DynamicAvoidanceModule::registerPrioritizedObjects (
591
+ void DynamicAvoidanceModule::registerUnregulatedObjects (
592
592
const std::vector<DynamicAvoidanceObject> & prev_objects)
593
593
{
594
594
const auto input_path = getPreviousModuleOutput ().path ;
@@ -606,14 +606,14 @@ void DynamicAvoidanceModule::registerPrioritizedObjects(
606
606
predicted_object.kinematics .predicted_paths .end (),
607
607
[](const PredictedPath & a, const PredictedPath & b) { return a.confidence < b.confidence ; });
608
608
609
- // 1.a. check label
609
+ // 1.a. Check if the obstacle is labeled as pedestrians, bicycle or similar.
610
610
if (
611
611
getLabelAsTargetObstacle (predicted_object.classification .front ().label ) !=
612
- ObjectBehaviorType::PRIORITIZED ) {
612
+ ObjectType::UNREGULATED ) {
613
613
continue ;
614
614
}
615
615
616
- // 1.b. check obstacle velocity
616
+ // 1.b. Check if the object's velocity is within the module's coverage range.
617
617
const auto [obj_tangent_vel, obj_normal_vel] =
618
618
projectObstacleVelocityToTrajectory (input_path.points , predicted_object);
619
619
if (
@@ -622,7 +622,7 @@ void DynamicAvoidanceModule::registerPrioritizedObjects(
622
622
continue ;
623
623
}
624
624
625
- // 1.c. check if object is not crossing ego's path
625
+ // 1.c. Check if object' lateral velocity is small enough to be avoid.
626
626
if (obj_normal_vel > parameters_->max_pedestrians_crossing_vel ) {
627
627
RCLCPP_INFO_EXPRESSION (
628
628
getLogger (), parameters_->enable_debug_info ,
@@ -632,20 +632,12 @@ void DynamicAvoidanceModule::registerPrioritizedObjects(
632
632
continue ;
633
633
}
634
634
635
- // 1.e. check if object lateral distance to ego's path is small enough
635
+ // Blocks for compatibility with existing code
636
+ // 1.e. check if object lateral distance to ego's path is small enough
637
+ // 1.f. calculate the object is on ego's path or not
638
+
636
639
const double dist_obj_center_to_path =
637
640
std::abs (motion_utils::calcLateralOffset (input_path.points , obj_pose.position ));
638
-
639
- // constexpr double max_ped_obj_lat_offset_to_ego_path = 30.0;
640
- // if (dist_obj_center_to_path > max_ped_obj_lat_offset_to_ego_path) {
641
- // RCLCPP_INFO_EXPRESSION(
642
- // getLogger(), parameters_->enable_debug_info,
643
- // "[DynamicAvoidance] Ignore obstacle (%s) since lateral distance (%7.3f) is large.",
644
- // obj_uuid.c_str(), dist_obj_center_to_path);
645
- // continue;
646
- // }
647
-
648
- // 1.f. calculate the object is on ego's path or not
649
641
const bool is_object_on_ego_path =
650
642
dist_obj_center_to_path <
651
643
planner_data_->parameters .vehicle_width / 2.0 + parameters_->min_obj_lat_offset_to_ego_path ;
@@ -664,6 +656,7 @@ void DynamicAvoidanceModule::registerPrioritizedObjects(
664
656
return *prev_object->latest_time_inside_ego_path ;
665
657
}();
666
658
659
+ // register the object
667
660
const auto target_object = DynamicAvoidanceObject (
668
661
predicted_object, obj_tangent_vel, obj_normal_vel, is_object_on_ego_path,
669
662
latest_time_inside_ego_path);
@@ -677,7 +670,7 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstRegulatedObjects(
677
670
const auto & input_path = getPreviousModuleOutput ().path ;
678
671
679
672
for (const auto & object : target_objects_manager_.getValidObjects ()) {
680
- if (getLabelAsTargetObstacle (object.label ) != ObjectBehaviorType ::REGULATED) {
673
+ if (getLabelAsTargetObstacle (object.label ) != ObjectType ::REGULATED) {
681
674
continue ;
682
675
}
683
676
@@ -810,7 +803,7 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstRegulatedObjects(
810
803
const auto lon_offset_to_avoid = calcMinMaxLongitudinalOffsetToAvoid (
811
804
ref_path_points_for_obj_poly, object.pose , obj_points, object.vel , obj_path, object.shape ,
812
805
time_while_collision);
813
- const auto lat_offset_to_avoid = calcMinMaxLateralOffsetToAvoid (
806
+ const auto lat_offset_to_avoid = calcMinMaxLateralOffsetToAvoidRegulatedObject (
814
807
ref_path_points_for_obj_poly, obj_points, object.pose .position , object.vel , is_collision_left,
815
808
object.lat_vel , prev_object);
816
809
@@ -831,30 +824,22 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstRegulatedObjects(
831
824
// prev_input_ref_path_points_ = input_ref_path_points;
832
825
}
833
826
834
- void DynamicAvoidanceModule::determineWhetherToAvoidAgainstPrioritizedObjects (
827
+ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstUnregulatedObjects (
835
828
const std::vector<DynamicAvoidanceObject> & prev_objects)
836
829
{
837
830
const auto & input_path = getPreviousModuleOutput ().path ;
838
831
839
832
for (const auto & object : target_objects_manager_.getValidObjects ()) {
840
- if (getLabelAsTargetObstacle (object.label ) != ObjectBehaviorType::PRIORITIZED ) {
833
+ if (getLabelAsTargetObstacle (object.label ) != ObjectType::UNREGULATED ) {
841
834
continue ;
842
835
}
843
836
844
837
const auto obj_uuid = object.uuid ;
845
- const auto prev_object = getObstacleFromUuid (prev_objects, obj_uuid);
846
- const auto obj_path = *std::max_element (
847
- object.predicted_paths .begin (), object.predicted_paths .end (),
848
- [](const PredictedPath & a, const PredictedPath & b) { return a.confidence < b.confidence ; });
849
-
850
838
const auto & ref_path_points_for_obj_poly = input_path.points ;
851
839
852
- // 2.b. calculate which side object exists against ego's path
853
- const bool is_object_left = isLeft (input_path.points , object.pose .position );
840
+ // 2.g. check if the ego is not ahead of the object.
854
841
const auto lat_lon_offset =
855
842
getLateralLongitudinalOffset (input_path.points , object.pose , object.shape );
856
-
857
- // 2.g. check if the ego is not ahead of the object.
858
843
const double signed_dist_ego_to_obj = [&]() {
859
844
const size_t ego_seg_idx = planner_data_->findEgoSegmentIndex (input_path.points );
860
845
const double lon_offset_ego_to_obj = motion_utils::calcSignedArcLength (
@@ -879,8 +864,8 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstPrioritizedObjects(
879
864
880
865
// 2.h. calculate longitudinal and lateral offset to avoid to generate object polygon by
881
866
// "ego_path_base"
882
- const auto lat_offset_to_avoid = calcMinMaxLateralOffsetAgainstPrioritizedObject (
883
- ref_path_points_for_obj_poly, prev_object , object);
867
+ const auto lat_offset_to_avoid = calcMinMaxLateralOffsetToAvoidUnregulatedObject (
868
+ ref_path_points_for_obj_poly, getObstacleFromUuid (prev_objects, obj_uuid) , object);
884
869
if (!lat_offset_to_avoid) {
885
870
RCLCPP_INFO_EXPRESSION (
886
871
getLogger (), parameters_->enable_debug_info ,
@@ -1409,7 +1394,7 @@ double DynamicAvoidanceModule::calcValidLengthToAvoid(
1409
1394
}
1410
1395
1411
1396
// min value denotes near side, max value denotes far side
1412
- std::optional<MinMaxValue> DynamicAvoidanceModule::calcMinMaxLateralOffsetToAvoid (
1397
+ std::optional<MinMaxValue> DynamicAvoidanceModule::calcMinMaxLateralOffsetToAvoidRegulatedObject (
1413
1398
const std::vector<PathPointWithLaneId> & ref_path_points_for_obj_poly,
1414
1399
const Polygon2d & obj_points, const geometry_msgs::msg::Point & obj_pos, const double obj_vel,
1415
1400
const bool is_collision_left, const double obj_normal_vel,
@@ -1503,7 +1488,7 @@ std::optional<MinMaxValue> DynamicAvoidanceModule::calcMinMaxLateralOffsetToAvoi
1503
1488
}
1504
1489
1505
1490
// min value denotes near side, max value denotes far side
1506
- std::optional<MinMaxValue> DynamicAvoidanceModule::calcMinMaxLateralOffsetAgainstPrioritizedObject (
1491
+ std::optional<MinMaxValue> DynamicAvoidanceModule::calcMinMaxLateralOffsetToAvoidUnregulatedObject (
1507
1492
const std::vector<PathPointWithLaneId> & ref_path_points_for_obj_poly,
1508
1493
const std::optional<DynamicAvoidanceObject> & prev_object,
1509
1494
const DynamicAvoidanceObject & object) const
@@ -1691,6 +1676,7 @@ DynamicAvoidanceModule::calcEgoPathBasedDynamicObstaclePolygon(
1691
1676
return obj_poly;
1692
1677
}
1693
1678
1679
+ // TODO (takagi): replace by another function?
1694
1680
std::optional<tier4_autoware_utils::Polygon2d>
1695
1681
DynamicAvoidanceModule::calcObjectPathBasedDynamicObstaclePolygon (
1696
1682
const DynamicAvoidanceObject & object) const
@@ -1747,8 +1733,11 @@ DynamicAvoidanceModule::calcObjectPathBasedDynamicObstaclePolygon(
1747
1733
return obj_poly;
1748
1734
}
1749
1735
1736
+ // Calculate polygons according to predicted_path with certain confidence,
1737
+ // except for the area required for ego safety.
1738
+ // input: an object, the minimum area required for ego safety, and some global params
1750
1739
std::optional<tier4_autoware_utils::Polygon2d>
1751
- DynamicAvoidanceModule::calcPrioritizedObstacleAvoidPolygon (
1740
+ DynamicAvoidanceModule::calcPredictedPathBasedDynamicObstaclePolygon (
1752
1741
const DynamicAvoidanceObject & object, const EgoPathReservePoly & ego_path_poly) const
1753
1742
{
1754
1743
std::vector<geometry_msgs::msg::Pose> candidate_poses;
@@ -1763,19 +1752,13 @@ DynamicAvoidanceModule::calcPrioritizedObstacleAvoidPolygon(
1763
1752
}
1764
1753
}
1765
1754
1766
- constexpr double deviation_scale = 0.0 ; // for experimental
1767
- namespace cov_idx = tier4_autoware_utils::xyzrpy_covariance_index;
1768
- const double obj_half_length =
1769
- object.shape .dimensions .x * 0.5 + object.pose_covariance_sqrt [cov_idx::X_X] * deviation_scale;
1770
- const double obj_half_width =
1771
- object.shape .dimensions .y * 0.5 + object.pose_covariance_sqrt [cov_idx::Y_Y] * deviation_scale;
1772
-
1773
1755
tier4_autoware_utils::Polygon2d obj_points_as_poly;
1774
1756
for (const auto pose : candidate_poses) {
1775
1757
boost::geometry::append (
1776
- obj_points_as_poly,
1777
- tier4_autoware_utils::toFootprint (pose, obj_half_length, obj_half_length, obj_half_width)
1778
- .outer ());
1758
+ obj_points_as_poly, tier4_autoware_utils::toFootprint (
1759
+ pose, object.shape .dimensions .x * 0.5 , object.shape .dimensions .x * 0.5 ,
1760
+ object.shape .dimensions .y * 0.5 )
1761
+ .outer ());
1779
1762
}
1780
1763
boost::geometry::correct (obj_points_as_poly);
1781
1764
Polygon2d obj_poly;
@@ -1812,6 +1795,9 @@ DynamicAvoidanceModule::calcPrioritizedObstacleAvoidPolygon(
1812
1795
return output_poly[0 ];
1813
1796
}
1814
1797
1798
+ // Calculate the driving area required to ensure the safety of the own vehicle.
1799
+ // It is assumed that this area will not be clipped.
1800
+ // input: ego's reference path, ego's pose, ego's speed, and some global params
1815
1801
DynamicAvoidanceModule::EgoPathReservePoly DynamicAvoidanceModule::calcEgoPathPreservePoly (
1816
1802
const PathWithLaneId & ego_path) const
1817
1803
{
0 commit comments