Micro-ROS – bringing the most popular robotics middleware onto tiny microcontrollers
Bosch Research Blog | Post by Ralph Lange, 2021-01-14
The Robot Operating System (ROS) is the most important robotics middleware that enables developers to build complex robot applications in less time. So far, for low-level functions such as control, sensor and actuator access running on on-board microcontrollers, a seamless middleware integration was not possible. Micro-ROS, launched by a European research initiative, addresses this point and brings ROS onto microcontrollers.
We will describe how in the last months, Bosch Research and its partners developed relevant API features for execution management and runtime configuration, added support for the popular ESP32 microcontroller family, and integrated micro-ROS with two further open-source real-time operating systems, namely FreeRTOS and Zephyr.
What is ROS?
With tens of thousands of users, the Robot Operating System (ROS) is the most important robotics middleware developed in a global open-source endeavor under a permissive license model. ROS provides communication mechanisms and a component model to build up complex robotics systems in a modular architecture. It provides tools for deployment, monitoring, introspection, data visualization and simulation. And it provides base algorithms for almost all aspects of robotics, such as localization, path planning, navigation and motion control. All these features facilitate robotics software developers to focus on application-level functionalities and thus on the differentiating part of the software stack. However, the most important characteristic of ROS is the global community. Thousands of robotics software developers – from PhD students to professional developers – are advancing to the middleware functionalities of ROS or provide application-level software components. ROS is backed by a California-based nonprofit public benefit corporation and a technical steering committee with a couple of renowned industrial players including Bosch.
What is micro-ROS?
ROS has been developed for use on microprocessors, assuming several hundred megabytes of RAM at the minimum. This applies to both the classic ROS and the current version named ROS 2. However, robotic systems usually are networks of one or more microprocessors with several microcontrollers. The microcontrollers are used to access sensors and actuators, to implement control functions with hard real-time requirements or to embed safety mechanisms. Obviously, ROS cannot be used directly on a microcontroller that features only a few kilobytes of RAM. Also, the development tools and operating systems for microcontrollers are very different. That is why Bosch Research and three partners collaborate in the to bridge this gap using micro-ROS.
Major project goals
Seamless integration of microcontrollers with ROS 2
Facilitate portability of ROS 2 code to microcontrollers
Ensure long-term maintenance of micro-ROS stack
Overview of micro-ROS architecture
Figure 1 depicts the architecture of the micro-ROS stack. As far as possible, micro-ROS reuses existing layers of the standard ROS 2 stack to ensure compatibility and to ease maintenance. However, there are three important differences:
1. Due to its dynamic memory requirements, the ROS 2 C++ API (rclcpp) cannot be used on many microcontrollers. Instead, micro-ROS enriches the existing ROS 2 Client Support Library (rcl) by a small library rclc, which together offer a complete C API optimized for microcontrollers. The rclc provides mechanisms for execution management and runtime lifecycle management as well as convenience functions for rcl.
2. Micro-XRCE-DDS, an open-source implementation of the new DDS standard for Extremely Resource-Constrained Environments (XRCE), is used as communication middleware. It couples with the standard DDS middleware used in ROS 2 by the micro-ROS agent. The agent takes over discovery and QoS mechanisms that are too computationally expensive for the microcontroller.
3. A real-time operating system (RTOS) optimized for microcontrollers is used on the lowest layer instead of a desktop operating system such as Linux, macOS, or Windows. For interoperability with the upper layers, micro-ROS requires the RTOS to provide a POSIX interface.
Advanced execution management with the rclc Executor
The contributions by Bosch Research to micro-ROS are focused on the APIs for user code. In the last months, we added new concepts for execution management – as part of the rclc Executor – to meet typical use-cases in robotics systems:
- Sense-plan-act pipelines: Such pipelines can be considered as control loops distributed to multiple software components, i.e. ROS nodes. The rclc Executor ensures that algorithms of the different components are executed in the order of the pipeline to minimize latencies.
- Synchronization of multiple rates: Fusing sensor data from multiple sources is a common task in robotics. This requires aligning the computations to the sampling rates of the sensors. The rclc Executor allows synchronizing the computations with these rates in a deterministic fashion.
- High-priority processing path: Often, the same data is processed by multiple components concurrently. The rclc Executor allows specifying a fixed priority order to ensure that time-critical components are executed before others.
Finally, the rclc Executor implements relevant parts of the Logical Execution Time (LET) semantics, a widely used mechanism in deeply embedded systems to ensure deterministic communication between concurrent tasks or processes.
Runtime lifecycle and system modes
The lifecycle is a new concept introduced with ROS 2. It specifies a fixed set of component runtime states (unconfigured, inactive, active, error-processing, etc.) and transitions between them. This results in more control over start and shutdown of the components. The new rclc_lifecycle package brings the same concept to micro-ROS and thus onto microcontrollers.
Furthermore, we developed a package named system_modes which (1.) allows extending the lifecycle state active by custom modes and, in a similar fashion, (2.) brings the lifecycle concept to the whole hierarchy of a robotics software system. For this, a model-based approach is used: The whole system hierarchy, the lifecycle states and modes of the components and subsystems are specified in a lightweight format in a YAML file. In this file, the mapping between states and modes of subsystems to the individual components is also defined. During runtime, the system modes manager reads this YAML file and infers the overall system state from the component states. Vice versa, it can reconfigure the individual components by means of a requested subsystem state and mode as illustrated in Figure 2.
Support of FreeRTOS and Zephyr
In the last months, our partner eProsima, who coordinates the EU-funded OFERA project, integrated the open-source systems RTOS FreeRTOS and Zephyr into the micro-ROS build system. With them, micro-ROS provides built-in support for three open-source RTOS.
Both FreeRTOS and Zephyr unlock important communities for micro-ROS, and we are convinced that micro-ROS will unlock the ROS community for those RTOS.
Support for ESP32 microcontrollers
The ESP32 is an important microcontroller family, which is especially known for its use in the maker culture. At Bosch Research, we have been using the ESP32 in various prototypes and demonstrators. Because of its importance, we have integrated the ESP32 toolchain in the micro_ros_setup tools. Furthermore, our OFERA partner eProsima built an ESP-IDF component for micro-ROS. Hence, whatever you prefer – the ROS-based toolchain or the Espressif IoT Development Framework – you can directly build micro-ROS applications for the ESP32.
We are happy to see the adoption of micro-ROS by the ROS community. The various demos that have been developed by open-source contributors in the last months demonstrate that micro-ROS has achieved the desired seamless integration and portability with ROS 2. The growing community around micro-ROS makes us confident that its long-term maintenance will be ensured after the end of the EU-funded OFERA project. At Bosch Research, we are proud to have given birth to this open-source project. Checkout out micro-ros.github.io for more information and first-user tutorials. Furthermore, we would like to invite you to participate in the next meeting of the ROS Embedded Working Group, which is held monthly.
Links and references
- Micro-ROS overview and first-user tutorials:
- Technical description of rclc package:
- Technical description of system modes:
- Micro-ROS demo application for ESP32:
- Article at FreeRTOS blog about micro-ROS:
- Article at Zephyr website about micro-ROS:
Micro-ROS is developed in the OFERA project, which is funded by the European Union‘s Horizon 2020 research and innovation programme under grant agreement No 780785.
What are your thoughts on this topic?
Please feel free to share them via LinkedIn or ResearchGate or to contact me directly.
Author: Ralph Lange
Ralph studied computer science and electrical engineering at the University of Stuttgart, Germany, where he also obtained a PhD in the field of context-aware computing in 2010. As a software engineer for TRUMPF Machine Tools from 2010 to 2012, he worked on the CAD/CAM system TruTops for graphical NC programming of punching and punch-laser machines, concentrating on algorithms for skeleton-free processing of sheet metal. Ralph joined Bosch Research in January 2013, working as a research engineer on formal analysis and modeling methods for embedded systems, particularly in robotics. Since 2016, he has been leading a Bosch-internal research project on system and software engineering in robotics, which not only supports the Bosch business units on the use of ROS but also contributes to the development of ROS. He also is Principal Investigator in the EU-funded OFERA project, which forms the nucleus for the development of micro-ROS.