Introduction

The aim of this project is to provide a set of tools and tutorials to make robot development and operations easier.

Project goals

The project is concerned around the following ideas and goals (in no particular order).

  • Document using ROS2 in distrobox
  • Document using Neovim to develop ROS2 nodes (with working autocomplete, etc.)
  • Solve running integration tests in gazebo in CI
  • Solve continuous deployment for robots
  • Test and document existing Rust for ROS2 solutions
  • Describe using microROS with Rust embedded

MicroROS with embedded Rust

The Freyr project currently contains a proof of concept of MicroROS bindings for use with Rust. You can find the PoC here. The PoC currently only supports RP2040 and has many shortcomings documented in its README.

The Ultimate ROS2 Development Setup

This chapter goes over configuring your system to achieve maximal ergonomics when developing ROS2 systems. On the other hand it is meant to be more like a cookbook with useful snippets providing some sane defaults for tools commonly used when developing with ROS2. Meaning, that it is up to you, which of these you want to include in your setup.

Using ROS2 with Neovim

Developing for ROS2 with Neovim works almost out of the box. To kickstart working with Neovim as an IDE for ROS2, we recommend either creating your own config based on kickstart.nvim, or using our basic Neovim config tailored for getting started with ROS2, which can be found here.

In any case, in your Neovim config, you should have installed and working:

  • clangd LSP
  • pyright LSP (requires working node and npm, to manage these, we recommend using asdf)
  • treesitter setup for c++ and python

For installation of LSPs, we recommend using mason.

LSP integration for python works automatically when you open Neovim from a terminal with sourced ROS2 environment. In the case of clangd, colcon needs to instruct CMake to export compile commands. A useful shell alias for doing this is:

alias cb="colcon build \
    --symlink-install \
    --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
    && source install/setup.zsh"

Running ROS2 in Distrobox

ROS2 currently supports a limited set of operating systems. This makes sense from the maintenance standpoint, but greatly complicates things when upgrading to new ROS/OS version or when you simply don't want to use Ubuntu, but stick to your fine-tuned Arch installation.

It is possible to run ROS2 in Docker, but setting it up is quite cumbersome. This is where Distrobox come into play. Distrobox is a thin wrapper around docker, that provides seamless integration with the host filesystem, display manager and other hardware.

Let's get started by installing distrobox.

sudo pacman -S distrobox

Now, you can create your first distrobox container.

We recommend using a different home directory for the container to avoid clashing between tool versionsand their configs. You can then symlink only parts of your dotfiles to the container.

distrobox create \
    --name ros2-humble \
    --init \
    --image osrf/ros:humble-desktop 
    --additional-packages "systemd libpam-systemd pipewire-audio-client-libraries" 
    --home $HOME/distrobox/humble

This command creates a new container based on the osrf/ros:humble-desktop, sets it up with an init system (systemd in this case), installs some recommended packages and configures it to use a home directory other than your home directory.

Now, you can start the container using:

distrobox enter ros2-humble --clean-path --no-workdir

The --clean-path argument is important as it avoids your local software to leak into the container.

--no-workdir makes the container start in its own directory.

The container welcoms us with a pretty bare ZSH shell.

Let's do some quality of life improvements before starting our first nodes.

We can create and modify the .zshrc to source ROS and to set domain id.

source /opt/ros/humble/setup.zsh
export ROS_DOMAIN_ID=1

You can also install an editor and terminal multiplexer.

Beware of TMUX, there are some defaults that are not quite sane for the purposes of ROS development.

After sourcing the file, you can run your first ROS nodes.

In a first terminal:

ros2 topic pub /hello std_msgs/String '{"data": "world"}'

In a second terminal:

ros2 topic echo /hello

You should see messages being sent over the topic.

To check that GUI apps work, let's also try launching RVIZ.

ros2 run rviz2 rviz2

That is all there is to it, you now have a working distrobox container with ROS.