Sharing a tool we just open-sourced, in case it’s useful to anyone else thinking about the same approach.
The problem: on a robot, the data worth keeping is sparse — a few seconds around a disengagement, a near-miss, a moment perception got it wrong. But you can’t know an event mattered until after it’s already started, and a useful clip needs the lead-up, not just the aftermath. That preroll only exists if the data was already on disk when the event fired.
momentedge-clipper runs alongside an ordinary ros2 bag record, tails the growing MCAP file, and on each trigger cuts a standalone MCAP clip covering [trigger_time − preroll, trigger_time + postroll]. Recording stays rosbag2’s job; the clipper only extracts windows. The two communicate through the file on disk, nothing else.
A few design choices that might be relevant:
- It tails an already-on-disk recording, rather than buffering in RAM. This is the main difference from rosbag2’s snapshot mode: snapshot holds messages in a memory buffer and writes on trigger, so preroll is bounded by RAM and you only get what was buffered at trigger time. The clipper reads from the continuous on-disk recording, so preroll is bounded by disk, and a trigger can reach back into data that was written well before it fired.
- Decode-free. It copies MCAP message bytes straight through — channels and schemas carry over, message bodies are never deserialized. It’s agnostic to your message types.
- MCAP in, MCAP out. Clips are standard, complete MCAP files — they open in Foxglove, the
mcapCLI, andros2 bagreplay. No custom format on either side. - A trigger is just a topic. Anything that publishes
momentedge_msgs/Trigger— a fault detector, a watchdog, an operator button, your perception stack — can drive it. The clipper has no opinion about when something matters; it just captures the window you ask for.
It’s written in Rust (built on r2r), passes its e2e suite on Humble and Jazzy, and ships as Debian packages per distro. There’s a synthetic camera in-repo so you can exercise the whole thing without hardware.
It’s early and Apache-2.0. I’d genuinely like to know where it breaks against real recordings and real trigger sources — bug reports, design objections, and “why not just do X” questions all welcome.