ros-navigation / navigation2

ROS 2 Navigation Framework and System
https://nav2.org/
Other
2.45k stars 1.24k forks source link

MPPI dynamic parameter not working with vx_max #4315

Closed Huyhust13 closed 3 months ago

Huyhust13 commented 3 months ago

Bug report

Required Info:

Expected behavior

I set vx_max = 0.5 in file parameter, then when it is running, I change the vx_max to 0.3. I use parameter get to show param, it shows vx_max = 0.3 but the robot runs with vx = 0.5.

SteveMacenski commented 3 months ago

Correct, we update settings.base_constraints with parameter inputs, not settings.constraints which is what is used for clipping (https://github.com/open-navigation/navigation2/blob/main/nav2_mppi_controller/src/optimizer.cpp#L76). This is done to decouple the parameters and allow for dynamic updates of the velocities via the speed limiter API (https://github.com/open-navigation/navigation2/blob/main/nav2_mppi_controller/src/optimizer.cpp#L419-L444) so we can store the "true" max velocity for setting percentage adjustments with respect to.

We do however sync them up when the controller is reset (https://github.com/open-navigation/navigation2/blob/main/nav2_mppi_controller/src/optimizer.cpp#L126) which happens when parameter updates are made in main https://github.com/open-navigation/navigation2/blob/main/nav2_mppi_controller/src/optimizer.cpp#L89.

It looks like that might need the following added to Humble's reset() method like we have in main. Can you test to verify that does what you need it to do then open a PR?

  settings_.constraints = settings_.base_constraints;

https://github.com/open-navigation/navigation2/commit/569f1672609c22bc52c4c4c486818fde3bd99646

Huyhust13 commented 3 months ago

Thank for your replying @SteveMacenski. I'll do test.

Huyhust13 commented 3 months ago

It's correct, it works now @SteveMacenski Thank you very much for your help.