fix: add class default inheritance for actuator parsing in MJCF#1503
Conversation
Actuator elements (<general>, <position>, etc.) now properly inherit attributes like biasprm, gainprm, ctrlrange from their default class. This fixes parsing of menagerie robots like UR5e that rely on class defaults for actuator configuration. Changes: - Use merge_attrib to combine class defaults with element attributes - Apply __all__ defaults first, then class-specific defaults, then element attributes Add tests for class default inheritance in actuator parsing.
📝 WalkthroughWalkthroughCentralizes attribute resolution for actuators by merging class-based defaults with element-specific attributes before use. Modified the parse_actuators function to derive target names and parameters from merged attributes rather than raw element attributes. Added comprehensive test coverage for class inheritance behavior. Changes
Sequence DiagramsequenceDiagram
participant Parser as MJCF Parser
participant Defaults as Class Defaults Resolver
participant Merge as Attribute Merger
participant ActParse as Actuator Parser
participant Model as Model Builder
Parser->>Defaults: Request class defaults hierarchy
Defaults-->>Parser: Return resolved class defaults (with inheritance)
Parser->>ActParse: Begin parsing actuator element
ActParse->>Merge: Element attributes + class defaults
Merge->>Merge: Combine global defaults<br/>+ class defaults<br/>+ element attributes
Merge-->>ActParse: Return merged_attrib
ActParse->>ActParse: Derive target (joint/body/tendon)<br/>from merged_attrib
ActParse->>ActParse: Extract kp, kv, actuation name<br/>from merged_attrib
ActParse->>ActParse: Parse custom attributes<br/>using merged_attrib
ActParse-->>Model: Finalized actuator with<br/>inherited parameters
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Actuator elements (, , etc.) now properly inherit attributes like biasprm, gainprm, ctrlrange from their default class. This fixes parsing of menagerie robots like UR5e that rely on class defaults for actuator configuration.
Changes:
Add tests for class default inheritance in actuator parsing.
Before your PR is "Ready for review"
newton/tests/test_examples.py)pre-commit run -aSummary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.