@@ -56,7 +56,6 @@ void SmacPlannerLattice::configure(
56
56
_costmap_ros = costmap_ros;
57
57
_name = name;
58
58
_global_frame = costmap_ros->getGlobalFrameID ();
59
- _raw_plan_publisher = node->create_publisher <nav_msgs::msg::Path>(" unsmoothed_plan" , 1 );
60
59
61
60
RCLCPP_INFO (_logger, " Configuring %s of type SmacPlannerLattice" , name.c_str ());
62
61
@@ -238,10 +237,15 @@ void SmacPlannerLattice::configure(
238
237
_smoother->initialize (_metadata.min_turning_radius );
239
238
}
240
239
240
+ _raw_plan_publisher = node->create_publisher <nav_msgs::msg::Path>(" unsmoothed_plan" , 1 );
241
+
241
242
if (_debug_visualizations) {
242
243
_expansions_publisher = node->create_publisher <geometry_msgs::msg::PoseArray>(" expansions" , 1 );
243
244
_planned_footprints_publisher = node->create_publisher <visualization_msgs::msg::MarkerArray>(
244
245
" planned_footprints" , 1 );
246
+ _smoothed_footprints_publisher =
247
+ node->create_publisher <visualization_msgs::msg::MarkerArray>(
248
+ " smoothed_footprints" , 1 );
245
249
}
246
250
247
251
RCLCPP_INFO (
@@ -262,6 +266,7 @@ void SmacPlannerLattice::activate()
262
266
if (_debug_visualizations) {
263
267
_expansions_publisher->on_activate ();
264
268
_planned_footprints_publisher->on_activate ();
269
+ _smoothed_footprints_publisher->on_activate ();
265
270
}
266
271
auto node = _node.lock ();
267
272
// Add callback for dynamic parameters
@@ -278,6 +283,7 @@ void SmacPlannerLattice::deactivate()
278
283
if (_debug_visualizations) {
279
284
_expansions_publisher->on_deactivate ();
280
285
_planned_footprints_publisher->on_deactivate ();
286
+ _smoothed_footprints_publisher->on_deactivate ();
281
287
}
282
288
// shutdown dyn_param_handler
283
289
auto node = _node.lock ();
@@ -296,6 +302,11 @@ void SmacPlannerLattice::cleanup()
296
302
_a_star.reset ();
297
303
_smoother.reset ();
298
304
_raw_plan_publisher.reset ();
305
+ if (_debug_visualizations) {
306
+ _expansions_publisher.reset ();
307
+ _planned_footprints_publisher.reset ();
308
+ _smoothed_footprints_publisher.reset ();
309
+ }
299
310
}
300
311
301
312
nav_msgs::msg::Path SmacPlannerLattice::createPlan (
@@ -390,9 +401,10 @@ nav_msgs::msg::Path SmacPlannerLattice::createPlan(
390
401
_tolerance / static_cast <float >(_costmap->getResolution ()), cancel_checker, expansions.get ()))
391
402
{
392
403
if (_debug_visualizations) {
404
+ auto now = _clock->now ();
393
405
geometry_msgs::msg::PoseArray msg;
394
406
geometry_msgs::msg::Pose msg_pose;
395
- msg.header .stamp = _clock-> now () ;
407
+ msg.header .stamp = now;
396
408
msg.header .frame_id = _global_frame;
397
409
for (auto & e : *expansions) {
398
410
msg_pose.position .x = std::get<0 >(e);
@@ -441,10 +453,11 @@ nav_msgs::msg::Path SmacPlannerLattice::createPlan(
441
453
}
442
454
443
455
if (_debug_visualizations) {
456
+ auto now = _clock->now ();
444
457
// Publish expansions for debug
445
458
geometry_msgs::msg::PoseArray msg;
446
459
geometry_msgs::msg::Pose msg_pose;
447
- msg.header .stamp = _clock-> now () ;
460
+ msg.header .stamp = now;
448
461
msg.header .frame_id = _global_frame;
449
462
for (auto & e : *expansions) {
450
463
msg_pose.position .x = std::get<0 >(e);
@@ -454,19 +467,20 @@ nav_msgs::msg::Path SmacPlannerLattice::createPlan(
454
467
}
455
468
_expansions_publisher->publish (msg);
456
469
457
- // plot footprint path planned for debug
458
470
if (_planned_footprints_publisher->get_subscription_count () > 0 ) {
471
+ // Clear all markers first
459
472
auto marker_array = std::make_unique<visualization_msgs::msg::MarkerArray>();
473
+ visualization_msgs::msg::Marker clear_all_marker;
474
+ clear_all_marker.action = visualization_msgs::msg::Marker::DELETEALL;
475
+ marker_array->markers .push_back (clear_all_marker);
476
+ _planned_footprints_publisher->publish (std::move (marker_array));
477
+
478
+ // Publish smoothed footprints for debug
479
+ marker_array = std::make_unique<visualization_msgs::msg::MarkerArray>();
460
480
for (size_t i = 0 ; i < plan.poses .size (); i++) {
461
481
const std::vector<geometry_msgs::msg::Point> edge =
462
482
transformFootprintToEdges (plan.poses [i].pose , _costmap_ros->getRobotFootprint ());
463
- marker_array->markers .push_back (createMarker (edge, i, _global_frame, _clock->now ()));
464
- }
465
-
466
- if (marker_array->markers .empty ()) {
467
- visualization_msgs::msg::Marker clear_all_marker;
468
- clear_all_marker.action = visualization_msgs::msg::Marker::DELETEALL;
469
- marker_array->markers .push_back (clear_all_marker);
483
+ marker_array->markers .push_back (createMarker (edge, i, _global_frame, now));
470
484
}
471
485
_planned_footprints_publisher->publish (std::move (marker_array));
472
486
}
@@ -494,6 +508,27 @@ nav_msgs::msg::Path SmacPlannerLattice::createPlan(
494
508
" milliseconds to smooth path." << std::endl;
495
509
#endif
496
510
511
+ if (_debug_visualizations) {
512
+ if (_smoothed_footprints_publisher->get_subscription_count () > 0 ) {
513
+ // Clear all markers first
514
+ auto marker_array = std::make_unique<visualization_msgs::msg::MarkerArray>();
515
+ visualization_msgs::msg::Marker clear_all_marker;
516
+ clear_all_marker.action = visualization_msgs::msg::Marker::DELETEALL;
517
+ marker_array->markers .push_back (clear_all_marker);
518
+ _smoothed_footprints_publisher->publish (std::move (marker_array));
519
+
520
+ // Publish smoothed footprints for debug
521
+ marker_array = std::make_unique<visualization_msgs::msg::MarkerArray>();
522
+ auto now = _clock->now ();
523
+ for (size_t i = 0 ; i < plan.poses .size (); i++) {
524
+ const std::vector<geometry_msgs::msg::Point> edge =
525
+ transformFootprintToEdges (plan.poses [i].pose , _costmap_ros->getRobotFootprint ());
526
+ marker_array->markers .push_back (createMarker (edge, i, _global_frame, now));
527
+ }
528
+ _smoothed_footprints_publisher->publish (std::move (marker_array));
529
+ }
530
+ }
531
+
497
532
return plan;
498
533
}
499
534
0 commit comments