Skip to content

Commit 048ad8a

Browse files
authored
Merge pull request #116 from space-ros/space_robots
Move space_robots from docker repo (space-ros/docker#256)
2 parents ed22c3e + 96c7661 commit 048ad8a

File tree

7 files changed

+248
-0
lines changed

7 files changed

+248
-0
lines changed

space_robots/Dockerfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright 2021 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# A Docker configuration script to build the Space ROS image.
16+
#
17+
# The script provides the following build arguments:
18+
#
19+
# VCS_REF - The git revision of the Space ROS source code (no default value).
20+
# VERSION - The version of Space ROS (default: "preview")
21+
22+
FROM osrf/space-ros-moveit2:main
23+
24+
# Define arguments used in the metadata definition
25+
ARG VCS_REF
26+
ARG VERSION="preview"
27+
ARG USERNAME="spaceros-user"
28+
29+
# Specify the docker image metadata
30+
LABEL org.label-schema.schema-version="1.0"
31+
LABEL org.label-schema.name="Curiosity Rover"
32+
LABEL org.label-schema.description="Curiosity rover demo on the Space ROS platform"
33+
LABEL org.label-schema.vendor="Open Robotics"
34+
LABEL org.label-schema.version=${VERSION}
35+
LABEL org.label-schema.url="https://github.com/space-ros"
36+
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker"
37+
LABEL org.label-schema.vcs-ref=${VCS_REF}
38+
39+
# Define a few key variables
40+
ENV DEMO_DIR=${HOME}/demos_ws
41+
WORKDIR ${DEMO_DIR}
42+
43+
# Disable prompting during package installation
44+
ARG DEBIAN_FRONTEND=noninteractive
45+
46+
# Update the ROS package keys
47+
ADD --chmod=644 https://raw.githubusercontent.com/ros/rosdistro/master/ros.key /usr/share/keyrings/ros-archive-keyring.gpg
48+
49+
# Install base image dependencies
50+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
51+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
52+
sudo apt-get update -y && \
53+
sudo -E apt-get install -y \
54+
git-lfs \
55+
python3-rosinstall-generator
56+
57+
RUN git clone https://github.com/space-ros/demos.git ${DEMO_DIR}/src/demos
58+
RUN git clone https://github.com/space-ros/simulation.git ${DEMO_DIR}/src/simulation
59+
60+
# Get a list of all installed ros2 packges
61+
RUN source "${SPACEROS_DIR}/setup.bash" && \
62+
source "${MOVEIT2_DIR}/install/setup.bash" && \
63+
ros2 pkg list > /tmp/installed-pkgs.txt
64+
65+
# Generate repos file for demo dependencies, excluding previously installed packages
66+
COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/
67+
COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/
68+
RUN rosinstall_generator \
69+
--rosdistro ${ROS_DISTRO} \
70+
--deps \
71+
--exclude $(cat /tmp/excluded-pkgs.txt /tmp/installed-pkgs.txt) -- \
72+
$(cat /tmp/demo-pkgs.txt) \
73+
> demo_generated_pkgs.repos
74+
75+
RUN vcs import --shallow src < demo_generated_pkgs.repos
76+
77+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
78+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
79+
sudo apt-get update -y && \
80+
source "${SPACEROS_DIR}/setup.bash" && \
81+
source "${MOVEIT2_DIR}/install/setup.bash" && \
82+
rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO}
83+
84+
# Build the demo
85+
RUN source ${SPACEROS_DIR}/setup.bash && \
86+
source ${MOVEIT2_DIR}/install/setup.bash && \
87+
colcon build \
88+
--cmake-args \
89+
-DCMAKE_BUILD_TYPE=Release
90+
91+
# Setup the entrypoint
92+
COPY ./entrypoint.sh /
93+
ENTRYPOINT ["/entrypoint.sh"]
94+
CMD ["bash"]

space_robots/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Space Robots Demo Docker Image
2+
3+
This folder contains the Dockerfile and scripts required to build the Curiosity Mars rover and Canadarm demos into an image called `space_robots_demo`.
4+
5+
The Dockerfile installs all of the prerequisite system dependencies along with the demos source code, then builds the demo code.
6+
7+
The image uses [osrf/space-ros-moveit2:latest](https://hub.docker.com/r/osrf/space-ros-moveit2/tags) as its base image.
8+
9+
**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.
10+
11+
## Building the Demo Image
12+
13+
Use the build script provided to build the docker image.
14+
15+
```
16+
./build.sh
17+
```
18+
19+
## Running the image container
20+
21+
Run the following to allow GUI passthrough:
22+
23+
```bash
24+
xhost +local:docker
25+
```
26+
27+
Then run:
28+
29+
```bash
30+
./run.sh
31+
```
32+
33+
## Running the Demos
34+
35+
### Curiosity Mars rover demo
36+
37+
1. Launch the demo in Gazebo:
38+
39+
```bash
40+
ros2 launch curiosity_gazebo curiosity_gazebo.launch.py
41+
```
42+
43+
On the top left corner, click on the refresh button to show camera feed.
44+
45+
2. Launch the ROS 2 control nodes
46+
Open a new terminal and attach to the currently running container:
47+
48+
```bash
49+
docker exec -it openrobotics_space_robots_demo bash
50+
```
51+
Within the container, launch the control nodes:
52+
```
53+
ros2 launch curiosity_rover_demo mars_rover.launch.py
54+
```
55+
56+
3. Send commands to the rover
57+
Open a new terminal and attach to the currently running container:
58+
59+
```bash
60+
docker exec -it openrobotics_space_robots_demo bash
61+
```
62+
Within the container, you can now move the rover using the commands in [demos/curiosity_rover/README.md](../curiosity_rover/README.md)
63+
64+
#### Canadarm demo
65+
Run the demo container as shown above:
66+
```bash
67+
./run.sh
68+
```
69+
70+
1. Launch the canadarm demo in Gazebo
71+
```bash
72+
ros2 launch canadarm_gazebo canadarm.launch.py
73+
```
74+
2. Launch the ROS 2 control node
75+
Open a new terminal and attach to the currently running container:
76+
77+
```bash
78+
docker exec -it openrobotics_space_robots_demo bash
79+
```
80+
Within the container, launch the control node:
81+
82+
```bash
83+
ros2 launch canadarm_demo canadarm.launch.py
84+
```
85+
Within the container, you can now move the arm using the commands in [demos/canadarm2/README.md](../canadarm2/README.md)

space_robots/build.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
ORG=openrobotics
4+
IMAGE=space_robots_demo
5+
TAG=latest
6+
7+
VCS_REF=""
8+
VERSION=preview
9+
10+
# Exit script with failure if build fails
11+
set -eo pipefail
12+
13+
echo ""
14+
echo "##### Building Space ROS Demo Docker Image #####"
15+
echo ""
16+
17+
docker build -t $ORG/$IMAGE:$TAG \
18+
--build-arg VCS_REF="$VCS_REF" \
19+
--build-arg VERSION="$VERSION" .
20+
21+
echo ""
22+
echo "##### Done! #####"
23+

space_robots/demo-pkgs.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gz_ros2_control
2+
qt_gui_core
3+
actuator_msgs
4+
ros_gz
5+
vision_msgs
6+
gps_msgs

space_robots/entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Setup the Demo environment
5+
source "${DEMO_DIR}/install/setup.bash"
6+
7+
exec "$@"

space_robots/excluded-pkgs.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fastrtps
2+
fastcdr
3+
generate_parameter_library
4+
rmw_fastrtps_cpp
5+
rmw_fastrtps_dynamic_cpp
6+
rmw_fastrtps_shared_cpp
7+
rmw_connextdds
8+
rosidl_typesupport_fastrtps_c
9+
rosidl_typesupport_fastrtps_cpp
10+
fastrtps_cmake_module

space_robots/run.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# Runs a docker container with the image created by build.bash
4+
# Requires:
5+
# docker
6+
# an X server
7+
8+
IMG_NAME=openrobotics/space_robots_demo
9+
IMG_TAG=latest
10+
11+
# Replace `/` with `_` to comply with docker container naming
12+
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")"
13+
14+
# Start the container
15+
docker run \
16+
--rm \
17+
-it \
18+
--name "${CONTAINER_NAME}" \
19+
--network host \
20+
-e DISPLAY \
21+
-e TERM \
22+
-e QT_X11_NO_MITSHM=1 \
23+
"${IMG_NAME}:${IMG_TAG}"

0 commit comments

Comments
 (0)