ROS 2 types on the wire
Emerson Knapp (Bonsai Robotics)

Type descriptions and hashing in Iron…and beyond!

Terminology

ROS 2 Interface- Message, Service, Action- Topic Name + Type Name + QoS

Motivation: Evolving Interface Types

Existing types change

New types are deﬁned

Evolving Types:
End Goals

Dynamic comms:
Subscribe and publish
to types deﬁned atruntime
Make the dynamic
portion invisible automatically translatechanged type

Evolving Types: First Steps
Represent a typeCommunicate a uniqueand compact ID of types
to all participantsCommunicate full typeon request…then there’s a whole lot more to do,but this is an essential start!

Terminology

ROS 2 Interface- Message, Service, Action- Topic Name + Type Name + QoS
Type Description- What are the ﬁelds of an interface type?
Type Hash- Compact unique identiﬁcation for aninterface type, to detect changes
Type Source- Original text used to deﬁne a type- Could be .msg, .srv, .action, .idl

Representing types

TypeDescription
Interfaces

type_description_interfaces
For representing types:●●●●

TypeDescription.msg
IndividualTypeDescription.msg
Field.msg
FieldType.msg

Additionally, for transmitting types●●GetTypeDescription.srv
TypeSource.msg

Type Description Interfaces
TypeDescription.msg
IndividualTypeDescription
type_description
IndividualTypeDescription[] referenced_type_descriptions

IndividualTypeDescription.msg
string type_name
Field[] fields

Type Description Interfaces
Field.msg
stringnameFieldType typestringdefault_value

FieldType.msg
uint8 type_id
uint64 capacity
uint64 string_capacity
string nested_type_nameHashing types

ROS Interface
Hashing Standard(RIHS)

Type Description
Type HashRIHS●●●

Versioned, Iron has RIHS01
Goals○ Widely available tools○ Computable from received msg○ Versioned string representation
Two implementations built:● C (in rcl)
● Python(rosidl_generator_type_description)

RIHS01 Overview
1.
2.
3.
4.

Map TypeDescription -> JSON (skip default values!) -> text (speciﬁc formatting)Exact bytes of text -> SHA256
Preﬁx “RIHS01_” + hex-string of SHA256 (e.g. 01a5e….)
Result: 71 byte ﬁxed-length string output

Code Generation
Embedded in the C code generation for interface types, available via typesupport:●●●Type Hash
Type Description
Type Source text

For minimized builds:
Description and source can be disabled by a preprocessor deﬁnition--cmake-args -DROSIDL_GENERATOR_C_DISABLE_TYPE_DESCRIPTION_CODEGEN=ON

Type Hash Discovery
rmw_topic_endpoint_info_t contains new member type_hash

TopicPublishingNode

topic_nametype_name+type_hashqosSubscribing
NodeDistributing descriptions

Type Description Service●●●On discovering a Type Hash, want to get a Type Description
In Iron, ~/get_type_description service on Nodes, enabled by default
Controlled by Parameter start_type_description_service

GetTypeDescription.srv
string type_namestring type_hashboolinclude_type_sources true--boolsuccessfulstringfailure_reason
TypeDescription type_description
TypeSource[]
type_sources
KeyValue[]extra_information

…and beyond!

For more info

Design of these features in REP-2016(still under review)https://bit.ly/ros-rep2016

What’s missing?

●
●
●
●

Type Hash discovery for
Services and Actions
Constants / “Enums” in msgs, do theychange the hash? (not right now)
Automatic hash-mismatch detection
CLI tooling to fetch Type Descriptions

Future work:

Enable using Type Descriptions discovered
dynamically to subscribe and publish any type.

Dynamic Types

Especially useful for developer tools such as RViz,Foxglove, Rosbag2, PlotJuggler, etc

Author (mostly): Brandon Ong @methylDragon

DDS XTypes for implementation in DDS-based RMWs
Map between TypeDescription ↔ DynamicTypeFirst pass for Fast-DDS is in Iron RCL layer(rclcpp C++ API open as experimental PR)

Future Work:
Evolved TypeTranslation

Author (mostly): William Woodall @wjwwood
Long term plan with large scope, delivery TBD●●●

Provide plugin infrastructure to automaticallytranslate between versions of types as theyevolve over time
A translation function could be provided for any
pair of hashes - allowing for arbitrary complexityof translation chains
Type Description and Dynamic Types get closer
to these goals

See REP-2011 draft for details

Acknowledgements
My work on this project done on contract for Foxglove- not possible without them!

Chris Lalancette
William Woodall
Brandon Ong
And thanks to the entire ROS 2
contributor community!
(especially if you reviewed the PRs!)

Thank you!

Emerson Knapp
Staff Robotics EngineerBonsai Robotics

emersonknapp@bonsairobotics.ai
linkedin.com/in/emersonknapp
github.com/emersonknapp