Skip to content

Commit a925147

Browse files
nav2_smac_planner: fix smoother test when path is in collision
The added pose was indeed invalid, but the it was ignored by the smoother, since considered as a cusp. Instead, let's make the end of the plan invalid as it won't be ignored. Also, let's duplicate the last pose to make the orientation estimation fail, rather than adding a new arbitrary pose. Signed-off-by: Dylan De Coeyer <dylan.decoeyer@quimesis.be>
1 parent 966b6b6 commit a925147

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

nav2_smac_planner/test/test_smoother.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,19 @@ TEST(SmootherTest, test_full_smoother)
168168
double max_no_time = 0.0;
169169
EXPECT_FALSE(smoother->smooth(plan, costmap, max_no_time));
170170

171-
// Failure mode: Path is in collision, do 2x to exercise overlapping point
172-
// attempts to update orientation should also fail
173-
pose.pose.position.x = 1.25;
174-
pose.pose.position.y = 1.25;
175-
plan.poses.push_back(pose);
176-
plan.poses.push_back(pose);
171+
// Failure mode: invalid path and invalid orientation
172+
// make the end of the path invalid
173+
geometry_msgs::msg::PoseStamped lastPose = plan.poses.back();
174+
unsigned int mx, my;
175+
costmap->worldToMap(lastPose.pose.position.x, lastPose.pose.position.y, mx, my);
176+
for (unsigned int i = mx - 10; i <= mx + 10; ++i) {
177+
for (unsigned int j = my - 10; j <= my + 10; ++j) {
178+
costmap->setCost(i, j, 254);
179+
}
180+
}
181+
182+
// duplicate last pose to make the orientation update fail
183+
plan.poses.push_back(lastPose);
177184
EXPECT_FALSE(smoother->smooth(plan, costmap, maxtime));
178185
EXPECT_NEAR(plan.poses.end()[-2].pose.orientation.z, 1.0, 1e-3);
179186
EXPECT_NEAR(plan.poses.end()[-2].pose.orientation.x, 0.0, 1e-3);

0 commit comments

Comments
 (0)