Core Types¶
Enumerations¶
- class osi_utilities._types.MessageType(*values)[source]¶
-
OSI top-level message types.
- UNKNOWN = 'Unknown'¶
- GROUND_TRUTH = 'GroundTruth'¶
- SENSOR_DATA = 'SensorData'¶
- SENSOR_VIEW = 'SensorView'¶
- SENSOR_VIEW_CONFIGURATION = 'SensorViewConfiguration'¶
- HOST_VEHICLE_DATA = 'HostVehicleData'¶
- TRAFFIC_COMMAND = 'TrafficCommand'¶
- TRAFFIC_COMMAND_UPDATE = 'TrafficCommandUpdate'¶
- TRAFFIC_UPDATE = 'TrafficUpdate'¶
- MOTION_REQUEST = 'MotionRequest'¶
- STREAMING_UPDATE = 'StreamingUpdate'¶
Data Classes¶
- class osi_utilities._types.ReadResult(message, message_type, channel_name='', status=ReadStatus.OK, error_message='')[source]¶
Bases:
objectResult of reading a single message from a trace file.
- Parameters:
message (Message | None)
message_type (MessageType)
channel_name (str)
status (ReadStatus)
error_message (str)
- message_type: MessageType¶
- status: ReadStatus = 'ok'¶
- class osi_utilities.api.types.ChannelSpecification(path, message_type=None, topic=None, metadata=<factory>)[source]¶
Bases:
objectImmutable specification for an OSI channel within a trace file.
- Parameters:
- message_type: MessageType | str | None = None¶
OSI message type (normalized to MessageType if provided).
- property trace_file_format: TraceFileFormat¶
Determine the trace file format from the file extension.
- property autodetected_message_type: MessageType | None¶
Best-effort inferred message type from filename, without mutating this instance.
- with_autodetected_message_type()[source]¶
Return a specification with auto-detected message type when possible.
If message_type is already set or cannot be inferred, returns self unchanged.
- Return type:
- with_autofilled_topic()[source]¶
Return a specification with topic set to filename stem if missing.
- Return type:
- with_message_type(message_type)[source]¶
Return a new ChannelSpecification with a different message type.
- Parameters:
message_type (MessageType | str)
- Return type:
- with_topic(topic)[source]¶
Return a new ChannelSpecification with a different topic.
- Parameters:
topic (str)
- Return type:
- with_path(path)[source]¶
Return a new ChannelSpecification with a different path.
- Parameters:
- Return type:
- with_metadata(metadata)[source]¶
Return a new ChannelSpecification with replaced metadata.
- Parameters:
- Return type:
- with_metadata_updates(updates)[source]¶
Return a new ChannelSpecification with metadata updated by key.
- Parameters:
- Return type:
- with_metadata_entry(key, value)[source]¶
Return a new ChannelSpecification with one metadata key updated.
- Parameters:
- Return type:
- with_trace_file_format(format)[source]¶
Return a new ChannelSpecification with a different file extension.
- Parameters:
format (TraceFileFormat)
- Return type:
Utility Functions¶
- osi_utilities.filename.infer_message_type_from_filename(filename)[source]¶
Infer message type from filename patterns.
Matches the underscore-delimited patterns (e.g.
_gt_) and also supports the common convention where the type code appears at the end of the stem before the extension (e.g.trace_gt.osi,output_sv.mcap).- Parameters:
filename (str)
- Return type:
- osi_utilities.tracefile.format.get_trace_file_format(path)[source]¶
Determine the trace file format from the file extension.
- Parameters:
path (Path)
- Return type:
- osi_utilities.filename.parse_osi_trace_filename(filename)[source]¶
Parse an OSI trace filename according to OSI naming convention 2.2.6.2.
Format: <timestamp>_<type>_<osi-version>_<protobuf-version>_<number-of-frames>_<custom-trace-name>.osi
Returns a dict with parsed fields, or empty dict if parsing fails.