Skip to content

Commit 07accae

Browse files
SteveMacenskienricosutera
authored andcommitted
Fix Smac Planner confined collision checker (ros-navigation#4055)
* Update collision_checker.cpp Signed-off-by: Steve Macenski <stevenmacenski@gmail.com> * Fix tests Signed-off-by: Steve Macenski <stevenmacenski@gmail.com> * Update test_a_star.cpp Signed-off-by: Steve Macenski <stevenmacenski@gmail.com> --------- Signed-off-by: Steve Macenski <stevenmacenski@gmail.com> Signed-off-by: enricosutera <enricosutera@outlook.com>
1 parent e7bcf6d commit 07accae

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

nav2_smac_planner/src/collision_checker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool GridCollisionChecker::inCollision(
107107
// if footprint, then we check for the footprint's points, but first see
108108
// if the robot is even potentially in an inscribed collision
109109
footprint_cost_ = costmap_->getCost(
110-
static_cast<unsigned int>(x), static_cast<unsigned int>(y));
110+
static_cast<unsigned int>(x + 0.5), static_cast<unsigned int>(y + 0.5));
111111

112112
if (footprint_cost_ < possible_inscribed_cost_) {
113113
if (possible_inscribed_cost_ > 0) {
@@ -157,7 +157,7 @@ bool GridCollisionChecker::inCollision(
157157
} else {
158158
// if radius, then we can check the center of the cost assuming inflation is used
159159
footprint_cost_ = costmap_->getCost(
160-
static_cast<unsigned int>(x), static_cast<unsigned int>(y));
160+
static_cast<unsigned int>(x + 0.5), static_cast<unsigned int>(y + 0.5));
161161

162162
if (footprint_cost_ == UNKNOWN && traverse_unknown) {
163163
return false;

nav2_smac_planner/test/test_a_star.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ TEST(AStarTest, test_a_star_se2)
164164
EXPECT_TRUE(a_star.createPath(path, num_it, tolerance, expansions.get()));
165165

166166
// check path is the right size and collision free
167-
EXPECT_EQ(num_it, 3186);
168-
EXPECT_EQ(path.size(), 64u);
167+
EXPECT_EQ(num_it, 3146);
168+
EXPECT_EQ(path.size(), 63u);
169169
for (unsigned int i = 0; i != path.size(); i++) {
170170
EXPECT_EQ(costmapA->getCost(path[i].x, path[i].y), 0);
171171
}
@@ -229,8 +229,8 @@ TEST(AStarTest, test_a_star_lattice)
229229
EXPECT_TRUE(a_star.createPath(path, num_it, tolerance));
230230

231231
// check path is the right size and collision free
232-
EXPECT_EQ(num_it, 26);
233-
EXPECT_GT(path.size(), 47u);
232+
EXPECT_EQ(num_it, 22);
233+
EXPECT_GT(path.size(), 45u);
234234
for (unsigned int i = 0; i != path.size(); i++) {
235235
EXPECT_EQ(costmapA->getCost(path[i].x, path[i].y), 0);
236236
}

0 commit comments

Comments
 (0)