@@ -42,6 +42,8 @@ using tier4_autoware_utils::createPoint;
42
42
using tier4_autoware_utils::findNearestIndex;
43
43
using tier4_autoware_utils::getRPY;
44
44
45
+ using PointCloud = pcl::PointCloud<pcl::PointXYZ>;
46
+
45
47
namespace
46
48
{
47
49
rclcpp::SubscriptionOptions createSubscriptionOptions (rclcpp::Node * node_ptr)
@@ -443,7 +445,7 @@ ObstacleStopPlannerNode::ObstacleStopPlannerNode(const rclcpp::NodeOptions & nod
443
445
auto & p = node_param_;
444
446
p.enable_slow_down = declare_parameter (" enable_slow_down" , false );
445
447
p.max_velocity = declare_parameter (" max_velocity" , 20.0 );
446
- p.hunting_threshold = declare_parameter (" hunting_threshold " , 0.5 );
448
+ p.chattering_threshold = declare_parameter (" chattering_threshold " , 0.5 );
447
449
p.lowpass_gain = declare_parameter (" lowpass_gain" , 0.9 );
448
450
lpf_acc_ = std::make_shared<LowpassFilter1d>(0.0 , p.lowpass_gain );
449
451
const double max_yaw_deviation_deg = declare_parameter (" max_yaw_deviation_deg" , 90.0 );
@@ -503,7 +505,6 @@ ObstacleStopPlannerNode::ObstacleStopPlannerNode(const rclcpp::NodeOptions & nod
503
505
acc_controller_ = std::make_unique<motion_planning::AdaptiveCruiseController>(
504
506
this , i.vehicle_width_m , i.vehicle_length_m , i.max_longitudinal_offset_m );
505
507
debug_ptr_ = std::make_shared<ObstacleStopPlannerDebugNode>(this , i.max_longitudinal_offset_m );
506
- last_detection_time_ = this ->now ();
507
508
508
509
// Publishers
509
510
path_pub_ = this ->create_publisher <Trajectory>(" ~/output/trajectory" , 1 );
@@ -632,9 +633,7 @@ void ObstacleStopPlannerNode::pathCallback(const Trajectory::ConstSharedPtr inpu
632
633
current_vel, stop_param);
633
634
634
635
const auto no_slow_down_section = !planner_data.slow_down_require && !latest_slow_down_section_;
635
- const auto no_hunting = (rclcpp::Time (input_msg->header .stamp ) - last_detection_time_).seconds () >
636
- node_param_.hunting_threshold ;
637
- if (node_param_.enable_slow_down && no_slow_down_section && set_velocity_limit_ && no_hunting) {
636
+ if (node_param_.enable_slow_down && no_slow_down_section && set_velocity_limit_) {
638
637
resetExternalVelocityLimit (current_acc, current_vel);
639
638
}
640
639
@@ -662,6 +661,11 @@ void ObstacleStopPlannerNode::searchObstacle(
662
661
return ;
663
662
}
664
663
664
+ const auto now = this ->now ();
665
+ const bool is_stopping = (std::fabs (current_velocity_ptr->twist .twist .linear .x ) < 0.001 );
666
+ const double history_erase_sec = (is_stopping) ? node_param_.chattering_threshold : 0.0 ;
667
+ updateObstacleHistory (now, history_erase_sec);
668
+
665
669
for (size_t i = 0 ; i < decimate_trajectory.size () - 1 ; ++i) {
666
670
// create one step circle center for vehicle
667
671
const auto & p_front = decimate_trajectory.at (i).pose ;
@@ -721,37 +725,79 @@ void ObstacleStopPlannerNode::searchObstacle(
721
725
new pcl::PointCloud<pcl::PointXYZ>);
722
726
collision_pointcloud_ptr->header = obstacle_candidate_pointcloud_ptr->header ;
723
727
724
- planner_data. found_collision_points = withinPolygon (
728
+ const auto found_collision_points = withinPolygon (
725
729
one_step_move_vehicle_polygon, stop_param.stop_search_radius , prev_center_point,
726
730
next_center_point, slow_down_pointcloud_ptr, collision_pointcloud_ptr);
727
731
728
- if (planner_data.found_collision_points ) {
729
- planner_data.decimate_trajectory_collision_index = i;
732
+ if (found_collision_points) {
733
+ pcl::PointXYZ nearest_collision_point;
734
+ rclcpp::Time nearest_collision_point_time;
730
735
getNearestPoint (
731
- *collision_pointcloud_ptr, p_front, &planner_data. nearest_collision_point ,
732
- &planner_data. nearest_collision_point_time );
736
+ *collision_pointcloud_ptr, p_front, &nearest_collision_point,
737
+ &nearest_collision_point_time);
733
738
734
- debug_ptr_->pushObstaclePoint (planner_data.nearest_collision_point , PointType::Stop);
735
- debug_ptr_->pushPolygon (
736
- one_step_move_vehicle_polygon, p_front.position .z , PolygonType::Collision);
737
-
738
- planner_data.stop_require = planner_data.found_collision_points ;
739
- acc_controller_->insertAdaptiveCruiseVelocity (
740
- decimate_trajectory, planner_data.decimate_trajectory_collision_index ,
741
- planner_data.current_pose , planner_data.nearest_collision_point ,
742
- planner_data.nearest_collision_point_time , object_ptr, current_velocity_ptr,
743
- &planner_data.stop_require , &output, trajectory_header);
739
+ obstacle_history_.emplace_back (now, nearest_collision_point);
744
740
745
741
break ;
746
742
}
747
743
}
748
744
}
745
+ for (size_t i = 0 ; i < decimate_trajectory.size () - 1 ; ++i) {
746
+ // create one step circle center for vehicle
747
+ const auto & p_front = decimate_trajectory.at (i).pose ;
748
+ const auto & p_back = decimate_trajectory.at (i + 1 ).pose ;
749
+ const auto prev_center_pose = getVehicleCenterFromBase (p_front, vehicle_info);
750
+ const Point2d prev_center_point (prev_center_pose.position .x , prev_center_pose.position .y );
751
+ const auto next_center_pose = getVehicleCenterFromBase (p_back, vehicle_info);
752
+ const Point2d next_center_point (next_center_pose.position .x , next_center_pose.position .y );
753
+ std::vector<cv::Point2d> one_step_move_vehicle_polygon;
754
+ // create one step polygon for vehicle
755
+ createOneStepPolygon (
756
+ p_front, p_back, one_step_move_vehicle_polygon, vehicle_info, stop_param.expand_stop_range );
757
+ debug_ptr_->pushPolygon (
758
+ one_step_move_vehicle_polygon, decimate_trajectory.at (i).pose .position .z ,
759
+ PolygonType::Vehicle);
760
+
761
+ PointCloud::Ptr collision_pointcloud_ptr (new PointCloud);
762
+ collision_pointcloud_ptr->header = obstacle_candidate_pointcloud_ptr->header ;
763
+
764
+ // check new collision points
765
+ planner_data.found_collision_points = withinPolygon (
766
+ one_step_move_vehicle_polygon, stop_param.stop_search_radius , prev_center_point,
767
+ next_center_point, getOldPointCloudPtr (), collision_pointcloud_ptr);
768
+
769
+ if (planner_data.found_collision_points ) {
770
+ planner_data.decimate_trajectory_collision_index = i;
771
+ getNearestPoint (
772
+ *collision_pointcloud_ptr, p_front, &planner_data.nearest_collision_point ,
773
+ &planner_data.nearest_collision_point_time );
774
+
775
+ debug_ptr_->pushObstaclePoint (planner_data.nearest_collision_point , PointType::Stop);
776
+ debug_ptr_->pushPolygon (
777
+ one_step_move_vehicle_polygon, p_front.position .z , PolygonType::Collision);
778
+
779
+ planner_data.stop_require = planner_data.found_collision_points ;
780
+
781
+ acc_controller_->insertAdaptiveCruiseVelocity (
782
+ decimate_trajectory, planner_data.decimate_trajectory_collision_index ,
783
+ planner_data.current_pose , planner_data.nearest_collision_point ,
784
+ planner_data.nearest_collision_point_time , object_ptr, current_velocity_ptr,
785
+ &planner_data.stop_require , &output, trajectory_header);
786
+
787
+ if (!planner_data.stop_require ) {
788
+ obstacle_history_.clear ();
789
+ }
790
+
791
+ break ;
792
+ }
793
+ }
749
794
}
750
795
751
796
void ObstacleStopPlannerNode::insertVelocity (
752
797
TrajectoryPoints & output, PlannerData & planner_data,
753
- const std_msgs::msg::Header & trajectory_header, const VehicleInfo & vehicle_info,
754
- const double current_acc, const double current_vel, const StopParam & stop_param)
798
+ [[maybe_unused]] const std_msgs::msg::Header & trajectory_header,
799
+ const VehicleInfo & vehicle_info, const double current_acc, const double current_vel,
800
+ const StopParam & stop_param)
755
801
{
756
802
if (output.size () < 3 ) {
757
803
return ;
@@ -799,17 +845,8 @@ void ObstacleStopPlannerNode::insertVelocity(
799
845
index_with_dist_remain.get ().second , dist_baselink_to_obstacle, vehicle_info, current_acc,
800
846
current_vel);
801
847
802
- if (
803
- !latest_slow_down_section_ &&
804
- dist_baselink_to_obstacle + index_with_dist_remain.get ().second <
805
- vehicle_info.max_longitudinal_offset_m ) {
806
- latest_slow_down_section_ = slow_down_section;
807
- }
808
-
809
848
insertSlowDownSection (slow_down_section, output);
810
849
}
811
-
812
- last_detection_time_ = trajectory_header.stamp ;
813
850
}
814
851
815
852
if (node_param_.enable_slow_down && latest_slow_down_section_) {
0 commit comments