> ## 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.

# WrenchClient

> A Zenoh client for publishing and receiving wrench messages over Zenoh topics

```python theme={null}
from grid_sim_client.isaac import WrenchClient
```

A Zenoh client for publishing and receiving wrench messages over Zenoh topics.
Wrenches are commonly received from contact sensors,
and published to end effectors that need to apply a force or torque.

## Fields

<ResponseField name="force" type="numpy.ndarray">
  Current force as \[x, y, z]
</ResponseField>

<ResponseField name="torque" type="numpy.ndarray">
  Current torque as \[x, y, z]
</ResponseField>

<ResponseField name="relative" type="bool">
  Whether wrenches are relative to current position
</ResponseField>

<ResponseField name="blocking" type="bool">
  Whether wrench commands block until complete
</ResponseField>

## Constructor

```python Signature theme={null}
WrenchClient(
    *,
    client_dict: dict,
    agent_dict: Optional[dict] = None,
    shared_session: Any = None,
)
```

Initialize the wrench client.

<ParamField body="client_dict" type="dict" required>
  Configuration dictionary for the client
</ParamField>

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

<ParamField body="shared_session">
  Optional shared Zenoh session. Defaults to None.
</ParamField>

## Methods

### `getLatestMessage()`

```python Signature theme={null}
getLatestMessage() -> Any
```

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_force()`

```python Signature theme={null}
get_force() -> Optional[np.ndarray]
```

Get the current force.

**Returns:**

numpy.ndarray: Current force as \[x, y, z]

### `get_torque()`

```python Signature theme={null}
get_torque() -> Optional[np.ndarray]
```

Get the current torque.

**Returns:**

numpy.ndarray: Current torque as \[x, y, z]

### `get_wrench()`

```python Signature theme={null}
get_wrench() -> Optional[tuple]
```

Get the latest wrench message.

**Returns:**

tuple: (force, torque) as numpy arrays or None

### `msg_cb()`

```python Signature theme={null}
msg_cb(sample: Any) -> None
```

Handle an incoming Zenoh sample by storing its payload in the queue.

<ParamField body="sample" required>
  The Zenoh sample received from the subscription.
</ParamField>

### `process_latest_msg()`

```python Signature theme={null}
process_latest_msg() -> None
```

Process the latest received wrench message.

### `publish()`

```python Signature theme={null}
publish(data: bytes) -> None
```

Publish data to the topic.

<ParamField body="data" required>
  Raw bytes to publish on the configured topic.
</ParamField>

### `publish_wrench()`

```python Signature theme={null}
publish_wrench(force: np.ndarray, torque: np.ndarray) -> None
```

Publish a wrench message.

<ParamField body="force" type="array-like" required>
  Force as \[x, y, z]
</ParamField>

<ParamField body="torque" type="array-like" required>
  Torque as \[x, y, z]
</ParamField>

### `run()`

```python Signature theme={null}
run() -> None
```

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

### `stop()`

```python Signature theme={null}
stop() -> None
```

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


## Related topics

- [Customizing RL Training](/simulation/isaac/reinforcement-learning/customizing-training.md)
- [ROS2 Communication](/simulation/isaac/comms.md)
- [GRID Cortex Client](/models/cortex.md)
- [grid-cortex-client](/python-api/grid-cortex-client/overview.md)
- [CortexClient](/python-api/grid-cortex-client/cortexclient.md)
