-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gazebo docker image for curiosity rover demo
Related to space-ros/space-ros#178
- Loading branch information
1 parent
cd2f1eb
commit e68ca4d
Showing
4 changed files
with
132 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
FROM ros:humble-ros-core-jammy | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
ENV ROS_DISTRO=humble | ||
ENV USERNAME=spaceros-user | ||
ENV HOME=/home/spaceros-user | ||
ENV IGNITION_VERSION=fortress | ||
ENV GZ_VERSION=fortress | ||
|
||
# Install dependencies | ||
RUN apt update && apt install -y ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ | ||
wget \ | ||
curl \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg\ | ||
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null | ||
|
||
# Install Gazebo | ||
RUN apt-get update -qq \ | ||
&& apt-get install -y \ | ||
gz-${GZ_VERSION} \ | ||
libgz-sim7 \ | ||
libgz-transport12 \ | ||
libgz-gui7 \ | ||
build-essential\ | ||
ros-${ROS_DISTRO}-rcl-interfaces\ | ||
ros-${ROS_DISTRO}-rclcpp\ | ||
ros-${ROS_DISTRO}-builtin-interfaces\ | ||
ros-${ROS_DISTRO}-ros-gz\ | ||
ros-${ROS_DISTRO}-sdformat-urdf\ | ||
ros-${ROS_DISTRO}-vision-msgs\ | ||
ros-${ROS_DISTRO}-actuator-msgs\ | ||
ros-${ROS_DISTRO}-image-transport\ | ||
ros-${ROS_DISTRO}-xacro\ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# Install Rviz2 | ||
RUN apt-get update -qq \ | ||
&& apt-get install -y \ | ||
ros-${ROS_DISTRO}-rviz2 \ | ||
ros-${ROS_DISTRO}-moveit-ros-visualization \ | ||
ros-${ROS_DISTRO}-nav2-rviz-plugins \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Demo package | ||
RUN mkdir -p ${HOME}/curiosity_ws/src | ||
WORKDIR ${HOME}/curiosity_ws/src | ||
COPY ./curiosity_description ./curiosity_description | ||
COPY ./curiosity_gazebo ./curiosity_gazebo | ||
COPY .defaults.yaml ${HOME}/curiosity_ws/.defaults.yaml | ||
|
||
RUN apt update \ | ||
&& apt install -y python3-rosdep python3-colcon-common-extensions \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rosdep init \ | ||
&& rosdep update | ||
|
||
RUN . /opt/ros/humble/setup.sh \ | ||
&& cd ${HOME}/curiosity_ws \ | ||
&& apt update \ | ||
&& rosdep install --from-paths src --ignore-src -r -y \ | ||
&& colcon build | ||
|
||
WORKDIR ${HOME}/curiosity_ws | ||
|
||
RUN apt update && apt install -y ros-humble-ros-ign-gazebo | ||
RUN echo "source /opt/ros/humble/setup.bash" >> ${HOME}/.bashrc | ||
RUN echo "source ${HOME}/curiosity_ws/install/setup.bash" >> ${HOME}/.bashrc | ||
|
||
CMD ign gazebo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: "3" | ||
|
||
services: | ||
curiosity_gui: | ||
image: osrf/space-ros:curiosity_gui | ||
build: | ||
context: ./ | ||
dockerfile: ./Dockerfile.GUI | ||
# runtime: nvidia | ||
environment: | ||
- PYTHONUNBUFFERED=1 # important to show error messages if a ros service crashes! | ||
- DISPLAY # for UI | ||
- QT_X11_NO_MITSHM=1 #fix some QT bugs | ||
- NVIDIA_VISIBLE_DEVICES=all # for docker-nvidia2 | ||
- NVIDIA_DRIVER_CAPABILITIES=all # for docker-nvidia2 | ||
- XDG_RUNTIME_DIR | ||
- __NV_PRIME_RENDER_OFFLOAD=1 | ||
- __GLX_VENDOR_LIBRARY_NAME=nvidia | ||
- XAUTHORITY=$XAUTHORITY | ||
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
volumes: | ||
- /tmp/.X11-unix:/tmp/.X11-unix:rw # for UI | ||
- /run/user:/run/user:ro # for UI | ||
command: | ||
[ | ||
"bash", | ||
"-c", | ||
"source /opt/ros/$ROS_DISTRO/setup.bash && source ~/curiosity_ws/install/setup.bash && ros2 launch curiosity_gazebo curiosity_gazebo.launch.py", | ||
] | ||
network_mode: host | ||
privileged: true # for UI | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [gpu] | ||
curiosity_demo: | ||
image: osrf/space-ros:canadarm_demo | ||
build: | ||
context: ./ | ||
dockerfile: ./Dockerfile | ||
environment: | ||
- PYTHONUNBUFFERED=1 # important to show error messages if a ros service crashes! | ||
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
network_mode: host | ||
command: | ||
[ | ||
"bash", | ||
"-c", | ||
"source /home/spaceros-user/curiosity_ws/install/setup.bash && ros2 launch curiosity_rover_demo mars_rover.launch.py", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC2089 | ||
XTERM_CONFIG="-bg black -fg white -fa 'Monospace' -fs 11" | ||
DOCKER_IMAGE="osrf/space-ros:curiosity_demo" | ||
LOCAL_WORKSPACE=$(pwd) | ||
|
||
# Run the Curiosity Rover Gazebo simulation locally | ||
run-gazebo() { | ||
# shellcheck disable=SC2090 | ||
# shellcheck disable=SC2086 | ||
xterm $XTERM_CONFIG -T 'Curiosity Rover Gazebo' -e "source /opt/ros/\${ROS_DISTRO}/setup.bash \ | ||
&& source $LOCAL_WORKSPACE/install/setup.bash \ | ||
&& ros2 launch curiosity_gazebo curiosity_gazebo.launch.py" & | ||
} | ||
|
||
run-control-demo() { | ||
# shellcheck disable=SC2090 | ||
# shellcheck disable=SC2086 | ||
xterm $XTERM_CONFIG -T 'Curiosity Rover Demo' -e "docker run -it --rm \ | ||
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \ | ||
$DOCKER_IMAGE \ | ||
bash -c 'source /home/spaceros-user/curiosity_ws/install/setup.bash && ros2 launch curiosity_rover_demo mars_rover.launch.py'" & | ||
} | ||
|
||
check_docker() { | ||
if ! command -v docker &>/dev/null; then | ||
echo "Docker is not installed. Please install Docker to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_xterm() { | ||
if ! command -v xterm &>/dev/null; then | ||
echo "xterm is not installed. Please install xterm to continue." | ||
echo "On Ubuntu, you can install xterm with 'sudo apt install xterm'." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_ros2() { | ||
if ! command -v ros2 &>/dev/null; then | ||
echo "ROS 2 is not installed. Please install ROS 2 to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
run() { | ||
|
||
check_docker | ||
check_xterm | ||
check_ros2 | ||
|
||
run-gazebo | ||
run-control-demo | ||
} | ||
|
||
run | ||
docker-compose down | ||
docker-compose up -d |