diff --git a/lunarsim_demo/Dockerfile b/lunarsim_demo/Dockerfile new file mode 100644 index 00000000..449cf194 --- /dev/null +++ b/lunarsim_demo/Dockerfile @@ -0,0 +1,164 @@ +# 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:latest + +# Define arguments used in the metadata definition +ARG VCS_REF +ARG VERSION="preview" + +# Specify the docker image metadata +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.name="Lunar Sim" +LABEL org.label-schema.description="Lunar sim 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} + +# Clone all space-ros sources +RUN mkdir ${SPACEROS_DIR}/src \ + && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos + +# Define a few key variables +ENV DEMO_DIR=${HOME_DIR}/demos_ws +ENV GZ_VERSION=garden +ENV GZ_PARTITION=spaceros + +# Disable prompting during package installation +ARG DEBIAN_FRONTEND=noninteractive + +# Make sure the latest versions of packages are installed +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get update +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get dist-upgrade -y +RUN rosdep update + +# Install the various build and test tools +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt install -y \ + build-essential \ + clang-format \ + cmake \ + git \ + libbullet-dev \ + python3-colcon-common-extensions \ + python3-flake8 \ + python3-pip \ + python3-pytest-cov \ + python3-rosdep \ + python3-setuptools \ + python3-vcstool \ + wget + +RUN sudo add-apt-repository ppa:kisak/kisak-mesa + +RUN sudo apt install xterm -y + +# Get rosinstall_generator +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +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 apt-get install -y python3-rosinstall-generator + +# Install Gazebo Garder +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \ + && 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 \ + && sudo apt-get update -y && sudo apt-get install -y gz-garden + +# Generate repos file for demo dependencies, excluding packages from Space ROS core. +COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/ +COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/ +RUN rosinstall_generator \ + --rosdistro ${ROSDISTRO} \ + --deps \ + --exclude-path ${SPACEROS_DIR}/src \ + --exclude $(cat /tmp/excluded-pkgs.txt) -- \ + -- $(cat /tmp/demo-pkgs.txt) \ + > /tmp/demo_generated_pkgs.repos + + +RUN mkdir -p ${DEMO_DIR}/src +WORKDIR ${DEMO_DIR} +RUN vcs import src < /tmp/demo_generated_pkgs.repos + +# Install system dependencies +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash' \ + && rosdep install --from-paths ../spaceros/src src --ignore-src --rosdistro ${ROSDISTRO} -r -y --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" + + +# # Install libmongoc for development +# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +# --mount=type=cache,target=/var/lib/apt,sharing=locked \ +# sudo apt-get install libmongoc-dev -y + +# # Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/ +# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +# --mount=type=cache,target=/var/lib/apt,sharing=locked \ +# sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y +# RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz +# RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz +# 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 + +# Get the source for the dependencies +# RUN vcs import src < /tmp/demo_generated_pkgs.repos +COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/ +RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' + +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get update -y \ +&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ +&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO} + +# Copy the demo source code +COPY --chown=${USERNAME}:${USERNAME} lunar_sun_gz_plugin src/lunar_sun_gz_plugin +COPY --chown=${USERNAME}:${USERNAME} lunarsim_gz_bringup src/lunarsim_gz_bringup +COPY --chown=${USERNAME}:${USERNAME} lunarsim_gz_worlds src/lunarsim_gz_worlds + +# Build the demo +RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ + && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release' + +# Create the render group if it doesn't exist +RUN sudo groupadd -f render + +# Add the user to the render group so that the user can access /dev/dri/renderD128 +RUN sudo usermod -aG render $USERNAME + +# Setup the entrypoint +COPY ./entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] +CMD ["bash"] \ No newline at end of file diff --git a/lunarsim_demo/build.sh b/lunarsim_demo/build.sh new file mode 100755 index 00000000..25b3d3c8 --- /dev/null +++ b/lunarsim_demo/build.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +ORG=openrobotics +IMAGE=space_robots_lunarsim_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! #####" + diff --git a/lunarsim_demo/demo-pkgs.txt b/lunarsim_demo/demo-pkgs.txt new file mode 100644 index 00000000..810d8895 --- /dev/null +++ b/lunarsim_demo/demo-pkgs.txt @@ -0,0 +1,4 @@ +leo_gz_plugins +rviz2 +xacro +teleop_twist_keyboard \ No newline at end of file diff --git a/lunarsim_demo/demo_manual_pkgs.repos b/lunarsim_demo/demo_manual_pkgs.repos new file mode 100644 index 00000000..87341643 --- /dev/null +++ b/lunarsim_demo/demo_manual_pkgs.repos @@ -0,0 +1,23 @@ +repositories: + actuator_msgs: + type: git + url: https://github.com/rudislabs/actuator_msgs.git + version: main + ros_gz: + type: git + url: https://github.com/gazebosim/ros_gz.git + version: humble + vision_msgs: + type: git + url: https://github.com/ros-perception/vision_msgs.git + version: ros2 + gps_msgs: + type: git + url: https://github.com/swri-robotics/gps_umd.git + path: gps_msgs + version: 113782d + + leo_common-ros2: + type: git + url: https://github.com/LeoRover/leo_common-ros2.git + version: humble \ No newline at end of file diff --git a/lunarsim_demo/entrypoint.sh b/lunarsim_demo/entrypoint.sh new file mode 100755 index 00000000..045695ed --- /dev/null +++ b/lunarsim_demo/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +# Setup the Demo environment +# source "${DEMO_DIR}/install/setup.bash" +exec "$@" diff --git a/lunarsim_demo/excluded-pkgs.txt b/lunarsim_demo/excluded-pkgs.txt new file mode 100644 index 00000000..7a57a8ae --- /dev/null +++ b/lunarsim_demo/excluded-pkgs.txt @@ -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 diff --git a/lunarsim_demo/lunar_sun_gz_plugin/src/lunar_sun.cpp b/lunarsim_demo/lunar_sun_gz_plugin/src/lunar_sun.cpp index 6c0495a5..3129648b 100644 --- a/lunarsim_demo/lunar_sun_gz_plugin/src/lunar_sun.cpp +++ b/lunarsim_demo/lunar_sun_gz_plugin/src/lunar_sun.cpp @@ -55,7 +55,7 @@ class LunarSun : public gazebo::System, this->actorEntity = ecm.EntityByComponents(gazebo::components::Name("animated_sun")); - LoadCSV("/home/spaceros-user/demos_ws/src/lunarsim_demo/lunar_sun_gz_plugin/horizons_az_el.csv"); + LoadCSV("/home/spaceros-user/demos_ws/src/lunar_sun_gz_plugin/horizons_az_el.csv"); ignition::math::Pose3d startPose(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // Position the light above the ground diff --git a/lunarsim_demo/lunarsim_gz_worlds/CMakeLists.txt b/lunarsim_demo/lunarsim_gz_worlds/CMakeLists.txt index d72ee480..0fd65854 100644 --- a/lunarsim_demo/lunarsim_gz_worlds/CMakeLists.txt +++ b/lunarsim_demo/lunarsim_gz_worlds/CMakeLists.txt @@ -25,7 +25,7 @@ endif() # Install launch files. install( - DIRECTORY src launch world models + DIRECTORY launch world models DESTINATION share/${PROJECT_NAME}/ ) diff --git a/lunarsim_demo/lunarsim_gz_worlds/world/dem_moon.sdf b/lunarsim_demo/lunarsim_gz_worlds/world/dem_moon.sdf index f7d8e996..bfbb2afa 100644 --- a/lunarsim_demo/lunarsim_gz_worlds/world/dem_moon.sdf +++ b/lunarsim_demo/lunarsim_gz_worlds/world/dem_moon.sdf @@ -189,7 +189,7 @@ - <-- Without script plug does not move actor --> +