Skip to content
Loïc Dauphin edited this page Feb 8, 2018 · 1 revision

Design

The RIOT-ROS2 stack is based on 4 main components :

1 The toolchain file ament2riot.cmake

ament2riot.cmake is a toolchain-like file that is supposed to be usable as any CMake cross-compilation toolchain. The idea of this file comes from the ROS2 ARM cross-compilation toolchain file.

Since the aim of this project is to cross-compile for microcontrollers, this is quite understandable. But actually this file does not configure CMake/Ament to use a cross-compilator, it configure CMake to transform an Ament package into a RIOT module. It is mainly done by modifying the behavior of the CMake commands add_executable and add_library.

Since Ament/CMake and RIOT have hardly compatible build systems, this was the easiest way to go.

1.1 The beginning : manual transformation

Since ROS2 needs some code generation for ROSIDL, which is scheduled from CMake, my first action was to copy/paste the output of this generation to my repository, and transform it into a RIOT module (with a simple Makefile).

But this was very limited because the system could not generate the code for new ROSIDL messages. Also since all ROS2 package were manually transformed into RIOT modules, any update would be (and have been) painful.

1.2 Generate RIOT modules with CMake

The second step was to modify CMakeLists.txt to make them generate RIOT modules instead of compiling the sources. This enables the ROSIDL code generation, but all the ROS2 packages still needed to be manually modified to support microcontrollers.

1.3 Modify the CMake behavior with a CMake toolchain file

Once the transformation of Ament package to RIOT modules were mastered, a way to get the same behaviour without modifying the original CMakeLists.txt was developed.

2 The ROS Client Library for C

While ROS2 already supported rclcpp, it could not be used on microcontroller because of the use of the C++14 standard. So an simple implementation of rclc was developed, and is a candidate to the "main" rclc.

Currently, only the Publish/Subscribe part of the API is defined and implemented.

3 The NDN-based ROS MiddleWare

Since I was not able to compile any DDS implementation of previous attempts (ros2_embedded_nuttx, freertps), I tried to find a good alternative protocol : NDN.

NDN was already ported on RIOT, and was tiny enough to fit on the targeted microcontrollers. See this paper for more detailed information

4 The CBOR-based ROSIDL

While DDS was managing the data serialization, NDN needed some. CBOR was the most obvious choice (for memory size). It was incorporated into the ROSIDL code generation instead of using the "introspection" default generator, because it is less memory-consuming.