Skip to content

Conversation

@jslee02
Copy link
Member

@jslee02 jslee02 commented Jan 16, 2026

Summary

  • Add validation for NaN/Inf/negative friction, restitution, and slip compliance values in ContactSurface and SoftContactConstraint
  • Invalid values now log a warning and fall back to defaults, preventing assertion failures in the LCP solver

Backport of #2434 to release-6.16

Problem

When malformed SDF files contain invalid friction values (e.g., <mu>NaN</mu>), these propagate through DART's constraint system and cause an assertion failure in dSolveLCP:

lo[k] <= 0 && hi[k] >= 0

This crashes simulations in gz-physics and any other downstream consumers.

Solution

Validate contact surface parameters at extraction time in:

  • DefaultContactSurfaceHandler::computeFrictionCoefficient()
  • DefaultContactSurfaceHandler::computePrimaryFrictionCoefficient()
  • DefaultContactSurfaceHandler::computeSecondaryFrictionCoefficient()
  • DefaultContactSurfaceHandler::computePrimarySlipCompliance()
  • DefaultContactSurfaceHandler::computeSecondarySlipCompliance()
  • DefaultContactSurfaceHandler::computeRestitutionCoefficient()
  • SoftContactConstraint::computeFrictionCoefficient()
  • SoftContactConstraint::computeRestitutionCoefficient()

Invalid values are rejected with a warning and replaced with safe defaults.

Testing

  • Added unit tests covering NaN, Inf, negative, and valid value cases
  • Awaiting CI verification

Related Issues

Related to gazebosim/gz-physics#841

Checklist

  • Code compiles without errors (pending CI)
  • Added new tests for the fix
  • Updated CHANGELOG.md

@jslee02 jslee02 added this to the DART 6.16.5 milestone Jan 16, 2026
@jslee02 jslee02 changed the title fix: validate contact surface parameters to prevent LCP solver crashes fix: validate contact surface parameters to prevent LCP solver crashes (DART 6.16) Jan 16, 2026
@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 59.61538% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.81%. Comparing base (991315e) to head (63e535f).
⚠️ Report is 4 commits behind head on release-6.16.

Files with missing lines Patch % Lines
dart/constraint/SoftContactConstraint.cpp 0.00% 14 Missing ⚠️
dart/constraint/ContactSurface.cpp 81.57% 7 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           release-6.16    #2435      +/-   ##
================================================
+ Coverage         58.74%   58.81%   +0.06%     
================================================
  Files               385      385              
  Lines             32194    32241      +47     
  Branches           3884     3893       +9     
================================================
+ Hits              18911    18961      +50     
+ Misses            13283    13280       -3     
Flag Coverage Δ
unittests 58.81% <59.61%> (+0.06%) ⬆️

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

Files with missing lines Coverage Δ
dart/constraint/ContactSurface.cpp 73.93% <81.57%> (+1.34%) ⬆️
dart/constraint/SoftContactConstraint.cpp 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

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

@jslee02
Copy link
Member Author

jslee02 commented Jan 17, 2026

@codex review

@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 force-pushed the fix/nan-friction-validation-6.16 branch from c3698ba to 63e535f Compare January 18, 2026 06:36
@jslee02
Copy link
Member Author

jslee02 commented Jan 18, 2026

@codex review

This PR has been rebased on release-6.16. Updated CHANGELOG with correct PR number and resolved merge conflict. The validation approach using DART_WARN with fallback to default values is appropriate for this use case (expected failures from malformed SDF data).

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

Add validation for NaN/Inf/negative friction, restitution, and slip
compliance values in ContactSurface and SoftContactConstraint.
Invalid values now log a warning and fall back to defaults.

This prevents assertion failures in the LCP solver when malformed SDF
files (e.g., <mu>NaN</mu>) propagate invalid values through the
constraint system.

Backport of fix from main branch.
Fixes gazebosim/gz-physics#841
Fully qualify constraint::DART_DEFAULT_FRICTION_COEFF and
constraint::DART_DEFAULT_RESTITUTION_COEFF to avoid ambiguity with
dynamics namespace constants.
@jslee02 jslee02 force-pushed the fix/nan-friction-validation-6.16 branch from 63e535f to 8e2b4a2 Compare January 18, 2026 15:08
@jslee02
Copy link
Member Author

jslee02 commented Jan 18, 2026

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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 d0499b5 into release-6.16 Jan 18, 2026
6 of 25 checks passed
@jslee02 jslee02 deleted the fix/nan-friction-validation-6.16 branch January 18, 2026 15:19
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