Skip to content

Conversation

@jslee02
Copy link
Member

@jslee02 jslee02 commented Jan 17, 2026

Summary

  • Add NaN/Inf validation to BodyNode::addExtForce, setExtForce, addExtTorque, setExtTorque
  • Add NaN/Inf validation to PointMass::addExtForce
  • Invalid values are logged as warnings and ignored to prevent simulation crashes

Related Issue

Addresses gz-physics#844 - Crash in BodyNode::updateBiasForce when Gazebo Hydrodynamics plugin passes NaN parameters (e.g., <xDotU>NaN</xDotU>).

Changes

File Change
dart/dynamics/BodyNode.cpp Validate force/torque vectors before applying
dart/dynamics/PointMass.cpp Validate force vector before applying
tests/unit/dynamics/test_BodyNodeExternalForce.cpp 9 unit tests for NaN/Inf handling
tests/unit/dynamics/CMakeLists.txt New test target
tests/unit/CMakeLists.txt Add dynamics subdirectory

Testing

All 9 new unit tests pass locally:

  • AddExtForceWithNaN
  • AddExtForceWithInf
  • AddExtForceWithNaNOffset
  • SetExtForceWithNaN
  • AddExtTorqueWithNaN
  • AddExtTorqueWithInf
  • SetExtTorqueWithNaN
  • ValidForceApplication
  • GzPhysics844Scenario

@jslee02 jslee02 added this to the DART 6.16.5 milestone Jan 17, 2026
@jslee02 jslee02 force-pushed the fix/nan-external-force-validation-6.16 branch from 3ecf5ee to 5a49c13 Compare January 17, 2026 19:33
@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 74.13793% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.85%. Comparing base (991315e) to head (2ad582d).
⚠️ Report is 5 commits behind head on release-6.16.

Files with missing lines Patch % Lines
dart/dynamics/PointMass.cpp 0.00% 8 Missing ⚠️
dart/dynamics/BodyNode.cpp 86.00% 7 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           release-6.16    #2443      +/-   ##
================================================
+ Coverage         58.74%   58.85%   +0.11%     
================================================
  Files               385      385              
  Lines             32194    32241      +47     
  Branches           3884     3896      +12     
================================================
+ Hits              18911    18977      +66     
+ Misses            13283    13264      -19     
Flag Coverage Δ
unittests 58.85% <74.13%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
dart/dynamics/BodyNode.hpp 50.00% <ø> (ø)
dart/dynamics/PointMass.hpp 100.00% <ø> (ø)
dart/dynamics/BodyNode.cpp 80.10% <86.00%> (+0.65%) ⬆️
dart/dynamics/PointMass.cpp 48.35% <0.00%> (-0.43%) ⬇️

... and 5 files with indirect coverage changes

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

Add validation to reject NaN and Inf values in external force/torque
setters to prevent simulation crashes when upstream physics middleware
(e.g., Gazebo Hydrodynamics plugin) passes invalid parameters.

Modified files:
- dart/dynamics/BodyNode.cpp: Add validation to addExtForce, setExtForce,
  addExtTorque, setExtTorque
- dart/dynamics/PointMass.cpp: Add validation to addExtForce

Tests:
- tests/unit/dynamics/test_BodyNodeExternalForce.cpp: 9 unit tests

Related: gazebosim/gz-physics#844
@jslee02 jslee02 force-pushed the fix/nan-external-force-validation-6.16 branch from fe4f564 to 2ad582d Compare January 18, 2026 06:39
@jslee02
Copy link
Member Author

jslee02 commented Jan 18, 2026

@codex review

This PR has been rebased on release-6.16. The validation approach using DART_WARN with early return is appropriate for this use case (handling NaN/Inf external forces from hydrodynamics parameters in gz-physics).

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jslee02 jslee02 merged commit 36b0812 into release-6.16 Jan 18, 2026
28 checks passed
@jslee02 jslee02 deleted the fix/nan-external-force-validation-6.16 branch January 18, 2026 15:04
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