Skip to content

Commit

Permalink
Move projectState after getPointsInside (#4356)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
BriceRenaudeau authored and SteveMacenski committed May 23, 2024
1 parent a0911c6 commit b332b05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion nav2_collision_monitor/src/polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ double Polygon::getCollisionTime(
Velocity vel = velocity;

// Array of points transformed to the frame concerned with pose on each simulation step
std::vector<Point> points_transformed;
std::vector<Point> points_transformed = collision_points;

// Check static polygon
if (getPointsInside(points_transformed) >= min_points_) {
return 0.0;
}

// Robot movement simulation
for (double time = 0.0; time <= time_before_collision_; time += simulation_time_step_) {
Expand Down
3 changes: 2 additions & 1 deletion nav2_collision_monitor/test/collision_monitor_node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ TEST_F(Tester, testProcessApproach)
// 3. Obstacle is inside robot footprint
publishScan(0.5, curr_time);
ASSERT_TRUE(waitData(0.5, 500ms, curr_time));
publishCmdVel(0.5, 0.2, 0.0);
// Publish impossible cmd_vel to ensure robot footprint is checked
publishCmdVel(1000000000.0, 0.2, 0.0);
ASSERT_TRUE(waitCmdVel(500ms));
ASSERT_NEAR(cmd_vel_out_->linear.x, 0.0, EPSILON);
ASSERT_NEAR(cmd_vel_out_->linear.y, 0.0, EPSILON);
Expand Down

0 comments on commit b332b05

Please sign in to comment.