@@ -749,11 +749,7 @@ void ObstacleStopPlannerNode::searchPredictedObject(
749
749
}
750
750
751
751
{
752
- double min_collision_norm = 0.0 ;
753
- bool is_init = false ;
754
- size_t nearest_collision_object_index = 0 ;
755
- geometry_msgs::msg::Point nearest_collision_point;
756
-
752
+ bool collision_found_on_trajectory_point = false ;
757
753
for (size_t j = 0 ; j < filtered_objects.objects .size (); ++j) {
758
754
const auto & obj = filtered_objects.objects .at (j);
759
755
if (node_param_.enable_z_axis_obstacle_filtering ) {
@@ -798,43 +794,10 @@ void ObstacleStopPlannerNode::searchPredictedObject(
798
794
continue ;
799
795
}
800
796
if (found_collision_object) {
801
- geometry_msgs::msg::PoseArray collision_points_tmp;
802
-
803
- std::vector<Point2d> collision_point;
804
- bg::intersection (one_step_move_collision_polygon, object_polygon, collision_point);
805
- for (const auto & point : collision_point) {
806
- geometry_msgs::msg::Pose pose;
807
- pose.position .x = point.x ();
808
- pose.position .y = point.y ();
809
- collision_points_tmp.poses .push_back (pose);
810
- }
811
-
812
- // Also check the corner points
813
- for (const auto & point : object_polygon.outer ()) {
814
- if (bg::within (point, one_step_move_collision_polygon)) {
815
- geometry_msgs::msg::Pose pose;
816
- pose.position .x = point.x ();
817
- pose.position .y = point.y ();
818
- collision_points_tmp.poses .push_back (pose);
819
- }
820
- }
821
- geometry_msgs::msg::Point nearest_collision_point_tmp;
822
- const double norm = getNearestPointAndDistanceForPredictedObject (
823
- collision_points_tmp, p_front, &nearest_collision_point_tmp);
824
- if (norm < min_collision_norm || !is_init) {
825
- min_collision_norm = norm;
826
- nearest_collision_point = nearest_collision_point_tmp;
827
- is_init = true ;
828
- nearest_collision_object_index = j;
829
- }
797
+ addPredictedObstacleToHistory (obj, now);
798
+ collision_found_on_trajectory_point = true ;
830
799
}
831
800
}
832
- if (is_init) {
833
- predicted_object_history_.emplace_back (
834
- now, nearest_collision_point,
835
- filtered_objects.objects .at (nearest_collision_object_index));
836
- break ;
837
- }
838
801
839
802
// only used for pedestrian
840
803
Polygon2d one_step_move_collision_dbg;
@@ -848,6 +811,10 @@ void ObstacleStopPlannerNode::searchPredictedObject(
848
811
debug_ptr_->pushPolygon (
849
812
one_step_move_collision_dbg, p_front.position .z , PolygonType::Vehicle);
850
813
}
814
+
815
+ if (collision_found_on_trajectory_point) {
816
+ break ;
817
+ }
851
818
}
852
819
}
853
820
@@ -863,9 +830,7 @@ void ObstacleStopPlannerNode::searchPredictedObject(
863
830
const auto z_axis_max =
864
831
p_front.position .z + vehicle_info.vehicle_height_m + node_param_.z_axis_filtering_buffer ;
865
832
866
- double min_collision_norm = 0.0 ;
867
- bool is_init = false ;
868
- size_t nearest_collision_object_index = 0 ;
833
+ std::vector<IntersectedPredictedObject> intersected_predicted_obj{};
869
834
870
835
for (size_t j = 0 ; j < predicted_object_history_.size (); ++j) {
871
836
// check new collision points
@@ -875,93 +840,118 @@ void ObstacleStopPlannerNode::searchPredictedObject(
875
840
continue ;
876
841
}
877
842
}
878
- Point2d collision_point;
879
- collision_point.x () = predicted_object_history_.at (j).point .x ;
880
- collision_point.y () = predicted_object_history_.at (j).point .y ;
843
+ Polygon2d object_polygon{};
881
844
Polygon2d one_step_move_vehicle_polygon;
882
- // create one step polygon for vehicle
845
+ bool found_collision_object = false ;
883
846
if (obj.shape .type == autoware_auto_perception_msgs::msg::Shape::CYLINDER) {
847
+ object_polygon = convertCylindricalObjectToGeometryPolygon (
848
+ obj.kinematics .initial_pose_with_covariance .pose , obj.shape );
849
+
884
850
createOneStepPolygon (
885
851
p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
886
852
stop_param.pedestrian_lateral_margin );
887
853
854
+ found_collision_object = bg::intersects (one_step_move_vehicle_polygon, object_polygon);
888
855
} else if (obj.shape .type == autoware_auto_perception_msgs::msg::Shape::BOUNDING_BOX) {
856
+ const double & length_m = obj.shape .dimensions .x / 2 ;
857
+ const double & width_m = obj.shape .dimensions .y / 2 ;
858
+ object_polygon = convertBoundingBoxObjectToGeometryPolygon (
859
+ obj.kinematics .initial_pose_with_covariance .pose , length_m, length_m, width_m);
889
860
createOneStepPolygon (
890
861
p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
891
862
stop_param.vehicle_lateral_margin );
892
863
864
+ found_collision_object = bg::intersects (one_step_move_vehicle_polygon, object_polygon);
893
865
} else if (obj.shape .type == autoware_auto_perception_msgs::msg::Shape::POLYGON) {
866
+ object_polygon = convertPolygonObjectToGeometryPolygon (
867
+ obj.kinematics .initial_pose_with_covariance .pose , obj.shape );
894
868
createOneStepPolygon (
895
869
p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
896
870
stop_param.unknown_lateral_margin );
897
871
872
+ found_collision_object = bg::intersects (one_step_move_vehicle_polygon, object_polygon);
898
873
} else {
899
874
RCLCPP_WARN_THROTTLE (
900
875
get_logger (), *get_clock (), 3000 , " Object type is not supported. type: %d" ,
901
876
obj.shape .type );
902
877
continue ;
903
878
}
904
- if (bg::within (collision_point, one_step_move_vehicle_polygon)) {
905
- const double norm = calcDistance2d (predicted_object_history_.at (j).point , p_front.position );
879
+ if (found_collision_object) {
880
+ intersected_predicted_obj.emplace_back (
881
+ predicted_object_history_.at (j).detection_time , obj, object_polygon,
882
+ one_step_move_vehicle_polygon);
883
+ }
884
+ }
885
+
886
+ planner_data.found_collision_points = !intersected_predicted_obj.empty ();
887
+
888
+ if (planner_data.found_collision_points ) {
889
+ // find the nearest point for each object polygon
890
+ double min_collision_norm = 0.0 ;
891
+ bool is_init = false ;
892
+ size_t nearest_collision_object_index = 0 ;
893
+ geometry_msgs::msg::Point nearest_collision_point;
894
+
895
+ for (size_t j = 0 ; j < intersected_predicted_obj.size (); ++j) {
896
+ const auto & one_step_move_vehicle_polygon =
897
+ intersected_predicted_obj.at (j).vehicle_polygon ;
898
+ const auto & obj_polygon = intersected_predicted_obj.at (j).object_polygon ;
899
+ geometry_msgs::msg::PoseArray collision_points_tmp;
900
+
901
+ std::vector<Point2d> collision_point;
902
+ bg::intersection (one_step_move_vehicle_polygon, obj_polygon, collision_point);
903
+ for (const auto & point : collision_point) {
904
+ geometry_msgs::msg::Pose pose;
905
+ pose.position .x = point.x ();
906
+ pose.position .y = point.y ();
907
+ collision_points_tmp.poses .push_back (pose);
908
+ }
909
+
910
+ // Also check the corner points
911
+ for (const auto & point : obj_polygon.outer ()) {
912
+ if (bg::within (point, one_step_move_vehicle_polygon)) {
913
+ geometry_msgs::msg::Pose pose;
914
+ pose.position .x = point.x ();
915
+ pose.position .y = point.y ();
916
+ collision_points_tmp.poses .push_back (pose);
917
+ }
918
+ }
919
+ geometry_msgs::msg::Point nearest_collision_point_tmp;
920
+ const double norm = getNearestPointAndDistanceForPredictedObject (
921
+ collision_points_tmp, p_front, &nearest_collision_point_tmp);
906
922
if (norm < min_collision_norm || !is_init) {
907
923
min_collision_norm = norm;
924
+ nearest_collision_point = nearest_collision_point_tmp;
908
925
is_init = true ;
909
926
nearest_collision_object_index = j;
910
927
}
911
928
}
912
- }
913
-
914
- planner_data.found_collision_points = is_init;
915
929
916
- if (planner_data.found_collision_points ) {
917
- planner_data.nearest_collision_point = pointToPcl (
918
- predicted_object_history_.at (nearest_collision_object_index).point .x ,
919
- predicted_object_history_.at (nearest_collision_object_index).point .y , p_front.position .z );
930
+ planner_data.nearest_collision_point =
931
+ pointToPcl (nearest_collision_point.x , nearest_collision_point.y , p_front.position .z );
920
932
921
933
planner_data.decimate_trajectory_collision_index = i;
922
934
923
935
planner_data.nearest_collision_point_time =
924
- predicted_object_history_ .at (nearest_collision_object_index).detection_time ;
936
+ intersected_predicted_obj .at (nearest_collision_object_index).detection_time ;
925
937
926
- // create one step polygon for vehicle collision debug
927
- Polygon2d one_step_move_vehicle_polygon;
928
- Polygon2d object_polygon{};
929
-
930
- const auto & obj = predicted_object_history_.at (nearest_collision_object_index).object ;
931
- if (obj.shape .type == autoware_auto_perception_msgs::msg::Shape::CYLINDER) {
932
- createOneStepPolygon (
933
- p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
934
- stop_param.pedestrian_lateral_margin );
935
- object_polygon = convertCylindricalObjectToGeometryPolygon (
936
- obj.kinematics .initial_pose_with_covariance .pose , obj.shape );
937
- } else if (obj.shape .type == autoware_auto_perception_msgs::msg::Shape::BOUNDING_BOX) {
938
- createOneStepPolygon (
939
- p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
940
- stop_param.vehicle_lateral_margin );
941
- const double & length_m = obj.shape .dimensions .x / 2 ;
942
- const double & width_m = obj.shape .dimensions .y / 2 ;
943
- object_polygon = convertBoundingBoxObjectToGeometryPolygon (
944
- obj.kinematics .initial_pose_with_covariance .pose , length_m, length_m, width_m);
945
-
946
- } else if (obj.shape .type == autoware_auto_perception_msgs::msg::Shape::POLYGON) {
947
- createOneStepPolygon (
948
- p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
949
- stop_param.unknown_lateral_margin );
950
- object_polygon = convertPolygonObjectToGeometryPolygon (
951
- obj.kinematics .initial_pose_with_covariance .pose , obj.shape );
952
- }
938
+ // debug
953
939
debug_ptr_->pushObstaclePoint (planner_data.nearest_collision_point , PointType::Stop);
954
940
955
941
if (node_param_.enable_z_axis_obstacle_filtering ) {
956
942
debug_ptr_->pushPolyhedron (
957
- one_step_move_vehicle_polygon, z_axis_min, z_axis_max, PolygonType::Collision);
943
+ intersected_predicted_obj.at (nearest_collision_object_index).vehicle_polygon , z_axis_min,
944
+ z_axis_max, PolygonType::Collision);
958
945
} else {
959
946
debug_ptr_->pushPolygon (
960
- one_step_move_vehicle_polygon, p_front.position .z , PolygonType::Collision);
947
+ intersected_predicted_obj.at (nearest_collision_object_index).vehicle_polygon ,
948
+ p_front.position .z , PolygonType::Collision);
961
949
}
962
950
963
951
if (node_param_.publish_obstacle_polygon ) {
964
- debug_ptr_->pushPolygon (object_polygon, p_front.position .z , PolygonType::Obstacle);
952
+ debug_ptr_->pushPolygon (
953
+ intersected_predicted_obj.at (nearest_collision_object_index).object_polygon ,
954
+ p_front.position .z , PolygonType::Obstacle);
965
955
}
966
956
967
957
planner_data.stop_require = planner_data.found_collision_points ;
@@ -970,10 +960,12 @@ void ObstacleStopPlannerNode::searchPredictedObject(
970
960
const auto latest_object_ptr = object_ptr_;
971
961
mutex_.unlock ();
972
962
// find latest state of predicted object to get latest velocity and acceleration values
973
- auto obj_latest_state = getObstacleFromUuid (*latest_object_ptr, obj.object_id );
963
+ auto obj_latest_state = getObstacleFromUuid (
964
+ *latest_object_ptr,
965
+ intersected_predicted_obj.at (nearest_collision_object_index).object .object_id );
974
966
if (!obj_latest_state) {
975
967
// Can not find the object in the latest object list. Send previous state.
976
- obj_latest_state = obj ;
968
+ obj_latest_state = intersected_predicted_obj. at (nearest_collision_object_index). object ;
977
969
}
978
970
979
971
acc_controller_->insertAdaptiveCruiseVelocity (
0 commit comments