Add Unitree G1 Sonic robot model#813
Open
Xucxname wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a robosuite-native integration for the Unitree G1 “SONIC” stack, including a new SonicG1/SonicG1Fixed robot with Dex3 grippers, a SONIC_WBC composite controller that routes streamed per-joint PD commands through robosuite controllers, and supporting tooling for recording/replay/testing.
Changes:
- Introduces SONIC command-source + torque engine utilities (
robosuite.utils.sonic.*) and a newSONIC_WBCcomposite controller. - Adds
SonicG1robot model + Dex3 grippers, committed MJCF assets, and a script to (re)build assets from upstream model_data. - Adds an end-to-end test suite and documentation / demo collection script for live DDS + deterministic replay.
Reviewed changes
Copilot reviewed 24 out of 139 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_robots/test_sonic_g1.py | End-to-end tests for registration, assembly, OSC, SONIC_WBC PD dispatch matching, floating-base behavior, and data collection. |
| robosuite/utils/sonic/sources.py | Adds DDS / replay / mock command sources and one-time DDS init helper. |
| robosuite/utils/sonic/debug.py | Adds per-step recorder to generate “golden” trajectories for deterministic replay/tests. |
| robosuite/utils/sonic/controller.py | Adds G1SonicController engine for obs-building + PD torque computation + effort clipping (+ optional hands). |
| robosuite/utils/sonic/init.py | Exposes SONIC utilities as a package. |
| robosuite/scripts/collect_sonic_g1_demos.py | Script to drive SonicG1 in robosuite envs via DDS/replay/mock and record demo.hdf5. |
| robosuite/scripts/build_sonic_g1_assets.py | Script to split upstream integrated MJCF into robosuite-native robot + gripper assets. |
| robosuite/robots/init.py | Registers SonicG1 / SonicG1Fixed in ROBOT_CLASS_MAPPING. |
| robosuite/models/robots/manipulators/sonic_g1_robot.py | New SonicG1 / SonicG1Fixed robot models with base + arm ordering adjustments for robosuite. |
| robosuite/models/robots/manipulators/g1_sonic_robot.py | Existing G1Sonic model file included in manipulator imports / mapping updates. |
| robosuite/models/robots/manipulators/init.py | Exports G1Sonic, SonicG1, SonicG1Fixed. |
| robosuite/models/grippers/sonic_dex3_gripper.py | New Dex3 left/right gripper models and action formatting. |
| robosuite/models/grippers/init.py | Ensures Dex3 grippers import so they self-register. |
| robosuite/models/assets/robots/sonic_g1/robot.xml | Adds committed SonicG1 body asset (split from upstream model). |
| robosuite/models/assets/robots/g1_sonic/robot.xml | Adds/updates integrated G1 Sonic asset (with hands) used by other paths. |
| robosuite/models/assets/grippers/sonic_dex3_right.xml | Adds committed right Dex3 gripper MJCF asset. |
| robosuite/models/assets/grippers/sonic_dex3_left.xml | Adds committed left Dex3 gripper MJCF asset. |
| robosuite/controllers/parts/generic/joint_pos.py | Extends joint position controller to accept streamed PD commands (dq*, tau_ff, optional torque clip). |
| robosuite/controllers/parts/controller_factory.py | Adds JOINT_TORQUE option for gripper/torso/head factories. |
| robosuite/controllers/config/robots/default_sonic_g1.json | Adds default composite config for SONIC_WBC using joint position part controllers. |
| robosuite/controllers/composite/sonic_whole_body_controller.py | Adds SONIC_WBC composite controller: exchange DDS + route PD to part controllers + startup elastic band. |
| robosuite/controllers/composite/init.py | Imports SonicWholeBodyController so it registers. |
| docs/modules/sonic_g1.rst | Adds setup / usage docs for the SonicG1 integration. |
| docs/index.rst | Adds modules/sonic_g1 to documentation toctree. |
Comments suppressed due to low confidence (6)
tests/test_robots/test_sonic_g1.py:1
- Hard-coded, machine-specific absolute paths make these tests non-portable and will cause most environments (including CI) to skip important coverage or fail to find assets. Prefer deriving paths from installed packages (e.g.,
gear_sonic.__file__), using repository-relative test data, or reading paths from environment variables / pytest options with a clear default + skip reason that includes the resolved path.
tests/test_robots/test_sonic_g1.py:1 - Hard-coded, machine-specific absolute paths make these tests non-portable and will cause most environments (including CI) to skip important coverage or fail to find assets. Prefer deriving paths from installed packages (e.g.,
gear_sonic.__file__), using repository-relative test data, or reading paths from environment variables / pytest options with a clear default + skip reason that includes the resolved path.
robosuite/scripts/collect_sonic_g1_demos.py:1 - This script is currently tied to a specific developer filesystem layout via
GOLD_DIRandWITH_HAND_XML, which will break for other users. Make these configurable via CLI flags (e.g.,--gold-dir,--with-hand-xml) and/or environment variables, and consider defaultingWITH_HAND_XMLby locating it relative to the installedgear_sonicpackage (when present).
robosuite/scripts/build_sonic_g1_assets.py:1 - The asset build script is not reusable as-is because it hardcodes an absolute upstream checkout path. Consider accepting
--gear-sonic-dir/--src/--meshdirCLI args (with env-var fallbacks) so others can regenerate assets without editing source, and so the script can be used in automated build pipelines.
robosuite/utils/sonic/controller.py:1 - If
torso_linkcan’t be found,torso_idbecomes-1andmd.xquat[-1]silently reads the last body’s quaternion, producing incorrect IMU observations without any error. This should fail fast (e.g., raise with a clear message) or fall back to a safe default (e.g., zeros) rather than indexing-1.
robosuite/utils/sonic/controller.py:1 - If
torso_linkcan’t be found,torso_idbecomes-1andmd.xquat[-1]silently reads the last body’s quaternion, producing incorrect IMU observations without any error. This should fail fast (e.g., raise with a clear message) or fall back to a safe default (e.g., zeros) rather than indexing-1.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if self.interpolator is not None: | ||
| self.interpolator.set_goal(self.goal_qpos) | ||
|
|
||
| def set_pd_command(self, qpos, qvel=None, kp=None, kd=None, tau_feedforward=None): |
Comment on lines
+255
to
+263
| self.goal_qpos = np.asarray(qpos, dtype=float) | ||
| if qvel is not None: | ||
| self.desired_vel = np.asarray(qvel, dtype=float) | ||
| if kp is not None: | ||
| self.kp = np.asarray(kp, dtype=float) | ||
| if kd is not None: | ||
| self.kd = np.asarray(kd, dtype=float) | ||
| if tau_feedforward is not None: | ||
| self.torque_feedforward = np.asarray(tau_feedforward, dtype=float) |
| if self.interpolator is not None: | ||
| self.interpolator.set_goal(self.goal_qpos) | ||
|
|
||
| def set_pd_command(self, qpos, qvel=None, kp=None, kd=None, tau_feedforward=None): |
Comment on lines
+11
to
+12
| routes the per-motor PD command streamed by the C++ stack through robosuite's per-part | ||
| ``JointPositionController`` s. **robosuite** owns the physics clock; on the SONIC path the |
Comment on lines
294
to
306
Comment on lines
29
to
30
Comment on lines
171
to
183
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.
What this does
Adds the Unitree G1 Sonic robot model with Dex-3 hands,
G1Sonicmodel class, and robosuite registry wiring.Label: (✨ Feature)
How it was tested