docs(readme): clarify mapping and Nav2 multi-terminal workflow
- Document per-terminal commands for Cartographer SLAM and map save path - Document Nav2 two-terminal flow and custom map:= usage - Warn against pasting blocking launch commands in one shell - Fix Docker comment: compose service name is go2_sim - Sync README_EN.md with the same structure Made-with: Cursor
This commit is contained in:
71
README.md
71
README.md
@@ -38,7 +38,7 @@ ros2 service call /robot1/robot_behavior_command quadropted_msgs/srv/RobotBehavi
|
||||
```bash
|
||||
cd go2_sim_ws/src/docker
|
||||
docker compose up -d --build --remove-orphans #容器构建
|
||||
docker compose up -d go2_sim #启动容器,-d为不进入docker终端,ros2_sim是众多服务中的一个服务
|
||||
docker compose up -d go2_sim #启动容器,-d 为后台运行;go2_sim 为 compose 中的服务名
|
||||
docker compose ps #容器查看
|
||||
docker compose exec go2_sim bash #进入容器
|
||||
docker compose down #容器删除
|
||||
@@ -70,18 +70,71 @@ ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/ro
|
||||
ros2 service call /robot1/robot_behavior_command quadropted_msgs/srv/RobotBehaviorCommand "{command: 'walk'}"
|
||||
```
|
||||
## 2.3 建图和导航
|
||||
建图需在终端中输入如下命令
|
||||
|
||||
**是否需要多个终端**:需要。`ros2 launch ...` 会持续占用当前终端直到你 Ctrl+C 结束;建图时要让 **Gazebo、Cartographer、键盘遥控** 同时运行,因此必须在 **不同终端**(或 tmux/screen 分屏)中分别启动。**不要**把下面多条 `launch`/`run` 无修饰地粘进同一个终端顺序执行,否则第一条会一直阻塞,后面的命令不会执行。
|
||||
|
||||
**每个新终端的公共前提**(在仓库根目录进入工作空间并加载环境):
|
||||
|
||||
```bash
|
||||
ros2 launch gazebo_sim launch.py sensors:=true world:=warehouse.sdf
|
||||
ros2 launch cartographer go2_cartographer.launch.py
|
||||
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/robot1/cmd_vel #【键盘控制
|
||||
ros2 run nav2_map_server map_saver_cli -t map -f warehouse_map #保存地图
|
||||
cd go2_sim_ws
|
||||
source install/setup.bash
|
||||
```
|
||||
|
||||
### 建图(Cartographer SLAM)
|
||||
|
||||
1. **终端 1 — Gazebo 仿真**(带扩展传感器与仓库世界):
|
||||
|
||||
```bash
|
||||
ros2 launch gazebo_sim launch.py sensors:=true world:=warehouse.sdf
|
||||
```
|
||||
|
||||
2. **终端 2 — Cartographer 与 RViz**:
|
||||
|
||||
```bash
|
||||
ros2 launch cartographer go2_cartographer.launch.py
|
||||
```
|
||||
|
||||
3. **终端 3 — 键盘遥控(强烈建议)**:控制机器狗在环境中移动,激光才能扫到足够区域,地图质量才有保障。
|
||||
|
||||
```bash
|
||||
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/robot1/cmd_vel
|
||||
```
|
||||
|
||||
4. **终端 4 — 保存占据栅格地图**(建图效果满意后再执行;会在**当前工作目录**生成 `warehouse_map.yaml` 和 `warehouse_map.pgm`):
|
||||
|
||||
```bash
|
||||
cd go2_sim_ws
|
||||
source install/setup.bash
|
||||
mkdir -p maps_out && cd maps_out
|
||||
ros2 run nav2_map_server map_saver_cli -t map -f warehouse_map
|
||||
```
|
||||
|
||||
若你在其他目录新开终端,请先 `cd` 到 `go2_sim_ws` 并 `source install/setup.bash`,再 `cd` 到保存目录后执行 `map_saver_cli`。导航时把 `map:=` 设为该 `warehouse_map.yaml` 的**绝对路径**(在 `maps_out` 下可执行 `realpath warehouse_map.yaml` 查看)。
|
||||
|
||||

|
||||
|
||||
导航需要在终端中输入如下命令
|
||||
### 导航(Nav2)
|
||||
|
||||
使用功能包自带的 `warehouse` 地图时,仿真世界需与建图时一致(仍为 `warehouse.sdf`)。
|
||||
|
||||
1. **终端 1 — Gazebo**:
|
||||
|
||||
```bash
|
||||
ros2 launch gazebo_sim launch.py sensors:=true world:=warehouse.sdf
|
||||
ros2 launch navigation2 go2_navigation2.launch.py
|
||||
ros2 launch gazebo_sim launch.py sensors:=true world:=warehouse.sdf
|
||||
```
|
||||
|
||||
2. **终端 2 — Nav2**(默认加载已安装的 `navigation2/maps/warehouse_map.yaml`):
|
||||
|
||||
```bash
|
||||
ros2 launch navigation2 go2_navigation2.launch.py
|
||||
```
|
||||
|
||||
若使用你在建图步骤中自行保存的地图,请传入 **绝对路径**(指向 `.yaml`):
|
||||
|
||||
```bash
|
||||
ros2 launch navigation2 go2_navigation2.launch.py map:=/绝对路径/go2_sim_ws/maps_out/warehouse_map.yaml
|
||||
```
|
||||
|
||||
启动后在 RViz 中使用 Nav2 插件设置初始位姿与目标点即可;导航栈会自动规划路径,**不必**再开键盘遥控作为主控方式。
|
||||
|
||||

|
||||
63
README_EN.md
63
README_EN.md
@@ -48,7 +48,7 @@ The following commands cover the main Docker workflow:
|
||||
```bash
|
||||
cd go2_sim_ws/src/docker
|
||||
docker compose up -d --build --remove-orphans # Build containers
|
||||
docker compose up -d go2_sim # Start container in detached mode
|
||||
docker compose up -d go2_sim # Start in detached mode; go2_sim is the compose service name
|
||||
docker compose ps # List containers
|
||||
docker compose exec go2_sim bash # Enter container
|
||||
docker compose down # Remove containers
|
||||
@@ -85,20 +85,71 @@ ros2 service call /robot1/robot_behavior_command quadropted_msgs/srv/RobotBehavi
|
||||
```
|
||||
|
||||
## 2.3 Mapping and Navigation
|
||||
For mapping, run the following commands in terminal:
|
||||
|
||||
**Multiple terminals are required.** `ros2 launch ...` blocks the shell until you stop it with Ctrl+C. For mapping you must run **Gazebo, Cartographer, and teleop** at the same time, so use **separate terminals** (or tmux/screen panes). **Do not** paste all commands into one terminal in sequence—the first `launch` will block and the rest will never run.
|
||||
|
||||
**In every new terminal**, load the workspace:
|
||||
|
||||
```bash
|
||||
cd go2_sim_ws
|
||||
source install/setup.bash
|
||||
```
|
||||
|
||||
### Mapping (Cartographer SLAM)
|
||||
|
||||
1. **Terminal 1 — Gazebo** (extended sensors, warehouse world):
|
||||
|
||||
```bash
|
||||
ros2 launch gazebo_sim launch.py sensors:=true world:=warehouse.sdf
|
||||
ros2 launch cartographer go2_cartographer.launch.py
|
||||
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/robot1/cmd_vel # keyboard control
|
||||
ros2 run nav2_map_server map_saver_cli -t map -f warehouse_map # save map
|
||||
```
|
||||
|
||||
2. **Terminal 2 — Cartographer + RViz**:
|
||||
|
||||
```bash
|
||||
ros2 launch cartographer go2_cartographer.launch.py
|
||||
```
|
||||
|
||||
3. **Terminal 3 — Keyboard teleop (strongly recommended)** so the robot explores; otherwise the map will stay poor or incomplete.
|
||||
|
||||
```bash
|
||||
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/robot1/cmd_vel
|
||||
```
|
||||
|
||||
4. **Terminal 4 — Save the occupancy grid** (run when you are happy with the map; writes `warehouse_map.yaml` and `warehouse_map.pgm` in the **current directory**):
|
||||
|
||||
```bash
|
||||
cd go2_sim_ws
|
||||
source install/setup.bash
|
||||
mkdir -p maps_out && cd maps_out
|
||||
ros2 run nav2_map_server map_saver_cli -t map -f warehouse_map
|
||||
```
|
||||
|
||||
If you open a fresh terminal elsewhere, `cd` into `go2_sim_ws`, `source install/setup.bash`, then `cd` to the save directory and run `map_saver_cli`. For Nav2, pass the **absolute path** to `warehouse_map.yaml` as `map:=` (from `maps_out`, run `realpath warehouse_map.yaml`).
|
||||
|
||||

|
||||
|
||||
For navigation, run:
|
||||
### Navigation (Nav2)
|
||||
|
||||
When using the bundled warehouse map, keep the same world as for mapping (`warehouse.sdf`).
|
||||
|
||||
1. **Terminal 1 — Gazebo**:
|
||||
|
||||
```bash
|
||||
ros2 launch gazebo_sim launch.py sensors:=true world:=warehouse.sdf
|
||||
```
|
||||
|
||||
2. **Terminal 2 — Nav2** (default map: installed `navigation2/maps/warehouse_map.yaml`):
|
||||
|
||||
```bash
|
||||
ros2 launch navigation2 go2_navigation2.launch.py
|
||||
```
|
||||
|
||||
To use a map you saved yourself:
|
||||
|
||||
```bash
|
||||
ros2 launch navigation2 go2_navigation2.launch.py map:=/absolute/path/to/go2_sim_ws/maps_out/warehouse_map.yaml
|
||||
```
|
||||
|
||||
Set the initial pose and goal in RViz; Nav2 plans and executes—keyboard teleop is not required as the primary interface.
|
||||
|
||||

|
||||
|
||||
Reference in New Issue
Block a user