-
Notifications
You must be signed in to change notification settings - Fork 10
Design
The RIOT-ROS2 stack is based on 4 main components :
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.
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.
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.
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.
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.
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
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.