Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

127 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy Robot in Simulation and on Hardware

This repo is for deploying asynchronous sim and real robot code for the Unitree G1 robot.

A brief overview of the repo structure is as follows:

  • deploy: main deployment code for both sim and real robot. The simulation folder contains code for sim deployment, and the hardware folder contains code for real robot deployment.
  • models: contains the Mujoco XML files and mesh files for the robot.
  • motions: contains motion files for the robot.
  • policy: contains the policies to use for controlling the robot.
  • utils: contains utility code.

Installation

Important

If you are on Ubuntu 24:

  • Use ROS2 jazzy instead. Simply replace every mention of humble with jazzy.
  • Install the conda env with Python 3.12. Simply change python=3.10 to python=3.12 in the environment.yml file.

ROS2

Use ROS2 humble to communicate across different pieces of code. Install instructions are here: https://docs.ros.org/en/humble/Installation.html

If your scripts use the ROS joystick, you can install joy package via:

sudo apt update
sudo apt install ros-humble-joy

Conda Environment

Use make to create the deploy conda environment from environment.yml:

make install

This creates the env and sets the DEPLOY_ROOT_DIR environment variable (scoped to the env) to this repo. Then, activate the env:

conda activate deploy

Other make targets:

make update      # update the env from environment.yml (after editing dependencies)
make uninstall   # remove the deploy env (run `conda deactivate` first)

Unitree SDK2 for Python

After the conda environment is set up, install the Unitree SDK inside the conda environment. Make sure you are in the deploy conda environment by using conda activate deploy, and then follow the Unitree SDK installation instructions here: https://github.com/unitreerobotics/unitree_sdk2_python

Policy

To download a policy from WandB into the policy/ folder, you can for example run:

python policy/get_wandb_policy.py sesteban-california-institute-of-technology-caltech/mjlab/bysdsnbu

Deployment

Simulation

Launching

You will open terminals, each in the deploy conda environment. In the first terminal, you will launch the joystick node (if you use it). In the second terminal, you will launch the controller. In the third terminal, you will launch the Mujoco simulation.

Terminal 1 (if you use joystick):

python deploy/joystick/joystick_ros.py 

Terminal 2:

python deploy/simulation/<control_script>.py --config <your-config-file>.yaml

Terminal 3:

python deploy/simulation/simulation.py --config <your-config-file>.yaml

Terminal 4 (optional, to log data to logs/simulation/):

python deploy/logger/log.py --mode sim

Hardware

Turning the robot on

Press the power button twice and hold on the second press. You should see the robot's eyes light up and hear fan sounds from the motors. After a while of setup, the robot will say "zero torque mode".

This means the robot is on and ready to receive commands.

Network Configuration

First ensure that you are connected to the robot via an ethernet cable. Then go to Ubuntu settings and configure the IPv4 Method to Manual, set the Address to 192.168.123.99, and the Netmask to 255.255.255.0.

You can find the network interface name (e.g. enp8s0) via ifconfig command in a terminal. You will need it to run hardware deployment code.

Sanity Check

To make sure everything is working and you can communicate with the robot, you can run the example low level control script where the robot moves its arms and ankles. Run:

python deploy/hardware/g1_low_level_example.py <network_interface_name>

where <network_interface_name> is the name of your network interface (e.g. enp8s0).

Launching

You will open terminals, each in the deploy conda environment. In the first terminal, you will launch the joystick node (if you use it). In the second terminal, you will launch the controller. In the third terminal, you will launch the hardware SDK node.

Terminal 1 (if you use joystick):

python deploy/joystick/joystick_ros.py 

Terminal 2:

python deploy/hardware/<control_script>.py --config <your-config-file>.yaml

Terminal 3:

python deploy/hardware/hardware.py --config <your-config-file>.yaml --network <network_interface_name>

Terminal 4 (optional, to log data to logs/hardware/):

python deploy/logger/log.py --mode hw

where <network_interface_name> is the name of your network interface (e.g. enp8s0).


Plotting

To visualize a logged run, use logs/plot.py. With no arguments it plots the most recent log found under logs/simulation/ or logs/hardware/:

python logs/plot.py

To plot a specific log, pass its path:

python logs/plot.py --filename logs/hardware/<your-log>.h5

This brings up joint positions and velocities (measured vs commanded), estimated joint torques, the pelvis and torso IMUs, joystick commands, and motor temperatures — whichever of these datasets the log contains.


Small details

If you want VS Code to recognize the Unitree SDK source code, just add the following to your .vscode/settings.json that is located in your root directory:

{
  "python.analysis.extraPaths": ["<path-to>/unitree_sdk2_python"]
}

To be clear, this is only so you can do the ctrl + click to jump to the source code of the Unitree SDK. You don't need this for the code to run.

About

Deploy code for the Unitree G1 robot.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages