ROSCon 2022

micro-ROS goes Automotive: supporting AUTOSARbased microcontrollers
Jan Staschulat and Ralph Lange, Bosch ResearchLinux-based
computerSensors,Actuators
 300 MHz Clock Frequency
 1 MB SRAM AUTOSAR Classic2

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. 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 Architecture
Application
component

C API

…

rcl + rclc:Application
component

Application
component…

Application
component

Convenience functions,executor, node graph, …

Micro XRCE-DDS Client

DDS-XRCE

Adaptermicro-ROS
AgentDDS

rmw – middleware interface

ROS 2stack

UART, IP, Bluetooth, …

POSIX interface
Additional drivers

FreeRTOS, Zephyr, NuttX, …
microcontroller
3

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Linuxmicroprocessor

Modified Architecture
Application
component

C API

…

rcl + rclc

Application
component

Application
component…

Application
component

Convenience functions,
Newnode
Executor
executor,graph, …

Micro XRCE-DDS ClientCAN
as customtransport…
UART,
IP, Bluetooth,in Micro XRCE-DDS

micro-ROS
AgentDDS

Adapter

DDS-XRCE

rmw – middleware interface

ROS 2
stack

POSIXcompatibility
interface layer
CLib + POSIX
Additional drivers

4

AUTOSAR Classic
FreeRTOS,
Zephyr,BODAS
NuttX,(here with Rexroth’s
API)…

Linuxmicrocontroller

microprocessor

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Challenge 1: Mapping ROS Execution to AUTOSAR Tasks

Node 1 Executor

Node 2 Executor

5

ROS 2

AUTOSAR Classic

POSIX threads

Fixed Periodic Task Scheduling

cb1

cb2?

cb3

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Solution: Dispatching Executor
ROS 2Middleware

AUTOSAR ClassicExecutorabMiddleware

1 kHz

50 Hz(Executor)

Task

Task

a
rcl_wait()b

rcl_take()

rcl_wait()

rcl_take()cb_1(a)cb_2(b)Available in github.com/ros2/rclc (for Rolling)
6

1 kHz Task

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

cb_1(a)cb_2(b)Challenge 2: Handling blocking initializations in rcl and rmw
On AUTOSAR Classic

On POSIX
ClientClientClientClient???

Agent

7

Agent
time

time

Client thread waits for Agent‘s reply

Periodic tasks cannot wait in stack

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Solution: Refactoring into state machineState machine
Create entity
ClientSent request

Received
response

Agenttime

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Solution: Refactoring into state machineState machine
Create entityClient

Sent request

Received
response

Agenttime

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Solution: Refactoring into state machineState machine
Create entity
ClientClientSent request

Received
response

Agenttime

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Solution: Refactoring into state machineState machine
Create entity
ClientClientSent request

Received
response

Agenttime

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Solution: Refactoring into state machineState machine
Create entity
ClientClientClientSent request

Received
response

Agenttime

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

How to model the performance of a micro-ROS application?
Application Model#subscriptions
message size
data ratecb1

cb2
micro-ROS stack

Micro-ROS Model

Hardware Model
Execution time

13Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Demonstrator with BODAS Controller by Bosch Rexroth

14

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Results

 Runtime overhead by micro-ROS
stack is < 3%
 … despite quick user code callbacks

 Model estimates response times witherror of ≈6%

15

Jan Staschulat (CR/ADI1.2) and Ralph Lange (CR/AD CE-RSE) | 2022-10-21© Robert Bosch GmbH 2020. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Real HWModel

min latency [us]

970

1029

avg latency [us]10320

n/amax latency [us]

19978

20070

Ported micro-ROS stack to AUTOSAR-based platform rclc Dispatching Executor to map execution model Refactored blocking initializations into state machines Support for classical CAN as custom transport micro-ROS performance model in Amalthea
 Many thanks to Kaiwalya Kalyan Belsare and Suraj Rao Bappanadu
for the contributions in their Master’s theses!
Learn more?
 Jan.Staschulat@de.bosch.com | github.com/JanStaschulat Ralph.Lange@de.bosch.com | github.com/ralph-lange… also see upcoming chapter “micro-ROS”
in Springer’s ROS Book Vol. 7