From 286d0cae9fc8a96e92cc5ba35c308ad07cfd66e8 Mon Sep 17 00:00:00 2001 From: Jakub Delicat Date: Mon, 15 Jan 2024 08:34:18 +0100 Subject: [PATCH 1/3] Added multirobot demo and set using prebuilt imags as default for gazebo Signed-off-by: Jakub Delicat --- demo/compose.gazebo.multirobot.yaml | 33 +++++++++++++++++++++++++++++ demo/compose.gazebo.yaml | 8 +++---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 demo/compose.gazebo.multirobot.yaml diff --git a/demo/compose.gazebo.multirobot.yaml b/demo/compose.gazebo.multirobot.yaml new file mode 100644 index 0000000..d0e960b --- /dev/null +++ b/demo/compose.gazebo.multirobot.yaml @@ -0,0 +1,33 @@ +# Quick Start +# +# 1. run `xhost +local:docker && docker compose -f compose.gazebo.yaml up` on the laptop +# 2. open a shell inside a docker container `docker compose -f compose.gazebo.yaml exec -it rosbot bash` +# 2. run `ros2 run teleop_twist_keyboard teleop_twist_keyboard` inside the container + +x-gpu-config: + &gpu-config + runtime: nvidia + environment: + - DISPLAY=${DISPLAY:?err} + - NVIDIA_VISIBLE_DEVICES=all + - NVIDIA_DRIVER_CAPABILITIES=all + +x-cpu-config: + &cpu-config + environment: + - DISPLAY=${DISPLAY:?err} + - LIBGL_ALWAYS_SOFTWARE=1 + +services: + rosbot: + # image: husarion/rosbot-gazebo:humble + # build: + # context: ../ + # dockerfile: Dockerfile.gazebo + <<: [ *gpu-config] + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + command: > + ros2 launch rosbot_gazebo simulation.launch.py + mecanum:=${MECANUM:-False} + robots:="robot1={y: 0.0}; robot2={y: 1.0}; robot3={y: 2.0}; diff --git a/demo/compose.gazebo.yaml b/demo/compose.gazebo.yaml index 52032cd..54c35c9 100644 --- a/demo/compose.gazebo.yaml +++ b/demo/compose.gazebo.yaml @@ -20,10 +20,10 @@ x-cpu-config: services: rosbot: - # image: husarion/rosbot-gazebo:humble - build: - context: ../ - dockerfile: Dockerfile.gazebo + image: husarion/rosbot-gazebo:humble + # build: + # context: ../ + # dockerfile: Dockerfile.gazebo <<: [ *gpu-config] volumes: - /tmp/.X11-unix:/tmp/.X11-unix:rw From 5ceade9f292c0166683dc8b4ec97215a8495fef2 Mon Sep 17 00:00:00 2001 From: Jakub Delicat Date: Mon, 15 Jan 2024 08:35:35 +0100 Subject: [PATCH 2/3] updated comment compose.gazebo.multirobot.yaml Signed-off-by: Jakub Delicat --- demo/compose.gazebo.multirobot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/compose.gazebo.multirobot.yaml b/demo/compose.gazebo.multirobot.yaml index d0e960b..073782a 100644 --- a/demo/compose.gazebo.multirobot.yaml +++ b/demo/compose.gazebo.multirobot.yaml @@ -1,6 +1,6 @@ # Quick Start # -# 1. run `xhost +local:docker && docker compose -f compose.gazebo.yaml up` on the laptop +# 1. run `xhost +local:docker && docker compose -f compose.gazebo.multirobot.yaml up` on the laptop # 2. open a shell inside a docker container `docker compose -f compose.gazebo.yaml exec -it rosbot bash` # 2. run `ros2 run teleop_twist_keyboard teleop_twist_keyboard` inside the container From d0929c6abb3911bd73c5d6feeccbfb6ceb35e4c3 Mon Sep 17 00:00:00 2001 From: Jakub Delicat Date: Mon, 15 Jan 2024 09:32:32 +0100 Subject: [PATCH 3/3] updated readme and positions of spawning robots Signed-off-by: Jakub Delicat --- demo/README.md | 13 ++++++++++++- demo/compose.gazebo.multirobot.yaml | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/demo/README.md b/demo/README.md index 173c882..b70451b 100644 --- a/demo/README.md +++ b/demo/README.md @@ -25,7 +25,7 @@ docker compose -f compose.yaml up ``` ## Simulation -If you don't have Nvidia GPU replace `*gpu-config` with `*cpu-config` in `rosbot` service inside `compose.simulation.yaml` file. +If you don't have Nvidia GPU replace `*gpu-config` with `*cpu-config` in `rosbot` service inside `compose.gazebo.yaml` file. In the PC's shell execute (in the `demo/` directory): ``` @@ -33,6 +33,12 @@ xhost local:root docker compose -f compose.gazebo.yaml up ``` +If you want to use multiple robots check the `compose.gazebo.multirobot.yaml` (in the `demo/` directory): +``` +xhost local:root +docker compose -f compose.gazebo.multiplerobot.yaml up +``` + ## Drive the ROSbot In another shell (if you use hardware use another ROSbot's shell) enter the docker container: ``` @@ -43,4 +49,9 @@ and run inside `teleop_twist_keyboard` to drive the ROSbot ros2 run teleop_twist_keyboard teleop_twist_keyboard ``` +In case of driving one of the robot running `compose.gazebo.multirobot.yaml` add the namespace to the `teleop_twist_keyboard`. For the `robot1`: +``` +ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r __ns:=/robot1 +``` + With keys `i`, `j`, `l`, `,` you can drive forward, counter clockwise, clockwise and backwards. If you are using macanum wheels (see `demo/.env` file) hold `Shift` key that way the ROSbot goes left and right with `j` and `l` keys instead rotates. diff --git a/demo/compose.gazebo.multirobot.yaml b/demo/compose.gazebo.multirobot.yaml index 073782a..ce3a4be 100644 --- a/demo/compose.gazebo.multirobot.yaml +++ b/demo/compose.gazebo.multirobot.yaml @@ -1,8 +1,8 @@ # Quick Start # # 1. run `xhost +local:docker && docker compose -f compose.gazebo.multirobot.yaml up` on the laptop -# 2. open a shell inside a docker container `docker compose -f compose.gazebo.yaml exec -it rosbot bash` -# 2. run `ros2 run teleop_twist_keyboard teleop_twist_keyboard` inside the container +# 2. open a shell inside a docker container `docker compose -f compose.gazebo.multirobot.yaml exec -it rosbot bash` +# 2. run for e. g. `ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r __ns:=/robot1` inside the container x-gpu-config: &gpu-config @@ -20,7 +20,7 @@ x-cpu-config: services: rosbot: - # image: husarion/rosbot-gazebo:humble + image: husarion/rosbot-gazebo:humble-nightly # build: # context: ../ # dockerfile: Dockerfile.gazebo @@ -30,4 +30,4 @@ services: command: > ros2 launch rosbot_gazebo simulation.launch.py mecanum:=${MECANUM:-False} - robots:="robot1={y: 0.0}; robot2={y: 1.0}; robot3={y: 2.0}; + robots:="robot1={y: -4.0}; robot2={y: -2.0}; robot3={y: 4.0};"