Skip to content

Commit bc79fd8

Browse files
committed
Added Dockerfile, build.sh & run.sh scripts (space-ros#46)
Signed-off-by: Jasmeet Singh <[email protected]>
1 parent 00da536 commit bc79fd8

File tree

5 files changed

+298
-0
lines changed

5 files changed

+298
-0
lines changed

custom_gz_plugins/Dockerfile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Copyright 2024 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:latest
23+
24+
# Define arguments used in the metadata definition
25+
ARG VCS_REF
26+
ARG VERSION="preview"
27+
28+
# Specify the docker image metadata
29+
LABEL org.label-schema.schema-version="1.0"
30+
LABEL org.label-schema.name="Real World Extraterrestrial Simulations"
31+
LABEL org.label-schema.description="Realistic Extraterrestrial Simulations demos using custom GZ plugins & data from NASA PDS"
32+
LABEL org.label-schema.vendor="Open Robotics"
33+
LABEL org.label-schema.version=${VERSION}
34+
LABEL org.label-schema.url="https://github.com/space-ros"
35+
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker"
36+
LABEL org.label-schema.vcs-ref=${VCS_REF}
37+
38+
# Define a few key variables
39+
ENV DEMO_DIR=${HOME_DIR}/demos_ws
40+
ENV GZ_VERSION=harmonic
41+
42+
# Disable prompting during package installation
43+
ARG DEBIAN_FRONTEND=noninteractive
44+
45+
# Clone all space-ros sources
46+
RUN mkdir ${SPACEROS_DIR}/src \
47+
&& vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos
48+
49+
# Make sure the latest versions of packages are installed
50+
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
51+
# the cache won't make it into the built image but will be maintained between steps.
52+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
53+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
54+
sudo apt-get update
55+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
56+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
57+
sudo apt-get dist-upgrade -y
58+
RUN rosdep update
59+
60+
# Get rosinstall_generator
61+
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
62+
# the cache won't make it into the built image but will be maintained between steps.
63+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
64+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
65+
sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator
66+
67+
RUN mkdir -p ${DEMO_DIR}/src
68+
WORKDIR ${DEMO_DIR}
69+
70+
# Install libmongoc for development
71+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
72+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
73+
sudo apt-get install libmongoc-dev -y
74+
75+
# Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/
76+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
77+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
78+
sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y
79+
RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz
80+
RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz
81+
RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local && sudo cmake --build . --target EP_mnmlstc_core && cmake --build . && sudo cmake --build . --target install
82+
83+
# Add osrf packages repository and manually install gz sim harmonic dependecies as they haven't been added to the rosdep index as of yet
84+
RUN sudo curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
85+
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
86+
RUN sudo apt-get update && sudo apt-get install -y libgz-math7-dev libgz-transport13-dev libgz-sim8-dev libgz-msgs10-dev libgz-plugin2-dev
87+
88+
# Get the source for the dependencies
89+
COPY --chown=${USERNAME}:${USERNAME} dependencies_source_pkgs.repos /tmp/
90+
RUN vcs import src < /tmp/dependencies_source_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"'
91+
92+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
93+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
94+
sudo apt-get update -y \
95+
&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \
96+
&& rosdep install --from-paths ${SPACEROS_DIR}/src src --ignore-src -r -y --rosdistro ${ROSDISTRO} --skip-keys "console_bridge generate_parameter_library fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers rmw_connextdds ros_testing rmw_connextdds rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp composition demo_nodes_py lifecycle rosidl_typesupport_fastrtps_cpp rosidl_typesupport_fastrtps_c ikos diagnostic_aggregator diagnostic_updater joy qt_gui rqt_gui rqt_gui_py"
97+
98+
# Build the demo
99+
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \
100+
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release'
101+
102+
# Add the user to the render group so that the user can access /dev/dri/renderD128
103+
RUN sudo usermod -aG render $USERNAME
104+
105+
# Setup the entrypoint
106+
COPY ./entrypoint.sh /
107+
ENTRYPOINT ["/entrypoint.sh"]
108+
CMD ["bash"]

custom_gz_plugins/build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
ORG=spaceros
4+
IMAGE=custom_sim_custom_plugins_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 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! #####"
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
repositories:
2+
demos:
3+
type: git
4+
url: https://github.com/jasmeet0915/demos
5+
version: jasmeet/custom_gz_plugins_pkg
6+
realtime_tools:
7+
type: git
8+
url: https://github.com/ros-controls/realtime_tools.git
9+
version: master
10+
ros2_control:
11+
type: git
12+
url: https://github.com/ros-controls/ros2_control.git
13+
version: humble
14+
ackermann_msgs:
15+
type: git
16+
url: https://github.com/ros-drivers/ackermann_msgs.git
17+
version: ros2
18+
resource_retriever:
19+
type: git
20+
url: https://github.com/ros/resource_retriever.git
21+
version: humble
22+
angles:
23+
type: git
24+
url: https://github.com/ros/angles.git
25+
version: humble-devel
26+
control_toolbox:
27+
type: git
28+
url: https://github.com/ros-controls/control_toolbox.git
29+
version: ros2-master
30+
control_msgs:
31+
type: git
32+
url: https://github.com/ros-controls/control_msgs.git
33+
version: humble
34+
gz_ros2_control:
35+
type: git
36+
url: https://github.com/jasmeet0915/gz_ros2_control.git
37+
version: jasmeet/humble_harmonic_support
38+
backward_ros:
39+
type: git
40+
url: https://github.com/pal-robotics/backward_ros.git
41+
version: foxy-devel
42+
qt_gui_core:
43+
type: git
44+
url: https://github.com/ros-visualization/qt_gui_core.git
45+
version: humble
46+
python_qt_binding:
47+
type: git
48+
url: https://github.com/ros-visualization/python_qt_binding.git
49+
version: humble
50+
ros2_controllers:
51+
type: git
52+
url: https://github.com/tonylitianyu/ros2_controllers.git
53+
version: effort_group_position_controller_2
54+
actuator_msgs:
55+
type: git
56+
url: https://github.com/rudislabs/actuator_msgs.git
57+
version: main
58+
filters:
59+
type: git
60+
url: https://github.com/ros/filters.git
61+
version: ros2
62+
rviz:
63+
type: git
64+
url: https://github.com/ros2/rviz.git
65+
version: humble
66+
ros_gz:
67+
type: git
68+
url: https://github.com/gazebosim/ros_gz.git
69+
version: humble
70+
generate_parameter_library:
71+
type: git
72+
url: https://github.com/PickNikRobotics/generate_parameter_library.git
73+
version: main
74+
joint_state_publisher:
75+
type: git
76+
url: https://github.com/ros/joint_state_publisher.git
77+
version: ros2
78+
rsl:
79+
type: git
80+
url: https://github.com/PickNikRobotics/RSL.git
81+
version: main
82+
cpp_polyfills:
83+
type: git
84+
url: https://github.com/PickNikRobotics/cpp_polyfills.git
85+
version: main
86+
image_transport:
87+
type: git
88+
url: https://github.com/ros-perception/image_common.git
89+
version: humble
90+
interactive_markers:
91+
type: git
92+
url: https://github.com/ros-visualization/interactive_markers.git
93+
version: humble
94+
laser_geometry:
95+
type: git
96+
url: https://github.com/ros-perception/laser_geometry.git
97+
version: humble
98+
simulation:
99+
type: git
100+
url: https://github.com/jasmeet0915/simulation
101+
version: real_data_planet_models
102+
warehouse_ros:
103+
type: git
104+
url: https://github.com/moveit/warehouse_ros.git
105+
version: ros2
106+
ros-humble-warehouse-ros-mongo:
107+
type: git
108+
url: https://github.com/ros-planning/warehouse_ros_mongo.git
109+
version: ros2
110+
vision_msgs:
111+
type: git
112+
url: https://github.com/ros-perception/vision_msgs.git
113+
version: ros2
114+
navigation_msgs:
115+
type: git
116+
url: https://github.com/ros-planning/navigation_msgs.git
117+
version: humble
118+
gps_msgs:
119+
type: git
120+
url: https://github.com/swri-robotics/gps_umd.git
121+
path: gps_msgs
122+
version: 113782d
123+
yaml_cpp_vendor:
124+
type: git
125+
url: https://github.com/ros2/yaml_cpp_vendor.git
126+
version: humble

custom_gz_plugins/entrypoint.sh

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

custom_gz_plugins/run.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
DOCKER_ARGS+=("-e NVIDIA_VISIBLE_DEVICES=all")
4+
DOCKER_ARGS+=("-e NVIDIA_DRIVER_CAPABILITIES=all")
5+
6+
xhost +local:root
7+
8+
ORG=spaceros
9+
IMAGE=custom_sim_custom_plugins_demo
10+
TAG=latest
11+
12+
container_name="space_ros_custom_gz_plugins_demo"
13+
14+
ros_domain_id=$(printenv ROS_DOMAIN_ID)
15+
16+
# Check if a Docker container with "$container_name" is already running.
17+
# If it is running, open an interactive bash shell inside it.
18+
# If the container is not running, create and run a new Docker container with specified configurations
19+
if docker ps --format '{{.Names}}' | grep -q "$container_name"; then
20+
docker exec -it "$container_name" /bin/bash
21+
else
22+
docker run -it --rm \
23+
${DOCKER_ARGS[@]} \
24+
-e DISPLAY=$DISPLAY \
25+
-v $PWD/..:/workspaces/sim_ws/src \
26+
-v /var/run/docker.sock:/var/run/docker.sock \
27+
--name "$container_name" \
28+
--workdir /home/spaceros-user/demos_ws/src \
29+
--env ROS_DOMAIN_ID=$ros_domain_id \
30+
--runtime nvidia \
31+
--network host \
32+
-v /dev/input:/dev/input --device-cgroup-rule='c 13:* rmw' \
33+
$@ \
34+
$ORG/$IMAGE:$TAG \
35+
/bin/bash
36+
fi

0 commit comments

Comments
 (0)