Skip to content

Conversation

@jslee02
Copy link
Member

@jslee02 jslee02 commented Jan 17, 2026

Summary

  • Replace DART_ASSERT(radius > 0.0) with proper validation using std::isfinite() and DART_WARN()
  • Invalid values (NaN, infinity, non-positive) are now rejected with a warning instead of crashing
  • Add unit tests covering all validation cases

Motivation

Addresses gz-physics#843 where DART crashes with an assertion failure when SphereShape::setRadius() receives invalid radius values from upstream physics interfaces.

Related PR

Changes

  • dart/dynamics/SphereShape.cpp: Added validation with graceful rejection
  • tests/unit/dynamics/test_SphereShape.cpp: New test file with 5 test cases
  • tests/unit/CMakeLists.txt: Added SphereShape test entry
  • CHANGELOG.md: Added entry under Collision and Geometry section

Testing

  • Unit tests verify valid radius acceptance and invalid value rejection (NaN, Inf, zero, negative)
  • Follows existing validation pattern from World::setTimeStep()

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d3a483603

ℹ️ 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 added this to the DART 7.0 milestone Jan 17, 2026
@jslee02 jslee02 changed the title fix: validate SphereShape radius to prevent assertion failures Fix: Validate SphereShape radius to prevent assertion failures (DART 7) Jan 17, 2026
@jslee02 jslee02 force-pushed the fix/gz-physics-843-sphere-nan-validation branch from fcaa0bd to d822d4a Compare January 17, 2026 19:22
@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. Swish!

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

@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.49%. Comparing base (a15166f) to head (2389de2).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2442   +/-   ##
=======================================
  Coverage   66.49%   66.49%           
=======================================
  Files         407      407           
  Lines       37254    37256    +2     
  Branches     4901     4902    +1     
=======================================
+ Hits        24772    24774    +2     
  Misses      12482    12482           
Flag Coverage Δ
unittests 66.49% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
dart/dynamics/SphereShape.cpp 83.33% <100.00%> (+0.98%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jslee02 jslee02 force-pushed the fix/gz-physics-843-sphere-nan-validation branch from 9ec25b5 to e5dbe9e Compare January 18, 2026 05:52
Replace DART_ASSERT(radius > 0.0) with proper validation using
std::isfinite() and DART_WARN(). Invalid values (NaN, infinity,
non-positive) are now rejected with a warning instead of crashing.

This addresses gz-physics#843 where DART crashes when SphereShape
receives invalid radius values from upstream physics interfaces.

Includes unit tests for:
- Valid radius acceptance
- NaN rejection
- Infinity rejection
- Non-positive value rejection
@jslee02 jslee02 force-pushed the fix/gz-physics-843-sphere-nan-validation branch from e5dbe9e to 2389de2 Compare January 18, 2026 06:37
@jslee02
Copy link
Member Author

jslee02 commented Jan 18, 2026

@codex review

This PR has been rebased on main to incorporate the new error handling infrastructure from #2445. The validation approach using DART_WARN with fallback to default value (1.0) is appropriate for this use case (handling invalid radius values from upstream physics interfaces like gz-physics).

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ 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 46838eb into main Jan 18, 2026
46 checks passed
@jslee02 jslee02 deleted the fix/gz-physics-843-sphere-nan-validation branch January 18, 2026 15:05
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