Skip to content

sim2bot.Robot.move_to_pose

move_to_pose(position: Sequence[float], orientation: Optional[Sequence[float]] = None, robot: int = 0) -> None

Command a Cartesian TCP target solved by in-browser inverse kinematics.

Parameters:

  • position (Sequence[float]) –

    World-frame [x, y, z] in metres.

  • orientation (Optional[Sequence[float]], default: None ) –

    Optional world-frame quaternion [x, y, z, w]. Omit it for position-only IK.

  • robot (int, default: 0 ) –

    Robot index returned by describe.

Returns:

  • None

    The pose target is sent to the browser IK controller.

Raises:

  • TypeError

    If position or orientation is not an iterable of numbers.

  • ValueError

    If a supplied component cannot be converted to float.

  • 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 IK solution drives the same external target path as joint control. Unreachable targets may settle at the closest configuration the solver finds; verify RobotState.tcp before continuing.

Warning

IK does not imply a collision-free path and can choose a different joint configuration near singularities.

Examples:

Send a position-only target, then a full pose::

sim.move_to_pose([0.45, 0.0, 0.35])
sim.move_to_pose([0.45, 0.0, 0.35], [0.0, 0.0, 0.0, 1.0])
Source code in sim2bot/client.py
def move_to_pose(
    self,
    position: Sequence[float],
    orientation: Optional[Sequence[float]] = None,
    robot: int = 0,
) -> None:
    """Command a Cartesian TCP target solved by in-browser inverse kinematics.

    Args:
        position: World-frame ``[x, y, z]`` in metres.
        orientation: Optional world-frame quaternion ``[x, y, z, w]``. Omit
            it for position-only IK.
        robot: Robot index returned by
            [`describe`][sim2bot.client.Robot.describe].

    Returns:
        The pose target is sent to the browser IK controller.

    Raises:
        TypeError: If position or orientation is not an iterable of numbers.
        ValueError: If a supplied component cannot be converted to ``float``.
        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 IK solution drives the same external target path as joint control.
        Unreachable targets may settle at the closest configuration the solver
        finds; verify `RobotState.tcp` before continuing.

    Warning:
        IK does not imply a collision-free path and can choose a different
        joint configuration near singularities.

    Examples:
        Send a position-only target, then a full pose::

            sim.move_to_pose([0.45, 0.0, 0.35])
            sim.move_to_pose([0.45, 0.0, 0.35], [0.0, 0.0, 0.0, 1.0])
    """
    message: dict = {
        "type": "tcp_pose",
        "position": [float(v) for v in position],
        "robot": robot,
    }
    if orientation is not None:
        message["orientation"] = [float(v) for v in orientation]
    self._send(message)

Practical examples

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

Position-only IK

sim.move_to_pose(
    [0.45, 0.0, 0.35],
    robot=arm.index,
)

Full six-degree-of-freedom pose

sim.move_to_pose(
    position=[0.45, 0.0, 0.35],
    orientation=[0.0, 0.0, 0.0, 1.0],
    robot=arm.index,
)

Verify the achieved TCP

sim.move_to_pose(goal, orientation, robot=arm.index)
state = sim.state(robot=arm.index)
print("requested", goal)
print("achieved", state.tcp if state else None)

Guidance

Usage tip

Omit orientation when position matters more than wrist attitude; it gives IK more freedom to find a solution.

Important behavior

IK can settle at the closest reachable pose and may choose a different joint configuration near singularities.

Common error

Quaternion order is [x, y, z, w], not [w, x, y, z].


See also