Skip to content

Commit

Permalink
Update mppi controller with the latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-corvo committed Jul 11, 2023
2 parents 4a82bf2 + ead48a9 commit 087ce49
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
22 changes: 11 additions & 11 deletions nav2_mppi_controller/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace mppi::critics
* @class mppi::critics::ConstraintCritic
* @brief Critic objective function for aligning to the path. Note:
* High settings of this will follow the path more precisely, but also makes it
* difficult (or impossible) to deviate in the presense of dynamic obstacles.
* difficult (or impossible) to deviate in the presence of dynamic obstacles.
* This is an important critic to tune and consider in tandem with Obstacle.
*/
class PathAlignCritic : public CriticFunction
Expand Down
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
2 changes: 1 addition & 1 deletion nav2_mppi_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>nav2_mppi_controller</name>
<version>0.2.1</version>
<version>1.1.8</version>
<description>nav2_mppi_controller</description>
<maintainer email="[email protected]">Aleksei Budyakov</maintainer>
<maintainer email="[email protected]">Steve Macenski</maintainer>
Expand Down
5 changes: 2 additions & 3 deletions nav2_mppi_controller/src/critics/path_follow_critic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ void PathFollowCritic::initialize()

void PathFollowCritic::score(CriticData & data)
{
const size_t path_size = data.path.x.shape(0) - 1;

if (!enabled_ || path_size == 0 ||
if (!enabled_ || data.path.x.shape(0) < 2 ||
utils::withinPositionGoalTolerance(threshold_to_consider_, data.state.pose.pose, data.path))
{
return;
}

utils::setPathFurthestPointIfNotSet(data);
utils::setPathCostsIfNotSet(data, costmap_ros_);
const size_t path_size = data.path.x.shape(0) - 1;

auto offseted_idx = std::min(
*data.furthest_reached_path_point + offset_from_furthest_, path_size);
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 087ce49

Please sign in to comment.