Skip to content

[mppi] fix division by zero, clean raw pointers code#5636

Merged
SteveMacenski merged 3 commits intoros-navigation:mainfrom
adivardi:fix_division_by_zero
Oct 22, 2025
Merged

[mppi] fix division by zero, clean raw pointers code#5636
SteveMacenski merged 3 commits intoros-navigation:mainfrom
adivardi:fix_division_by_zero

Conversation

@adivardi
Copy link
Contributor


Basic Info

Info Please fill out this column
Ticket(s) this addresses -
Primary OS tested on Ubuntu
Robotic platform tested on gazebo simulation & real robot
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

fix division by zero in constraint_critic, leading to cost values being NaNs. These values then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high turning at the start of a run.

Before the change:
https://github.com/user-attachments/assets/d43f7455-e8b7-4bd6-a8b1-12326bd4ce2b

After the change:
https://github.com/user-attachments/assets/31c06d84-6bec-4b57-bbee-d7d33f944515

Also, a minor change in applyConstraints() to use Eigen Array operations instead of loop and raw pointers. No functional change.

Description of documentation updates required from your changes

None

Description of how this change was tested

  • Tested on simulation and on robot
  • Manually inspected the cost values and control_sequence.wz

Future work that may be required in bullet points

None

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-*.

leading to cost values being NaNs, which then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high steering at the start of a run

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
@adivardi adivardi force-pushed the fix_division_by_zero branch from 69abc07 to eb1dec4 Compare October 22, 2025 12:59
Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
@adivardi adivardi force-pushed the fix_division_by_zero branch from 0835690 to f868f6e Compare October 22, 2025 13:07
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...ler/include/nav2_mppi_controller/motion_models.hpp 100.00% <100.00%> (ø)
..._mppi_controller/src/critics/constraint_critic.cpp 65.21% <ø> (ø)

... and 3 files with indirect coverage changes

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

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.

Nice, love it thanks!

@SteveMacenski SteveMacenski merged commit feb3418 into ros-navigation:main Oct 22, 2025
16 checks passed
@adivardi adivardi deleted the fix_division_by_zero branch October 23, 2025 11:20
jonipol pushed a commit to Karelics/navigation2 that referenced this pull request Dec 5, 2025
…5636)

* [mppi] fix division by zero

leading to cost values being NaNs, which then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high steering at the start of a run

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* [mppi] clean ackermann constraints

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* fix long line

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

---------

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
decwest pushed a commit to decwest/navigation2 that referenced this pull request Dec 10, 2025
…5636)

* [mppi] fix division by zero

leading to cost values being NaNs, which then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high steering at the start of a run

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* [mppi] clean ackermann constraints

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* fix long line

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

---------

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
jonipol pushed a commit to Karelics/navigation2 that referenced this pull request Dec 11, 2025
…5636)

* [mppi] fix division by zero

leading to cost values being NaNs, which then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high steering at the start of a run

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* [mppi] clean ackermann constraints

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* fix long line

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

---------

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
jonipol added a commit to Karelics/navigation2 that referenced this pull request Dec 11, 2025
…ann robots (#2)

* Add debug topic to visualize whether MPPI critic has an effect on costs (ros-navigation#5485)

* Publish criticsStats

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* linting

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* change header to stamp

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* make unique_pointer

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* typo

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* Add readme

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* add to readme

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* fixes

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

---------

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>

* Make critic stats to work with current branch

* [mppi] fix division by zero, clean raw pointers code (ros-navigation#5636)

* [mppi] fix division by zero

leading to cost values being NaNs, which then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high steering at the start of a run

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* [mppi] clean ackermann constraints

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* fix long line

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

---------

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

---------

Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>
Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
Co-authored-by: Tony Najjar <tony.najjar.1997@gmail.com>
Co-authored-by: Adi Vardi <57910756+adivardi@users.noreply.github.com>
decwest pushed a commit to decwest/navigation2 that referenced this pull request Dec 11, 2025
…5636)

* [mppi] fix division by zero

leading to cost values being NaNs, which then propagate through all the critics and results in NaN control_sequence. These NaNs were removed by the hard applyControlSequenceConstraints(), but replaced with ax_max & wz_max. These lead to high steering at the start of a run

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* [mppi] clean ackermann constraints

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

* fix long line

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>

---------

Signed-off-by: Adi Vardi <adi.vardi@enway.ai>
Signed-off-by: Decwest <fumiyaonishi1016@gmail.com>
Alessio-Parmeggiani added a commit to Alessio-Parmeggiani/navigation2 that referenced this pull request Jan 9, 2026
backporting ros-navigation#5636 to humble_main branch.
This leads to nan costs when wz is zero.

Signed-off-by: Alessio Parmeggiani <parmeggiani.alessio1@gmail.com>
Alessio-Parmeggiani added a commit to Alessio-Parmeggiani/navigation2 that referenced this pull request Jan 9, 2026
backporting ros-navigation#5636 to humble_main branch.
This leads to nan costs when wz is zero.

Signed-off-by: Alessio Parmeggiani <parmeggiani.alessio1@gmail.com>
SteveMacenski pushed a commit that referenced this pull request Jan 9, 2026
backporting #5636 to humble_main branch.
This leads to nan costs when wz is zero.

Signed-off-by: Alessio Parmeggiani <parmeggiani.alessio1@gmail.com>
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.

2 participants