Skip to content

Commit c9b349a

Browse files
committed
Publish planned footprints after smoothing
Signed-off-by: Tony Najjar <[email protected]>
1 parent d362e74 commit c9b349a

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

nav2_smac_planner/src/smac_planner_hybrid.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,28 @@ nav_msgs::msg::Path SmacPlannerHybrid::createPlan(
520520
_raw_plan_publisher->publish(plan);
521521
}
522522

523+
// Find how much time we have left to do smoothing
524+
steady_clock::time_point b = steady_clock::now();
525+
duration<double> time_span = duration_cast<duration<double>>(b - a);
526+
double time_remaining = _max_planning_time - static_cast<double>(time_span.count());
527+
528+
#ifdef BENCHMARK_TESTING
529+
std::cout << "It took " << time_span.count() * 1000 <<
530+
" milliseconds with " << num_iterations << " iterations." << std::endl;
531+
#endif
532+
533+
// Smooth plan
534+
if (_smoother && num_iterations > 1) {
535+
_smoother->smooth(plan, costmap, time_remaining);
536+
}
537+
538+
#ifdef BENCHMARK_TESTING
539+
steady_clock::time_point c = steady_clock::now();
540+
duration<double> time_span2 = duration_cast<duration<double>>(c - b);
541+
std::cout << "It took " << time_span2.count() * 1000 <<
542+
" milliseconds to smooth path." << std::endl;
543+
#endif
544+
523545
if (_debug_visualizations) {
524546
// Publish expansions for debug
525547
geometry_msgs::msg::PoseArray msg;
@@ -552,28 +574,6 @@ nav_msgs::msg::Path SmacPlannerHybrid::createPlan(
552574
}
553575
}
554576

555-
// Find how much time we have left to do smoothing
556-
steady_clock::time_point b = steady_clock::now();
557-
duration<double> time_span = duration_cast<duration<double>>(b - a);
558-
double time_remaining = _max_planning_time - static_cast<double>(time_span.count());
559-
560-
#ifdef BENCHMARK_TESTING
561-
std::cout << "It took " << time_span.count() * 1000 <<
562-
" milliseconds with " << num_iterations << " iterations." << std::endl;
563-
#endif
564-
565-
// Smooth plan
566-
if (_smoother && num_iterations > 1) {
567-
_smoother->smooth(plan, costmap, time_remaining);
568-
}
569-
570-
#ifdef BENCHMARK_TESTING
571-
steady_clock::time_point c = steady_clock::now();
572-
duration<double> time_span2 = duration_cast<duration<double>>(c - b);
573-
std::cout << "It took " << time_span2.count() * 1000 <<
574-
" milliseconds to smooth path." << std::endl;
575-
#endif
576-
577577
return plan;
578578
}
579579

nav2_smac_planner/src/smac_planner_lattice.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,28 @@ nav_msgs::msg::Path SmacPlannerLattice::createPlan(
440440
_raw_plan_publisher->publish(plan);
441441
}
442442

443+
// Find how much time we have left to do smoothing
444+
steady_clock::time_point b = steady_clock::now();
445+
duration<double> time_span = duration_cast<duration<double>>(b - a);
446+
double time_remaining = _max_planning_time - static_cast<double>(time_span.count());
447+
448+
#ifdef BENCHMARK_TESTING
449+
std::cout << "It took " << time_span.count() * 1000 <<
450+
" milliseconds with " << num_iterations << " iterations." << std::endl;
451+
#endif
452+
453+
// Smooth plan
454+
if (_smoother && num_iterations > 1) {
455+
_smoother->smooth(plan, _costmap, time_remaining);
456+
}
457+
458+
#ifdef BENCHMARK_TESTING
459+
steady_clock::time_point c = steady_clock::now();
460+
duration<double> time_span2 = duration_cast<duration<double>>(c - b);
461+
std::cout << "It took " << time_span2.count() * 1000 <<
462+
" milliseconds to smooth path." << std::endl;
463+
#endif
464+
443465
if (_debug_visualizations) {
444466
// Publish expansions for debug
445467
geometry_msgs::msg::PoseArray msg;
@@ -472,28 +494,6 @@ nav_msgs::msg::Path SmacPlannerLattice::createPlan(
472494
}
473495
}
474496

475-
// Find how much time we have left to do smoothing
476-
steady_clock::time_point b = steady_clock::now();
477-
duration<double> time_span = duration_cast<duration<double>>(b - a);
478-
double time_remaining = _max_planning_time - static_cast<double>(time_span.count());
479-
480-
#ifdef BENCHMARK_TESTING
481-
std::cout << "It took " << time_span.count() * 1000 <<
482-
" milliseconds with " << num_iterations << " iterations." << std::endl;
483-
#endif
484-
485-
// Smooth plan
486-
if (_smoother && num_iterations > 1) {
487-
_smoother->smooth(plan, _costmap, time_remaining);
488-
}
489-
490-
#ifdef BENCHMARK_TESTING
491-
steady_clock::time_point c = steady_clock::now();
492-
duration<double> time_span2 = duration_cast<duration<double>>(c - b);
493-
std::cout << "It took " << time_span2.count() * 1000 <<
494-
" milliseconds to smooth path." << std::endl;
495-
#endif
496-
497497
return plan;
498498
}
499499

0 commit comments

Comments
 (0)