This repository is forked from walk-these-ways, which is a Go1 Sim-to-Real Locomotion Starter Kit. It seems that walk-these-ways can be untilized on Unitree A1 with simple modifications, since those robots are base on unitree-legged-sdk.
However, the brand-new architecture unitree-sdk2 is not base on UDP anymore, so this project aims to train and deploy walk-these-ways on Unitree Go2 by modifying SDK interfaces.
- pytorch 1.10 with cuda-11.3
- Isaac Gym
- Nvidia GPU with at least 8GB of VRAM
Clone this repository and install:
git clone https://github.com/Teddy-Liao/walk-these-ways-go2.git
cd walk-these-ways-go2
pip install -e .
Start training:
python scripts/train.py
For convenience, urdf file path is directly swtitched from go1.urdf
to go2.urdf
.
Play the model:
python scripts/play.py
Go2 pretrained model is provided in ./runs, you can choose whether to use provide pretrained model by modifying the label line label = "gait-conditioned-agility/pretrain-go2/train"
to your own trained model.
flip_visual_attachments
in go1_config should be set toTrue
, otherwise errors would occur when visualizing.- To change configuration parameters of env or the robot, you should modify parameters in go1_config, not in legged_robot_config
Trained policy is only supported to be deployed through your PC or laptop now, because I am not familiar with Jetson Orin, and hope I can fix it and deploy on Jetson Orin.
Since walk-these-ways implement an interface based on Lightweight Communications and Marshalling (LCM) to pass sensor data, motor commands, and joystick state between their code and the low-level control SDK provided by Unitree, LCM should be installed firstly in your PC or laptlop.
Clone LCM repository to the path you usually place installed softwares, then install LCM:
git clone https://github.com/lcm-proj/lcm.git
mkdir build
cd build
cmake ..
make
sudo make install
unitree_sdk2 has been inclued in go2_gym_deploy/unitree_sdk2_bin/library/unitree_sdk2
, you can also clone from Unitree Robotics to make sure the sdk is updated version.
cd go2_gym_deploy
Delete build file
rm -r build
Install and build:
sudo ./install.sh
mkdir build
cd build
cmake ..
make
go2_gym_deploy/unitree_sdk2_bin/lcm_position_go2.cpp
is the core file of this project, which is similar to lcm_position.cpp
in walk-these-ways, but replace unitree_legged_sdk with unitree_sdk2.
Build lcm_position_go2 and generate runfile lcm_position_go2
cd go2_gym_deploy
rm -r build
mkdir build
cd build
cmake ..
make -j
All LCM messages in go2_gym_deploy/lcm_types
are set as the same format shown in walk-these-ways to ensure successful connection with python files.
xxx_lcmt.hpp
files are generated by:
lcm-gen -x xxx.lcm
Connect your PC/Laptop with Go2 robot with ethernet cable and check connection by:
ping 192.168.123.161
Check the network interface address, and copy the network interface address.
ifconfig
If error occurs, please check Unitree Support for details.
cd go2_gym_deploy/build
sudo ./lcm_position_go2 enx10086
Aeplace enx10086
with your own network interface address. According to the messages shown in terminal, press Enter
for several times and the communication between LCM and unitree_sdk2 will set up.
This command will automatically shut down Unitree sport_mode Service and set the robot to LOW-LEVEL. Please make sure This will Go2 is hung up or lie on the ground.
You can verify LCM send by opening a new terminal:
cd go2_gym_deploy/build
sudo ./lcm_receive
Open a new terminate and run:
cd go2_gym_deploy/scripts
python deploy_policy.py
According to the hints shown in terminal, Press [R2] to start the controller. You can check RC mapping from walk-these-ways page.
Caution:
- Press [L2+B] if any unexpected situation occurs!!!
- This is research code; use at your own risk; we do not take responsibility for any damage.
Test Video on Unitree Go2: https://www.bilibili.com/video/BV1tQ4y1c7ZG/?spm_id_from=333.999.0.0&vd_source=07873ebe2a113dac57775e264a210929
Please star this repository if it does help you! Thanks!
- Many thanks to XiaoxiaoMeitou, who provide Nvidia 3060ti and supporting.
- Many thanks to Jony for his support and encourage me to learn basic kownledge about RL.
- Many thanks to Simonforyou, who provide Go2 pretrained model.
- Deploy on Jeston Orin Nano