OWA support for the Python MCAP library
Project description
Copied from https://github.com/foxglove/mcap/tree/main/python/mcap-ros1-support
Usage Demo
import tempfile
from mcap_owa.highlevel import OWAMcapReader, OWAMcapWriter
from owa.core.message import OWAMessage
from owa.core import MESSAGES
# Access message types through the global registry
KeyboardEvent = MESSAGES['desktop/KeyboardEvent']
class String(OWAMessage):
_type = "std_msgs/String"
data: str
def main():
with tempfile.TemporaryDirectory() as tmpdir:
file_path = tmpdir + "/output.mcap"
# Writing messages to an OWAMcap file
with OWAMcapWriter(file_path) as writer:
for i in range(0, 10):
publish_time = i
if i % 2 == 0:
topic = "/chatter"
event = String(data="string message")
else:
topic = "/keyboard"
event = KeyboardEvent(event_type="press", vk=1)
writer.write_message(event, topic=topic, timestamp=publish_time)
# Reading messages from an OWAMcap file
with OWAMcapReader(file_path, decode_args={"return_dict": True}) as reader:
for mcap_msg in reader.iter_messages():
print(f"Topic: {mcap_msg.topic}, Timestamp: {mcap_msg.timestamp}, Message: {mcap_msg.decoded}")
if __name__ == "__main__":
main()
For above script, stdout is following:
Topic: /chatter, Timestamp: 1741767097157638598, Message: {'data': 'string message'}
Topic: /keyboard, Timestamp: 1741767097157965764, Message: {'event_type': 'press', 'vk': 1}
Topic: /chatter, Timestamp: 1741767097157997762, Message: {'data': 'string message'}
Topic: /keyboard, Timestamp: 1741767097158019602, Message: {'event_type': 'press', 'vk': 1}
Topic: /chatter, Timestamp: 1741767097158036925, Message: {'data': 'string message'}
Topic: /keyboard, Timestamp: 1741767097158051239, Message: {'event_type': 'press', 'vk': 1}
Topic: /chatter, Timestamp: 1741767097158065463, Message: {'data': 'string message'}
Topic: /keyboard, Timestamp: 1741767097158089318, Message: {'event_type': 'press', 'vk': 1}
Topic: /chatter, Timestamp: 1741767097158113250, Message: {'data': 'string message'}
Topic: /keyboard, Timestamp: 1741767097158129738, Message: {'event_type': 'press', 'vk': 1}
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
mcap_owa_support-0.6.6.tar.gz
(13.7 kB
view details)
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 mcap_owa_support-0.6.6.tar.gz.
File metadata
- Download URL: mcap_owa_support-0.6.6.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9866f41eccfca215fe8f9e2c1b857709458f77b13ebc7426974207737149312
|
|
| MD5 |
97e71e550df585ff836b8aeda6bf124c
|
|
| BLAKE2b-256 |
21dfa328940f66a6aa0dcf268d97c54ac2618abbb2801520018506d60c634d1a
|
File details
Details for the file mcap_owa_support-0.6.6-py3-none-any.whl.
File metadata
- Download URL: mcap_owa_support-0.6.6-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
846d6c3512befac5ef5f634a035667dab8da250d0b36d2c105fe26811ba832f7
|
|
| MD5 |
1c9be41cdc68d3f4bfd9477924c08b0c
|
|
| BLAKE2b-256 |
49c72355fecf37d81b4ee8e0ac42c95493a1e0df70a08ddb84c7415327b43963
|