Introduce RobotDef protocol and robot registry#268
Draft
yuecideng wants to merge 7 commits into
Draft
Conversation
Introduce a runtime-checkable RobotDef protocol that defines the contract for robot definitions in EmbodiChain. The protocol specifies required properties (name, urdf_cfg, control_parts, solver_cfg, drive_pros, attrs) and a build_cfg method that converts a RobotDef into a RobotCfg with support for property copying and merge overrides. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a global robot registry (register_robot, get_robot_def, build_robot_cfg) so callers can reference robots by string name without knowing import paths. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Refactor CobotMagic to implement the RobotDef protocol and register it
in the global robot registry under the name "CobotMagic". All existing
configuration values (URDF paths, transforms, control parts, solver
configs, drive properties, rigid-body attributes) are preserved exactly.
CobotMagicCfg.from_dict() continues to work as a backward-compatible
wrapper that delegates to CobotMagicDef().build_cfg(). The __init__.py
exports both CobotMagicDef and CobotMagicCfg.
Tests added:
- test_cobotmagic_def_builds_valid_cfg: verifies uid, urdf_cfg,
control_parts, solver_cfg
- test_cobotmagic_def_registry: verifies get_robot_def("CobotMagic")
works and produces correct cfg
- test_cobotmagic_backward_compat_from_dict: verifies the legacy
CobotMagicCfg.from_dict({}) path still works
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add DexforceW1Def implementing the RobotDef protocol, registered as "DexforceW1" in the global robot registry. The existing DexforceW1Cfg class retains backward compatibility by delegating from_dict to DexforceW1Def. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a RobotDef protocol and registry-driven robot definition flow for simulation robots, and migrates existing robot definitions to the new interface.
Motivation and context:
Dependencies: None.
Related issue: N/A (no linked issue)
Type of change
Screenshots
Not applicable.
Checklist
black .command to format the code base.🤖 Generated with Claude Code