Skip to content
Merged
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
94 changes: 94 additions & 0 deletions space_robots/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2021 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# A Docker configuration script to build the Space ROS image.
#
# The script provides the following build arguments:
#
# VCS_REF - The git revision of the Space ROS source code (no default value).
# VERSION - The version of Space ROS (default: "preview")

FROM osrf/space-ros-moveit2:main

# Define arguments used in the metadata definition
ARG VCS_REF
ARG VERSION="preview"
ARG USERNAME="spaceros-user"

# Specify the docker image metadata
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="Curiosity Rover"
LABEL org.label-schema.description="Curiosity rover demo on the Space ROS platform"
LABEL org.label-schema.vendor="Open Robotics"
LABEL org.label-schema.version=${VERSION}
LABEL org.label-schema.url="https://github.com/space-ros"
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker"
LABEL org.label-schema.vcs-ref=${VCS_REF}

# Define a few key variables
ENV DEMO_DIR=${HOME}/demos_ws
WORKDIR ${DEMO_DIR}

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive

# Update the ROS package keys
ADD --chmod=644 https://raw.githubusercontent.com/ros/rosdistro/master/ros.key /usr/share/keyrings/ros-archive-keyring.gpg

# Install base image dependencies
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y && \
sudo -E apt-get install -y \
git-lfs \
python3-rosinstall-generator

RUN git clone https://github.com/space-ros/demos.git ${DEMO_DIR}/src/demos
RUN git clone https://github.com/space-ros/simulation.git ${DEMO_DIR}/src/simulation

# Get a list of all installed ros2 packges
RUN source "${SPACEROS_DIR}/setup.bash" && \
source "${MOVEIT2_DIR}/install/setup.bash" && \
ros2 pkg list > /tmp/installed-pkgs.txt

# Generate repos file for demo dependencies, excluding previously installed packages
COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/
COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/
RUN rosinstall_generator \
--rosdistro ${ROS_DISTRO} \
--deps \
--exclude $(cat /tmp/excluded-pkgs.txt /tmp/installed-pkgs.txt) -- \
$(cat /tmp/demo-pkgs.txt) \
> demo_generated_pkgs.repos

RUN vcs import --shallow src < demo_generated_pkgs.repos

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y && \
source "${SPACEROS_DIR}/setup.bash" && \
source "${MOVEIT2_DIR}/install/setup.bash" && \
rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO}

# Build the demo
RUN source ${SPACEROS_DIR}/setup.bash && \
source ${MOVEIT2_DIR}/install/setup.bash && \
colcon build \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release

# Setup the entrypoint
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
85 changes: 85 additions & 0 deletions space_robots/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Space Robots Demo Docker Image

This folder contains the Dockerfile and scripts required to build the Curiosity Mars rover and Canadarm demos into an image called `space_robots_demo`.

The Dockerfile installs all of the prerequisite system dependencies along with the demos source code, then builds the demo code.

The image uses [osrf/space-ros-moveit2:latest](https://hub.docker.com/r/osrf/space-ros-moveit2/tags) as its base image.

**Note:** This demo was moved from the [space-ros/docker](https:/github.com/space-ros/docker) repository. For history prior to the move, search that repo.

## Building the Demo Image

Use the build script provided to build the docker image.

```
./build.sh
```

## Running the image container

Run the following to allow GUI passthrough:

```bash
xhost +local:docker
```

Then run:

```bash
./run.sh
```

## Running the Demos

### Curiosity Mars rover demo

1. Launch the demo in Gazebo:

```bash
ros2 launch curiosity_gazebo curiosity_gazebo.launch.py
```

On the top left corner, click on the refresh button to show camera feed.

2. Launch the ROS 2 control nodes
Open a new terminal and attach to the currently running container:

```bash
docker exec -it openrobotics_space_robots_demo bash
```
Within the container, launch the control nodes:
```
ros2 launch curiosity_rover_demo mars_rover.launch.py
```

3. Send commands to the rover
Open a new terminal and attach to the currently running container:

```bash
docker exec -it openrobotics_space_robots_demo bash
```
Within the container, you can now move the rover using the commands in [demos/curiosity_rover/README.md](../curiosity_rover/README.md)

#### Canadarm demo
Run the demo container as shown above:
```bash
./run.sh
```

1. Launch the canadarm demo in Gazebo
```bash
ros2 launch canadarm_gazebo canadarm.launch.py
```
2. Launch the ROS 2 control node
Open a new terminal and attach to the currently running container:

```bash
docker exec -it openrobotics_space_robots_demo bash
```
Within the container, launch the control node:

```bash
ros2 launch canadarm_demo canadarm.launch.py
```
Within the container, you can now move the arm using the commands in [demos/canadarm2/README.md](../canadarm2/README.md)
23 changes: 23 additions & 0 deletions space_robots/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

ORG=openrobotics
IMAGE=space_robots_demo
TAG=latest

VCS_REF=""
VERSION=preview

# Exit script with failure if build fails
set -eo pipefail

echo ""
echo "##### Building Space ROS Demo Docker Image #####"
echo ""

docker build -t $ORG/$IMAGE:$TAG \
--build-arg VCS_REF="$VCS_REF" \
--build-arg VERSION="$VERSION" .

echo ""
echo "##### Done! #####"

6 changes: 6 additions & 0 deletions space_robots/demo-pkgs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gz_ros2_control
qt_gui_core
actuator_msgs
ros_gz
vision_msgs
gps_msgs
7 changes: 7 additions & 0 deletions space_robots/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

# Setup the Demo environment
source "${DEMO_DIR}/install/setup.bash"

exec "$@"
10 changes: 10 additions & 0 deletions space_robots/excluded-pkgs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fastrtps
fastcdr
generate_parameter_library
rmw_fastrtps_cpp
rmw_fastrtps_dynamic_cpp
rmw_fastrtps_shared_cpp
rmw_connextdds
rosidl_typesupport_fastrtps_c
rosidl_typesupport_fastrtps_cpp
fastrtps_cmake_module
23 changes: 23 additions & 0 deletions space_robots/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Runs a docker container with the image created by build.bash
# Requires:
# docker
# an X server

IMG_NAME=openrobotics/space_robots_demo
IMG_TAG=latest

# Replace `/` with `_` to comply with docker container naming
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")"

# Start the container
docker run \
--rm \
-it \
--name "${CONTAINER_NAME}" \
--network host \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
"${IMG_NAME}:${IMG_TAG}"