Python utilities for reading and writing ASAM OSI trace files (MCAP, binary .osi, text .txth)
Project description
osi-utilities (Python)
Python utilities for reading and writing ASAM OSI (Open Simulation Interface) trace files.
Supported Formats
- MCAP (
.mcap) - Multi-channel container format with metadata - Binary (
.osi) - Single-channel binary format with length-prefixed protobuf messages - Text (
.txth) - Human-readable protobuf TextFormat
Installation
From PyPI:
pip install asam-osi-utilities
For development (uses a virtual environment):
make setup # creates .venv and installs in editable mode
API Entrypoints
The package exposes two API levels:
Channel abstraction(simple API) viaopen_channel(...)
- Use this when you want to read one logical channel and get protobuf messages directly.
- Works across
.osiand.mcap.
Advanced tracefile APIviacreate_reader(...)and concrete readers/writers
- Use this when you need explicit control over topics, decoder mode, metadata, writer behavior, or multi-channel features.
Quick Start
1) Channel abstraction (simple API)
from pathlib import Path
from osi_utilities import ChannelSpecification, MessageType, open_channel
# Single channel from an MCAP file (explicit topic)
spec = ChannelSpecification(
path=Path("trace.mcap"),
topic="GroundTruthTopic",
message_type=MessageType.GROUND_TRUTH,
)
with open_channel(spec) as channel:
for message in channel:
print(type(message).__name__)
Channel abstraction writing uses open_channel_writer(...):
from pathlib import Path
from osi3.osi_groundtruth_pb2 import GroundTruth
from osi_utilities import ChannelSpecification, MessageType, open_channel_writer
spec = ChannelSpecification(
path=Path("output.osi"),
message_type=MessageType.GROUND_TRUTH,
)
msg = GroundTruth()
msg.timestamp.seconds = 1
with open_channel_writer(spec) as channel_writer:
channel_writer.write_message(msg)
2) Advanced reading API
from pathlib import Path
from osi_utilities import MultiTraceReader, create_reader
# Create reader by extension (.osi/.mcap/.txth), then configure explicitly
path = Path("trace.mcap")
reader = create_reader(path)
if isinstance(reader, MultiTraceReader):
reader.set_topics(["GroundTruthTopic"])
if not reader.open(path):
raise RuntimeError(f"Failed to open {path}")
with reader:
for result in reader:
print(result.message_type, result.message)
Advanced configuration helpers based on ChannelSpecification are also available in osi_utilities.tracefile.configure:
from pathlib import Path
from osi_utilities import create_reader
from osi_utilities.api import ChannelSpecification, MessageType
from osi_utilities.tracefile.configure import configure_reader, configure_reader_for_channels
path = Path("trace.mcap")
reader = create_reader(path)
# Configure from one channel spec
configure_reader(
reader,
ChannelSpecification(
path=path,
topic="GroundTruthTopic",
message_type=MessageType.GROUND_TRUTH,
),
)
# Or configure from multiple channel specs (same file path)
configure_reader_for_channels(
reader,
[
ChannelSpecification(path=path, topic="GroundTruthTopic", message_type=MessageType.GROUND_TRUTH),
ChannelSpecification(path=path, topic="SensorDataTopic", message_type=MessageType.SENSOR_DATA),
],
)
3) Writing (advanced API)
from pathlib import Path
from osi3.osi_sensorview_pb2 import SensorView
from osi_utilities import SingleTraceWriter
sensor_view = SensorView()
sensor_view.version.version_major = 3
sensor_view.timestamp.seconds = 123
sensor_view.timestamp.nanos = 456
with SingleTraceWriter() as writer:
writer.open(Path("output.osi"))
writer.write_message(sensor_view)
For multi-channel MCAP writing, use MultiTraceWriter or MCAPChannel.
Development
make setup # Create venv and install dependencies
make test # Run tests
make lint # Run linter
make format # Format code
make typecheck # Run type checker
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asam_osi_utilities-0.4.0.tar.gz.
File metadata
- Download URL: asam_osi_utilities-0.4.0.tar.gz
- Upload date:
- Size: 38.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c00c4fdadb00f29e6440b107488c1371499a4886b0ff16d9f63ea96ea5606632
|
|
| MD5 |
901f7ca35d92b21794f5bdd5ea1af0fd
|
|
| BLAKE2b-256 |
d4ecd5f41c43c5c730f450b3ac2608e0d26d00de6a2542914a6fd963fca4fb20
|
Provenance
The following attestation bundles were made for asam_osi_utilities-0.4.0.tar.gz:
Publisher:
cd_release.yml on lichtblick-suite/asam-osi-utilities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asam_osi_utilities-0.4.0.tar.gz -
Subject digest:
c00c4fdadb00f29e6440b107488c1371499a4886b0ff16d9f63ea96ea5606632 - Sigstore transparency entry: 1397257483
- Sigstore integration time:
-
Permalink:
lichtblick-suite/asam-osi-utilities@61bc1ed85b622e0ea70e8955f98cdd10e815bc0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lichtblick-suite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd_release.yml@61bc1ed85b622e0ea70e8955f98cdd10e815bc0b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file asam_osi_utilities-0.4.0-py3-none-any.whl.
File metadata
- Download URL: asam_osi_utilities-0.4.0-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0392f2b1b9be6b920a5e74f78b63ad0c286b60476ce063c94caa39b1dfa1153
|
|
| MD5 |
b5135fa5a6ddaedd45fc0c7bcace30a8
|
|
| BLAKE2b-256 |
bc410f27c4754a785a921f0a948d669c2ce1dce4cc5d6c94d787cc5b83fe77f6
|
Provenance
The following attestation bundles were made for asam_osi_utilities-0.4.0-py3-none-any.whl:
Publisher:
cd_release.yml on lichtblick-suite/asam-osi-utilities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asam_osi_utilities-0.4.0-py3-none-any.whl -
Subject digest:
b0392f2b1b9be6b920a5e74f78b63ad0c286b60476ce063c94caa39b1dfa1153 - Sigstore transparency entry: 1397257488
- Sigstore integration time:
-
Permalink:
lichtblick-suite/asam-osi-utilities@61bc1ed85b622e0ea70e8955f98cdd10e815bc0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lichtblick-suite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd_release.yml@61bc1ed85b622e0ea70e8955f98cdd10e815bc0b -
Trigger Event:
workflow_dispatch
-
Statement type: