mcap-owa-support-0.6.5
توضیحات
OWA support for the Python MCAP library
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | mcap-owa-support-0.6.5 |
| نام | mcap-owa-support |
| نسخه کتابخانه | 0.6.5 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/mcap-owa-support/ |
| مجوز | MIT |
# Copied from https://github.com/foxglove/mcap/tree/main/python/mcap-ros1-support
### Usage Demo
```python
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}
```
نیازمندی
| مقدار | نام |
|---|---|
| - | mcap>=1.0.0 |
| - | orjson |
| - | owa-core==0.6.5 |
| - | packaging>=20.0 |
| - | pydantic>=2.0 |
| - | requests>=2.32.2 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.11 | Python |
نحوه نصب
نصب پکیج whl mcap-owa-support-0.6.5:
pip install mcap-owa-support-0.6.5.whl
نصب پکیج tar.gz mcap-owa-support-0.6.5:
pip install mcap-owa-support-0.6.5.tar.gz