@@ -309,26 +309,22 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
309
309
// step3. create ego path based on sensor data
310
310
bool has_collision_ego = false ;
311
311
if (use_imu_path_) {
312
- Path ego_path;
313
312
std::vector<Polygon2d> ego_polys;
314
313
const double current_w = angular_velocity_ptr_->z ;
315
314
constexpr double color_r = 0.0 / 256.0 ;
316
315
constexpr double color_g = 148.0 / 256.0 ;
317
316
constexpr double color_b = 205.0 / 256.0 ;
318
317
constexpr double color_a = 0.999 ;
319
318
const auto current_time = get_clock ()->now ();
320
- const auto ego_path_opt = generateEgoPath (current_v, current_w, ego_polys);
321
- if (ego_path_opt) {
322
- const auto & ego_path = ego_path_opt.value ();
323
- std::vector<ObjectData> objects;
324
- createObjectData (ego_path, ego_polys, current_time, objects);
325
- has_collision_ego = hasCollision (current_v, ego_path, objects);
326
-
327
- std::string ns = " ego" ;
328
- addMarker (
329
- current_time, ego_path, ego_polys, objects, color_r, color_g, color_b, color_a, ns,
330
- debug_markers);
331
- }
319
+ const auto ego_path = generateEgoPath (current_v, current_w, ego_polys);
320
+ std::vector<ObjectData> objects;
321
+ createObjectData (ego_path, ego_polys, current_time, objects);
322
+ has_collision_ego = hasCollision (current_v, ego_path, objects);
323
+
324
+ std::string ns = " ego" ;
325
+ addMarker (
326
+ current_time, ego_path, ego_polys, objects, color_r, color_g, color_b, color_a, ns,
327
+ debug_markers);
332
328
}
333
329
334
330
// step4. transform predicted trajectory from control module
@@ -388,7 +384,7 @@ bool AEB::hasCollision(
388
384
return false ;
389
385
}
390
386
391
- std::optional< Path> AEB::generateEgoPath (
387
+ Path AEB::generateEgoPath (
392
388
const double curr_v, const double curr_w, std::vector<Polygon2d> & polygons)
393
389
{
394
390
Path path;
@@ -402,7 +398,7 @@ std::optional<Path> AEB::generateEgoPath(
402
398
403
399
if (curr_v < 0.1 ) {
404
400
// if current velocity is too small, assume it stops at the same point
405
- return std::nullopt ;
401
+ return path ;
406
402
}
407
403
408
404
constexpr double epsilon = 1e-6 ;
@@ -450,7 +446,6 @@ std::optional<Path> AEB::generateEgoPath(
450
446
return std::nullopt;
451
447
}
452
448
453
- Path path;
454
449
geometry_msgs::msg::TransformStamped transform_stamped{};
455
450
try {
456
451
transform_stamped = tf_buffer_.lookupTransform (
@@ -462,6 +457,7 @@ std::optional<Path> AEB::generateEgoPath(
462
457
}
463
458
464
459
// create path
460
+ Path path;
465
461
path.resize (predicted_traj.points .size ());
466
462
for (size_t i = 0 ; i < predicted_traj.points .size (); ++i) {
467
463
geometry_msgs::msg::Pose map_pose;
0 commit comments