Skip to content

Commit

Permalink
update ros simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
zcemycl committed Aug 10, 2024
1 parent 2b72a65 commit e6ef200
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 22 deletions.
13 changes: 12 additions & 1 deletion src/containers/docker/ros-simulation/Dockerfile.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
FROM osrf/ros:noetic-desktop-full

ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

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-gmapping ros-noetic-robot-state-publisher \
ros-noetic-rviz ros-noetic-gazebo-ros-control \
ros-noetic-gazebo-ros-pkgs \
# ros-noetic-ignition-math6-vendor \
# ignition ignition-launch-cli ignition-tools \
ros-noetic-gazebo-plugins ros-noetic-rgbd-launch -y
WORKDIR /
RUN mkdir -p catkin_ws/src/
Expand All @@ -21,4 +32,4 @@ RUN /bin/bash -c 'source /opt/ros/noetic/setup.bash; \
# WORKDIR /catkin_ws
# RUN catkin_make
WORKDIR /
COPY ./run_gazebo.sh /run_gazebo.sh
COPY ./run_gazebo.sh ./run_rviz.sh ./run_algo.sh /
64 changes: 44 additions & 20 deletions src/containers/docker/ros-simulation/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,56 @@
x-ros-common: &ros_common
build:
context: .
dockerfile: Dockerfile.old
networks:
- rosnet
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
environment:
- ROS_MASTER_URI=http://roscore:11311/
- DISPLAY=host.docker.internal:0.0
- QT_X11_NO_MITSHM=1
# runtime: nvidia
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 5
window: 10s
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
networks:
rosnet:
name: rosnet
driver: bridge
services:
roscore:
build:
context: .
dockerfile: Dockerfile.old
networks:
- rosnet
<<: *ros_common
command: roscore -p 11311
container_name: roscore
ports:
- 11311:11311
gazebo:
build:
context: .
dockerfile: Dockerfile.old
networks:
- rosnet
ros-simulation:
<<: *ros_common
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
container_name: ros-simulation
depends_on:
- roscore
ros-algo:
<<: *ros_common
command: /run_algo.sh
container_name: ros-algo
depends_on:
- roscore
- ros-simulation
ros-rviz:
<<: *ros_common
command: /run_rviz.sh
container_name: ros-rviz
depends_on:
- roscore
- ros-simulation
5 changes: 5 additions & 0 deletions src/containers/docker/ros-simulation/run_algo.sh
Original file line number Diff line number Diff line change
@@ -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_simulation.launch
2 changes: 1 addition & 1 deletion src/containers/docker/ros-simulation/run_gazebo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
export TURTLEBOT3_MODEL=burger
source /opt/ros/noetic/setup.bash
source /catkin_ws/devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
roslaunch turtlebot3_gazebo turtlebot3_house.launch
5 changes: 5 additions & 0 deletions src/containers/docker/ros-simulation/run_rviz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
export TURTLEBOT3_MODEL=burger
source /opt/ros/noetic/setup.bash
source /catkin_ws/devel/setup.bash
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping

0 comments on commit e6ef200

Please sign in to comment.