Skip to content

Commit e52f072

Browse files
committed
Validate Smac smoother footprint collisions
Signed-off-by: Alyss <u7288133@anu.edu.au>
1 parent b586284 commit e52f072

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

nav2_smac_planner/include/nav2_smac_planner/smoother.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "nav2_util/geometry_utils.hpp"
2424
#include "nav_msgs/msg/path.hpp"
2525
#include "ompl/base/StateSpace.h"
26+
#include "geometry_msgs/msg/point.hpp"
2627

2728
namespace nav2_smac_planner
2829
{
@@ -97,8 +98,9 @@ class Smoother
9798
bool smooth(
9899
nav_msgs::msg::Path & path,
99100
const nav2_costmap_2d::Costmap2D * costmap,
100-
const double & max_time,
101-
const nav2_costmap_2d::Footprint & footprint = nav2_costmap_2d::Footprint(),
101+
const double & max_time,
102+
const std::vector<geometry_msgs::msg::Point> & footprint =
103+
std::vector<geometry_msgs::msg::Point>(),
102104
const bool & use_radius = true);
103105

104106
protected:
@@ -115,7 +117,7 @@ class Smoother
115117
bool & reversing_segment,
116118
const nav2_costmap_2d::Costmap2D * costmap,
117119
const double & max_time,
118-
const nav2_costmap_2d::Footprint & footprint,
120+
const std::vector<geometry_msgs::msg::Point> & footprint,
119121
const bool & use_radius);
120122

121123
/**

nav2_smac_planner/src/smoother.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ bool Smoother::smooth(
5454
nav_msgs::msg::Path & path,
5555
const nav2_costmap_2d::Costmap2D * costmap,
5656
const double & max_time,
57-
const double & max_time,
58-
const nav2_costmap_2d::Footprint & footprint = nav2_costmap_2d::Footprint(),
59-
const bool & use_radius = true)
57+
const std::vector<geometry_msgs::msg::Point> & footprint,
58+
const bool & use_radius)
6059
{
6160
// by-pass path orientations approximation when skipping smac smoother
6261
if (max_its_ == 0) {
@@ -90,7 +89,8 @@ bool Smoother::smooth(
9089
const geometry_msgs::msg::Pose start_pose = curr_path_segment.poses.front().pose;
9190
const geometry_msgs::msg::Pose goal_pose = curr_path_segment.poses.back().pose;
9291
bool local_success =
93-
smoothImpl(curr_path_segment, reversing_segment, costmap, time_remaining,
92+
smoothImpl(
93+
curr_path_segment, reversing_segment, costmap, time_remaining,
9494
footprint, use_radius);
9595
success = success && local_success;
9696

@@ -115,9 +115,8 @@ bool Smoother::smoothImpl(
115115
nav_msgs::msg::Path & path,
116116
bool & reversing_segment,
117117
const nav2_costmap_2d::Costmap2D * costmap,
118-
const double & max_time,
119118
const double & max_time,
120-
const nav2_costmap_2d::Footprint & footprint,
119+
const std::vector<geometry_msgs::msg::Point> & footprint,
121120
const bool & use_radius)
122121
{
123122
steady_clock::time_point a = steady_clock::now();
@@ -192,21 +191,21 @@ bool Smoother::smoothImpl(
192191
return false;
193192
}
194193
}
195-
194+
196195
if (costmap && !use_radius) {
197196
nav2_util::updateApproximatePathOrientations(new_path, reversing_segment, is_holonomic_);
198197

199-
nav2_costmap_2d::FootprintCollisionChecker<const nav2_costmap_2d::Costmap2D *>
200-
footprint_checker(costmap);
198+
nav2_costmap_2d::FootprintCollisionChecker<nav2_costmap_2d::Costmap2D *>
199+
footprint_checker(const_cast<nav2_costmap_2d::Costmap2D *>(costmap));
201200

202201
for (const auto & pose : new_path.poses) {
203202
const double footprint_cost = footprint_checker.footprintCostAtPose(
204-
pose.pose.position.x,
205-
pose.pose.position.y,
206-
f2f::getYaw(pose.pose.orientation),
203+
pose.pose.position.x,
204+
pose.pose.position.y,
205+
tf2::getYaw(pose.pose.orientation),
207206
footprint);
208-
209-
if (footprint_cost >= nav2_costmap_2d::LETHAL_OBSTACLE) {
207+
208+
if (footprint_cost > MAX_NON_OBSTACLE_COST && footprint_cost != UNKNOWN_COST) {
210209
RCLCPP_DEBUG(
211210
rclcpp::get_logger("SmacPlannerSmoother"),
212211
"Smoothing process resulted in an infeasible footprint collision. "

nav2_smac_planner/test/test_smoother.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ TEST(SmootherTest, test_full_smoother)
9595

9696
std::unique_ptr<nav2_smac_planner::GridCollisionChecker> checker =
9797
std::make_unique<nav2_smac_planner::GridCollisionChecker>(costmap_ros, size_theta, node);
98-
checker->setFootprint(nav2_costmap_2d::Footprint(), true, 0.0);
98+
checker->setFootprint(std::vector<geometry_msgs::msg::Point>(), true, 0.0);
9999

100100
auto dummy_cancel_checker = []() {
101101
return false;
@@ -201,9 +201,9 @@ TEST(SmootherTest, rejects_non_circular_footprint_collision)
201201
nav2_costmap_2d::Costmap2D costmap(
202202
200, 200, 0.1, 0.0, 0.0, nav2_costmap_2d::FREE_SPACE);
203203

204-
nav2_costmap_2d::Footprint footprint;
204+
std::vector<geometry_msgs::msg::Point> footprint;
205205
for (const auto & coordinates : std::vector<std::pair<double, double>>{
206-
{-0.6, -0.2}, {0.6, -0.2}, {0.6, 0.2}, {-0.6, 0.2}})
206+
{-0.6, -0.2}, {0.6, -0.2}, {0.6, 0.2}, {-0.6, 0.2}})
207207
{
208208
geometry_msgs::msg::Point point;
209209
point.x = coordinates.first;

0 commit comments

Comments
 (0)