Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GUI stack for Space ROS #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,42 @@ See individual template directories for details.
* [rtems](./rtems)
* [space_robots](./space_robots)
* [zynq_rtems](./zynq_rtems)


### Build stacks

To build the docker images available in the stack, run the following command:

```bash
# To show the available options
./build.sh -help
# Usage: ./build.sh stack-name [options]
# USAGE
# -h, --help: display this help message
# stack-name: the name of the stack to build. Must be one of the following:
# - gui
# - nav2
# - moveit2

# To build GUI stack
./build.sh gui
```

### Starting a stack container

To run the docker images available in the stack, run the following command:

```bash
# To show the available options
./run.sh -help
# Usage: ./build.sh stack-name [options]
# USAGE
# -h, --help: display this help message
# stack-name: the name of the stack to build. Must be one of the following:
# - gui
# - nav2
# - moveit2

# To run GUI stack
./run.sh gui
```
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