Skip to content

Commit

Permalink
Fix the condition in ackerman motion model constraints (#3581)
Browse files Browse the repository at this point in the history
* Fix the condition in ackerman motion model constraints

* Fix ackerman motion model tests

* Fix another ackerman motion model test
  • Loading branch information
alexbuyval authored and SteveMacenski committed Jun 9, 2023
1 parent 52f2115 commit b7cfadf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class AckermannMotionModel : public MotionModel
auto & vx = control_sequence.vx;
auto & wz = control_sequence.wz;

auto view = xt::masked_view(wz, xt::fabs(vx) / xt::fabs(wz) > min_turning_r_);
auto view = xt::masked_view(wz, xt::fabs(vx) / xt::fabs(wz) < min_turning_r_);
view = xt::sign(wz) * vx / min_turning_r_;
}

Expand Down
4 changes: 2 additions & 2 deletions nav2_mppi_controller/test/motion_model_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ TEST(MotionModelTests, AckermannTest)
// Check that application of constraints are non-empty for Ackermann Drive
for (unsigned int i = 0; i != control_sequence.vx.shape(0); i++) {
control_sequence.vx(i) = i * i * i;
control_sequence.wz(i) = i * i * i;
control_sequence.wz(i) = i * i * i * i;
}

models::ControlSequence initial_control_sequence = control_sequence;
Expand All @@ -168,7 +168,7 @@ TEST(MotionModelTests, AckermannTest)
// Now, check the specifics of the minimum curvature constraint
EXPECT_NEAR(model->getMinTurningRadius(), 0.2, 1e-6);
for (unsigned int i = 1; i != control_sequence.vx.shape(0); i++) {
EXPECT_TRUE(fabs(control_sequence.vx(i)) / fabs(control_sequence.wz(i)) <= 0.2);
EXPECT_TRUE(fabs(control_sequence.vx(i)) / fabs(control_sequence.wz(i)) >= 0.2);
}

// Check that Ackermann Drive is properly non-holonomic and parameterized
Expand Down

0 comments on commit b7cfadf

Please sign in to comment.