> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GenericClient

## GenericClient

Inherits from: [`ZenohClient`](/robot-api/reference/sim/zenoh/base_client/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`](/robot-api/reference/sim/zenoh/base_client/ZenohClient): `getLatestMessage`, `msg_cb`, `run`, `publish`, `stop`

### **init**

```python theme={null}
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
  }

<ResponseField name="Arguments">
  <ParamField query="client_dict (dict)" type="dict" required>
    Configuration dictionary for the client
  </ParamField>

  <ParamField query="agent_dict (dict, optional)" type="dict, optional">
    Dictionary of agent parameters. Defaults to None.
  </ParamField>

  <ParamField query="shared_session" type="">
    Optional shared Zenoh session. Defaults to None.
  </ParamField>
</ResponseField>

### publish\_msg

```python theme={null}
GenericClient.publish_msg(msg)
```

Publish a message to the configured topic.

If a processing function is defined, it will be called before publishing.

<ResponseField name="Arguments">
  <ParamField query="msg" type="" required>
    The message to publish (can be a pycdr2 IdlStruct, dict, or primitive)
  </ParamField>
</ResponseField>

### process\_latest\_msg

```python theme={null}
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

```python theme={null}
GenericClient.get_msg()
```

Get the most recent message.
