Skip to content

Commit ade7c96

Browse files
authored
dwb_critics flaky test - lineCost coordinates must be within costmap (#4889)
(#4884) There is no protection/checks in the pathway from lineCost to costmap_2d::getIndex(mx, my) for grid coordinates that exceed the of bounds of the allocated costmap. (presumably for speed) This test was triggering an off by one error attempting to read the the 2500 byte costmap at byte 2503 costmap size 50x50. getIndex(3, 50) = my * size_x_ + mx; = 50 * 50 + 3; = 2503 Signed-off-by: Mike Wake <macwake@gmail.com>
1 parent 27fdcb7 commit ade7c96

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

nav2_dwb_controller/dwb_critics/test/obstacle_footprint_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ TEST(ObstacleFootprint, LineCost)
248248
costmap_ros->getCostmap()->setCost(4, 3, 100);
249249
costmap_ros->getCostmap()->setCost(4, 4, 100);
250250

251-
ASSERT_EQ(critic->lineCost(3, 3, 0, 50), 50); // all 50
251+
auto max_y_in_grid_coordinates = costmap_ros->getCostmap()->getSizeInCellsY() - 1;
252+
ASSERT_EQ(max_y_in_grid_coordinates, 49);
253+
ASSERT_EQ(critic->lineCost(3, 3, 0, max_y_in_grid_coordinates), 50); // all 50
252254
ASSERT_EQ(critic->lineCost(4, 4, 0, 10), 100); // all 100
253255
ASSERT_EQ(critic->lineCost(0, 50, 3, 3), 100); // pass 50 and 100
254256
}

0 commit comments

Comments
 (0)