Skip to content

Commit

Permalink
specification: add ros2idl to MCAP spec appendix
Browse files Browse the repository at this point in the history
  • Loading branch information
james-rms committed Aug 24, 2022
1 parent 430745c commit f3119e7
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
76 changes: 73 additions & 3 deletions docs/specification/appendix.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,19 @@ Schema `encoding` may only be omitted for self-describing message encodings such

- `name`: A valid [package resource name](http://wiki.ros.org/Names#Package_Resource_Names), e.g. `sensor_msgs/PointCloud2`
- `encoding`: `ros1msg`
- `data`: Concatenated ROS1 .msg files
- `data`: ROS1 .msg files, concatenated with [`gendeps`-style message definition delimiting](#gendeps-style-message-definition-delimiting)

### ros2msg

- `name`: A valid [package resource name](http://wiki.ros.org/Names#Package_Resource_Names), e.g. `sensor_msgs/msg/PointCloud2`
- `encoding`: `ros2msg`
- `data`: Concatenated ROS2 .msg files
- `data`: ROS2 .msg files, concatenated with [`gendeps`-style message definition delimiting](#gendeps-style-message-definition-delimiting)

### ros2idl

- `name`: A valid [package resource name](http://wiki.ros.org/Names#Package_Resource_Names), e.g. `sensor_msgs/msg/PointCloud2`
- `encoding`: `ros2idl`
- `data`: ROS2 .idl files, concatenated with [`gendeps`-style message definition delimiting](#gendeps-style-message-definition-delimiting)

### jsonschema

Expand Down Expand Up @@ -118,4 +124,68 @@ The `ros2` profile describes how to create MCAP files for [ROS 2](https://docs.r

#### Schema

- `encoding`: MUST contain `ros2msg`
- `encoding`: MUST contain either `ros2msg` or `ros2idl`

## `gendeps`-style message definition delimiting

For ROS1 and ROS2 message types, the message definition is stored in the [Schema record](./README.md#schema-op0x03) along with the definitions of any non-primitive field types. These definitions are concatenated together using a simple delimiting scheme:

- The full content of the top-level message definition file is stored first.
- for each dependent definition, first a "separator" is inserted. A separator consists of:
- a line containing only `=` characters, with more than one `=` character, then
- A line containing only `MSG: <package resource name>` for the following message definition.
- The full content of the next message definition file is inserted after that.

This scheme has its roots in [ROS1 gentools](http://wiki.ros.org/roslib/gentools). The scheme described here can be produced for ROS1 `.msg` definitions using `gendeps --cat`.

### Example

The common `diagnostic_msgs/DiagnosticArray` message definition would be stored in a schema record as follows:

- `name`: `diagnostic_msgs/DiagnosticArray`
- `encoding`: `ros1msg`
- `data`:

```
# This message is used to send diagnostic information about the state of the robot
Header header #for timestamp
DiagnosticStatus[] status # an array of components being reported on
================================================================================
MSG: std_msgs/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data
# in a particular coordinate frame.
#
# sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
string frame_id
================================================================================
MSG: diagnostic_msgs/DiagnosticStatus
# This message holds the status of an individual component of the robot.
#
# Possible levels of operations
byte OK=0
byte WARN=1
byte ERROR=2
byte STALE=3
byte level # level of operation enumerated above
string name # a description of the test/component reporting
string message # a description of the status
string hardware_id # a hardware unique string
KeyValue[] values # an array of values associated with the status
================================================================================
MSG: diagnostic_msgs/KeyValue
string key # what to label this value when viewing
string value # a value to track over time
```
1 change: 1 addition & 0 deletions python/mcap/mcap/mcap0/well_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SchemaEncoding:
Flatbuffer = "flatbuffer"
ROS1 = "ros1msg"
ROS2 = "ros2msg"
ROS2IDL = "ros2idl"
JSONSchema = "jsonschema"


Expand Down

0 comments on commit f3119e7

Please sign in to comment.