@@ -129,6 +129,9 @@ AEB::AEB(const rclcpp::NodeOptions & node_options)
129
129
publish_debug_pointcloud_ = declare_parameter<bool >(" publish_debug_pointcloud" );
130
130
use_predicted_trajectory_ = declare_parameter<bool >(" use_predicted_trajectory" );
131
131
use_imu_path_ = declare_parameter<bool >(" use_imu_path" );
132
+ crop_pointcloud_with_path_footprint_ =
133
+ declare_parameter<bool >(" crop_pointcloud_with_path_footprint" );
134
+ path_footprint_extra_margin_ = declare_parameter<double >(" path_footprint_extra_margin" );
132
135
detection_range_min_height_ = declare_parameter<double >(" detection_range_min_height" );
133
136
detection_range_max_height_margin_ =
134
137
declare_parameter<double >(" detection_range_max_height_margin" );
@@ -322,23 +325,30 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
322
325
// step3. create ego path based on sensor data
323
326
bool has_collision_ego = false ;
324
327
if (use_imu_path_) {
325
- std::vector<Polygon2d> ego_polys;
326
328
const double current_w = angular_velocity_ptr_->z ;
327
329
constexpr double color_r = 0.0 / 256.0 ;
328
330
constexpr double color_g = 148.0 / 256.0 ;
329
331
constexpr double color_b = 205.0 / 256.0 ;
330
332
constexpr double color_a = 0.999 ;
331
333
const auto current_time = get_clock ()->now ();
332
- const auto ego_path = generateEgoPath (current_v, current_w, ego_polys );
334
+ const auto ego_path = generateEgoPath (current_v, current_w);
333
335
334
- std::vector<ObjectData> objects_cluster;
335
- cropPointCloudWithEgoPath (ego_polys);
336
- createClusteredPointCloudObjectData (ego_path, ego_polys, current_time, objects_cluster);
337
- has_collision_ego = hasCollision (current_v, ego_path, objects_cluster);
336
+ // Crop out Pointcloud using an extra wide ego path
337
+ if (crop_pointcloud_with_path_footprint_) {
338
+ const auto expanded_ego_polys =
339
+ generatePathFootprint (ego_path, expand_width_ + path_footprint_extra_margin_);
340
+ cropPointCloudWithEgoFootprintPath (expanded_ego_polys);
341
+ }
342
+
343
+ std::vector<ObjectData> objects_from_point_clusters;
344
+ const auto ego_polys = generatePathFootprint (ego_path, expand_width_);
345
+ createObjectDataUsingPointCloudClusters (
346
+ ego_path, ego_polys, current_time, objects_from_point_clusters);
347
+ has_collision_ego = hasCollision (current_v, ego_path, objects_from_point_clusters);
338
348
std::string ns = " ego" ;
339
349
addMarker (
340
- current_time, ego_path, ego_polys, objects_cluster , color_r, color_g, color_b, color_a, ns ,
341
- debug_markers);
350
+ current_time, ego_path, ego_polys, objects_from_point_clusters , color_r, color_g, color_b,
351
+ color_a, ns, debug_markers);
342
352
}
343
353
344
354
// step4. transform predicted trajectory from control module
@@ -351,19 +361,28 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
351
361
constexpr double color_b = 0.0 ;
352
362
constexpr double color_a = 0.999 ;
353
363
const auto current_time = predicted_traj_ptr->header .stamp ;
354
- const auto predicted_path_opt = generateEgoPath (*predicted_traj_ptr, predicted_polys );
364
+ const auto predicted_path_opt = generateEgoPath (*predicted_traj_ptr);
355
365
if (predicted_path_opt) {
356
366
const auto & predicted_path = predicted_path_opt.value ();
357
367
358
- std::vector<ObjectData> objects_cluster;
359
- cropPointCloudWithEgoPath (predicted_polys);
360
- createClusteredPointCloudObjectData (
361
- predicted_path, predicted_polys, current_time, objects_cluster);
362
- has_collision_predicted = hasCollision (current_v, predicted_path, objects_cluster);
368
+ // Crop out Pointcloud using an extra wide ego path
369
+ if (crop_pointcloud_with_path_footprint_) {
370
+ const auto expanded_ego_polys =
371
+ generatePathFootprint (predicted_path, expand_width_ + path_footprint_extra_margin_);
372
+ cropPointCloudWithEgoFootprintPath (expanded_ego_polys);
373
+ }
374
+
375
+ std::vector<ObjectData> objects_from_point_clusters;
376
+ const auto predicted_polys = generatePathFootprint (predicted_path, expand_width_);
377
+ cropPointCloudWithEgoFootprintPath (predicted_polys);
378
+ createObjectDataUsingPointCloudClusters (
379
+ predicted_path, predicted_polys, current_time, objects_from_point_clusters);
380
+ has_collision_predicted =
381
+ hasCollision (current_v, predicted_path, objects_from_point_clusters);
363
382
std::string ns = " predicted" ;
364
383
addMarker (
365
- current_time, predicted_path, predicted_polys, objects_cluster , color_r, color_g, color_b ,
366
- color_a, ns, debug_markers);
384
+ current_time, predicted_path, predicted_polys, objects_from_point_clusters , color_r,
385
+ color_g, color_b, color_a, ns, debug_markers);
367
386
}
368
387
}
369
388
@@ -404,8 +423,7 @@ bool AEB::hasCollision(
404
423
return false ;
405
424
}
406
425
407
- Path AEB::generateEgoPath (
408
- const double curr_v, const double curr_w, std::vector<Polygon2d> & polygons)
426
+ Path AEB::generateEgoPath (const double curr_v, const double curr_w)
409
427
{
410
428
Path path;
411
429
double curr_x = 0.0 ;
@@ -450,17 +468,10 @@ Path AEB::generateEgoPath(
450
468
}
451
469
path.push_back (current_pose);
452
470
}
453
-
454
- // generate ego polygons
455
- polygons.resize (path.size () - 1 );
456
- for (size_t i = 0 ; i < path.size () - 1 ; ++i) {
457
- polygons.at (i) = createPolygon (path.at (i), path.at (i + 1 ), vehicle_info_, expand_width_);
458
- }
459
471
return path;
460
472
}
461
473
462
- std::optional<Path> AEB::generateEgoPath (
463
- const Trajectory & predicted_traj, std::vector<tier4_autoware_utils::Polygon2d> & polygons)
474
+ std::optional<Path> AEB::generateEgoPath (const Trajectory & predicted_traj)
464
475
{
465
476
if (predicted_traj.points .empty ()) {
466
477
return std::nullopt;
@@ -488,12 +499,18 @@ std::optional<Path> AEB::generateEgoPath(
488
499
break ;
489
500
}
490
501
}
491
- // create polygon
492
- polygons.resize (path.size ());
502
+ return path;
503
+ }
504
+
505
+ std::vector<Polygon2d> AEB::generatePathFootprint (
506
+ const Path & path, const double extra_width_margin)
507
+ {
508
+ std::vector<Polygon2d> polygons;
493
509
for (size_t i = 0 ; i < path.size () - 1 ; ++i) {
494
- polygons.at (i) = createPolygon (path.at (i), path.at (i + 1 ), vehicle_info_, expand_width_);
510
+ polygons.push_back (
511
+ createPolygon (path.at (i), path.at (i + 1 ), vehicle_info_, extra_width_margin));
495
512
}
496
- return path ;
513
+ return polygons ;
497
514
}
498
515
499
516
void AEB::createObjectData (
@@ -526,7 +543,7 @@ void AEB::createObjectData(
526
543
}
527
544
}
528
545
529
- void AEB::cropPointCloudWithEgoPath (const std::vector<Polygon2d> & ego_polys)
546
+ void AEB::cropPointCloudWithEgoFootprintPath (const std::vector<Polygon2d> & ego_polys)
530
547
{
531
548
PointCloud::Ptr full_points_ptr (new PointCloud);
532
549
pcl::fromROSMsg (*obstacle_ros_pointcloud_ptr_, *full_points_ptr);
@@ -564,7 +581,7 @@ void AEB::cropPointCloudWithEgoPath(const std::vector<Polygon2d> & ego_polys)
564
581
}
565
582
}
566
583
567
- void AEB::createClusteredPointCloudObjectData (
584
+ void AEB::createObjectDataUsingPointCloudClusters (
568
585
const Path & ego_path, const std::vector<Polygon2d> & ego_polys, const rclcpp::Time & stamp,
569
586
std::vector<ObjectData> & objects)
570
587
{
0 commit comments