Skip to content

sim2bot.Robot.move_to

move_to(q: Sequence[float], robot: int = 0) -> None

Send a joint-position target to one robot.

Parameters:

  • q (Sequence[float]) –

    Joint positions in radians, ordered exactly like RobotInfo.joint_names. Normally supply dof values.

  • robot (int, default: 0 ) –

    Robot index returned by describe.

Returns:

  • None

    The target is sent asynchronously to the simulator.

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.

Notes

The command is latest-writer-wins. In physics mode the robot's controller tracks the target; in kinematics-only mode it is applied directly. Sending a new joint, velocity, TCP, stop, reset, or trajectory command replaces the prior external motion mode.

Warning

Use discovered limits and a model-appropriate trajectory. This method does not plan around collisions or guarantee a safe path.

Examples:

Move the first discovered robot to its model-defined home::

arm = sim.describe()[0]
sim.move_to(arm.home, robot=arm.index)
Source code in sim2bot/client.py
def move_to(self, q: Sequence[float], robot: int = 0) -> None:
    """Send a joint-position target to one robot.

    Args:
        q: Joint positions in radians, ordered exactly like
            `RobotInfo.joint_names`. Normally supply ``dof`` values.
        robot: Robot index returned by
            [`describe`][sim2bot.client.Robot.describe].

    Returns:
        The target is sent asynchronously to the simulator.

    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.

    Notes:
        The command is latest-writer-wins. In physics mode the robot's
        controller tracks the target; in kinematics-only mode it is applied
        directly. Sending a new joint, velocity, TCP, stop, reset, or
        trajectory command replaces the prior external motion mode.

    Warning:
        Use discovered limits and a model-appropriate trajectory. This method
        does not plan around collisions or guarantee a safe path.

    Examples:
        Move the first discovered robot to its model-defined home::

            arm = sim.describe()[0]
            sim.move_to(arm.home, robot=arm.index)
    """
    self._send({"type": "joint_position", "q": list(q), "robot": robot})

Practical examples

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

Move to the discovered home pose

arm = sim.describe()[0]
sim.move_to(arm.home, robot=arm.index)

Change one joint without hard-coding DOF

state = sim.state(robot=arm.index)
target = list(state.q)
target[0] += 0.2
sim.move_to(target, robot=arm.index)

Address two robots independently

left, right = sim.describe()[:2]
sim.move_to(left.home, robot=left.index)
sim.move_to(right.home, robot=right.index)

Guidance

Usage tip

Build targets from discovered home or current state.q so the length and joint order stay correct.

Important behavior

This command does not plan around collisions or enforce a safe Cartesian path.

Common error

A target with the wrong joint count or order can move unexpected joints. Never assume every arm has seven joints.


See also