Skip to main content

A python wrapper around libcluon

Project description

pycluon

A python wrapper around libcluon. pycluon aims to follow the API of libcluon as closely as possible to avoid surprises.

So far, pycluon wraps the following concepts from libcluon:

  • Envelope
  • OD4Session
  • UDPSender
  • UDPReceiver
  • TCPConnection
  • TCPServer

It also bundles the following command-line applications:

  • protoc
  • cluon-msc
  • cluon-OD4toStdout
  • cluon-OD4toJSON
  • cluon-LCMtoJSON
  • cluon-filter
  • cluon-livefeed
  • cluon-rec2csv
  • cluon-replay

Versioning

pycluon version libcluon version
0.1.0 0.0.140

Installation

pycluon is available on PyPI:

pip install pycluon

Examples

Import an odvd specification into a python module

from pycluon.importer import import_odvd

my_module = import_odvd("/path/to/my/odvd/specification.odvd")

Send an envelope

import time
from pycluon import OD4Session, Envelope

session = OD4Session(111)

message = my_module.MyMessage()

envelope = Envelope()
envelope.sent = envelope.sampled = time.time()
envelope.serialized_data = message.SerializeToString()
envelope.data_type = 13
envelope.sender_stamp = 13

session.send(envelope)

Receive an envelope

import time
from pycluon import OD4Session

session = OD4Session(111)

def callback(envelope):
    message = my_module.MyMessage()
    message.ParseFromString(envelope.serialized_data)
    print(f"Received at {envelope.received} seconds since epoch")

session.add_data_trigger(13, callback)

while session.is_running():
    time.sleep(0.01)

See the tests for usage of UDPSender, UDPReceiver, TCPConnection and TCPServer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pycluon-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pycluon-0.1.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

pycluon-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pycluon-0.1.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

pycluon-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pycluon-0.1.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

pycluon-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pycluon-0.1.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page