Skip to content

sim2bot.Robot.stop_trajectory

stop_trajectory(robot: int = 0) -> None

Cancel trajectory playback and hold the current joint pose.

Parameters:

  • robot (int, default: 0 ) –

    Robot index returned by describe.

Returns:

  • None

    Playback is cancelled and the current pose is held.

Raises:

  • RuntimeError

    If the client is not connected.

  • ConnectionClosed

    If the WebSocket closes while sending the command.

  • OSError

    If the selected transport cannot send the command.

Source code in sim2bot/client.py
def stop_trajectory(self, robot: int = 0) -> None:
    """Cancel trajectory playback and hold the current joint pose.

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

    Returns:
        Playback is cancelled and the current pose is held.

    Raises:
        RuntimeError: If the client is not connected.
        ConnectionClosed: If the WebSocket closes while sending the command.
        OSError: If the selected transport cannot send the command.
    """
    self._send({"type": "joint_trajectory_stop", "robot": robot})

Practical examples

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

Cancel looping playback

sim.stop_trajectory(robot=arm.index)

Stop after a fixed duration

import time

sim.move_trajectory(points, robot=arm.index, loop=True)
time.sleep(5.0)
sim.stop_trajectory(robot=arm.index)

Guidance

Usage tip

Use this instead of reset() when you want to preserve the rest of the scene.


See also