@@ -231,6 +231,94 @@ void ObstacleSlowDownModule::update_parameters(
231
231
{
232
232
}
233
233
234
+ std::vector<autoware::motion_velocity_planner::SlowDownPointData>
235
+ ObstacleSlowDownModule::convert_point_cloud_to_slow_down_points (
236
+ const PlannerData::Pointcloud & pointcloud, const std::vector<TrajectoryPoint> & traj_points,
237
+ const VehicleInfo & vehicle_info, const size_t ego_idx)
238
+ {
239
+ if (pointcloud.pointcloud .empty ()) {
240
+ return {};
241
+ }
242
+
243
+ autoware::universe_utils::ScopedTimeTrack st (__func__, *time_keeper_);
244
+
245
+ const auto & p = obstacle_filtering_param_;
246
+
247
+ std::vector<autoware::motion_velocity_planner::SlowDownPointData> slow_down_points;
248
+
249
+ // 1. transform pointcloud
250
+ pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud_ptr =
251
+ std::make_shared<pcl::PointCloud<pcl::PointXYZ>>(pointcloud.pointcloud );
252
+ // 2. downsample & cluster pointcloud
253
+ PointCloud::Ptr filtered_points_ptr (new PointCloud);
254
+ pcl::VoxelGrid<pcl::PointXYZ> filter;
255
+ filter.setInputCloud (pointcloud_ptr);
256
+ filter.setLeafSize (
257
+ p.pointcloud_obstacle_filtering_param .pointcloud_voxel_grid_x ,
258
+ p.pointcloud_obstacle_filtering_param .pointcloud_voxel_grid_y ,
259
+ p.pointcloud_obstacle_filtering_param .pointcloud_voxel_grid_z );
260
+ filter.filter (*filtered_points_ptr);
261
+
262
+ pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
263
+ tree->setInputCloud (filtered_points_ptr);
264
+ std::vector<pcl::PointIndices> clusters;
265
+ pcl::EuclideanClusterExtraction<pcl::PointXYZ> ec;
266
+ ec.setClusterTolerance (p.pointcloud_obstacle_filtering_param .pointcloud_cluster_tolerance );
267
+ ec.setMinClusterSize (p.pointcloud_obstacle_filtering_param .pointcloud_min_cluster_size );
268
+ ec.setMaxClusterSize (p.pointcloud_obstacle_filtering_param .pointcloud_max_cluster_size );
269
+ ec.setSearchMethod (tree);
270
+ ec.setInputCloud (filtered_points_ptr);
271
+ ec.extract (clusters);
272
+
273
+ // 3. convert clusters to obstacles
274
+ for (const auto & cluster_indices : clusters) {
275
+ double ego_to_slow_down_front_collision_distance = std::numeric_limits<double >::max ();
276
+ double ego_to_slow_down_back_collision_distance = std::numeric_limits<double >::min ();
277
+ double lat_dist_from_obstacle_to_traj = std::numeric_limits<double >::max ();
278
+ std::optional<geometry_msgs::msg::Point > slow_down_front_collision_point = std::nullopt;
279
+ std::optional<geometry_msgs::msg::Point > slow_down_back_collision_point = std::nullopt;
280
+
281
+ for (const auto & index : cluster_indices.indices ) {
282
+ const auto obstacle_point = autoware::motion_velocity_planner::utils::to_geometry_point (
283
+ filtered_points_ptr->points [index ]);
284
+ const auto current_lat_dist_from_obstacle_to_traj =
285
+ autoware::motion_utils::calcLateralOffset (traj_points, obstacle_point);
286
+ const auto min_lat_dist_to_traj_poly =
287
+ std::abs (current_lat_dist_from_obstacle_to_traj) - vehicle_info.vehicle_width_m ;
288
+
289
+ if (min_lat_dist_to_traj_poly >= p.max_lat_margin ) {
290
+ continue ;
291
+ }
292
+
293
+ const auto current_ego_to_obstacle_distance =
294
+ autoware::motion_velocity_planner::utils::calc_distance_to_front_object (
295
+ traj_points, ego_idx, obstacle_point);
296
+ if (!current_ego_to_obstacle_distance) {
297
+ continue ;
298
+ }
299
+
300
+ lat_dist_from_obstacle_to_traj =
301
+ std::min (lat_dist_from_obstacle_to_traj, current_lat_dist_from_obstacle_to_traj);
302
+
303
+ if (*current_ego_to_obstacle_distance < ego_to_slow_down_front_collision_distance) {
304
+ slow_down_front_collision_point = obstacle_point;
305
+ ego_to_slow_down_front_collision_distance = *current_ego_to_obstacle_distance;
306
+ } else if (*current_ego_to_obstacle_distance > ego_to_slow_down_back_collision_distance) {
307
+ slow_down_back_collision_point = obstacle_point;
308
+ ego_to_slow_down_back_collision_distance = *current_ego_to_obstacle_distance;
309
+ }
310
+ }
311
+
312
+ if (slow_down_front_collision_point) {
313
+ slow_down_points.emplace_back (
314
+ slow_down_front_collision_point, slow_down_back_collision_point,
315
+ lat_dist_from_obstacle_to_traj);
316
+ }
317
+ }
318
+
319
+ return slow_down_points;
320
+ }
321
+
234
322
VelocityPlanningResult ObstacleSlowDownModule::plan (
235
323
const std::vector<autoware_planning_msgs::msg::TrajectoryPoint> & raw_trajectory_points,
236
324
[[maybe_unused]] const std::vector<autoware_planning_msgs::msg::TrajectoryPoint> &
@@ -249,12 +337,22 @@ VelocityPlanningResult ObstacleSlowDownModule::plan(
249
337
planner_data->ego_nearest_dist_threshold , planner_data->ego_nearest_yaw_threshold ,
250
338
planner_data->trajectory_polygon_collision_check .decimate_trajectory_step_length , 0.0 );
251
339
252
- const auto slow_down_obstacles = filter_slow_down_obstacle_for_predicted_object (
340
+ auto slow_down_obstacles_for_predicted_object = filter_slow_down_obstacle_for_predicted_object (
253
341
planner_data->current_odometry , planner_data->ego_nearest_dist_threshold ,
254
342
planner_data->ego_nearest_yaw_threshold , raw_trajectory_points, decimated_traj_points,
255
343
planner_data->objects , rclcpp::Time (planner_data->predicted_objects_header .stamp ),
256
344
planner_data->vehicle_info_ , planner_data->trajectory_polygon_collision_check );
257
345
346
+ auto slow_down_obstacles_for_point_cloud = filter_slow_down_obstacle_for_point_cloud (
347
+ planner_data->current_odometry , raw_trajectory_points, decimated_traj_points,
348
+ planner_data->no_ground_pointcloud , planner_data->vehicle_info_ ,
349
+ planner_data->trajectory_polygon_collision_check ,
350
+ planner_data->find_index (raw_trajectory_points, planner_data->current_odometry .pose .pose ));
351
+
352
+ const auto slow_down_obstacles = autoware::motion_velocity_planner::utils::concat_vectors (
353
+ std::move (slow_down_obstacles_for_predicted_object),
354
+ std::move (slow_down_obstacles_for_point_cloud));
355
+
258
356
VelocityPlanningResult result;
259
357
result.slowdown_intervals = plan_slow_down (
260
358
planner_data, raw_trajectory_points, slow_down_obstacles, result.velocity_limit ,
@@ -348,6 +446,53 @@ ObstacleSlowDownModule::filter_slow_down_obstacle_for_predicted_object(
348
446
return slow_down_obstacles;
349
447
}
350
448
449
+ std::vector<SlowDownObstacle> ObstacleSlowDownModule::filter_slow_down_obstacle_for_point_cloud (
450
+ const Odometry & odometry, const std::vector<TrajectoryPoint> & traj_points,
451
+ const std::vector<TrajectoryPoint> & decimated_traj_points,
452
+ const PlannerData::Pointcloud & point_cloud, const VehicleInfo & vehicle_info,
453
+ const TrajectoryPolygonCollisionCheck & trajectory_polygon_collision_check, size_t ego_idx)
454
+ {
455
+ autoware::universe_utils::ScopedTimeTrack st (__func__, *time_keeper_);
456
+
457
+ // calculate collision points with trajectory with lateral stop margin
458
+ // NOTE: For additional margin, hysteresis is not divided by two.
459
+ const auto & p = obstacle_filtering_param_;
460
+ const auto & tp = trajectory_polygon_collision_check;
461
+ const auto decimated_traj_polys_with_lat_margin = polygon_utils::create_one_step_polygons (
462
+ decimated_traj_points, vehicle_info, odometry.pose .pose ,
463
+ p.max_lat_margin + p.lat_hysteresis_margin , tp.enable_to_consider_current_pose ,
464
+ tp.time_to_convergence , tp.decimate_trajectory_step_length );
465
+ debug_data_ptr_->decimated_traj_polys = decimated_traj_polys_with_lat_margin;
466
+
467
+ // Get Objects
468
+ const std::vector<autoware::motion_velocity_planner::SlowDownPointData> slow_down_points_data =
469
+ convert_point_cloud_to_slow_down_points (point_cloud, traj_points, vehicle_info, ego_idx);
470
+
471
+ // slow down
472
+ std::vector<SlowDownObstacle> slow_down_obstacles;
473
+ for (const auto & slow_down_point_data : slow_down_points_data) {
474
+ if (!slow_down_point_data.front ) {
475
+ continue ;
476
+ }
477
+ const auto & front_collision_point = *slow_down_point_data.front ;
478
+ const auto & back_collision_point = slow_down_point_data.back .value_or (front_collision_point);
479
+
480
+ const auto slow_down_obstacle = create_slow_down_obstacle_for_point_cloud (
481
+ rclcpp::Time (point_cloud.pointcloud .header .stamp ), front_collision_point,
482
+ back_collision_point, slow_down_point_data.lat_dist_to_traj );
483
+
484
+ if (slow_down_obstacle) {
485
+ slow_down_obstacles.push_back (*slow_down_obstacle);
486
+ continue ;
487
+ }
488
+ }
489
+
490
+ RCLCPP_DEBUG (
491
+ logger_, " The number of output obstacles of filter_slow_down_obstacles is %ld" ,
492
+ slow_down_obstacles.size ());
493
+ return slow_down_obstacles;
494
+ }
495
+
351
496
std::optional<SlowDownObstacle>
352
497
ObstacleSlowDownModule::create_slow_down_obstacle_for_predicted_object (
353
498
const std::vector<TrajectoryPoint> & traj_points,
@@ -485,6 +630,37 @@ ObstacleSlowDownModule::create_slow_down_obstacle_for_predicted_object(
485
630
back_collision_point};
486
631
}
487
632
633
+ std::optional<SlowDownObstacle> ObstacleSlowDownModule::create_slow_down_obstacle_for_point_cloud (
634
+ const rclcpp::Time & stamp, const geometry_msgs::msg::Point & front_collision_point,
635
+ const geometry_msgs::msg::Point & back_collision_point, const double lat_dist_to_traj)
636
+ {
637
+ if (!obstacle_filtering_param_.use_pointcloud ) {
638
+ return std::nullopt;
639
+ }
640
+ const unique_identifier_msgs::msg::UUID obj_uuid;
641
+ const auto & obj_uuid_str = autoware::universe_utils::toHexString (obj_uuid);
642
+
643
+ ObjectClassification unknown_object_classification;
644
+ unknown_object_classification.label = ObjectClassification::UNKNOWN;
645
+ unknown_object_classification.probability = 1.0 ;
646
+
647
+ const geometry_msgs::msg::Pose unconfigured_pose;
648
+
649
+ const double unconfigured_lon_velocity = 0 .;
650
+ const double unconfigured_lat_velocity = 0 .;
651
+
652
+ return SlowDownObstacle{
653
+ obj_uuid_str,
654
+ stamp,
655
+ unknown_object_classification,
656
+ unconfigured_pose,
657
+ unconfigured_lon_velocity,
658
+ unconfigured_lat_velocity,
659
+ lat_dist_to_traj,
660
+ front_collision_point,
661
+ back_collision_point};
662
+ }
663
+
488
664
std::vector<SlowdownInterval> ObstacleSlowDownModule::plan_slow_down (
489
665
const std::shared_ptr<const PlannerData> planner_data,
490
666
const std::vector<TrajectoryPoint> & traj_points, const std::vector<SlowDownObstacle> & obstacles,
0 commit comments