Skip to content

Commit

Permalink
feat: [Breaking change] split config.yaml into separate model folders
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-ziqi committed Aug 15, 2024
1 parent e42d926 commit 11d600a
Show file tree
Hide file tree
Showing 27 changed files with 314 additions and 301 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ cd ..
catkin build
```

If catkin build report errors: `Unable to find either executable 'empy' or Python module 'em'`, run `catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3` before `catkin build`

## Running

Before running, copy the trained pt model file to `rl_sar/src/rl_sar/models/YOUR_ROBOT_NAME`, and configure the parameters in `config.yaml`.
Expand Down Expand Up @@ -100,9 +102,9 @@ Control:
* Press **\<Space\>** to sets all control commands to zero.
* If robot falls down, press **R** to reset Gazebo environment.

### Physical Robots
### Real Robots

#### Unitree A1
**Example: Unitree A1**

Unitree A1 can be connected using both wireless and wired methods:

Expand Down Expand Up @@ -135,14 +137,13 @@ Or press **0** on the keyboard to switch the robot to the default standing posit

## Add Your Robot

In the following, let ROBOT represent the name of your robot.
In the following text, `<ROBOT>` represents the name of the robot

1. Create a model package named ROBOT_description in the robots folder. Place the URDF model in the urdf path within the folder and name it ROBOT.urdf. Create a namespace named ROBOT_gazebo in the config folder within the model file for joint configuration.
2. Place the model file in models/ROBOT.
3. Add a new field in rl_sar/config.yaml named ROBOT and adjust the parameters, such as changing the model_name to the model file name from the previous step.
4. Add a new launch file in the rl_sar/launch folder. Refer to other launch files for guidance on modification.
5. Change ROBOT_NAME to ROBOT in rl_xxx.cpp.
6. Compile and run.
1. Create a model package named `<ROBOT>_description` in the `rl_sar/src/robots` directory. Place the robot's URDF file in the `rl_sar/src/robots/<ROBOT>_description/urdf` directory and name it `<ROBOT>.urdf`. Additionally, create a joint configuration file with the namespace `<ROBOT>_gazebo` in the `rl_sar/src/robots/<ROBOT>_description/config` directory.
2. Place the trained RL model files in the `rl_sar/src/rl_sar/models/<ROBOT>` directory.
3. In the `rl_sar/src/rl_sar/models/<ROBOT>` directory, create a `config.yaml` file, and modify its parameters based on the `rl_sar/src/rl_sar/models/a1_isaacgym/config.yaml` file.
4. If you need to run simulations, modify the launch files as needed by referring to those in the `rl_sar/src/rl_sar/launch` directory.
5. If you need to run on the physical robot, modify the file `rl_sar/src/rl_sar/src/rl_real_a1.cpp` as needed.
## Reference
Expand Down
19 changes: 10 additions & 9 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ cd ..
catkin build
```

如果 catkin build 报错: `Unable to find either executable 'empy' or Python module 'em'`, 在`catkin build` 之前执行 `catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3`

## 运行

运行前请将训练好的pt模型文件拷贝到`rl_sar/src/rl_sar/models/YOUR_ROBOT_NAME`中,并配置`config.yaml`中的参数。
Expand Down Expand Up @@ -101,9 +103,9 @@ source devel/setup.bash
***\<Space\>** 将所有控制指令设置为零。
* 如果机器人摔倒,按 **R** 重置Gazebo环境。

### 实物
### 真实机器人

#### Unitree A1
**示例:Unitree A1**

与Unitree A1连接可以使用无线与有线两种方式

Expand Down Expand Up @@ -136,14 +138,13 @@ rosrun rl_sar rl_real_a1

## 添加你的机器人

下文中将ROBOT代表机器人名称
下文中将`<ROBOT>`代表机器人名称

1. 在robots文件夹中创建名为ROBOT_description的模型包,将模型的urdf放到文件夹中的urdf路径下并命名为ROBOT.urdf,在模型文件中的config文件夹中创建命名空间为ROBOT_gazebo的关节配置文件
2. 将模型文件放到models/ROBOT中
3. 在rl_sar/config.yaml中添加一个新的字段,命名为ROBOT,更改其中参数,如将model_name改为上一步的模型文件名
4. 在rl_sar/launch文件夹中添加一个新的launch文件,请参考其他launch文件自行修改
5. 修改rl_xxx.cpp中的ROBOT_NAME为ROBOT
6. 编译运行
1. 在`rl_sar/src/robots`路径下创建名为`<ROBOT>_description`的模型包,将模型的urdf放到`rl_sar/src/robots/<ROBOT>_description/urdf`路径下并命名为`<ROBOT>.urdf`,并在`rl_sar/src/robots/<ROBOT>_description/config`路径下创建命名空间为`<ROBOT>_gazebo`的关节配置文件
2. 将训练好的RL模型文件放到`rl_sar/src/rl_sar/models/<ROBOT>`路径下
3. 在`rl_sar/src/rl_sar/models/<ROBOT>`中新建config.yaml文件,参考`rl_sar/src/rl_sar/models/a1_isaacgym/config.yaml`文件修改其中参数
4. 若需要运行仿真,则参考`rl_sar/src/rl_sar/launch`路径下的launch文件自行修改
5. 若需要运行实物,则参考`rl_sar/src/rl_sar/src/rl_real_a1.cpp`文件自行修改

## 参考

Expand Down
257 changes: 0 additions & 257 deletions src/rl_sar/config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/rl_sar/include/rl_sim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class RL_Sim : public RL
void RobotControl();

// history buffer
bool use_history = true;
ObservationBuffer history_obs_buf;
torch::Tensor history_obs;

Expand Down Expand Up @@ -65,6 +64,7 @@ class RL_Sim : public RL
void CmdvelCallback(const geometry_msgs::Twist::ConstPtr &msg);

// others
std::string gazebo_model_name;
int motiontime = 0;
std::map<std::string, size_t> sorted_to_original_index;
std::vector<double> mapped_joint_positions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<launch>
<arg name="wname" default="stairs"/>
<arg name="rname" default="a1"/>
<param name="robot_name" type="str" value="$(arg rname)_isaaclab"/>
<param name="use_history" type="bool" value="false"/>
<param name="robot_name" type="str" value="$(arg rname)_isaacgym"/>
<param name="ros_namespace" type="str" value="/$(arg rname)_gazebo/"/>
<param name="gazebo_model_name" type="str" value="$(arg rname)_gazebo"/>
<arg name="robot_path" value="(find $(arg rname)_description)"/>
<arg name="dollar" value="$"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<launch>
<arg name="wname" default="stairs"/>
<arg name="rname" default="a1"/>
<param name="robot_name" type="str" value="$(arg rname)"/>
<param name="use_history" type="bool" value="true"/>
<param name="robot_name" type="str" value="$(arg rname)_isaacsim"/>
<param name="ros_namespace" type="str" value="/$(arg rname)_gazebo/"/>
<param name="gazebo_model_name" type="str" value="$(arg rname)_gazebo"/>
<arg name="robot_path" value="(find $(arg rname)_description)"/>
<arg name="dollar" value="$"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<launch>
<arg name="wname" default="stairs"/>
<arg name="rname" default="gr1t1"/>
<param name="robot_name" type="str" value="$(arg rname)"/>
<param name="use_history" type="bool" value="false"/>
<param name="robot_name" type="str" value="$(arg rname)_isaacgym"/>
<param name="ros_namespace" type="str" value="/$(arg rname)_gazebo/"/>
<param name="gazebo_model_name" type="str" value="$(arg rname)_gazebo"/>
<arg name="robot_path" value="(find $(arg rname)_description)"/>
<arg name="dollar" value="$"/>

Expand Down
Loading

0 comments on commit 11d600a

Please sign in to comment.