@@ -400,6 +400,8 @@ bool DynamicAvoidanceModule::isExecutionReady() const
400
400
401
401
void DynamicAvoidanceModule::updateData ()
402
402
{
403
+ // stop_watch_.tic(std::string(__func__));
404
+
403
405
info_marker_.markers .clear ();
404
406
debug_marker_.markers .clear ();
405
407
@@ -408,14 +410,14 @@ void DynamicAvoidanceModule::updateData()
408
410
409
411
// 1. Rough filtering of target objects with small computing cost
410
412
registerLaneDriveObjects (prev_objects);
411
- registerFreeRunObjects (prev_objects);
413
+ registerPrioritizedObjects (prev_objects);
412
414
413
415
const auto & ego_lat_feasible_paths = generateLateralFeasiblePaths (getEgoPose (), getEgoSpeed ());
414
416
target_objects_manager_.finalize (ego_lat_feasible_paths);
415
417
416
418
// 2. Precise filtering of target objects and check if they should be avoided
417
419
determineWhetherToAvoidAgainstLaneDriveObjects (prev_objects);
418
- determineWhetherToAvoidAgainstFreeRunObjects (prev_objects);
420
+ determineWhetherToAvoidAgainstPrioritizedObjects (prev_objects);
419
421
420
422
const auto target_objects_candidate = target_objects_manager_.getValidObjects ();
421
423
target_objects_.clear ();
@@ -424,6 +426,10 @@ void DynamicAvoidanceModule::updateData()
424
426
target_objects_.push_back (target_object_candidate);
425
427
}
426
428
}
429
+
430
+ // const double calculation_time = stop_watch_.toc(std::string(__func__));
431
+ // RCLCPP_INFO_STREAM_EXPRESSION(
432
+ // getLogger(), parameters_->enable_debug_info, __func__ << ":=" << calculation_time << " [ms]");
427
433
}
428
434
429
435
bool DynamicAvoidanceModule::canTransitSuccessState ()
@@ -433,15 +439,18 @@ bool DynamicAvoidanceModule::canTransitSuccessState()
433
439
434
440
BehaviorModuleOutput DynamicAvoidanceModule::plan ()
435
441
{
442
+ // stop_watch_.tic(std::string(__func__));
443
+
436
444
const auto & input_path = getPreviousModuleOutput ().path ;
445
+ const auto ego_path_reserve_poly = calcEgoPathReservePoly (input_path);
437
446
438
447
// create obstacles to avoid (= extract from the drivable area)
439
448
std::vector<DrivableAreaInfo::Obstacle> obstacles_for_drivable_area;
440
449
for (const auto & object : target_objects_) {
441
450
const auto obstacle_poly = [&]() {
442
451
if (parameters_->polygon_generation_method == PolygonGenerationMethod::EGO_PATH_BASE) {
443
- if (getLabelAsTargetObstacle (object.label ) == ObjectBehaviorType::NonRegulatedObject ) {
444
- return calcFreeRunObstaclePolygon (object, input_path );
452
+ if (getLabelAsTargetObstacle (object.label ) == ObjectBehaviorType::PrioritizedObject ) {
453
+ return calcPrioritizedObstaclePolygon (object, ego_path_reserve_poly );
445
454
} else {
446
455
return calcEgoPathBasedDynamicObstaclePolygon (object);
447
456
}
@@ -475,6 +484,11 @@ BehaviorModuleOutput DynamicAvoidanceModule::plan()
475
484
output.turn_signal_info = getPreviousModuleOutput ().turn_signal_info ;
476
485
output.modified_goal = getPreviousModuleOutput ().modified_goal ;
477
486
487
+ // const double calculation_time = stop_watch_.toc(std::string(__func__));
488
+ // RCLCPP_INFO_STREAM_EXPRESSION(
489
+ // getLogger(), parameters_->enable_debug_info, __func__ << ":=" << calculation_time << "
490
+ // [ms]");
491
+
478
492
return output;
479
493
}
480
494
@@ -507,18 +521,18 @@ ObjectBehaviorType DynamicAvoidanceModule::getLabelAsTargetObstacle(const uint8_
507
521
return ObjectBehaviorType::RegulatedObject;
508
522
}
509
523
if (label == ObjectClassification::UNKNOWN && parameters_->avoid_unknown ) {
510
- return ObjectBehaviorType::NonRegulatedObject ;
524
+ return ObjectBehaviorType::PrioritizedObject ;
511
525
}
512
526
if (label == ObjectClassification::BICYCLE && parameters_->avoid_bicycle ) {
513
- return ObjectBehaviorType::NonRegulatedObject ;
527
+ return ObjectBehaviorType::PrioritizedObject ;
514
528
}
515
529
if (label == ObjectClassification::MOTORCYCLE && parameters_->avoid_motorcycle ) {
516
530
return ObjectBehaviorType::RegulatedObject;
517
531
}
518
532
if (label == ObjectClassification::PEDESTRIAN && parameters_->avoid_pedestrian ) {
519
- return ObjectBehaviorType::NonRegulatedObject ;
533
+ return ObjectBehaviorType::PrioritizedObject ;
520
534
}
521
- return ObjectBehaviorType::NOT_TO_AVOID ;
535
+ return ObjectBehaviorType::OutOfTarget ;
522
536
}
523
537
524
538
void DynamicAvoidanceModule::registerLaneDriveObjects (
@@ -616,7 +630,7 @@ void DynamicAvoidanceModule::registerLaneDriveObjects(
616
630
}
617
631
}
618
632
619
- void DynamicAvoidanceModule::registerFreeRunObjects (
633
+ void DynamicAvoidanceModule::registerPrioritizedObjects (
620
634
const std::vector<DynamicAvoidanceObject> & prev_objects)
621
635
{
622
636
const auto input_path = getPreviousModuleOutput ().path ;
@@ -637,7 +651,7 @@ void DynamicAvoidanceModule::registerFreeRunObjects(
637
651
// 1.a. check label
638
652
if (
639
653
getLabelAsTargetObstacle (predicted_object.classification .front ().label ) !=
640
- ObjectBehaviorType::NonRegulatedObject ) {
654
+ ObjectBehaviorType::PrioritizedObject ) {
641
655
continue ;
642
656
}
643
657
@@ -661,25 +675,11 @@ void DynamicAvoidanceModule::registerFreeRunObjects(
661
675
continue ;
662
676
}
663
677
664
- constexpr double time = 3.0 ;
665
- constexpr double margin = 2.0 ;
666
-
667
678
// 1.e. check if object lateral distance to ego's path is small enough
679
+ constexpr double max_ped_obj_lat_offset_to_ego_path{30.0 };
668
680
const double dist_obj_center_to_path =
669
681
std::abs (motion_utils::calcLateralOffset (input_path.points , obj_pose.position ));
670
- const double obj_long_radius = calcObstacleMaxLength (predicted_object.shape );
671
-
672
- const double space_between_obj_and_ego = dist_obj_center_to_path - obj_long_radius -
673
- planner_data_->parameters .vehicle_width / 2.0 -
674
- obj_vel_norm * time ;
675
-
676
- debug (dist_obj_center_to_path);
677
- debug (obj_long_radius);
678
- debug (planner_data_->parameters .vehicle_width / 2.0 );
679
- debug (obj_vel_norm * time );
680
- debug (space_between_obj_and_ego);
681
-
682
- if (space_between_obj_and_ego > margin * 3.0 ) {
682
+ if (dist_obj_center_to_path > max_ped_obj_lat_offset_to_ego_path) {
683
683
RCLCPP_INFO_EXPRESSION (
684
684
getLogger (), parameters_->enable_debug_info ,
685
685
" [DynamicAvoidance] Ignore obstacle (%s) since lateral distance (%7.3f) is large." ,
@@ -710,7 +710,6 @@ void DynamicAvoidanceModule::registerFreeRunObjects(
710
710
predicted_object, obj_tangent_vel, obj_normal_vel, is_object_on_ego_path,
711
711
latest_time_inside_ego_path);
712
712
target_objects_manager_.updateObject (obj_uuid, target_object);
713
- // std::cerr << "register object: " << obj_uuid << std::endl;
714
713
}
715
714
}
716
715
@@ -874,13 +873,13 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstLaneDriveObjects(
874
873
// prev_input_ref_path_points_ = input_ref_path_points;
875
874
}
876
875
877
- void DynamicAvoidanceModule::determineWhetherToAvoidAgainstFreeRunObjects (
876
+ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstPrioritizedObjects (
878
877
const std::vector<DynamicAvoidanceObject> & prev_objects)
879
878
{
880
879
const auto & input_path = getPreviousModuleOutput ().path ;
881
880
882
881
for (const auto & object : target_objects_manager_.getValidObjects ()) {
883
- if (getLabelAsTargetObstacle (object.label ) != ObjectBehaviorType::NonRegulatedObject ) {
882
+ if (getLabelAsTargetObstacle (object.label ) != ObjectBehaviorType::PrioritizedObject ) {
884
883
continue ;
885
884
}
886
885
@@ -897,52 +896,6 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstFreeRunObjects(
897
896
const auto lat_lon_offset =
898
897
getLateralLongitudinalOffset (input_path.points , object.pose , object.shape );
899
898
900
- // 2.e. check time to collision
901
- // const auto time_while_collision =
902
- // calcTimeWhileCollision(input_path.points, object.vel, lat_lon_offset);
903
- // const double time_to_collision = time_while_collision.time_to_start_collision;
904
- // if (parameters_->max_stopped_object_vel < std::hypot(object.vel, object.lat_vel)) {
905
- // // NOTE: Only not stopped object is filtered by time to collision.
906
- // if (
907
- // (0 <= object.vel &&
908
- // parameters_->max_time_to_collision_overtaking_object < time_to_collision) ||
909
- // (object.vel <= 0 &&
910
- // parameters_->max_time_to_collision_oncoming_object < time_to_collision)) {
911
- // const auto time_to_collision_str = time_to_collision ==
912
- // std::numeric_limits<double>::max()
913
- // ? "infinity"
914
- // : std::to_string(time_to_collision);
915
- // RCLCPP_INFO_EXPRESSION(
916
- // getLogger(), parameters_->enable_debug_info,
917
- // "[DynamicAvoidance] Ignore obstacle (%s) since time to collision (%s) is large.",
918
- // obj_uuid.c_str(), time_to_collision_str.c_str());
919
- // continue;
920
- // }
921
- // if (time_to_collision < -parameters_->duration_to_hold_avoidance_overtaking_object) {
922
- // const auto time_to_collision_str = time_to_collision ==
923
- // std::numeric_limits<double>::max()
924
- // ? "infinity"
925
- // : std::to_string(time_to_collision);
926
- // RCLCPP_INFO_EXPRESSION(
927
- // getLogger(), parameters_->enable_debug_info,
928
- // "[DynamicAvoidance] Ignore obstacle (%s) since time to collision (%s) is a small "
929
- // "negative value.",
930
- // obj_uuid.c_str(), time_to_collision_str.c_str());
931
- // continue;
932
- // }
933
- // }
934
-
935
- // 2.f. calculate which side object will be against ego's path
936
- // const bool is_collision_left = [&]() {
937
- // if (0.0 < object.vel) {
938
- // return is_object_left;
939
- // }
940
- // const auto future_obj_pose =
941
- // object_recognition_utils::calcInterpolatedPose(obj_path, time_to_collision);
942
- // return future_obj_pose ? isLeft(input_path.points, future_obj_pose->position)
943
- // : is_object_left;
944
- // }();
945
-
946
899
// 2.g. check if the ego is not ahead of the object.
947
900
const double signed_dist_ego_to_obj = [&]() {
948
901
const size_t ego_seg_idx = planner_data_->findEgoSegmentIndex (input_path.points );
@@ -980,19 +933,12 @@ void DynamicAvoidanceModule::determineWhetherToAvoidAgainstFreeRunObjects(
980
933
}
981
934
982
935
const bool is_collision_left = (lat_offset_to_avoid.value ().max_value > 0.0 );
983
-
984
- // const auto obj_points = tier4_autoware_utils::toPolygon2d(object.pose, object.shape);
985
- // const auto lon_offset_to_avoid = calcMinMaxLongitudinalOffsetToAvoid(
986
- // ref_path_points_for_obj_poly, object.pose, obj_points, object.vel, obj_path, object.shape,
987
- // time_while_collision);
988
-
989
936
const auto lon_offset_to_avoid = MinMaxValue{0.0 , 1.0 }; // not used. dummy value
990
937
991
938
const bool should_be_avoided = true ;
992
939
target_objects_manager_.updateObjectVariables (
993
940
obj_uuid, lon_offset_to_avoid, *lat_offset_to_avoid, is_collision_left, should_be_avoided,
994
941
ref_path_points_for_obj_poly);
995
- // std::cerr << "labeling as avoid object: " << obj_uuid << std::endl;
996
942
}
997
943
}
998
944
@@ -1842,11 +1788,10 @@ DynamicAvoidanceModule::calcObjectPathBasedDynamicObstaclePolygon(
1842
1788
return obj_poly;
1843
1789
}
1844
1790
1845
- std::optional<tier4_autoware_utils::Polygon2d> DynamicAvoidanceModule::calcFreeRunObstaclePolygon (
1846
- const DynamicAvoidanceObject & object, const PathWithLaneId & ego_path) const
1791
+ std::optional<tier4_autoware_utils::Polygon2d>
1792
+ DynamicAvoidanceModule::calcPrioritizedObstaclePolygon (
1793
+ const DynamicAvoidanceObject & object, const EgoPathReservePoly & ego_path_poly) const
1847
1794
{
1848
- stop_watch_.tic (__func__);
1849
-
1850
1795
constexpr double end_time_to_consider = 3.0 ;
1851
1796
constexpr double required_confidence = 0.3 ;
1852
1797
@@ -1862,7 +1807,7 @@ std::optional<tier4_autoware_utils::Polygon2d> DynamicAvoidanceModule::calcFreeR
1862
1807
}
1863
1808
}
1864
1809
1865
- constexpr double deviation_scale = 1 .0 ;
1810
+ constexpr double deviation_scale = 0 .0 ;
1866
1811
1867
1812
tier4_autoware_utils::Polygon2d obj_points_as_poly;
1868
1813
const double obj_half_length =
@@ -1900,33 +1845,51 @@ std::optional<tier4_autoware_utils::Polygon2d> DynamicAvoidanceModule::calcFreeR
1900
1845
strategy::point_circle ());
1901
1846
if (expanded_poly.empty ()) return {};
1902
1847
1903
- // chack intersects and overwrite by the ego's path
1848
+ tier4_autoware_utils::MultiPolygon2d output_poly;
1849
+ boost::geometry::difference (
1850
+ expanded_poly[0 ],
1851
+ object.is_collision_left ? ego_path_poly.right_avoid : ego_path_poly.left_avoid , output_poly);
1852
+ if (output_poly.empty ()) return {};
1853
+
1854
+ return output_poly[0 ];
1855
+ }
1856
+
1857
+ DynamicAvoidanceModule::EgoPathReservePoly DynamicAvoidanceModule::calcEgoPathReservePoly (
1858
+ const PathWithLaneId & ego_path) const
1859
+ {
1860
+ // stop_watch_.tic(std::string(__func__));
1861
+
1904
1862
tier4_autoware_utils::LineString2d ego_path_lines;
1905
1863
for (const auto & path_point : ego_path.points ) {
1906
1864
ego_path_lines.push_back (tier4_autoware_utils::fromMsg (path_point.point .pose .position ).to_2d ());
1907
1865
}
1908
- // if (boost::geometry::intersects(expanded_poly[0], ego_path_lines)) return {};
1909
1866
1910
1867
const double path_half_width =
1911
1868
planner_data_->parameters .vehicle_width / 2.0 - parameters_->max_lat_offset_to_avoid ;
1912
- strategy::distance_asymmetric<double > distance_strategy (
1913
- object.is_collision_left ? path_half_width : 10.0 ,
1914
- object.is_collision_left ? 10.0 : path_half_width);
1869
+ constexpr double reserve_width = 3.0 ;
1870
+ namespace strategy = boost::geometry::strategy::buffer;
1915
1871
1916
- tier4_autoware_utils::MultiPolygon2d ego_path_restriction_poly;
1872
+ strategy::distance_asymmetric<double > left_avoid_distance_strategy{
1873
+ reserve_width, path_half_width};
1874
+ strategy::distance_asymmetric<double > right_avoid_distance_strategy{
1875
+ path_half_width, reserve_width};
1876
+
1877
+ tier4_autoware_utils::MultiPolygon2d left_avoid_poly;
1917
1878
boost::geometry::buffer (
1918
- ego_path_lines, ego_path_restriction_poly, distance_strategy , strategy::side_straight (),
1919
- strategy::join_miter (), strategy::end_flat (), strategy::point_square ());
1879
+ ego_path_lines, left_avoid_poly, left_avoid_distance_strategy , strategy::side_straight (),
1880
+ strategy::join_round (), strategy::end_flat (), strategy::point_square ());
1920
1881
1921
- tier4_autoware_utils::MultiPolygon2d output_poly;
1922
- boost::geometry::difference (expanded_poly[0 ], ego_path_restriction_poly, output_poly);
1923
- if (output_poly.empty ()) return {};
1882
+ tier4_autoware_utils::MultiPolygon2d right_avoid_poly;
1883
+ boost::geometry::buffer (
1884
+ ego_path_lines, right_avoid_poly, right_avoid_distance_strategy, strategy::side_straight (),
1885
+ strategy::join_round (), strategy::end_flat (), strategy::point_square ());
1924
1886
1925
- const double calculation_time = stop_watch_.toc (__func__);
1926
- RCLCPP_INFO_EXPRESSION (
1927
- getLogger (), parameters_->enable_debug_info , " %s := %f [ms]" , __func__, calculation_time);
1887
+ // const double calculation_time = stop_watch_.toc(std::string(__func__));
1888
+ // RCLCPP_INFO_STREAM_EXPRESSION(
1889
+ // getLogger(), parameters_->enable_debug_info, __func__ << ":=" << calculation_time << "
1890
+ // [ms]");
1928
1891
1929
- return output_poly[ 0 ] ;
1892
+ return {left_avoid_poly, right_avoid_poly} ;
1930
1893
}
1931
1894
1932
1895
} // namespace behavior_path_planner
0 commit comments