End-to-End Humanoid Robot Safe and Comfortable Locomotion Policy official code and other material.
This project implements an end-to-end policy for safe and comfortable humanoid robot locomotion using the G1 humanoid robot with 29 degrees of freedom. The policy is trained using reinforcement learning and can be deployed in simulation environments using the Genesis physics engine.
- G1 Humanoid Robot Support: Full implementation for G1 robot with 29-DOF including hands
- Genesis Physics Engine: Simulation using the Genesis physics engine for realistic physics
- Sim2Sim Transfer: Easy transfer of trained policies between different simulation environments
- 2D LiDAR Sensor: Integrated 2D ray-casting sensor for environment perception
- IMU Sensor Support: IMU sensor integration for orientation and velocity estimation
- Modular Design: Clean separation of robot configuration, sensors, and environment logic
SafeHumanoidsPolicy/
├── sim2sim.py # Main sim2sim evaluation script
├── requirements.txt # Python dependencies
├── assets/ # Robot assets and policies
│ ├── policy.jit # Trained policy (PyTorch JIT)
│ ├── g1_new/ # G1 robot URDF and meshes
│ ├── humanoid/ # Humanoid robot assets
│ └── resources/ # Additional resources
├── envs/ # Environment configurations
│ ├── base_task.py # Base task implementation
│ ├── g1_with_hand_robot.py # G1 robot environment
│ ├── g1_with_inspire_config.py # G1 configuration
│ ├── legged_robot_config.py # Base robot config
│ └── base_config.py # Base configuration
├── sensors/ # Sensor implementations
│ ├── base_sensor.py # Base sensor class
│ ├── imu_sensor.py # IMU sensor
│ └── warp/ # Warp-based sensor kernels
├── mesh/ # USD mesh files for visualization
└── utils/ # Utility functions
└── utils.py # Helper utilities
- Python 3.9+
- CUDA-compatible GPU (recommended)
- Genesis physics engine
- PyTorch 2.4.1+
- See
requirements.txtfor full list of dependencies
- Clone the repository:
git clone https://github.com/aCodeDog/SafeHumanoidsPolicy.git
cd SafeHumanoidsPolicy- Create a conda environment:
conda create -n genesis_gym python=3.9
conda activate genesis_gym- Install dependencies:
pip install -r requirements.txt- Install Genesis:
pip install genesis-world==0.2.1To run the trained policy in the Genesis simulator:
python sim2sim.pyThis will:
- Load the G1 robot with hand configuration
- Load the trained policy from
assets/policy.jit - Run the simulation with the policy controlling the robot
- Display the robot walking in the Genesis viewer
The robot configuration can be modified in envs/g1_with_inspire_config.py:
- Joint angles: Modify
default_joint_anglesto change the default pose - Control parameters: Adjust PD gains in
control.stiffnessandcontrol.damping - Command ranges: Set desired velocities in
commands.ranges - Sensor settings: Enable/disable sensors in
sensor_config
The policy was trained using the Genesis Legged Gym framework (see requirements.txt for the fork used). The observation space includes:
- Base orientation and angular velocity (12 dims)
- Joint positions and velocities (58 dims)
- 2D LiDAR scans (225 dims)
Action space: 29-dimensional continuous actions for joint position control
- DOF: 29 (legs: 12, waist: 3, arms: 14)
- Base Height: 0.77m
- Control: Position control with PD gains
- Action Scale: 0.5
- Decimation: 4 (control frequency = sim frequency / 4)
The robot includes:
- Hip joints (pitch, roll, yaw) for both legs
- Knee joints
- Ankle joints (pitch, roll)
- Waist joints (yaw, roll, pitch)
- Shoulder joints (pitch, roll, yaw)
- Elbow joints
- Wrist joints (roll, pitch, yaw)
- Range: 0.1m to 6.0m
- Field of View: Configurable theta range
- Resolution: Configurable theta step
- Features: Supports illusion mode for noise simulation
- Provides base orientation and angular velocity
- Used for state estimation
[Specify your license here]
If you use this code in your research, please cite:
@article{wang2025end,
title={End-to-End Humanoid Robot Safe and Comfortable Locomotion Policy},
author={Wang, Zifan and Yang, Xun and Zhao, Jianzhuang and Zhou, Jiaming and Ma, Teli and Gao, Ziyao and Ajoudani, Arash and Liang, Junwei},
journal={arXiv preprint arXiv:2508.07611},
year={2025}
}Contributions are welcome! Please feel free to submit a Pull Request.
For questions or issues, please open an issue on GitHub or contact the maintainers.
- Genesis physics engine team
- G1 humanoid robot developers
- RSL RL library for reinforcement learning
- Genesis Legged Gym framework
