diff --git a/Dockerfile.gui b/Dockerfile.gui new file mode 100644 index 0000000..5089a48 --- /dev/null +++ b/Dockerfile.gui @@ -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 \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..fadf3df --- /dev/null +++ b/build.sh @@ -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 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..82cb762 --- /dev/null +++ b/run.sh @@ -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