Skip to content

Commit

Permalink
dwb_critics flaky test - lineCost coordinates must be within costmap (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
ewak authored Jan 31, 2025
1 parent 27fdcb7 commit ade7c96
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ TEST(ObstacleFootprint, LineCost)
costmap_ros->getCostmap()->setCost(4, 3, 100);
costmap_ros->getCostmap()->setCost(4, 4, 100);

ASSERT_EQ(critic->lineCost(3, 3, 0, 50), 50); // all 50
auto max_y_in_grid_coordinates = costmap_ros->getCostmap()->getSizeInCellsY() - 1;
ASSERT_EQ(max_y_in_grid_coordinates, 49);
ASSERT_EQ(critic->lineCost(3, 3, 0, max_y_in_grid_coordinates), 50); // all 50
ASSERT_EQ(critic->lineCost(4, 4, 0, 10), 100); // all 100
ASSERT_EQ(critic->lineCost(0, 50, 3, 3), 100); // pass 50 and 100
}
Expand Down

0 comments on commit ade7c96

Please sign in to comment.