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.5.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.5.tar.gz.
File metadata
- Download URL: mcap_owa_support-0.6.5.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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 |
23937a8a35641bf941750c515753d986e2c46b1bf334b0b7e624308dc232aa55
|
|
| MD5 |
a310751f4c0b8b83efba9d7f5d5f76cc
|
|
| BLAKE2b-256 |
5c6ab6215cd93dc06f6d5b13e2157d87bf558e7f7a65201b76e7bdaf25081f0d
|
File details
Details for the file mcap_owa_support-0.6.5-py3-none-any.whl.
File metadata
- Download URL: mcap_owa_support-0.6.5-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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 |
22f6b10eb25879682f6fbdef21b121f52a6830e3f71a82a8aea239ffd504c572
|
|
| MD5 |
dae35997c8d028d1a8df579fdb2d09d5
|
|
| BLAKE2b-256 |
f1c522cf3b5fe08a07ea92bbd1a6101277c5867ff8099000b8d3d347349afca0
|