Skip to content

Stanford-TML/real_g1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

First install the unitree python sdk. You should install from source because the pip installation has some issues importing necessary files as of February 2025. Follow the instructions in unitree_sdk2_python to install from source.

pip install -r requirements.txt

Running Sim2sim

For Sim2sim, you will need 2 terminals.

# In the first terminal
python sim2sim.py --xml_path g1_description/g1.xml
# In the second terminal
python deploy.py --net lo --sim2sim

The processes will establish a connection. When prompted, press the "s" key to start moving into the default pose. After the robot is in the default pose, press the "a" key to start executing closed-loop control.

Running Sim2real

Sim2real is currently not tested, but it will use the exact same code in deploy.py.

python deploy.py --net <g1 network> --real

Why should we do Sim2sim?

There are two main reasons sim2sim is helpful. (1) Having as much overlapping code as possible for sim2sim and sim2real allows us to catch bugs before they occur on the hardware. Unexpected/untested code executing on hardware is dangerous! (2) Policies may sometimes overfit to their training simulator dynamics, especially when trained for a long time. Sim2sim allows you to test your policy's robustness to different dynamics/contacts.

Code Explanation

This code attempts to model as closely as possible the procedure you will encounter on the real robot. Some key ideas:

  1. We communicate between the high-level controller and low-level controller over a network. This is important because even milliseconds of delay can cause a trained policy to not work in real. (You should also be adding delays in your domain randomization)
  2. We simulate the remote controller (used for giving commands to the real robot) with a keyboard using a similar (keys -> buttons) mapping.
  3. The order of events is similar to that in real. First establish a connection between high-level and low-level, then smoothly transition to a default positions (while hanging on a gantry), then lower the robot to the floor, then begin closed-loop control.

To Do

  • Test in real
  • Add separate visualization process instead of blocking while rendering

About

Code for sim2sim and sim2real transfer on G1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages