Skip to content

Commit

Permalink
WIP: Add ROS2 subpackage into QM
Browse files Browse the repository at this point in the history
Just initial work to support The Robot Operational System (ROS2)
out of box into QM.

ContainerFile by Leonardo Rossetti <[email protected]> with few mods by me.

Signed-off-by: Douglas Landgraf <[email protected]>
  • Loading branch information
dougsland committed Oct 27, 2024
1 parent 5b6b21d commit 4672dfd
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ EN_QM_MNT_BIND_TTY7 ?= 0
# export EN_QM_MNT_BIND_SOUND=1
EN_QM_MNT_BIND_SOUND ?= 0

############################################
# subpackage QM - ros2-rolling #
############################################
# export EN_QM_ROS2_ROLLING=1
EN_QM_ROS2_ROLLING ?= 0

###########################################
# subpackage QM - Enable Window Manager #
###########################################
Expand Down Expand Up @@ -136,7 +142,8 @@ rpm: clean dist ## - Creates a local RPM package, useful for develop
--define="u_enable_qm_mount_bind_sound ${EN_QM_MNT_BIND_SOUND}" \
--define="u_enable_qm_mount_bind_kvm ${EN_QM_MNT_BIND_KVM}" \
--define="u_enable_qm_mount_bind_input ${EN_QM_MNT_BIND_INPUT}" \
--define="u_enable_qm_mount_bind_video ${EN_QM_MNT_BIND_VIDEO}" \
--define="u_enable_qm_mount_bind_video ${EN_QM_MNT_BIND_VIDEO}" \
--define="u_enable_qm_dropin_ros2_rolling ${EN_QM_ROS2_ROLLING}" \
--define="_topdir ${RPM_TOPDIR}" \
--define="version ${VERSION}" \
${SPECFILE}
Expand All @@ -155,6 +162,11 @@ qm_dropin_img_tempdir: ## - QM RPM sub-package qm_dropin_img_tempdir
sed -i 's/%define enable_qm_dropin_img_tempdir 0/%define enable_qm_dropin_img_tempdir 1/' ${SPECFILE}
$(MAKE) VERSION=${VERSION} rpm

.PHONY: qm_dropin_ros2_rolling
qm_dropin_ros2_rolling: ## - QM RPM sub-package to creating a quadlet container with ROS2 rolling env
sed -i 's/%define enable_qm_ros2_rolling 0/%define enable_qm_ros2_rolling 1/' ${SPECFILE}
$(MAKE) VERSION=${VERSION} rpm

.PHONY: qm_dropin_mount_bind_ttyUSB0
qm_dropin_mount_bind_ttyUSB0: ## - QM RPM sub-package to mount bind /dev/ttyUSB0 in the nested containers
sed -i 's/%define enable_qm_mount_bind_ttyUSB0 0/%define enable_qm_mount_bind_ttyUSB0 1/' ${SPECFILE}
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Installing QM Sub-Packages](#installing-qm-sub-packages)
- [Removing QM Sub-Packages](#removing-qm-sub-packages)
- [Creating Your Own Drop-In QM Sub-Package](#creating-your-own-drop-in-qm-sub-package)
- [QM Sub-Package ROS2](#qm-sub-package-ros2)
- [QM Sub-Package KVM](#qm-sub-package-kvm)
- [QM Sub-Package Sound](#qm-sub-package-sound)
- [QM Sub-Package Video](#qm-sub-package-video)
Expand Down Expand Up @@ -332,6 +333,26 @@ Example changing the spec and triggering the build via make (feel free to automa
$ make clean && VERSION=YOURVERSIONHERE make rpm
```

## QM sub-package ROS2

The QM sub-package ROS2 (a.k.a The Robot Operating System) is widely used by open-source projects, enterprises, companies, edge env and government agencies, including NASA, to advance robotics and autonomous systems. Enabled by Quadlet in QM, ROS2 on top of QM provides a secure environment where robots can operate and communicate safely, benefiting from QM's "Freedom from Interference" frequently tested layer. This ensures robots can function without external interference, enhancing their reliability and security.

The types of robots compatible with this environment are extensive, ranging from medical devices and aerial drones to aqua drones and space rockets. ROS2 within QM supports high availability, meaning these robotic systems can maintain continuous operations, crucial for mission-critical and industrial applications. This versatility makes it ideal for environments that demand robust communication and operational safety, from healthcare and aerospace to underwater exploration and autonomous land vehicles.

How to test this env?

```bash
$host> git clone https://github.com/containers/qm.git && cd qm
$host> make qm_dropin_ros2_rolling
$host> sudo dnf install rpmbuild/RPMS/noarch/qm_ros2_rolling-0.6.7-1.fc40.noarch.rpm -y
$host> sudo podman restart qm # if you have qm already running

Testing using talked and listener examples
$host> sudo podman exec -it qm bash
QM> ros2 run demo_nodes_cpp talker &
QM> ros2 run demo_nodes_cpp listener
```

## QM sub-package KVM

The QM sub-package KVM includes drop-in configuration that enables the integration of Kernel-based Virtual Machine (KVM) management into the QM (Quality Management) container environment. This configuration allows users to easily configure and manage KVM virtual machines within the QM system, streamlining virtualization tasks in containerized setups.
Expand Down
34 changes: 34 additions & 0 deletions rpm/qm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
###########################################
%define enable_qm_window_manager 0%{?u_enable_qm_window_manager}

###########################################
# subpackage QM - ROS2 Rolling version #
###########################################
%define enable_qm_ros2_rolling 1%{?u_enable_qm_ros2_rolling}

###########################################
# subpackage QM - mount bind /dev/ttyUSB0 #
###########################################
Expand Down Expand Up @@ -262,6 +267,17 @@ install -d %{buildroot}%{_sysconfdir}/qm/containers/containers.conf.d
# END - qm dropin sub-package - mount ttyUSB0 #
########################################################

########################################################
# START - qm dropin ROS2 - Rolling #
########################################################
%if %{enable_qm_ros2_rolling}
mkdir -p %{buildroot}/%{rootfs_qm}/%{_sysconfdir}/containers/systemd/
install -m 644 %{_builddir}/qm-%{version}/subsystems/ros2/ros2-rolling.container %{buildroot}/%{rootfs_qm}/etc/containers/systemd/ros2-rolling.container
%endif
########################################################
# END - qm dropin sub-package - ROS2 - Rolling #
########################################################

########################################################
# START - qm dropin sub-package - mount video #
########################################################
Expand Down Expand Up @@ -560,6 +576,24 @@ additional drop-in configurations.
%{rootfs_qm}/%{_sysconfdir}/containers/systemd/rear-camera.container
%endif

#######################################
# sub-package QM ROS2 rolling
#######################################
%if %{enable_qm_ros2_rolling}
%package -n qm_ros2_rolling
Summary: Subpackage container for quadlet container to ROS2 Rolling environment
Requires: %{name} = %{version}-%{release}
BuildArch: noarch

%description -n qm_ros2_rolling
This sub-package installs a drop-in configurations for the QM.
It creates the `/etc/qm/containers/containers.conf.d/` directory for adding
additional drop-in configurations.

%files -n qm_ros2_rolling
%{rootfs_qm}/%{_sysconfdir}/containers/systemd/ros2-rolling.container
%endif

#######################################

%changelog
Expand Down
89 changes: 89 additions & 0 deletions subsystems/ros2/ContainerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# ContainerFile used to create the image available at quay.io/qm-images/wm_active_session:latest
#
# How to build
# ==================
# podman login quay.io
# podman build -t quay.io/qm-images/ros2:rolling -f ContainerFile
# podman push quay.io/qm-images/ros2:rolling
#
# Run the demo
# ==================
# podman run -it quay.io/qm-images/ros2:rolling
# ros2 run demo_nodes_cpp talker &
# ros2 run demo_nodes_cpp listener

ARG FEDORA_VERSION=40

FROM registry.fedoraproject.org/fedora-toolbox:${FEDORA_VERSION}

ARG ROS_VERSION=rolling

ENV LANG=en_US.UTF-8
ENV RPM_ARCH=x86_64
ENV ROS_PYTHON_VERSION=3

RUN dnf update -y

RUN dnf install -y \
cmake \
cppcheck \
eigen3-devel \
gcc-c++ \
liblsan \
libXaw-devel \
libyaml-devel \
make \
opencv-devel \
patch \
python3-colcon-common-extensions \
python3-coverage \
python3-devel \
python3-empy \
python3-nose \
python3-pip \
python3-pydocstyle \
python3-pyparsing \
python3-pytest \
python3-pytest-cov \
python3-pytest-mock \
python3-pytest-runner \
python3-rosdep \
python3-setuptools \
python3-vcstool \
poco-devel \
poco-foundation \
python3-flake8 \
python3-flake8-import-order \
redhat-rpm-config \
uncrustify \
wget

RUN python3 -m pip install -U \
flake8-blind-except==0.1.1 \
flake8-class-newline \
flake8-deprecated

RUN mkdir -p /opt/ros2/src
WORKDIR /opt/ros2
RUN vcs import --input https://raw.githubusercontent.com/ros2/ros2/${ROS_VERSION}/ros2.repos src

RUN rosdep init
RUN rosdep update
RUN rosdep install \
--from-paths src \
--ignore-src -y \
--skip-keys "assimp fastcdr ignition-cmake2 ignition-math6 python3-matplotlib python3-pygraphviz rti-connext-dds-6.0.1 urdfdom_headers"

WORKDIR /opt/ros2

# TODO: temporary workaround, remove once those packages can be built
RUN touch ./src/ros-visualization/rqt/rqt_gui_cpp/CATKIN_IGNORE && \
touch ./src/ros-visualization/qt_gui_core/qt_gui_app/CATKIN_IGNORE && \
touch ./src/ros-visualization/qt_gui_core/qt_gui_cpp/CATKIN_IGNORE

RUN colcon build --symlink-install

# Source ROS 2 setup in the shell environment
RUN echo "source /opt/ros2/install/setup.bash" >> ~/.bashrc

RUN dnf clean all
12 changes: 12 additions & 0 deletions subsystems/ros2/ros2-rolling.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=ROS 2 Container Development env
After=network.target

[Container]
Image=quay.io/qm-images/ros2:rolling

# Automatically restart the container if it stops
Restart=always

[Install]
WantedBy=multi-user.target

0 comments on commit 4672dfd

Please sign in to comment.