Add joint effort limit parsing when importing from URDF#2244
Add joint effort limit parsing when importing from URDF#2244eric-heiden merged 5 commits intonewton-physics:mainfrom
Conversation
…eation plumbing using the updated effort_limit Signed-off-by: Kezhuo Wang <shuibianwang@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReads URDF joint Changes
Sequence Diagram(s)sequenceDiagram
participant URDF as URDF file
participant Parser as URDFParser
participant Builder as Builder
participant Joint as JointFactory
URDF->>Parser: read <joint> and <limit effort="...">
Parser->>Parser: set joint_data.limit_effort (explicit or default)
Parser->>Builder: add_joint_*(..., effort_limit=joint_data.limit_effort)
Builder->>Joint: construct revolute/prismatic with effort_limit
Joint-->>Builder: created joint (with effort_limit)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
newton/_src/utils/import_urdf.py (1)
803-821: Consider propagating effort limit to planar joints.The planar joint type constructs
JointDofConfigobjects but doesn't pass the URDF-parsedeffort_limit. This means planar joints will use theJointDofConfigdefault (1e6) instead of any URDF-specified value.This is likely acceptable since planar joints are uncommon and the PR scope focuses on revolute/prismatic, but could be addressed for completeness.
♻️ Optional: propagate effort_limit to planar JointDofConfig
created_joint_idx = builder.add_joint_d6( linear_axes=[ ModelBuilder.JointDofConfig( u, limit_lower=lower * scale, limit_upper=upper * scale, target_kd=joint_damping, actuator_mode=actuator_mode, + effort_limit=effort_limit if effort_limit is not None else builder.default_joint_cfg.effort_limit, ), ModelBuilder.JointDofConfig( v, limit_lower=lower * scale, limit_upper=upper * scale, target_kd=joint_damping, actuator_mode=actuator_mode, + effort_limit=effort_limit if effort_limit is not None else builder.default_joint_cfg.effort_limit, ), ], **joint_params, )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@newton/_src/utils/import_urdf.py` around lines 803 - 821, The planar joint creation currently builds two ModelBuilder.JointDofConfig entries without passing the URDF-parsed effort_limit, causing the defaults to be used; update the builder.add_joint_d6 call (and the two ModelBuilder.JointDofConfig constructors for u and v) to include effort_limit=<effort_limit_variable> (or effort_limit * scale if efforts are scaled) so the URDF effort limit is propagated to both DOFs when creating created_joint_idx.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@newton/_src/utils/import_urdf.py`:
- Around line 803-821: The planar joint creation currently builds two
ModelBuilder.JointDofConfig entries without passing the URDF-parsed
effort_limit, causing the defaults to be used; update the builder.add_joint_d6
call (and the two ModelBuilder.JointDofConfig constructors for u and v) to
include effort_limit=<effort_limit_variable> (or effort_limit * scale if efforts
are scaled) so the URDF effort limit is propagated to both DOFs when creating
created_joint_idx.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 916350a8-9cee-49fb-bad7-654754e737ea
📒 Files selected for processing (3)
CHANGELOG.mdnewton/_src/utils/import_urdf.pynewton/tests/test_import_urdf.py
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
newton/_src/utils/import_urdf.py (1)
803-821: Consider propagating effort_limit to planar joints for consistency.The
JointDofConfiginstances for planar joints are constructed withouteffort_limit, causing them to use the class default (1e6) rather than the URDF-specified or builder-default value. For consistency with revolute/prismatic handling, consider passing the effort limit here as well.♻️ Suggested fix
created_joint_idx = builder.add_joint_d6( linear_axes=[ ModelBuilder.JointDofConfig( u, limit_lower=lower * scale, limit_upper=upper * scale, target_kd=joint_damping, actuator_mode=actuator_mode, + effort_limit=effort_limit if effort_limit is not None else default_joint_limit_effort, ), ModelBuilder.JointDofConfig( v, limit_lower=lower * scale, limit_upper=upper * scale, target_kd=joint_damping, actuator_mode=actuator_mode, + effort_limit=effort_limit if effort_limit is not None else default_joint_limit_effort, ), ], **joint_params, )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@newton/_src/utils/import_urdf.py` around lines 803 - 821, The planar joint D6 DOF configs omit the effort limit, so update the two ModelBuilder.JointDofConfig calls inside builder.add_joint_d6 to include the URDF/builder effort value (e.g., effort_limit) so they don't fall back to the 1e6 default; add effort_limit=effort_limit (or effort_limit * scale if your units require scaling) alongside limit_lower, limit_upper, target_kd=joint_damping, and actuator_mode to both DOF configs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@newton/_src/utils/import_urdf.py`:
- Around line 803-821: The planar joint D6 DOF configs omit the effort limit, so
update the two ModelBuilder.JointDofConfig calls inside builder.add_joint_d6 to
include the URDF/builder effort value (e.g., effort_limit) so they don't fall
back to the 1e6 default; add effort_limit=effort_limit (or effort_limit * scale
if your units require scaling) alongside limit_lower, limit_upper,
target_kd=joint_damping, and actuator_mode to both DOF configs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 0f67a978-d3f5-4794-9521-f3787da69877
📒 Files selected for processing (3)
CHANGELOG.mdnewton/_src/utils/import_urdf.pynewton/tests/test_import_urdf.py
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
- newton/tests/test_import_urdf.py
|
@kwang-12 could you please have a look at the failing test? It looks ok visually, likely just an issue with the timing of the check. But it looks like a deterministic failure. |
…l_size to 1.1*voxel_size
Head branch was pushed to by a user without write access
|
@adenzler-nvidia I have investigated the issue and it turns out clamping joint effort limit for this particular test caused the particle to penetrate the ground slightly more than the old threshold at #line299 The example was ran with default voxel size of 0.03 so the violation is basically harmless. The debug print also shows the failed particles are clustered close to each other. In 800c672, I have relaxed the test_particle_state threshold in example_mpm_anymal from |
Description
This PR updates the URDF importer to read joint
<limit effort="...">values and forward them into imported revolute and prismatic joints viaeffort_limit.Previously, URDF import preserved joint position limits but ignored effort limits, so imported joints silently fell back to the builder default. With this change, URDF-authored effort limits are applied during joint creation, while joints that omit
effortcontinue to inheritbuilder.default_joint_cfg.effort_limit.Checklist
CHANGELOG.mdhas been updated (if user-facing change)Test plan
Added coverage in
newton.tests.test_import_urdf.TestImportUrdfBasic.test_revolute_joint_urdfto verify that a URDF joint witheffort="6.78"is imported with the expectedbuilder.joint_effort_limit.Verify with:
New feature / API change
Summary by CodeRabbit
New Features
Tests
Examples
Chores