nnspike.utils.recorder
Sensor Data Recorder Module
This module provides a class for recording ETRobot sensor status and control data to CSV files. It’s designed for high-performance logging during robot operation without impacting frame rates.
Classes
|
High-performance CSV recorder for ETRobot sensor data and control information. |
- class nnspike.utils.recorder.SensorRecorder(output_dir='storage/sensor_data', timestamp=None)[source]
- High-performance CSV recorder for ETRobot sensor data and control information.
This class manages CSV file creation, writing, and cleanup with optimizations for
real-time robot operation at high frame rates (30fps+).
Features: - Single file open/close for entire session - Buffered writing for performance - Periodic flushing for data safety - Automatic cleanup on program exit - Comprehensive sensor and control data logging
- __init__(output_dir='storage/sensor_data', timestamp=None)[source]
Initialize the sensor recorder.
- Parameters:
output_dir (
str
) – Directory to store CSV filestimestamp (
str
|None
) – Custom timestamp for filename, auto-generated if None
- start_recording()[source]
Start CSV recording session.
Creates output directory, opens CSV file, writes headers, and sets up cleanup.
- Return type:
None
- log_frame_data(spike_status, mode=None)[source]
Log sensor data for a single frame.
- Parameters:
spike_status (
SpikeStatus
) – SpikeStatus object with sensor datamode (
Mode
|None
) – Current behavior mode (e.g., Mode.LEFT_EDGE_FOLLOWING)
- Return type:
None
- get_filename()[source]
Get the current CSV filename.
- Returns:
Full path to the CSV file
- Return type:
str
- get_frame_count()[source]
Get the current frame count.
- Returns:
Number of frames recorded
- Return type:
int