2024-03-06 17:32:15 +08:00
|
|
|
# rl_sim2sim
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
[中文文档](README_CN.md)
|
2024-03-06 17:32:15 +08:00
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
## Preparation
|
|
|
|
|
|
|
|
Pull the code (synchronously pull submodules)
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git clone --recursive https://github.com/fan-ziqi/rl_sim2sim.git
|
|
|
|
```
|
|
|
|
|
|
|
|
If there are updates:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git pull
|
|
|
|
git submodule update --remote --recursive
|
|
|
|
```
|
|
|
|
|
|
|
|
Download and deploy `libtorch` at any location
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Install `teleop-twist-keyboard`
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo apt install ros-noetic-teleop-twist-keyboard
|
|
|
|
```
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
## Compilation
|
2024-03-06 17:32:15 +08:00
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Customize the following two functions in the code to adapt to different models:
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```cpp
|
|
|
|
torch::Tensor forward() override;
|
|
|
|
torch::Tensor compute_observation() override;
|
|
|
|
```
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Then compile in the root directory
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
cd ..
|
|
|
|
catkin build
|
|
|
|
```
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
## Run
|
2024-03-06 17:32:15 +08:00
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Copy the trained pt model file to `sim2sim/src/unitree_rl/models`
|
2024-03-06 17:32:15 +08:00
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Open a new terminal, start the gazebo simulation environment
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
source devel/setup.bash
|
|
|
|
roslaunch unitree_rl start_env.launch
|
|
|
|
```
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Open a new terminal, start the control program
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
source devel/setup.bash
|
|
|
|
rosrun unitree_rl unitree_rl
|
|
|
|
```
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
Open a new terminal, keyboard control program
|
2024-03-06 17:32:15 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-07 11:54:33 +08:00
|
|
|
> Part of the code refers to https://github.com/mertgungor/unitree_model_control
|