Local image and video archive¶
Capture one JPEG from /image, record a ten-second MP4 from the same topic,
then list saved files on the appliance. core.getImage returns the next frame
in memory; archive.captureImage and archive.captureVideo persist to disk.
Recording sessions are context-managed: use with session in Python or
await using session = await ... in TypeScript so stop() runs when the block
exits, including after errors. Calling stop() explicitly inside the block
is still fine — disposal is skipped once you have stopped.
import time
from olo import Client
# @olo-playground: autofill-sim-topics
TOPIC = "/image"
MESSAGE_TYPE = "sensor_msgs/msg/Image"
with Client() as client:
robot = client.robot()
# Capture one JPEG from /image and save it on the appliance.
snapshot = robot.archive.capture_image(topic=TOPIC, message_type=MESSAGE_TYPE)
print(f"Saved image: {snapshot.file_path} ({snapshot.file_size} bytes)")
# Record a 10s MP4 from the same topic.
with robot.archive.capture_video(topic=TOPIC, message_type=MESSAGE_TYPE) as session:
print(f"Recording video on {TOPIC} for 10s...")
time.sleep(10)
result = session.stop()
print(f"Saved video: {result.file_path} ({result.frame_count} frames, {result.duration_seconds:.1f}s)")
# List saved images and videos on the appliance.
print("Images:", [item.filename for item in robot.archive.list_images()])
print("Videos:", [item.filename for item in robot.archive.list_videos()])
import { connect } from "olo/node";
// @olo-playground: autofill-sim-topics
const TOPIC = "/image";
const MESSAGE_TYPE = "sensor_msgs/msg/Image";
const client = connect();
const robot = await client.robot();
// Capture one JPEG from /image and save it on the appliance.
const snapshot = await robot.archive.captureImage({ topic: TOPIC, messageType: MESSAGE_TYPE });
console.log(`Saved image: ${snapshot.filePath} (${snapshot.fileSize} bytes)`);
// Record a 10s MP4 from the same topic.
await using session = await robot.archive.captureVideo({
topic: TOPIC,
messageType: MESSAGE_TYPE,
});
console.log(`Recording video on ${TOPIC} for 10s...`);
await new Promise((r) => setTimeout(r, 10_000));
const result = await session.stop();
console.log(
`Saved video: ${result.filePath} (${result.frameCount} frames, ${result.durationSeconds.toFixed(1)}s)`,
);
// List saved images and videos on the appliance.
console.log(
"Images:",
(await robot.archive.listImages()).map((item) => item.filename),
);
console.log(
"Videos:",
(await robot.archive.listVideos()).map((item) => item.filename),
);