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

# IsaacClient

> Generic Zenoh pub/sub client for simulation scene interactions

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

Generic Zenoh pub/sub client for simulation scene interactions.

Instead of dedicated methods like `setObjectPose`, this client exposes
generic `pub` / `sub` / `get` operations over a predefined topic
registry. Topics are looked up by key (e.g. `"set_object_pose"`), and
the client handles CDR serialization using the topic's declared ROS2
message type.

Usage::

client = SimClient()

# Publish a Pose to the "set\_object\_pose" topic

client.pub("set\_object\_pose", \{
"position": \{"x": 1.0, "y": 2.0, "z": 0.5},
"orientation": \{"x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0},
})

# Subscribe and poll

client.sub("get\_object\_pose")
pose = client.get("get\_object\_pose")

## Constructor

```python Signature theme={null}
IsaacClient(
    topics: Optional[Dict[str, dict]] = None,
    *,
    connect: Optional[List[str]] = None,
    listen: Optional[List[str]] = None,
    mode: Optional[str] = None,
    config_file: Optional[str] = None,
    verbose: bool = False,
)
```

## Methods

### `add_topic()`

```python Signature theme={null}
add_topic(key: str, zenoh_topic: str, msg_type: str, mode: str = 'both') -> None
```

Register a new topic at runtime.

<ParamField body="key" required>
  Lookup key (e.g. `"my_custom_topic"`).
</ParamField>

<ParamField body="zenoh_topic" required>
  Zenoh key expression (e.g. `"/my/topic"`).
</ParamField>

<ParamField body="msg_type" required>
  ROS2 message class name from `ros2_types` (e.g. `"Pose"`).
</ParamField>

<ParamField body="mode" default="'both'">
  `"pub"`, `"sub"`, or `"both"`.
</ParamField>

### `close()`

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

Tear down all subscriptions and close the Zenoh session.

### `get()`

```python Signature theme={null}
get(topic_key: str, timeout: float = 1.0) -> Optional[Any]
```

Return the latest message on a subscribed topic.

Call `sub` first to start receiving messages.

<ParamField body="topic_key" required>
  Registered topic key.
</ParamField>

<ParamField body="timeout" default="1.0">
  Seconds to wait for a message.
</ParamField>

**Returns:**

Deserialized message, or `None` if nothing received within *timeout*.

### `pub()`

```python Signature theme={null}
pub(topic_key: str, data: Any) -> None
```

Publish *data* to a predefined topic.

*data* can be:

* A dict matching the ROS2 message fields (auto-converted & CDR-serialized).
* A primitive (bool, int, float) for single-field messages like `Bool`.
* A pre-built `pycdr2.IdlStruct` instance (serialized directly).
* A raw `bytes` object (published as-is).

<ParamField body="topic_key" required>
  Registered topic key.
</ParamField>

<ParamField body="data" required>
  Payload to publish.
</ParamField>

### `set_named_pose()`

```python Signature theme={null}
set_named_pose(
    name: str,
    position: Union[Sequence[float], Tuple[float, float, float]],
    orientation: Union[Sequence[float], Tuple[float, float, float, float]] = (1, 0, 0, 0),
) -> None
```

Teleport a named rigid body to a given pose.

<ParamField body="name" required>
  Scene object name (e.g. `"box_pass_005"`).
</ParamField>

<ParamField body="position" required>
  Target `(x, y, z)` world position.
</ParamField>

<ParamField body="orientation" default="(1, 0, 0, 0)">
  Target `(w, x, y, z)` quaternion. Defaults to identity.
</ParamField>

### `sub()`

```python Signature theme={null}
sub(topic_key: str, callback: Optional[Callable] = None) -> None
```

Subscribe to a predefined topic.

If *callback* is provided it is invoked with the deserialized message
each time a new sample arrives.  Regardless of callbacks, the latest
message is always available via `get`.

<ParamField body="topic_key" required>
  Registered topic key.
</ParamField>

<ParamField body="callback">
  Optional `fn(msg)` invoked on each message.
</ParamField>


## Related topics

- [Overview](/simulation/isaac/overview.md)
- [Workflow Config](/simulation/isaac/session_configuration/workflow.md)
- [Sensors](/simulation/isaac/sensors.md)
- [Training Workflow](/simulation/isaac/reinforcement-learning/training-workflow.md)
- [ROS2 Communication](/simulation/isaac/comms.md)
