Skip to content

Conversation

Decwest
Copy link

@Decwest Decwest commented Oct 8, 2025


Basic Info

Info Please fill out this column
Ticket(s) this addresses #5524
Primary OS tested on Ubuntu 24.04 (ROS2 rolling)
Robotic platform tested on gazebo simulation of turtlebot3_waffle
Does this PR contain AI generated software? No
Was this PR description generated by AI software? No

Description of contribution in a few bullet points

  • Implement DWPP as an extension to the current RPP implementation

Description of documentation updates required from your changes

  • Added new parameter, so need to add that to default configs and documentation page

Added Parameters

  • desired_angular_vel (double): maximum angular velocity (rad/s)
  • max_linear_accel (double): maximum linear acceleration (m/s²)
  • use_dynamic_window (bool): enable DWPP
  • velocity_feedback (string, no need to change) : How the current velocity is obtained during dynamic window computation.
    • "OPEN_LOOP": Uses the last commanded velocity (recommended)
    • "CLOSED_LOOP": Uses odometry velocity (may hinder proper acceleration/deceleration)

Description of how this change was tested

Simulation video

DWPP_simulation.mp4

Future work that may be required in bullet points

  • Discussion and modification regarding the renaming of Regulated Pure Pursuit
  • Documentation update

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists
  • Should this be backported to current distributions? If so, tag with backport-*.

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doisyg FYI - would this be of interest? See the video

Also, please add unit testing for the functions and features you added. Check out test/ in the package to see some examples. Your main function should be tested for all edge cases at the bare minimum


declare_parameter_if_not_declared(
node, plugin_name_ + ".desired_linear_vel", rclcpp::ParameterValue(0.5));
declare_parameter_if_not_declared(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All new parameters should be added to the RPP docs' configuration guide. Also probably worth adding a note to the migration guide about this new feature and a link to your paper

Comment on lines 432 to 434

last_command_velocity_ = cmd_vel.twist;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
last_command_velocity_ = cmd_vel.twist;
last_command_velocity_ = cmd_vel.twist;


// ---- 1) Dynamic Window ----
double dw_vmax = std::min(current_speed.linear.x + A_MAX * DT, V_MAX);
const double dw_vmin = std::max(current_speed.linear.x - A_MAX * DT, V_MIN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have different min/maxs for accel / decel? Not all robot are symmetric

double dw_wmax = std::min(current_speed.angular.z + AW_MAX * DT, W_MAX);
const double dw_wmin = std::max(current_speed.angular.z - AW_MAX * DT, W_MIN);

// Reflect regulated v (tighten upper limit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more descriptive comment here would be nice

}
}

if (best_v > -1e290) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

// ---- 3) If no intersection exists: Select the one with the smallest Euclidean distance to the line w = k v among the 4 corners
struct Corner { double v; double w; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these seem to be utility functions that should go into utility files rather than in the RPP main controller file

best_v = corners[0].v;
best_w = corners[0].w;

for (int i = 0; i < 4; ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you just make corners a vector of size 4,then you can use corners.size()


// Apply curvature to angular velocity after constraining linear velocity
angular_vel = linear_vel * regulation_curvature;
if (params_->use_dynamic_window == false){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (params_->use_dynamic_window == false){
if (!params_->use_dynamic_window) {

Comment on lines 399 to 400
}
else{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else{
} else {

@doisyg
Copy link
Contributor

doisyg commented Oct 9, 2025

@doisyg FYI - would this be of interest? See the video

Absolutely ! @Decwest, we were discussing internally your DWPP repo (at Dexory) and I am super happy that you guys are working toward a nav2 integration.
Having linear acceleration constraints would be an immediate win for us.
Side note: could be a separate PR, but it would be even better to split the accel constraints between max_linear_accel and max_linear_decel. And in doing so, beware of bi-directionality, e.g. #3529
cc @kaichie @tonynajjar

Copy link

codecov bot commented Oct 11, 2025

Codecov Report

❌ Patch coverage is 84.84848% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ntroller/src/regulated_pure_pursuit_controller.cpp 81.48% 10 Missing ⚠️
Files with missing lines Coverage Δ
...ated_pure_pursuit_controller/parameter_handler.hpp 100.00% <ø> (ø)
...t_controller/regulated_pure_pursuit_controller.hpp 100.00% <ø> (ø)
..._pure_pursuit_controller/src/parameter_handler.cpp 93.84% <100.00%> (+0.29%) ⬆️
...ntroller/src/regulated_pure_pursuit_controller.cpp 84.61% <81.48%> (-1.02%) ⬇️

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SteveMacenski
Copy link
Member

Let me know when you want me to take a look again after the review comments are addressed! Only things at a glance:

  const double A_MAX = params_->max_linear_accel;       // A_MAX
  const double V_MAX = params_->desired_linear_vel;     // V_MAX
  const double AW_MAX = params_->max_angular_accel;     // AW_MAX
  const double W_MAX = params_->desired_angular_vel;    // W_MAX
  const double DT = control_duration_;         // DT

  const double V_MIN = -V_MAX;
  const double W_MIN = -W_MAX;

Your very large block of code may be more concise as

// Lambda approach
auto check = [&](double v, double w) {
  if (v >= dw_vmin && v <= dw_vmax && w >= dw_wmin && w <= dw_wmax && v > best_v) {
    best_v = v; best_w = w;
  }
};
check(dw_vmin, k * dw_vmin);
check(dw_vmax, k * dw_vmax);
check(dw_wmin / k, dw_wmin);
check(dw_wmax / k, dw_wmax);

or

std::pair<double, double> candidates[] = {
  {dw_vmin, k * dw_vmin},
  {dw_vmax, k * dw_vmax},
  {dw_wmin / k, dw_wmin},
  {dw_wmax / k, dw_wmax}
};

for (auto [v, w] : candidates) {
  if (v >= dw_vmin && v <= dw_vmax && w >= dw_wmin && w <= dw_wmax && v > best_v) {
    best_v = v; best_w = w;
  }
}

I'd suggest reviewing your code a bit for how it can be as concise and self-descriptive as possible
Try to rename these variables to be more inline with the rest of the codebase please to make this function more readable.

@Decwest
Copy link
Author

Decwest commented Oct 15, 2025

@SteveMacenski
Thank you for reviewing again, and sorry for the delay in my response.
I’ll address all of your comments one by one and will mention you once everything has been updated.
I’ll also work on improving the code readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants