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

# JointAngleClient

> A Zenoh client for handling joint state messages

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

A Zenoh client for handling joint state messages.

This class inherits from ZenohClient and provides functionality for publishing and
receiving joint state messages over Zenoh topics using sensor\_msgs/JointState.

## Fields

<ResponseField name="joint_names" type="list">
  Names of the joints
</ResponseField>

<ResponseField name="joint_positions" type="numpy.ndarray">
  Current joint positions (angles)
</ResponseField>

<ResponseField name="joint_velocities" type="numpy.ndarray">
  Current joint velocities
</ResponseField>

<ResponseField name="joint_efforts" type="numpy.ndarray">
  Current joint efforts/torques
</ResponseField>

## Constructor

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

Initialize the joint angle 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_joint_efforts()`

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

Get the current joint efforts.

**Returns:**

numpy.ndarray: Current joint efforts/torques

### `get_joint_names()`

```python Signature theme={null}
get_joint_names() -> List[str]
```

Get the current joint names.

**Returns:**

list: Current joint names

### `get_joint_positions()`

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

Get the current joint positions.

**Returns:**

numpy.ndarray: Current joint positions/angles

### `get_joint_state()`

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

Get the latest joint state message.

**Returns:**

tuple: (joint\_names, joint\_positions, joint\_velocities, joint\_efforts) or None

### `get_joint_velocities()`

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

Get the current joint velocities.

**Returns:**

numpy.ndarray: Current joint velocities

### `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 joint state message.

Gets the latest message and updates the stored joint states. If an agent is
connected, calls setJointAngles with the new positions.

**Returns:**

None

### `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_agent_joint_state()`

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

Publish the current joint state of the connected agent.

### `publish_joint_state()`

```python Signature theme={null}
publish_joint_state(
    joint_names: List[str],
    joint_positions: List[float],
    joint_velocities: Optional[List[float]] = None,
    joint_efforts: Optional[List[float]] = None,
) -> None
```

Publish a joint state message.

<ParamField body="joint_names" type="list" required>
  Names of the joints
</ParamField>

<ParamField body="joint_positions" type="array-like" required>
  Joint positions/angles
</ParamField>

<ParamField body="joint_velocities" type="array-like, optional">
  Joint velocities. Defaults to None.
</ParamField>

<ParamField body="joint_efforts" type="array-like, optional">
  Joint efforts/torques. Defaults to None.
</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)
- [MDP Config](/simulation/isaac/session_configuration/mdp.md)
- [ROS2 Communication](/simulation/isaac/comms.md)
- [GRID Cortex Client](/models/cortex.md)
- [grid-cortex-client](/python-api/grid-cortex-client/overview.md)
