Skip to main content
A generic Zenoh client that can handle arbitrary message types and processing functions. This class inherits from ZenohClient and provides functionality for publishing and processing generic messages with optional custom processing functions.

Fields

str
The message type
callable
Optional function for custom message processing
The most recently published/received message

Constructor

Signature
Initialize the generic client. Note: { For generic client, you also need to include the following keys:
  • “msg_type”: The message type (e.g., “Bool”, “Twist”, “Pose”)
  • “fn”: The function to process the message }
dict
required
Configuration dictionary for the client
dict, optional
Dictionary of agent parameters. Defaults to None.
Optional shared Zenoh session. Defaults to None.

Methods

getLatestMessage()

Signature
Return the most recent message from the subscription queue. Blocks for up to one second waiting for a message. Returns: The raw payload bytes of the latest message, or None if no message was received within the timeout.

get_msg()

Signature
Get the most recent message. Returns: The most recently published/received message

msg_cb()

Signature
Handle an incoming Zenoh sample by storing its payload in the queue.
required
The Zenoh sample received from the subscription.

process_latest_msg()

Signature
Process the latest received message. Gets the latest message, deserializes it using CDR or JSON fallback, and processes it with the configured function if one exists. Returns: None

publish()

Signature
Publish data to the topic.
required
Raw bytes to publish on the configured topic.

publish_msg()

Signature
Publish a message to the configured topic. If a processing function is defined, it will be called before publishing.
required
The message to publish (can be a pycdr2 IdlStruct, dict, or primitive)
Raises: Exception: If the message is None

run()

Signature
Start the client by declaring a subscriber or publisher on the session.

stop()

Signature
Undeclare the subscriber and close the owned Zenoh session if any.