MICRO-ROS:
ROS2 ON MICROCONTROLLERSOFERA project
EU Grant 780785
www.ofera.eu

Micro-ROS: ROS2 on microcontrollers
Audience Check Disciplines: Computer science Electrical engineering Mechanical engineering Other?

 Who has used an Arduino or similar maker board?
 Who has written hardware drivers for ROS?

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Micro-ROS: ROS2 on microcontrollers
Microcontrollers are everywhere Typical applications
 Motor control
 Sensor interfaces (AD, post-processing)‒ Incl. sensor fusion

 Driving displays, LEDs, etc.
 Low-latency real-time control

 Characteristics
 Low power usage (up to battery operation for years)
 Very predictable execution times
 Hardware integration
 Many integrated I/Os (I²C, SPI, CAN, etc.)

 Sophisticated safety-rated versions available
CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

BUT: Development totally disconnectedfrom ROS-based development

4CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Micro-ROS: ROS2 on microcontrollers
Goals
Typical topology

 Run nodes on microcontroller seamlessly Publish/subscribe/services just workROS
Linux/Windows/Mac OS

 Parameters/lifecycle/… just workoptional

MCP
Serial/Bus/Wireless..
Firmware
MCU
Device (Sensor/Actuator)

5

 Take advantage of hardware features
 Power saving
 Hard real-time scheduling Easy hardware access Developer Experience Build using ROS tools Same codebase and APIs wherever possible

 Challenges
 Resource use (RAM, CPU, Disk) Different build-systems, OS, community expectation

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Micro-ROS: ROS2 on microcontrollers
Device Classes
ROS2

Micro-ROS

Hardware

X86, ARM Cortex-A, …

ARM Cortex-M, ….

Resources>512 MB RAM, >8 GB Disk

>100 KB RAM, >1 MB Flash

Communications

Ethernet, 802.11 WiFi

Serial, WPAN – 250 KBit - 1 MBit/s

Operating System

Linux, Windows, MacOS

RTOS (NuttX by default)

Middleware

DDS variant (by default)

XRCE-DDS (by default)

Middleware Abstraction RMW

RMWClient Support Library

RCL

RCL

Execution Layer

RCLCPP / RCLPY / …

RCL + RCLCPP

Executors

Generic

Micro-ROS custom6CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Micro-ROS: ROS2 on microcontrollers
Ingredients
Ease of use

MCU-targeted capabilities

Performance & Predictability

 Build system integration

 Middleware XRCE-DDS

 Executor performance Default configurations

 Custom executors

 Deterministic execution

 Default hardware
 Looking for collaborators!

 Tutorials
 Community demos E.g., static ordering MCU tracing and debugging
 Portability
 Transports extensible

 Slack channel
 Ready-to-use dockercontainers

7

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

 System Modes Benchmarking toolsmicro-ROS: ROS 2 on microcontrollers
Differences between ROS 2 and Micro-ROS

Systemmodes

Predictableexecution

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Copyright © 2019 Robert Bosch GmbHmicro-ROS: ROS 2 on microcontrollers
Target Devices
 Reference HW platform

STM32L1-DISCO

Olimex STM32-E407

 Cortex-M4 devices with ~100KB RAM‒ Olimex STM32-E407

 Cortex-M0 investigated but no longer pursued

 3rd Party platforms
 Renesas is on track to support GR-ROSEboards
 Sony has expressed interest in supporting theirSPRESENSE board

 RTOS Default RTOS is NuttX
 Intel has expressed interest in working onZephyr support
CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

GR-ROSEmicro-ROS: ROS 2 on microcontrollers
Build System: Background RTOS´s are complete packages including Scheduling (of course) Networking
 Standard libraries (libc, libm, libstdc++) etc
 Tools, and many more things

 RTOS´s are highly configurable
 Most things are turned off by default to save resources Every change can affect system headersRTOS‘s have relatively sophisticated, diverse and complex build systems
 Microcontrollers often build operating system and application into a single firmware image
 This includes all dependencies, e.g. ROS 2
 Everything is cross-compiled| 2019-10-31
10 CR/AEX3© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

micro-ROS: ROS 2 on microcontrollers
Micro-ROS Build Support
 See https://github.com/micro-ros/micro-ros-build/micro_ros_setup/ Features
 Creates the firmware workspace for you‒ RTOS‒ Apps‒ Necessary ROS 2 packages‒ Cross-compilation setup that avoids interference from already source ROS 2 host workspace Creates agent workspace for you Example: „ros2 run micro_ros_setup build_firmware.sh“ Upcoming work: Integrate as CMake macros for ease of use

11CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

micro-ROS: ROS 2 on microcontrollers
Executor Performance The current SingleThreadedExecutor adds measurable overhead For some use-cases, just polling the middleware already consumes 20% of CPU

 Nobleo has addresses this inrclcpp PR 873
 We‘ve also identified more
overhead in the rmw
implementations, this is current
work.

| 2019-10-31
12 CR/AEX3© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

micro-ROS: ROS 2 on microcontrollers
DDS meets MCUs: DDS-XRCE

OMG’s DDS-XRCE (DDS for eXtremely
Resource Constrained Environments)
brings DDS on MCUs
Based on Client-Server architecturePower-Saving
StatelessAgent acts on behalf of Clients (Lowresource devices) on the DDS global dataspace.

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Copyright © 2019 eProsima

micro-ROS: ROS 2 on microcontrollers
Micro XRCE-DDSeProsima C99 (Client) / C++11 (Agent)
implementation of XRCE protocol
Multiple and extensible transport support:
UDP/IP, TCP/IP, Serial … or create yourown!
Low memory usage (Client library):

Fast RTPS

Agent library API: micro-ROS-AgentROS 2

Open-source: https://github.com/eProsima/MicroXRCE-DDS/

Stack: ~2 KB
Heap: 0 KB (only static memory).Text (code in Flash): core: 64 KB +/- TCP
profile: 2 KB +/- UDP profile: 1 KB +/Serial profile: 5.5 KB …



Several success stories: Robotis,Renesas.
Crystal and Dashing enabled.

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

https://micro-xrce-dds.readthedocs.io/en/latest/

Copyright © 2019 eProsima

micro-ROS: ROS 2 on microcontrollers
Micro XRCE-DDS Client portabilityA) Clock dependency.
Relative clock measurement. Crazyflie
timer registers e.g.

Micro XRCE-DDS
ClockTransportPlatformB) Platform transports.
Simple pairs of functions required:Init/Close.
Write/Read.

Common platforms implementation
provided.

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Copyright © 2019 eProsima

micro-ROS: ROS 2 on microcontrollers
Drone demoCR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Status
CrystalDashing

No executor

LET executor

RMW Simple communication mechanisms.

RMW configuration.

Basic and nested type support, no arrays.

Full type support.

Next
Complete RMW Implementation.

NuttX firmware incorporated in build system.

Incorporate new platforms to build system. e.g. FreeRTOS

Plain C API support (RCL).

CPP API support (RCLPP) in some platforms.

Demos.

Demos and more tutorials.

Ready to use dockers.

ROS2 Packages.

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Copyright © 2019 eProsima

micro-ROS: ROS 2 on microcontrollers
Further informationAll open-sourced code at GitHub
 https://github.com/micro-ROS
Web-site: micro-ros.github.io
Slack micro-ros.slack.com
ROS 2 Embedded Working GroupROS Discourse in Embedded category
ROS 2 Embedded Design Page https://github.com/ros2/design/pull/197

CR/AEX3 | 2019-10-31© Robert Bosch GmbH 2019. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.