Skip to content

Commit

Permalink
Merge branch 'dev-gmacario' into freisa_on_mars
Browse files Browse the repository at this point in the history
  • Loading branch information
gmacario committed Sep 10, 2024
2 parents f460d4c + ac35d7c commit 13f5f0d
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"mhutchie.git-graph",
"openrobotics.spaceros-dashboard"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
92 changes: 92 additions & 0 deletions freisa_on_mars/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# freisa_on_mars/Dockerfile
#
# Adapted from https://github.com/space-ros/docker/blob/main/space_robots/Dockerfile

FROM osrf/space-ros:latest
# FROM openrobotics/moveit2: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="FREISA meets Curiosity Rover"
LABEL org.label-schema.description="FREISA Robot Dog meets Curiosity rover demo on the Space ROS platform"
LABEL org.label-schema.vendor="B-AROL-O Team"
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/demos"
LABEL org.label-schema.vcs-ref=${VCS_REF}

# Define a few key variables
ENV DEMO_DIR=${HOME_DIR}/demos_ws
ENV IGNITION_VERSION=fortress
ENV GZ_VERSION=fortress

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive

# 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

# TODO(anyone): remove demo-pkgs.txt, no packages left after exclusions
# 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-path ${MOVEIT2_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}


# # 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}

# && /bin/bash -c 'source "${MOVEIT2_DIR}/install/setup.bash"' \

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

# # 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"]

# EOF
24 changes: 24 additions & 0 deletions freisa_on_mars/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

ORG=baroloteam
IMAGE=freisa_on_mars
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! #####"

# EOF
76 changes: 76 additions & 0 deletions freisa_on_mars/demo_manual_pkgs.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# freisa_on_mars/demo_manual_pkgs.repos
#
# Adapted from https://github.com/space-ros/docker/blob/main/space_robots

repositories:
demos:
type: git
# FIXME: Update url/version once <https://github.com/space-ros/demos/pull/56> is merged
# url: https://github.com/space-ros/demos.git
url: https://github.com/B-AROL-O/space-ros-demos.git
# version: main
# version: freisa_on_mars
version: dev-gmacario

# === Repositories used by space_robots ===
# See https://github.com/space-ros/docker/blob/main/space_robots/demo_manual_pkgs.repos

# gz_ros2_control:
# type: git
# url: https://github.com/ros-controls/gz_ros2_control.git
# version: humble
# qt_gui_core:
# type: git
# url: https://github.com/ros-visualization/qt_gui_core.git
# version: humble
# ros2_controllers:
# type: git
# url: https://github.com/tonylitianyu/ros2_controllers.git
# version: effort_group_position_controller_2
# 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
# simulation:
# type: git
# url: https://github.com/space-ros/simulation.git
# version: main
ros-humble-warehouse-ros-mongo:
type: git
url: https://github.com/moveit/warehouse_ros_mongo.git
version: ros2
# 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

# === Extra repositories required by freisa_on_mars ===
mini_pupper_ros:
type: git
url: https://github.com/B-AROL-O/mini_pupper_ros.git
version: ros2-dev

# From https://github.com/B-AROL-O/mini_pupper_ros/blob/ros2-dev/.minipupper.repos
champ/champ:
type: git
url: https://github.com/mangdangroboticsclub/champ.git
version: ros2
champ/champ_teleop:
type: git
url: https://github.com/chvmp/champ_teleop.git
version: ros2
ldlidar_stl_ros:
type: git
url: https://github.com/ldrobotSensorTeam/ldlidar_stl_ros2.git
version: master

# EOF
6 changes: 6 additions & 0 deletions freisa_on_mars/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

# Setup the Demo environment
source "${DEMO_DIR}/install/setup.bash"
exec "$@"
43 changes: 43 additions & 0 deletions freisa_on_mars/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

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

IMG_NAME=baroloteam/freisa_on_mars

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

# Start the container
#
# --rm: delete container after exiting
# -it: Interactive TTY mode so you can use a shell.
# --network host: Does not isolate Docker container from host's network interfaces.
# Allows all traffic to pass through as if it originated from the host.
# In our case, useful for DDS traffic for ROS.
# -e DISPLAY: Pass the X11 display through to the container.
# -e TERM: Pass the kind of terminal being used through to the container.
# -e QT_X11_NO_MITSHM=1: Disables shared memory extension for Qt/X11, which does not work consistently inside a process namespace like a container.
# -v "$XAUTHORITY:/.Xauthority": the $XAUTHORITY environment variable on the host contains the path to a file that grants access to X11.
# We mount the path defined in that environment variable into the container at /.Xauthority.
# -e XAUTHORITY=/.Xauthority: We set $XAUTHORITY *inside* the container to the place we just mounted the Xauthority (/.Xauthority)
#
# Credits:
# * https://github.com/space-ros/docker/pull/168
# * https://github.com/space-ros/docker/pull/175
#
docker run --rm -it --name $CONTAINER_NAME \
--network host \
--volume=/tmp/.X11-unix:/tmp/.X11-unix \
--device=/dev/dri:/dev/dri \
--volume "$XAUTHORITY:/.Xauthority" \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
-e XAUTHORITY=/.Xauthority \
$IMG_NAME

# EOF

0 comments on commit 13f5f0d

Please sign in to comment.