Skip to main content

lcmutils

Python utility library for Lightweight Communications and Marshalling (LCM).

Installation

pip install lcmutils

Usage

Typing

lcmutils defines the LCMType protocol for LCM type classes generated via lcm-gen. You can use this protocol to type hint LCM type classes in your Python code.

from lcmutils import LCMType

def publish_lcm_message(lcm: LCM, message: LCMType) -> None:
    lcm.publish("channel", message.encode())

LCM Daemon

For many applications, it's desirable to run LCM handling in a background thread. lcmutils provides a LCMDaemon class that wraps an LCM instance and repeatedly calls its the handle method in a background thread.

from lcmutils import LCMDaemon

lcm = LCMDaemon()

@lcm.subscribe("channel1", "channel2")
def handle_message(channel: str, data: bytes) -> None:
    print(f"Received message {data} on channel {channel}")

lcm.start()
...
lcm.stop()  # will stop when the next message is handled

By default, the LCMDaemon instance will use the blocking LCM.handle method. If you want to use the LCM.handle_timeout method instead, you can pass a timeout_millis argument to the constructor. You can also pass a start argument to automatically start the daemon.

from lcmutils import LCMDaemon

# Use LCM.handle_timeout with a 100ms timeout and start the daemon
lcm = LCMDaemon(timeout_millis=100, start=True)
...
lcm.stop()  # will stop within 100ms

LCMDaemon can be passed an existing LCM instance to wrap, or it will create a new LCM instance if none is provided.

from lcm import LCM
from lcmutils import LCMDaemon

lcm = LCM("udpm://239.255.76.67:7667?ttl=1")  # create an LCM instance with ttl=1
lcm_daemon = LCMDaemon(lcm, start=True)
...
lcm_daemon.stop()

Type Registry

lcmutils provides an LCMTypeRegistry class that can be used to register and lookup LCM type classes by fingerprint.

from lcmutils import LCMTypeRegistry
from my_lcm_types import MyLCMType

registry = LCMTypeRegistry(MyLCMType)
# or:
#   registry = LCMTypeRegistry()
#   registry.register(MyLCMType)

msg = MyLCMType()
msg_encoded = msg.encode()

print(registry.detect(msg_encoded))         # MyLCMType
print(registry.decode(msg_encoded) == msg)  # True

Metadata

Release files for lcmutils 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lcmutils 0.2.0
File Size Uploaded Provenance Actions
lcmutils-0.2.0.tar.gz 5.5 kB Without provenance Details for lcmutils-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lcmutils 0.2.0
File Interpreter ABI Platform Actions
lcmutils-0.2.0-py3-none-any.whl Python 3 none any Details for lcmutils-0.2.0-py3-none-any.whl

Total release size: 10.6 kB

Release files / lcmutils-0.2.0.tar.gz

Download URL lcmutils-0.2.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2a55dbb87debe8daa7b50e565c51e88d679f62330653b45d35592e97dce621aa
BLAKE2b-256 checksum
How to use checksums
3184abf2703c3db20370ad593c5044af8503d894effe9399c1d84036230d50c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.27

Release files / lcmutils-0.2.0-py3-none-any.whl

Download URL lcmutils-0.2.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00ca19e0927fdbefecc9ce90d26544dc368947add060d8eb5963f639a28e3e4f
BLAKE2b-256 checksum
How to use checksums
a341e481a7ffd581fd4b6f704b7f629c95b955b2c87fd765b6df0bc6db04c4a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.27

Security for lcmutils 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page