Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NASA Challenge_[@gmacario]_[Integrate FREISA Robot Dog with Space ROS Mars Rover Demo] (closes #54) #56

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f460d4c
freisa_on_mars: Create README.md
gmacario Sep 9, 2024
3b65bd4
Add Dev Container configuration files
gmacario Sep 10, 2024
0438cd6
Add VSCode Extension: Git Graph
gmacario Sep 10, 2024
68a21f4
Add VSCode Extension: SpaceRos Dashboard
gmacario Sep 10, 2024
071b4df
freisa_on_mars: Create README.md
gmacario Sep 9, 2024
f5850ab
freisa_on_mars: Create Dockerfile
gmacario Sep 9, 2024
3b3d5a3
freisa_on_mars: Create build.sh
gmacario Sep 9, 2024
2dc4a9c
freisa_on_mars: Create run.sh
gmacario Sep 9, 2024
fab4d01
Update IMG_NAME=baroloteam/freisa_on_mars:latest
gmacario Sep 9, 2024
2a2c193
Change file mode
gmacario Sep 9, 2024
be44f79
freisa_on_mars: Add entrypoint.sh
gmacario Sep 10, 2024
0cf8406
freisa_on_mars: Add demo_manual_pkgs.repos
gmacario Sep 10, 2024
ef7c494
:Dockerfile: Add contents
gmacario Sep 10, 2024
24600d2
demo_manual_pkgs.repos: Add (commented) all upstream packages
gmacario Sep 10, 2024
b16135f
Install SPACEROS
gmacario Sep 10, 2024
adbbc2a
demo_manual_pkgs.repos: Add some more comments
gmacario Sep 10, 2024
e5838a2
Use the new KeyValueFormat for ENV
gmacario Sep 10, 2024
7bc25b9
Add mini_pupper_ros and its dependencies
gmacario Sep 10, 2024
ac35d7c
freisa_on_mars/run.sh: Add more command-line options to docker run
gmacario Sep 10, 2024
13f5f0d
Merge branch 'dev-gmacario' into freisa_on_mars
gmacario Sep 10, 2024
5cabf29
Uncomment all Repositories used by space_robots
gmacario Sep 11, 2024
64ac68a
Temporarily comment out --volume="$XAUTHORITY:..."
gmacario Sep 11, 2024
8292993
Sanity checks on environment variables
gmacario Sep 13, 2024
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
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
71 changes: 71 additions & 0 deletions freisa_on_mars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# FREISA Robot Dog with Space ROS Mars Rover Demo

## Introduction

This demo integrates the simulation of the [FREISA Robot Dog](https://github.com/B-AROL-O/FREISA) (based on the [Mini Pupper 2 Pro](https://www.kickstarter.com/projects/mdrobotkits/md-robot-kits-open-source-support-your-genai-creativity) by [MangDang (HK) Limited](https://mangdang.store/)) inside the [Space ROS Mars Rover demo](https://space-ros.github.io/docs/rolling/Demos.html).

This code is a part of the following challenge:

* Challenge Name: NASA Space ROS Sim Summer Sprint Challenge
* Team Lead Freelancer Username: [@gmacario](https://www.freelancer.com/u/gmacario)
* Submission Title: Integrate FREISA Robot Dog with Space ROS Mars Rover Demo

<!--
## Directory Overview

TODO
-->

<!--
## Dependencies

TODO
-->

<!--
## Build Instructions

TODO
-->

<!--
## Usage Instructions

TODO
-->

<!--
## Architecture and design choices

TODO
-->

## Added bonus

The proposed feature is only dealing with the integration of the [Mini Pupper 2](https://github.com/mangdangroboticsclub) robot inside Space ROS demo.
However, once the PR is merged, as an added bonus it should be possible to instantiate in the Space ROS Demo any of the quadruped robots supported by [CHAMP](https://github.com/chvmp/champ):

![champ](https://raw.githubusercontent.com/chvmp/champ/master/docs/images/robots.gif)

## Authors

The FREISA Robot Dog with Space ROS Mars Rover Demo is another fine project by [the B-AROL-O Team](https://github.com/B-AROL-O) - a group of friends who in their spare time enjoy creating fun projects with Robotics, Computer Vision and [LEGO®](https://www.lego.com/).

Everything we do - both hardware and software - is Open Source and [shared on GitHub](https://github.com/B-AROL-O).

Our projects have been awarded several prizes in worldwide competitions on Computer Vision and robotics.
As an example, project "[Four-legged Robot Ensuring Intelligent Sprinkler Automation](https://www.hackster.io/projects/845012)" (a.k.a. [FREISA](https://github.com/B-AROL-O/FREISA)) - was the Grand Prize Winner 🥇 of the [OpenCV AI Competition 2023](https://www.hackster.io/contests/opencv-ai-competition-2023) with [OpenCV](https://www.hackster.io/opencv), [Khadas](https://www.hackster.io/khadas) and [Seeed Studio](https://www.hackster.io/seeed).

[![OpenCV AI Competition 2023 Grand Prize Winners - OpenCV Live 126](https://img.youtube.com/vi/iUe4N7yvpmA/0.jpg)](https://www.youtube.com/watch?v=iUe4N7yvpmA "OpenCV AI Competition 2023 Grand Prize Winners - OpenCV Live 126")

### How to get in touch

You can reach out to us through the following platforms:

* [![Instagram](https://img.icons8.com/small/16/000000/instagram-new.png)](https://instagram.com/baroloteam) Instagram: [@baroloteam](https://instagram.com/baroloteam)

* [![Twitter](https://img.icons8.com/small/16/000000/twitter.png)](https://x.com/baroloteam) X: [@baroloteam](<https://x.com/baroloteam>)

* [![GitHub](https://img.icons8.com/small/16/000000/github.png)](https://github.com/B-AROL-O) GitHub: [B-AROL-O](https://github.com/B-AROL-O)

<!-- 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
77 changes: 77 additions & 0 deletions freisa_on_mars/demo_manual_pkgs.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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
# TODO: vcs import < mini_pupper_ros/.minipupper.repos --recursive
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 "$@"
59 changes: 59 additions & 0 deletions freisa_on_mars/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/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")"

# Sanity checks
if [ -z "$DISPLAY" ]; then
export DISPLAY=:0
echo "Warning: DISPLAY undefined, set to $DISPLAY"
fi
if [ -z "$TERM" ]; then
export TERM=xterm
echo "Warning: TERM undefined, set to $TERM"
fi
if [ -z "$XAUTHORITY" ]; then
export XAUTHORITY=~/.Xauthority
echo "Warning: XAUTHORITY undefined, set to $XAUTHORITY"
xauth extract \- $DISPLAY >>$XAUTHORITY
fi

# 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 \
--volume "$XAUTHORITY:/.Xauthority" \
--device=/dev/dri:/dev/dri \
-e DISPLAY \
-e TERM \
-e QT_X11_NO_MITSHM=1 \
-e XAUTHORITY=/.Xauthority \
$IMG_NAME


# EOF
Loading