Cerulion Core supports MCAP (Modular Container Format) logging, similar to ROS2 bag recording. You can enable logging on individual publishers/subscribers or use a standalone recorder.
MCAP is a container format for storing timestamped message data. It’s similar to ROS2 bag files but with better performance and cross-language support. Cerulion Core’s MCAP logging lets you record messages for later playback, analysis, or debugging.
MCAP logging is opt-in. You choose which publishers or subscribers should log their messages. This gives you fine-grained control over what gets recorded.
Enable logging on a subscriber to record all received messages:
Copy
Ask AI
use cerulion_core::prelude::*;use std::sync::Arc;// Create MCAP recorderlet recorder = Arc::new( McapRecorder::create("log.mcap", None, None)?);// Create subscriberlet mut subscriber = Subscriber::<SensorData>::create("sensors/data", None)?;// Enable MCAP loggingsubscriber.enable_mcap_logging(recorder.clone());// Messages will be logged automatically when receivedif let Ok(Some(data)) = subscriber.receive() { // Message is automatically logged to MCAP println!("Received: {:?}", data);}
Subscriber logging is useful when you want to record messages from external sources (e.g., ROS2 nodes via RCL Hooks) or when you want to log only specific topics.
Use a standalone recorder to record messages for a specific duration:
Copy
Ask AI
use cerulion_core::prelude::*;use std::sync::Arc;use std::time::{Duration, Instant};// Create standalone recorderlet recorder = Arc::new( McapRecorder::create("log.mcap", None, None)?);// Create subscriberlet subscriber = Subscriber::<SensorData>::create("sensors/data", None)?;// Record messages for a durationlet start = Instant::now();recorder.record_from_subscriber(&subscriber, "sensors/data", || { start.elapsed() < Duration::from_secs(10) // Record for 10 seconds})?;
The standalone recorder pattern is useful for time-limited recording or when you want to record messages from a subscriber without modifying the subscriber itself.
MCAP can use an existing schema registry for ROS2 message types:
Copy
Ask AI
use cerulion_core::prelude::*;// Create schema registry (if you have ROS2 message definitions)let schema_registry = Some(/* your schema registry */);// Create recorder with schema registrylet recorder = Arc::new( McapRecorder::create("log.mcap", None, schema_registry)?);
Schema registry integration is useful when logging ROS2 messages via RCL Hooks. It ensures proper schema registration in the MCAP file for ROS2 message types.
MCAP files can be read using the MCAP library or tools:
Copy
Ask AI
# List topics in MCAP filemcap info log.mcap# Extract messages to JSONmcap extract log.mcap --output messages.json# Playback messagesmcap playback log.mcap
MCAP files are self-contained and include schemas, metadata, and message data. They can be read by any MCAP-compatible tool or library.