Skip to content

Conversation

@jnskkmhr
Copy link

@jnskkmhr jnskkmhr commented Dec 21, 2025

Description

This PR creates Unitree G1 29dof locomotion task.
The issue is mentioned in #4064 where current G1 USD file is different from actual hardware.

Type of change

New file

  • Create g1_29dof task in manager_based env

Change to existing files

  • Add G1 29dof articulation config in source/isaaclab_assets/isaaclab_assets/robots/unitree.py
  • Create command config and class in source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/commands
  • Add root_height_below_minimum_adaptive function in source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/terminations.py

USD asset

  • Download the following asset zip file, place it at source/isaaclab_assets/data and unzip it.
    unitree.zip

Performance

The current implementation achieves up to 3.0m/s running.
Joint regularization, foot orientation regularization, and gait tracking reward need a bit more tuning in my opinion.
I used rsl_rl for policy training/inference.

g1_run.mp4

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions bot added enhancement New feature or request asset New asset feature or request labels Dec 21, 2025
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 21, 2025

Greptile Summary

This PR adds a G1 29DOF locomotion task for the Unitree G1 humanoid robot, addressing the hardware-simulation mismatch discussed in issue #4064.

Key Changes

  • Added UNITREE_G1_29DOF_CFG and UNITREE_G1_23DOF_CFG robot configurations aligned with actual hardware specs
  • Implemented PhaseCommand for gait cycle tracking and UniformLevelVelocityCommand with enhanced visualization
  • Created comprehensive reward system with 25+ terms covering velocity tracking, foot orientation, gait patterns, and joint regularization
  • Added root_height_below_minimum_adaptive termination function for bipedal robots
  • Implemented velocity-dependent posture regularization (variable_posture) to support standing, walking, and running gaits

Issues Found

  • Critical: velocity_command.py:49 checks wrong attribute (goal_vel_visualizer instead of goal_linvel_visualizer), will fail when disabling debug visualization
  • Critical: velocity_command.py:141 has duplicate prim_path between angular and linear velocity visualizers, causing marker collision
  • Critical: terminations.py:68 accesses undefined asset_cfg.body_ids when config only provides body_names, will throw AttributeError at runtime

Confidence Score: 2/5

  • PR has three critical runtime errors that will cause failures when using visualization or termination features
  • The locomotion task implementation is well-designed with comprehensive rewards and configurations, but contains three critical bugs that will cause AttributeErrors at runtime. The velocity command visualization has incorrect attribute checks and duplicate paths, and the termination function accesses undefined body_ids. These are not edge cases - they will fail immediately when the features are used
  • Pay close attention to velocity_command.py (attribute check + duplicate prim_path) and terminations.py (undefined body_ids access)

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/commands/velocity_command.py New velocity command with visualization. Has incorrect attribute check (line 49) and duplicate prim_path (line 141) that will cause runtime errors
source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/commands/phase_command.py Clean phase command implementation for gait timing. No issues found
source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/terminations.py Added adaptive height termination. body_ids will be undefined when body_names used in config, causing AttributeError
source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/config/g1_29dof/mdp/reward/reward.py Comprehensive reward implementations for G1 bipedal locomotion including foot orientation, gait tracking, and posture control
source/isaaclab_assets/isaaclab_assets/robots/unitree.py Added UNITREE_G1_29DOF_CFG and UNITREE_G1_23DOF_CFG configs aligned with hardware specs. Configuration looks correct

Sequence Diagram

sequenceDiagram
    participant Env as G1 Environment
    participant Cmd as CommandManager
    participant Phase as PhaseCommand
    participant Vel as UniformLevelVelocityCommand
    participant Robot as G1 Robot (29DOF)
    participant Reward as RewardManager
    participant Term as TerminationManager

    Env->>Robot: Initialize with UNITREE_G1_29DOF_CFG
    Env->>Cmd: Setup commands (velocity + gait phase)
    
    loop Every Episode
        Env->>Cmd: Reset commands
        Cmd->>Phase: Resample gait period
        Cmd->>Vel: Resample velocity targets
        
        loop Every Step
            Cmd->>Phase: Update phase (0 to 1)
            Phase-->>Cmd: Return current phase
            Cmd->>Vel: Update velocity command
            Vel-->>Cmd: Return velocity target
            
            Env->>Robot: Apply actions
            Robot-->>Env: Return state (positions, velocities, contacts)
            
            Env->>Reward: Calculate rewards
            Reward->>Reward: Track velocity (lin/ang)
            Reward->>Reward: Check foot orientation (roll/pitch/yaw)
            Reward->>Reward: Evaluate gait phase matching
            Reward->>Reward: Apply variable posture regularization
            Reward-->>Env: Return total reward
            
            Env->>Term: Check terminations
            Term->>Term: Check root_height_below_minimum_adaptive
            Term->>Term: Check bad orientation
            Term-->>Env: Return done flags
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (3)

  1. source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/commands/velocity_command.py, line 49 (link)

    logic: checking goal_vel_visualizer instead of goal_linvel_visualizer

  2. source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/commands/velocity_command.py, line 141 (link)

    logic: duplicate prim_path between current_angvel_visualizer_cfg and current_linvel_visualizer_cfg will cause collision

  3. source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/mdp/terminations.py, line 68-70 (link)

    logic: body_ids undefined - asset_cfg.body_ids not populated when only body_names provided in config

    the termination config uses body_names=".*_ankle_roll_link" but accesses body_ids directly. did you test this termination function with the G1 config?

28 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

asset New asset feature or request enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant