Skip to content

Commit dfb334d

Browse files
BriceRenaudeauManos-G
authored andcommitted
Move projectState after getPointsInside (ros-navigation#4356)
* Modify test to check fix Signed-off-by: Brice <[email protected]> * Add static polygon check before simulation Signed-off-by: Brice <[email protected]> --------- Signed-off-by: Brice <[email protected]>
1 parent 6d83992 commit dfb334d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

nav2_collision_monitor/src/polygon.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ double Polygon::getCollisionTime(
239239
Velocity vel = velocity;
240240

241241
// Array of points transformed to the frame concerned with pose on each simulation step
242-
std::vector<Point> points_transformed;
242+
std::vector<Point> points_transformed = collision_points;
243+
244+
// Check static polygon
245+
if (getPointsInside(points_transformed) >= min_points_) {
246+
return 0.0;
247+
}
243248

244249
// Robot movement simulation
245250
for (double time = 0.0; time <= time_before_collision_; time += simulation_time_step_) {

nav2_collision_monitor/test/collision_monitor_node_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,8 @@ TEST_F(Tester, testProcessApproach)
991991
// 3. Obstacle is inside robot footprint
992992
publishScan(0.5, curr_time);
993993
ASSERT_TRUE(waitData(0.5, 500ms, curr_time));
994-
publishCmdVel(0.5, 0.2, 0.0);
994+
// Publish impossible cmd_vel to ensure robot footprint is checked
995+
publishCmdVel(1000000000.0, 0.2, 0.0);
995996
ASSERT_TRUE(waitCmdVel(500ms));
996997
ASSERT_NEAR(cmd_vel_out_->linear.x, 0.0, EPSILON);
997998
ASSERT_NEAR(cmd_vel_out_->linear.y, 0.0, EPSILON);

0 commit comments

Comments
 (0)