Search documentation of bb

# BB.Command.MoveTo (bb v0.8.0)

View Source

Standard command handler for moving end-effectors to target positions.

This command uses inverse kinematics to compute joint angles and sends position commands to all actuators controlling the affected joints.

Supports both single-target and multi-target modes for coordinated motion.

## Goal Parameters

### Single Target Mode

Required:

- `target` - Target position as `{x, y, z}` or `{:vec3, x, y, z}` in metres
- `target_link` - Name of the link to move (end-effector)
- `solver` - Module implementing `BB.IK.Solver` behaviour

### Multi-Target Mode

Required:

- `targets` - Map of link names to target positions: `%{link: {x, y, z}}`
- `solver` - Module implementing `BB.IK.Solver` behaviour

### Optional (both modes)

- `max_iterations` - Maximum solver iterations (default: 50)
- `tolerance` - Convergence tolerance in metres (default: 1.0e-4)
- `respect_limits` - Whether to clamp to joint limits (default: true)
- `delivery` - Actuator command delivery: `:pubsub` (default), `:direct`, or `:sync`

## Usage

### Single Target

    alias BB.Message.Vec3

    {:ok, task} = MyRobot.move_to(%{
      target: Vec3.new(0.3, 0.2, 0.1),
      target_link: :gripper,
      solver: BB.IK.FABRIK
    })
    {:ok, meta} = Task.await(task)

### Multiple Targets (for gait, coordinated motion)

    {:ok, task} = MyRobot.move_to(%{
      targets: %{
        left_foot: {0.1, 0.0, 0.0},
        right_foot: {-0.1, 0.0, 0.0}
      },
      solver: BB.IK.FABRIK
    })
    {:ok, results} = Task.await(task)

## Return Value

### Single Target

On success, returns metadata from the IK solver:

    %{
      iterations: 12,
      residual: 0.00003,
      reached: true,
      reason: :converged
    }

### Multiple Targets

On success, returns a map of link → result:

    %{
      left_foot: {:ok, %{joint1: 0.5}, %{iterations: 10, ...}},
      right_foot: {:ok, %{joint2: 0.3}, %{iterations: 8, ...}}
    }