Skip to content

Commit

Permalink
Add docker file for GUI stack
Browse files Browse the repository at this point in the history
Related to space-ros#188
 - Add docker file for GUI stack
 - Add build.sh at root level to build GUI stack
 - Add run.sh at root level to run GUI stack
  • Loading branch information
franklinselva committed Sep 26, 2024
1 parent f885e27 commit 8c2dbf7
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
60 changes: 60 additions & 0 deletions Dockerfile.gui
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 \
python3-rosdep python3-colcon-common-extensions \
wget \
curl \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

# Run rosdep
RUN rosdep init \
&& rosdep update

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\
ros-${ROS_DISTRO}-ros-ign-gazebo \
&& 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/*

WORKDIR ${HOME}

RUN echo "source /opt/ros/humble/setup.bash" >> ${HOME}/.bashrc

CMD ign gazebo
37 changes: 37 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

IMAGE_NAME="osrf/ros2"

set -e

# Build the stack

# Helper function
function help {
echo "Usage: $0 stack-name [options]"
echo "USAGE"
echo "-h, --help: display this help message"
echo " stack-name: the name of the stack to build. Must be one of the following:"
echo " - gui"
echo " - nav2"
echo " - moveit2"
}

function build_gui {
echo "Building GUI stack"
docker build -t $IMAGE_NAME:gui -f Dockerfile.gui .
}

# Parse command line arguments
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
help
exit 0
fi

if [ "$1" == "gui" ]; then
build_gui
else
echo "Invalid stack name"
help
exit 1
fi
49 changes: 49 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

IMAGE_NAME="osrf/ros2"
CONTAINER_NAME="space-ros"

set -e

# Helper function
function help {
echo "Usage: $0 stack-name [options]"
echo "USAGE"
echo "-h, --help: display this help message"
echo " stack-name: the name of the stack to build. Must be one of the following:"
echo " - gui"
echo " - nav2"
echo " - moveit2"
}

function run_gui {
echo "Running GUI stack"
docker run -it --rm --name $CONTAINER_NAME-gui \
-e DISPLAY=$DISPLAY \
-e QT_X11_NO_MITSHM=1 \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=all \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e __NV_PRIME_RENDER_OFFLOAD=1 \
-e __GLX_VENDOR_LIBRARY_NAME=nvidia \
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \
-e XAUTHORITY=$XAUTHORITY \
-v /run/user:/run/user:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
$IMAGE_NAME:gui

}

# Parse command line arguments
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
help
exit 0
fi

if [ "$1" == "gui" ]; then
run_gui
else
echo "Invalid stack name"
help
exit 1
fi

0 comments on commit 8c2dbf7

Please sign in to comment.