Simulation verification and physical deployment of robot reinforcement learning algorithms, suitable for quadruped robots, wheeled robots, and humanoid robots. "sar" stands for "simulation and real"
Go to file
fan-ziqi f6fe3071d6 fix cyberdog model 2024-04-05 20:28:43 +08:00
.github/workflows feat: add auto update 2024-03-06 17:49:50 +08:00
src fix cyberdog model 2024-04-05 20:28:43 +08:00
.gitignore test update 2024-04-04 23:51:33 +08:00
.gitmodules feat: add submodule unitree_ros 2024-03-06 17:18:12 +08:00
LICENCE add LICENCE 2024-03-06 19:43:41 +08:00
README.md feat: add cyberdog interface 2024-03-29 16:49:28 +08:00
README_CN.md fix something 2024-03-29 22:29:28 +08:00

README.md

rl_sar

中文文档

Simulation verification and physical deployment of the quadruped robot's reinforcement learning algorithm. "sar" stands for "simulation and real".

Preparation

Clone the code (sync submodules)

git clone --recursive https://github.com/fan-ziqi/rl_sar.git

If there are updates:

git pull
git submodule update --remote --recursive

Download and deploy libtorch at any location

cd /path/to/your/torchlib
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip -d ./
echo 'export Torch_DIR=/path/to/your/torchlib' >> ~/.bashrc

Install teleop-twist-keyboard

sudo apt install ros-noetic-teleop-twist-keyboard

Compilation

Customize the following two functions in your code to adapt to different models:

torch::Tensor forward() override;
torch::Tensor compute_observation() override;

Then compile in the root directory

cd ..
catkin build

Running

Before running, copy the trained pt model file to rl_sar/src/rl_sar/models

Simulation

Open a new terminal, launch the gazebo simulation environment

source devel/setup.bash
roslaunch rl_sar start_a1.launch

Open a new terminal, run the control program

source devel/setup.bash
rosrun rl_sar rl_sim

Open a new terminal, run the keyboard control program

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

Physical Deployment

The connection to the physical robot can be done in both wireless and wired forms.

  • Wireless: Connect to the WIFI starting with "Unitree" emitted by the robot (Note: Wireless connection may experience packet loss, disconnection, or even loss of control, please pay attention to safety)
  • Wired: Use an Ethernet cable to connect any port on the computer to the robot, configure the computer's IP as 192.168.123.162, and the gateway as 255.255.255.0.

Create a new terminal and launch the control program.

source devel/setup.bash
rosrun rl_sar rl_real

Press the R2 button on the remote control to switch the robot to the default standing posture, press R1 to switch to RL control mode, and press L2 in any state to switch back to the initial lying posture. The left joystick controls x-axis up and down, controls yaw left and right, and the right joystick controls y-axis left and right.

Citation

Please cite the following if you use this code or parts of it:

@software{fan-ziqi2024rl_sar,
  author = {fan-ziqi},
  title = {{rl_sar: Simulation Verification and Physical Deployment of the Quadruped Robot's Reinforcement Learning Algorithm.}},
  url = {https://github.com/fan-ziqi/rl_sar},
  year = {2024}
}