foxglove / mcap

MCAP is a modular, performant, and serialization-agnostic container file format, useful for pub/sub and robotics applications.
https://mcap.dev
MIT License
533 stars 99 forks source link

Support ros2 actions #337

Open wkalt opened 2 years ago

wkalt commented 2 years ago

Currently the mcap ros2 profile does not specify how actions should be recorded. The profile should be updated to cover actions, and the CLI tool's ros2 bag converter also updated with the desired approach.

wkalt commented 2 years ago

I recorded a bag with some actions using the turtlesim node and my arrow keys for navigation. Observations:

turtlesim/action/RotateAbsolute.idl

// generated from rosidl_adapter/resource/action.idl.em
// with input from turtlesim/action/RotateAbsolute.action
// generated code does not contain a copyright notice

module turtlesim {
  module action {
    @verbatim (language="comment", text=
      " The desired heading in radians")
    struct RotateAbsolute_Goal {
      float theta;
    };
    struct RotateAbsolute_Result {
      @verbatim (language="comment", text=
        " The angular displacement in radians to the starting position")
      float delta;
    };
    struct RotateAbsolute_Feedback {
      @verbatim (language="comment", text=
        " The remaining rotation in radians")
      float remaining;
    };
  };
};

RotateAbsolute.action:

# The desired heading in radians
float32 theta
---
# The angular displacement in radians to the starting position
float32 delta
---
# The remaining rotation in radians
float32 remaining

Compounding the confusion, the messages on this topic are not actually recorded by ros2 record - just the topics record. So it isn't easy to check the data and understand what is necessary to parse it.

jmarsik commented 2 years ago

If you need message definitions for them (.msg files), you can split the .action file by -- lines and artificially create 3 .msg files with corresponding suffixes.

But it's a surprise to me that ros2 bag record does not record them, I thought that it does! If you create those artificial .msg definitions, would it be possible to use your storage driver to record them?

Aposhian commented 2 years ago

compounding the confusion, the messages on this topic are not actually recorded by ros2 record - just the topics record. So it isn't easy to check the data and understand what is necessary to parse it.

ros2 bag record can record these, but they are hidden topics (denoted by the _action namespace), which are not recorded by default. You can record them by either adding --include-hidden-topics or by explicitly listing them as a topic to record like

ros2 bag record /my_action/_action/feedback /my_action/_action/status`