From 2b72a65d1999b68108363b36fca171e67e8ea67e Mon Sep 17 00:00:00 2001 From: zcemycl Date: Fri, 9 Aug 2024 22:11:09 +0100 Subject: [PATCH] adding ros simulation in docker --- .../{ros => ros-simulation}/Dockerfile.old | 5 +++ .../docker/ros-simulation/README.md | 9 ++++++ .../docker/ros-simulation/docker-compose.yml | 32 +++++++++++++++++++ .../docker/ros-simulation/run_gazebo.sh | 5 +++ 4 files changed, 51 insertions(+) rename src/containers/docker/{ros => ros-simulation}/Dockerfile.old (88%) create mode 100644 src/containers/docker/ros-simulation/README.md create mode 100644 src/containers/docker/ros-simulation/docker-compose.yml create mode 100644 src/containers/docker/ros-simulation/run_gazebo.sh diff --git a/src/containers/docker/ros/Dockerfile.old b/src/containers/docker/ros-simulation/Dockerfile.old similarity index 88% rename from src/containers/docker/ros/Dockerfile.old rename to src/containers/docker/ros-simulation/Dockerfile.old index 160320a..6d6b786 100644 --- a/src/containers/docker/ros/Dockerfile.old +++ b/src/containers/docker/ros-simulation/Dockerfile.old @@ -16,4 +16,9 @@ RUN echo "source /catkin_ws/devel/setup.bash" > ~/.bashrc RUN pip install rospkg RUN /bin/bash -c 'source /opt/ros/noetic/setup.bash; \ cd /catkin_ws/; catkin_make; source /catkin_ws/devel/setup.bash' +# WORKDIR /opt/ros/noetic +# RUN . setup.bash +# WORKDIR /catkin_ws +# RUN catkin_make WORKDIR / +COPY ./run_gazebo.sh /run_gazebo.sh diff --git a/src/containers/docker/ros-simulation/README.md b/src/containers/docker/ros-simulation/README.md new file mode 100644 index 0000000..4d65c38 --- /dev/null +++ b/src/containers/docker/ros-simulation/README.md @@ -0,0 +1,9 @@ +## How to run? +1. Install this for remote visualisation from docker. + ``` + https://sourceforge.net/projects/vcxsrv/ + ``` +2. Run docker compose + ``` + docker compose up + ``` diff --git a/src/containers/docker/ros-simulation/docker-compose.yml b/src/containers/docker/ros-simulation/docker-compose.yml new file mode 100644 index 0000000..baaff99 --- /dev/null +++ b/src/containers/docker/ros-simulation/docker-compose.yml @@ -0,0 +1,32 @@ +networks: + rosnet: + name: rosnet + driver: bridge +services: + roscore: + build: + context: . + dockerfile: Dockerfile.old + networks: + - rosnet + command: roscore -p 11311 + ports: + - 11311:11311 + gazebo: + build: + context: . + dockerfile: Dockerfile.old + networks: + - rosnet + command: /run_gazebo.sh + environment: + - ROS_MASTER_URI=http://roscore:11311/ + - DISPLAY=host.docker.internal:0.0 + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 5 + window: 10s + depends_on: + - roscore diff --git a/src/containers/docker/ros-simulation/run_gazebo.sh b/src/containers/docker/ros-simulation/run_gazebo.sh new file mode 100644 index 0000000..57c6e24 --- /dev/null +++ b/src/containers/docker/ros-simulation/run_gazebo.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export TURTLEBOT3_MODEL=burger +source /opt/ros/noetic/setup.bash +source /catkin_ws/devel/setup.bash +roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch