From c5721663023b5e923fef9d0a8806bd89e34baaf3 Mon Sep 17 00:00:00 2001 From: zcemycl Date: Wed, 7 Aug 2024 22:23:09 +0100 Subject: [PATCH] update --- .../ros-gazebo-rviz-turtlebot/Dockerfile | 22 +---- .../ros-gazebo-rviz-turtlebot/Dockerfile.old | 19 ++++ .../ros-gazebo-rviz-turtlebot/README.md | 5 ++ .../docker-compose.yml | 88 +++++++++++++++++++ 4 files changed, 115 insertions(+), 19 deletions(-) create mode 100644 src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile.old create mode 100644 src/containers/docker/ros-gazebo-rviz-turtlebot/docker-compose.yml diff --git a/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile b/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile index 160320a..f8e92d4 100644 --- a/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile +++ b/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile @@ -1,19 +1,3 @@ -FROM osrf/ros:noetic-desktop-full -RUN apt-get update -y && apt-get upgrade -y -RUN apt-get install wget git python3-pip python3-catkin-tools -y -RUN apt-get install ros-noetic-joy ros-noetic-control-toolbox \ - ros-noetic-robot-controllers ros-noetic-gazebo-ros \ - ros-noetic-gazebo-plugins ros-noetic-rgbd-launch -y -WORKDIR / -RUN mkdir -p catkin_ws/src/ -WORKDIR /catkin_ws/src/ -RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git -RUN git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git -RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git -RUN echo "export TURTLEBOT3_MODEL=burger" > ~/.bashrc -RUN echo "source /opt/ros/noetic/setup.bash" > ~/.bashrc -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 / +FROM ros:noetic-ros-core +RUN apt-get update && apt-get install -y \ + ros-noetic-foxglove-bridge diff --git a/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile.old b/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile.old new file mode 100644 index 0000000..160320a --- /dev/null +++ b/src/containers/docker/ros-gazebo-rviz-turtlebot/Dockerfile.old @@ -0,0 +1,19 @@ +FROM osrf/ros:noetic-desktop-full +RUN apt-get update -y && apt-get upgrade -y +RUN apt-get install wget git python3-pip python3-catkin-tools -y +RUN apt-get install ros-noetic-joy ros-noetic-control-toolbox \ + ros-noetic-robot-controllers ros-noetic-gazebo-ros \ + ros-noetic-gazebo-plugins ros-noetic-rgbd-launch -y +WORKDIR / +RUN mkdir -p catkin_ws/src/ +WORKDIR /catkin_ws/src/ +RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git +RUN git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git +RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git +RUN echo "export TURTLEBOT3_MODEL=burger" > ~/.bashrc +RUN echo "source /opt/ros/noetic/setup.bash" > ~/.bashrc +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 / diff --git a/src/containers/docker/ros-gazebo-rviz-turtlebot/README.md b/src/containers/docker/ros-gazebo-rviz-turtlebot/README.md index 32379ed..ccaf093 100644 --- a/src/containers/docker/ros-gazebo-rviz-turtlebot/README.md +++ b/src/containers/docker/ros-gazebo-rviz-turtlebot/README.md @@ -11,3 +11,8 @@ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch # initialize the gazeb export TURTLEBOT3_MODEL=burger roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` + +## References + +1. https://foxglove.dev/blog/installing-ros1-on-macos-with-docker +2. https://foxglove.dev/blog/installing-ros2-on-macos-with-docker diff --git a/src/containers/docker/ros-gazebo-rviz-turtlebot/docker-compose.yml b/src/containers/docker/ros-gazebo-rviz-turtlebot/docker-compose.yml new file mode 100644 index 0000000..a7e5112 --- /dev/null +++ b/src/containers/docker/ros-gazebo-rviz-turtlebot/docker-compose.yml @@ -0,0 +1,88 @@ +x-ros-common: &ros_common + build: + context: . + dockerfile: Dockerfile + networks: + - rosnet +networks: + rosnet: + name: rosnet + driver: bridge +services: + roscore: + <<: *ros_common + ports: + - 11311:11311 + command: roscore -p 11311 + + rostopic-list: + <<: *ros_common + environment: + - ROS_MASTER_URI=http://roscore:11311/ + command: rostopic list + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 5 + window: 10s + depends_on: + - roscore + + rostopic-pub: + <<: *ros_common + environment: + - ROS_MASTER_URI=http://roscore:11311/ + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 5 + window: 10s + depends_on: + - roscore + - rostopic-list + command: + [ + "rostopic", + "pub", + "/chatter", + "std_msgs/String", + "data: hello", + "-r", + "1", + ] + + rostopic-sub: + <<: *ros_common + environment: + - ROS_MASTER_URI=http://roscore:11311/ + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 5 + window: 10s + depends_on: + - roscore + - rostopic-list + - rostopic-pub + command: ["rostopic", "echo", "/chatter"] + + roslaunch-foxglove-bridge: + <<: *ros_common + environment: + - ROS_MASTER_URI=http://roscore:11311/ + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 5 + window: 10s + ports: + - 8765:8765 + depends_on: + - roscore + - rostopic-list + - rostopic-pub + command: ["roslaunch", "foxglove_bridge", "foxglove_bridge.launch"]