Skip to main content

GenericClient

Inherits from: ZenohClient 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. Attributes: msg_type (str): The message type fn (callable): Optional function for custom message processing msg: The most recently published/received message

Inherited methods

  • From ZenohClient: getLatestMessage, msg_cb, run, publish, stop

init

GenericClient.__init__(client_dict, agent_dict = None, shared_session = None)
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 }
Arguments
client_dict (dict)
dict
required
Configuration dictionary for the client
agent_dict (dict, optional)
dict, optional
Dictionary of agent parameters. Defaults to None.
shared_session
Optional shared Zenoh session. Defaults to None.

publish_msg

GenericClient.publish_msg(msg)
Publish a message to the configured topic. If a processing function is defined, it will be called before publishing.
Arguments
msg
required
The message to publish (can be a pycdr2 IdlStruct, dict, or primitive)

process_latest_msg

GenericClient.process_latest_msg()
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.

get_msg

GenericClient.get_msg()
Get the most recent message.