Python SDKGuides
Record a Session
Capture every state sample and every command as JSON lines.
Wrap any run and get a file you can replay, plot, or attach to a bug report:
with robot.record("run.jsonl") as rec:
robot.stand()
robot.wait_for(Mode.STAND, timeout=20.0)
robot.set_velocity(vx=0.3, duration=4.0, wait=True)
robot.stop()
rec.samples, rec.commands_writtenEvery state sample the robot sent and every command your script sent lands in run.jsonl,
one JSON object per line, in order. Nothing is sampled or averaged.
It is a context manager: recording stops when the block exits, including when it exits because of an exception — which is exactly the run you want the file for.
from menlo.asimov import recording
for row in recording.load("run.jsonl"): # dicts with kind "state" | "sent"
...What It Is Good For
- Bug reports. A refusal or a fall is much easier to read from the log than to describe.
- Comparing runs. The same script against the simulator and against hardware gives two files with the same shape.
- Checking your loop. Command timestamps show whether your control loop actually held its rate.
Next
- Read State and React — the fields you will find in the file
How is this guide?