NEWAI chat: ask your fleet anything, in plain language. Chat with your fleet Read more →

A flight recorder for robots. How to capture and replay incidents in production

Logs can't show what a robot saw when it failed. How to record cameras, ROS, model decisions and metrics around incidents as MCAP, and replay them.

Illustration for "A flight recorder for robots": a drone, a camera, with the label "● recording last 5 min"

It's Monday morning. A customer emails: one of the arms dropped a part on Saturday night and stopped. Someone on the night shift restarted it and it's been fine since.

You open the logs. There's a line from the controller saying the goal was aborted. A few seconds before it, nothing interesting. CPU was normal. Memory was normal. The model process never crashed.

So what happened?

You can't ask the robot. You can't ask the night shift, who saw the arm stopped but not why. You can try to reproduce it in the lab, but you don't know what the bin looked like, where the part was, or what the light was doing at 11 p.m. on a Saturday. You end up writing "could not reproduce" in the ticket, and you wait for it to happen again.

Airplanes solved this decades ago. When something goes wrong, the recorder already has the last minutes of everything. Robots need the same thing, and I'd argue they need it more.

The short answer: Keep a rolling buffer on the robot with the last few minutes of camera frames, ROS messages, model inputs and outputs, metrics and logs, and save a window around the event when a trigger fires. Store it as MCAP so everything sits on one timeline and opens in standard tools. Then replay it from the trigger backwards, next to a good cycle of the same task.

Why robots need this more than other machines

A robot running a learned policy is a living mind. It looks at the world and decides what to do many times a second. Its model changes when you ship a new checkpoint. The world around it changes every day. And it's far from you, doing real work for a customer.

With a fixed program, a log line usually tells you which branch ran and why. The logic is in the code, and the code is in git.

With a model, the "why" lives in the inputs. The same weights will grip correctly a million times and then fail on one frame where a reflection made the part look like it was somewhere else. Nothing in the logs will tell you about that reflection. To understand the failure you need to see what the robot saw, what the model decided, and what the body actually did. All three, on the same clock.

Why logs aren't enough

Logs are still useful. Keep them. But think about what they miss for a robot:

  • They don't contain the inputs. A log says "grasp failed". It doesn't contain the camera frame, the joint states or the task prompt the model got.
  • They're written by the developer, ahead of time. You log what you thought might go wrong. The failures that hurt are the ones you didn't think of.
  • They're not synchronized with motion. Log timestamps, ROS message timestamps and camera timestamps come from different places. Lining them up by hand at 2 a.m. is how people lose a day.
  • They describe the software, not the body. A motor that lagged behind its planned trajectory by 0.2 rad shows up in controller feedback, not in your app's log.

What you want is a short, complete, synchronized recording of the moment.

What to record

I'd record everything that could explain a decision or a movement, and nothing else. Concretely:

  • Camera frames. What the robot saw. Not at full resolution and not at full rate, more on that below, but enough to see where the part was and what the scene looked like.
  • Model inputs and outputs. The task prompt, the shapes of the observations, the action chunk the model returned, how long inference took, and whether any action was NaN or jumped sharply from the previous chunk.
  • ROS traffic that describes the body. Joint states, planned trajectories, controller feedback, TF, wrench readings. This is how you see the difference between "the model asked for the wrong thing" and "the model asked for the right thing and the arm didn't do it."
  • `/rosout` and diagnostics. Warnings from drivers often explain everything. A camera driver complaining about dropped frames ten seconds before a failed pick is a strong hint.
  • System and app metrics. CPU, GPU, temperature, memory, control-loop rate. A board that started thermal throttling thirty seconds before the incident changes the whole story.
  • Logs and events. App logs, kernel messages, container restarts, config changes, reboots.
  • Context. Which release, which checkpoint, which config, which robot. A recording without the model version is a puzzle missing its corner pieces.

The thing that makes this useful is that all of it sits on one timeline. You drag a playhead and see the frame, the joint positions, the action the model chose and the log line, all at that instant.

When to record

The tempting answer is "record everything, all the time." Don't.

Continuous recording sounds safe, but it fails in practice. Video from two cameras around the clock is a lot of data. You can't upload it over a cellular link. You can't keep it on an SD card that's already half full. And nobody watches it. The interesting ten seconds are buried in a week of footage.

The pattern that works is the one airplanes use: a rolling buffer that's always recording on the machine, and triggers that decide which part of it to keep.

The rolling buffer

The device always holds the last few minutes of everything in a buffer, overwriting the oldest data as it goes. This costs some memory and disk, but almost no bandwidth, because nothing leaves the machine unless something happens. When a trigger fires, you freeze the buffer and save a window around the event: some time before, some time after.

The "before" matters most. Most failures start before they're visible. The camera froze twenty seconds before the arm missed. The loop rate dropped a minute before the timeout. If you only start recording when the error appears, you'll record the aftermath.

Triggers

Good triggers are specific and cheap to evaluate on the device:

  • An alert rule fires. Temperature, loop rate, topic rate, error rate. Evaluate rules on the device so they work when the network doesn't.
  • A process crashes or a container restarts.
  • A policy health check trips. NaN actions, a frozen camera, inputs outside the training range, the robot stopping while the model computes.
  • Tracking error crosses a limit. The arm drifted too far from its planned path.
  • A task cycle fails. This is the most useful trigger of all for robots that do repeated work.
  • Someone asks. An operator sees something strange and presses a button. Keep this option.

Failed cycles, and why you also need good ones

If your robot does repeated work, like picking, assembling, inspecting, mark the start and end of each cycle and whether it succeeded. Then a failed cycle becomes a trigger with natural boundaries: record from a little before the cycle started to a little after it ended. If you also mark steps inside the cycle, like pick_stator or insert_rotor, the recording shows exactly which step failed.

Then do the thing almost nobody does: keep some good cycles too.

A failed recording on its own is hard to read. Is that wrist angle normal? Does the gripper always pause there? You don't know until you put it next to a cycle of the same task that worked. Keeping one good cycle per task every hour or so is cheap, and it turns "something looks off" into "here, at step three, the arm went 4 cm lower than it does when it works."

Use MCAP as the format

Don't invent a format. Use MCAP.

  • It holds many channels on one timeline. Images, ROS messages, metrics, logs, each as its own channel with timestamps. That's exactly the shape of a robot incident.
  • It's self-describing. Schemas travel inside the file. You can open a recording from a robot you no longer have, running a message definition you've since changed.
  • It's indexed. You can jump to a time or read one channel without scanning the whole file.
  • It's the ROS 2 default. rosbag2 uses MCAP as its default storage format, so your robotics team already has tools that read it.
  • It's open. Your recordings stay yours, readable by many tools, including ones you write.

An incident file you can open anywhere is worth more than a nicer one locked in one viewer.

Storage and bandwidth budgets

A flight recorder that fills the disk is worse than no flight recorder. A robot that stops because its SD card is full of recordings of the time it stopped is not a joke I want to make twice.

Rules I'd follow:

  • Give the recorder a disk budget, and enforce it. A fixed share of the disk for the buffer, saved recordings and anything waiting to upload. When it's full, drop the oldest, never the system.
  • Keep recordings until they're uploaded. If the network is down, the recording waits on disk and goes when the link comes back. The incident you most need is often the one that happened while the robot was offline.
  • Downsample cameras. For most incidents, frames at 10 fps at reduced resolution tell you what you need. Full-resolution 30 fps is for training data, not for debugging.
  • Respect data plans. On cellular, set a daily or monthly data budget. Send essentials first: the event, metrics and logs. Frames can follow when there's room.
  • Bound the windows. The last five minutes before an incident, and a failed cycle plus about ten seconds before it and five after, are good defaults. If you need more than that, your trigger is probably too late.

Privacy: cameras see people

This part deserves more care than it usually gets.

Robots work near people. A camera pointed at a packing table also sees the hands, and sometimes the faces, of the people working there. Your customer will ask what leaves the building, and they should.

  • Send thumbnails, not footage. Small, low-rate frames in recordings are enough to debug, and much less sensitive than full video.
  • Make it possible to turn frames off. Some sites will want recordings with no images at all. The metrics, joints and model outputs still tell most of the story.
  • Let the customer lock the camera on the device. A setting on the machine that can't be turned back on from the cloud is a promise you can actually keep.
  • Mask secrets in logs before they leave. Tokens and passwords end up in log lines more often than anyone admits.
  • Write down what leaves. One page for customers saying exactly what a recording contains. It ends a lot of security reviews early.

How to replay an incident

Having the file is half of it. Here's the process I'd follow with a recording open:

  1. Start at the trigger and look backwards. Find the first moment anything looked different. That's usually well before the failure.
  2. Check the inputs first. Was the camera frame fresh, or the same frame repeated? Was the scene unusual? Was the joint state within the range the model was trained on?
  3. Then check the decision. Did the action chunk make sense for what the model saw? Did it jump from the previous chunk? Was inference slow enough to miss a control-loop deadline?
  4. Then check the body. Compare planned and actual joint positions. If the plan was right and the arm didn't follow it, look at controllers, motors and wrench, not the model.
  5. Then check the machine. Temperature, CPU, loop rate, recent config changes or restarts.
  6. Compare with a good cycle. Put the failed run next to a successful run of the same task and step through them together.

A 3D view helps a lot here. If the robot publishes its URDF, you can pose a model of the arm from the recorded joint states and draw the planned path as a ghost next to it. A tracking problem you'd never spot in a plot of six joint angles is obvious when you see the arm cut a corner.

This sequence also tells you who should fix it. Bad inputs point to the camera or calibration. A bad decision on good inputs points to the model, and that recording is now training data. My post on learning from the field is about what to do with it. Good decisions but late ones point to timing, which Eitan covers in his post on control-loop latency and jitter. If you don't yet have the per-inference data a recording needs, start with how to monitor a robot policy in production.

If you're building this yourself

A checklist:

  • A rolling buffer on the device covering cameras, ROS, model inputs and outputs, metrics, logs and events.
  • Triggers evaluated on the device, so they work offline.
  • Task cycles with steps, and failed cycles as triggers.
  • Good cycles kept for comparison.
  • MCAP files with the release, checkpoint and config inside.
  • A disk budget, and recordings kept until uploaded.
  • Downsampled frames, a way to turn them off, and a written privacy note.
  • A replay view that puts everything on one playhead.

How PhysicalFleet does it

In PhysicalFleet, the agent keeps the buffer and saves the last 5 minutes of metrics, logs, events, ROS logs and camera frames as MCAP when something goes wrong. Failed task cycles are recorded with step markers and replayed in the dashboard next to a good cycle, with a 3D arm built from the URDF and its planned path. Everything stays inside a disk budget and waits on the device while it's offline. We record triggered windows rather than continuous video, and for the reasons above I think that's the better default. More on our observability page.

If you've had to debug a robot incident from logs alone, I'd like to hear how you did it, and what you wish you'd had.

Common questions

What is a flight recorder for a robot?

It's a rolling buffer on the robot that always holds the last few minutes of camera frames, ROS messages, model inputs and outputs, metrics and logs. When something goes wrong, it saves a window around the event, including the minutes before it. That lets you replay what the robot saw and did instead of guessing from log lines.

What is MCAP and why use it for robot data?

MCAP is an open file format that stores many timestamped channels, like images, ROS messages, metrics and logs, on one timeline. It's self-describing, indexed so you can jump to a moment quickly, and it's the default storage format for rosbag2 in ROS 2. Your recordings stay readable by many tools, including ones you write yourself.

How much bandwidth does a robot flight recording use?

Very little most of the time, because the buffer stays on the robot and nothing is uploaded unless a trigger fires. When one does, you send a bounded window, like the last five minutes, with camera frames downsampled to around 10 fps at reduced resolution. On cellular, send the event, metrics and logs first, and let the frames follow when the data budget allows.

Should robots record video continuously?

For debugging, I don't think so. Continuous video from two cameras is too much to upload over cellular or keep on a small disk, and nobody watches it. A rolling buffer with triggers, like a failed cycle, a policy health check or a crash, keeps the moments that matter and lets the rest go.

How do I debug a robot failure I can't reproduce in the lab?

Get a recording of the moment, start at the failure and look backwards for the first thing that looked different. Check the inputs first, then the model's decision, then whether the arm followed the plan, then the machine itself. Putting the failed run next to a good cycle of the same task usually shows where the two split.

#robot incident replay#flight recorder#mcap#ros 2#robot debugging#robot observability#failed cycle recording
Amit EzerCo-founder, PhysicalFleet

From the lab bench. To the entire fleet.

Connect your first machine in minutes, develop it in the lab and run your whole fleet in production from one place.

Free for up to 3 machines · Then pay as you go