Skip to main content

COMPAS EVE

Made with COMPAS Github Actions Build Status License pip downloads PyPI Package latest release Supported implementations DOI Twitter Follow

Event-based communication for the COMPAS framework.

>>> import compas_eve as eve
>>> pub = eve.Publisher("/hello_world")
>>> sub = eve.EchoSubscriber("/hello_world")
>>> sub.subscribe()
>>> for i in range(10):
...    pub.publish(dict(text=f"Hello World {i}"))

It is extremely easy to send messages around. COMPAS EVE supports different transport mechanisms to send messages between different threads, processes, computers, etc.

Installation

Install using pip:

    pip install compas_eve

Or using conda:

    conda install compas_eve

Supported features

  • Publisher/subscriber communication model (N-to-N communication)
  • In-process events
  • MQTT support
  • ROS support through rosbridge
  • Zenoh support
  • Extensible codec system for message serialization (JSON, Protocol Buffers)

Examples

In-process events

The simplest option is to use in-process events. This works for simple applications and allows to communicate between threads.

import compas_eve as eve

pub = eve.Publisher("/hello_world")
sub = eve.EchoSubscriber("/hello_world")
sub.subscribe()

for i in range(10):
    pub.publish(dict(text=f"Hello World {i}"))

MQTT

MQTT is a protocol that allows to send messages between different systems/computers. Using MQTT is very simple as well:

import compas_eve as eve
from compas_eve.mqtt import MqttTransport

tx = MqttTransport("broker.hivemq.com")
eve.set_default_transport(tx)

pub = eve.Publisher("/hello_world")
sub = eve.EchoSubscriber("/hello_world")
sub.subscribe()

for i in range(10):
    pub.publish(dict(text=f"Hello World {i}"))

This example shows how to send and receive from a single script, but running publishers and subscribers on different scripts, different processes, or even different computers will work the exact same way.

ROS

The optional ROS backend uses native ROS message types through a rosbridge server:

pip install compas_eve[ros]
import time

import compas_eve as eve
from compas_eve.ros import RosTransport

tx = RosTransport("localhost", 9090)
topic = eve.Topic("/chatter", "std_msgs/String", queue_size=10)

sub = eve.EchoSubscriber(topic, transport=tx)
sub.subscribe()
eve.Publisher(topic, transport=tx).publish({"data": "Hello ROS"})
time.sleep(1)
tx.close()

ROS messages are passed as JSON-compatible dictionaries. Topic options supported by roslibpy—including compression, latch, throttle_rate, queue_size, queue_length, and reconnect_on_close—can be set on eve.Topic.

Zenoh

Apache Zenoh is a pub/sub/query protocol. In many ways, it is similar to MQTT but with some additional features and optimizations. COMPAS EVE also supports Zenoh as a transport protocol with an identical API to MQTT:

import compas_eve as eve
from compas_eve.zenoh import ZenohTransport

tx = ZenohTransport()
eve.set_default_transport(tx)

pub = eve.Publisher("/hello_world")
sub = eve.EchoSubscriber("/hello_world")
sub.subscribe()

for i in range(10):
    pub.publish(dict(text=f"Hello World {i}"))

Using different codecs

By default, COMPAS EVE uses JSON for message serialization. However, you can use different codecs for more efficient serialization:

import compas_eve as eve
from compas_eve import JsonMessageCodec
from compas_eve.codecs import ProtobufMessageCodec
from compas_eve.mqtt import MqttTransport

# Use JSON codec (default)
json_codec = JsonMessageCodec()
tx = MqttTransport("broker.hivemq.com", codec=json_codec)

# Or use Protocol Buffers for binary serialization (requires compas_pb)
pb_codec = ProtobufMessageCodec()
tx = MqttTransport("broker.hivemq.com", codec=pb_codec)

Usage from Rhinoceros 3D

It is possible to use the same code from within Rhino/Grasshopper.

To install compas_eve, use the the syntax # r: compas_eve at the top of any Python 3.x script in Rhino/Grasshopper.

Download files

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

Source Distribution

compas_eve-2.4.0.tar.gz (47.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compas_eve-2.4.0-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

Details for the file compas_eve-2.4.0.tar.gz.

File metadata

  • Download URL: compas_eve-2.4.0.tar.gz
  • Upload date:
  • Size: 47.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for compas_eve-2.4.0.tar.gz
Algorithm Hash digest
SHA256 2bf56aa8bd7cd94985d8008231f2466eb6824a7d60a739f28b37b20860a070ff
MD5 86c249b03a59b31532bf994c48754364
BLAKE2b-256 f9db355155322061ca3f714ce9e29d2299fe4cfb728078cd7d108b68f82b80fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_eve-2.4.0.tar.gz:

Publisher: release.yml on compas-dev/compas_eve

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_eve-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: compas_eve-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 49.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for compas_eve-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 295a827e0c358c775c1442febb641be50cbda43a45781dddafae407a85215c98
MD5 e6b7ed4143424e0c180389115deb9829
BLAKE2b-256 9cd72836dae037da1e2f8f08328f591ea59fdc4f8633f0930c72687ec97181b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_eve-2.4.0-py3-none-any.whl:

Publisher: release.yml on compas-dev/compas_eve

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.4.0 This release

2 files

2.3.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.0.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.0

2 files

0.2.1

2 files

0.1.2

2 files

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