Skip to content

sim2bot.Robot.states

states(robot: int = 0) -> list[dict]

Return physics-substep samples carried by the newest telemetry packet.

Parameters:

  • robot (int, default: 0 ) –

    Robot index returned by describe.

Returns:

  • list[dict]

    A list of {"t": seconds, "q": radians, "qd": radians_per_second}

  • list[dict]

    dictionaries, or an empty list before telemetry arrives.

Notes

The batch preserves model timestep resolution between lower-rate packets. It does not turn browser delivery into a deterministic wall-clock 500 Hz stream.

Source code in sim2bot/client.py
def states(self, robot: int = 0) -> list[dict]:
    """Return physics-substep samples carried by the newest telemetry packet.

    Args:
        robot: Robot index returned by
            [`describe`][sim2bot.client.Robot.describe].

    Returns:
        A list of ``{"t": seconds, "q": radians, "qd": radians_per_second}``
        dictionaries, or an empty list before telemetry arrives.

    Notes:
        The batch preserves model timestep resolution between lower-rate
        packets. It does not turn browser delivery into a deterministic
        wall-clock 500 Hz stream.
    """
    state = self.state(robot)
    return state.samples if state else []

Practical examples

Examples use objects discovered from the current scene rather than hard-coded robot metadata.

Inspect substep timestamps

for sample in sim.states(robot=arm.index):
    print(sample["t"], sample["q"], sample["qd"])

Copy a batch before processing

batch = list(sim.states(robot=arm.index))
positions = [sample["q"] for sample in batch]

Guidance

Usage tip

Use states() when you need trajectory resolution between packets; use state() for the complete current robot state.

Important behavior

Substep timestamps preserve simulated resolution but do not imply deterministic 500 Hz wall-clock delivery.


See also