Skip to content
PPHYSICAL AI GUIDESTART HERE →

Field guide

Robot Incident Recording: Build a Useful rosbag2 Replay

What to capture before a robot fails, how to check rosbag2 recording coverage, and how to replay evidence without confusing recorded outputs with new results.

By Physical AI Guide Editorial TeamPublished Updated

The short answer

Record the evidence needed to explain a decision, not only the robot’s final command. A useful incident package connects sensor inputs, frame and clock context, task state, issued commands, observed outcomes, and the software configuration that interpreted them. Then replay only the inputs required for a clearly defined test, with hardware isolated and original outputs kept separate from new results.

ROS 2’s rosbag2 records and plays back communications. It is not a complete copy of the robot, the workspace, or every internal state that influenced an action. The official Jazzy tutorial demonstrates recording selected topics, inspecting a bag, and playing it back. This guide builds an incident-review workflow around those documented capabilities.

The capture matrix and investigation sequence below are editorial engineering guidance, not results from a robot experiment. We reviewed the Jazzy documentation branches on October 27, 2026. Commands are documentation-based examples, not commands we executed on hardware. Check the installed package’s help because distribution labels alone do not identify every available option.

Define the question before choosing topics

A missed grasp, a delayed stop, and a lost task assignment need different evidence. Start with a question narrow enough that a recording could distinguish competing explanations.

For a missed grasp, for example:

  • Did perception identify the wrong target?
  • Was the target correct but transformed using the wrong frame or time?
  • Did the controller receive a valid command but execute it differently?
  • Did the grasp succeed initially and fail during the next movement?

A camera recording alone cannot distinguish all four. Neither can a command trace alone. Our coordinate-frame validation guide explains why a connected transform tree does not establish physical calibration. The incident package should preserve the calibration identity and relevant transform history so reviewers can examine that distinction later.

Write a capture contract

Use a small matrix that names the actual interface, its interpretation, and what its absence prevents you from concluding. The following is a proposed worksheet, not a universal list of ROS topics.

Evidence group Capture or preserve Question it helps answer
Observations Relevant sensor messages, acquisition timestamps, camera metadata, preprocessing configuration What information was available to the decision?
Geometry Frame identifiers, relevant transforms, calibration version, mounting configuration Where did the system believe the target was?
Task and authority Task identifier, operating mode, cancellations, controller ownership changes Was this command still authorized for this task?
Decision and command Model or planner output, selected command, limits applied, software and model versions What did the application request, and under which configuration?
Measured response Joint or base state, gripper feedback, application outcome, intervention markers What happened after the request?
Recording context Topic selection, effective QoS, recorder start and stop, clock mode, storage settings Which parts of the event could the recording have missed?

Not every item belongs inside a bag. Preserve configuration files, model identifiers, logs, and review notes alongside it when they are not published as messages. Identify unavailable fields explicitly. A manifest that says “controller internal state not captured” is more useful than a claim of complete reproducibility.

Do not assume ordinary topic selection captures every service interaction. The Jazzy tutorial’s service section describes service recording separately and requires service introspection to be enabled. Review the installed version and the application’s actual interfaces before declaring a task trace complete.

Prove that the recorder captured useful data

The official topic-recording example records turtlesim commands and pose together:

ros2 bag record -o subset /turtle1/cmd_vel /turtle1/pose

After stopping recording normally, its inspection step is:

ros2 bag info subset

The tutorial’s output includes storage format, duration, message totals, topic names, types, and per-topic counts. Use those fields as an initial coverage check, not a completeness certificate. A count does not show that every expected message arrived, that its timestamp is correct, or that it covers the failure interval.

Before a deployment, perform a non-motion capture check under representative traffic:

  1. Confirm each required interface exists and that the recorder subscribes to it.
  2. Inspect a short recording for the expected names, types, nonempty streams, and event coverage.
  3. Check that the timestamps and identifiers needed to align streams are present and meaningful.
  4. Compare recorder behavior with and without the expected camera and sensor load.
  5. Preserve warnings and gaps rather than silently treating an incomplete recording as normal operation.

The rosbag2 Jazzy README documents discovery of topics that appear after recording begins, as well as an option to disable discovery. Record which behavior the session used. A topic that appears in the final bag is not proof that it was captured from the beginning of the incident.

Treat recording QoS as part of the evidence

The official rosbag2 QoS guide says the tool adapts its requested or offered profile and attempts to preserve the original offered policy during playback. It also documents explicit per-topic overrides using --qos-profile-overrides-path.

That adaptation is not a reason to skip verification. Preserve the effective publisher, recorder, player, and receiving component profiles. If an override was necessary, retain the exact YAML and explain whether it applies to capture, replay, or both.

A missing stream may reflect compatibility rather than the robot publishing nothing. Conversely, receiving messages does not establish that they were fresh enough for the original task. Our ROS 2 QoS and stale-data guide separates delivery, compatibility, freshness, and physical response. Here, the narrower question is whether the recording supports the investigation you want to run.

Keep clock assumptions explicit

Write down which clock governs each timestamp and what the timestamp represents. Sensor acquisition time, message publication time, recorder time, and the time an application acts on the message are not interchangeable measurements.

The Jazzy rosbag2 README’s simulation-time section documents that recording with --use-sim-time uses the latest received /clock value for recorded message timestamps. It also says the recorder does not write messages until the first /clock message arrives. If that mode is enabled, verify clock startup rather than interpreting an empty early interval as proof that the robot was inactive.

For replay, document whether the receiving nodes use simulated time, who publishes the clock, and how the nodes are initialized. Changing playback speed or clock behavior changes the experiment. Do not combine results from different replay conditions without labeling them.

Snapshot mode needs a measured retention window

Continuous recording may be impractical for a high-volume stream. The Jazzy README describes snapshot mode as an in-memory circular buffer, sized with --max-cache-size, that can be written on request through the recorder’s snapshot service.

A byte budget is not a guaranteed number of seconds. Measure the retained interval under representative traffic, including bursts. Define who triggers a snapshot and how quickly that trigger can occur after a failure. Do not assume a later trigger captures post-event recovery or every earlier precursor.

For an incident review, preserve the observed start and end of the retained data, the trigger time, and any known missing interval. Choose the buffer and trigger policy from those requirements, not from an unexplained default.

Replay inputs without replaying the answer

Define the component under test before launching playback. For a perception regression, recorded images and required camera metadata may be inputs; original detections are comparison evidence. For a planner regression, recorded scene estimates may be inputs; original plans are the baseline. Neither comparison becomes valid just because both streams can be published.

Use this separation:

  1. Original evidence: Keep an unchanged copy of the captured bag and its manifest.
  2. Selected inputs: Publish only the interfaces required by the test.
  3. New execution: Run the named component version with documented configuration and initial state.
  4. New outputs: Capture its results separately from the original outputs.
  5. Comparison: Evaluate a stated criterion, such as target identity, timing, or command differences, and preserve unresolved cases.

Publishing original outputs into the same interface as newly generated outputs makes provenance ambiguous. It can also bypass the component you intended to evaluate. Namespace separation and topic selection should be reviewed as part of the test design, not improvised after the comparison fails.

Replay is active communication, not passive viewing. Isolate the test environment from production hardware and external side effects. A recorded command must not regain physical authority merely because a player republishes it. This isolation recommendation is an engineering boundary, not a claim that rosbag2 supplies a certified safety mechanism.

What replay can and cannot establish

The official turtlesim tutorial explicitly notes that its replayed path is not exactly identical because turtlesim is sensitive to small timing changes. Do not promote a successful playback into a stronger reproducibility claim than the experiment supports.

A bounded conclusion might be:

With these captured inputs, configuration, initialization, and replay conditions, the new perception component selected a different target. Physical grasp performance has not been retested.

That is different from “the robot is fixed.” Captured inputs do not respond to the new controller’s actions the way a physical environment would. A different command could have changed later observations, contact, or operator intervention. Use replay to narrow a hypothesis, then design the next appropriate simulation or supervised physical test.

Hand off an investigation package, not an unexplained file

Before sharing a recording, include:

  • the incident question, event interval, and task identifier;
  • the capture matrix, missing streams, and known recorder warnings;
  • software, model, calibration, interface, and configuration versions;
  • clock assumptions, QoS settings, and replay prerequisites;
  • original versus newly generated output locations;
  • the comparison criterion and remaining alternative explanations;
  • access restrictions, retention decisions, and permission to share captured scenes.

Review images, audio, location information, and operational context before distribution. Keep an access-controlled original and identify any redacted derivative so the next reviewer knows what changed. This is a data-handling recommendation, not a statement about a particular organization’s legal obligations.

A good handoff lets the next engineer answer three questions: What was captured? What experiment was actually run? What remains unknown? That makes a replay useful even when it cannot settle the root cause.

Before comparing replay timestamps, use the sensor-timing acceptance worksheet to distinguish clock domains, timestamp pairing, and age at the decision point.

Sources and scope

These are first-party technical references, reviewed October 27, 2026. The linked Jazzy branches can receive updates. No deployment statistics, measured rosbag performance, or independent robot trials are claimed here.

  1. ROS 2 Jazzy: Recording and playing back data, selected-topic capture, inspection, playback, timing limitation, and service introspection.
  2. ROS 2 Jazzy: rosbag2 QoS overrides, profile adaptation and explicit recording or playback overrides.
  3. rosbag2 Jazzy README, topic discovery, simulation-time recording, snapshot buffer semantics, and installed-command help.

Frequently asked questions

Does a rosbag recording prove why a robot failed?

No. It preserves the messages captured by the recorder. Missing inputs, unrecorded configuration, clock differences, and state outside those messages can leave competing explanations unresolved. Record the evidence boundary beside the diagnosis.

Should a robot replay publish every recorded topic?

Not automatically. For a component regression, supply the recorded inputs to the component under test and keep original outputs separate from newly generated outputs. Replaying both as if they were fresh results can contaminate the comparison.

Does rosbag2 snapshot mode preserve a fixed number of seconds?

The reviewed Jazzy README describes an in-memory circular buffer sized with max-cache-size, then written on a snapshot request. It is a byte budget, not a guaranteed time window. Measure retained duration under representative traffic.

Is successful replay equivalent to a successful physical robot test?

No. Replay can test a component against captured inputs, but it does not recreate the physical feedback loop. Even the official turtlesim tutorial notes that small timing differences can change the replayed path.