rebot_control.ik

Damped least-squares (DLS) inverse kinematics of the TCP.

The algorithm, with kinematics from Pinocchio:

  • error = [position error; rot_weight * orientation error], the orientation error being the small-angle rotation vector 0.5 * sum_i r_i x r_i* over the columns of the current / target rotation;

  • step dq = J^T (J J^T + lambda I)^-1 e plus a null-space term pulling towards a preferred posture (avoids drifting into odd configurations and singularities);

  • the step norm is capped at max_step and the result is clipped to the joint limits after every iteration.

Warm-started from the previous solution, 30 iterations per 30 Hz control cycle are enough for streaming targets.

Module Contents

Classes

IKResult

DiffIK

Position (+ optional orientation) IK of the model’s TCP frame.

Functions

small_angle_rot_error

Orientation error as a rotation vector in the base frame (small-angle approximation, sin(theta) * axis).

API

class rebot_control.ik.IKResult
q: numpy.ndarray = None
pos_err: float = None
rot_err: float = None
success: bool = None
iterations: int = None
rebot_control.ik.small_angle_rot_error(R: numpy.ndarray, R_target: numpy.ndarray) → numpy.ndarray

Orientation error as a rotation vector in the base frame (small-angle approximation, sin(theta) * axis).

class rebot_control.ik.DiffIK(model: rebot_control.model.RobotModel, posture: numpy.ndarray | None = None, damping: float = 0.001, posture_gain: float = 0.05, rot_weight: float = 0.3, success_pos_tol: float = 0.005, success_rot_tol: float = 0.05)

Position (+ optional orientation) IK of the model’s TCP frame.

Args:

model: The arm + tool model; its own Pinocchio data is created here (one solver per thread). posture: Preferred joint configuration for the null-space term (default: the middle of the joint range). damping: DLS damping lambda. posture_gain: Null-space gain towards posture. rot_weight: Weight of the orientation error relative to the position error (m vs rad). success_pos_tol / success_rot_tol: A solution further than this from the target is reported as failed.

Initialization

fk(q: numpy.ndarray) → tuple[numpy.ndarray, numpy.ndarray]
solve(target_pos: numpy.ndarray, target_rot: numpy.ndarray | None, q_init: numpy.ndarray, max_iters: int = 50, pos_tol: float = 0.0001, rot_tol: float = 0.001, max_step: float = 0.2) → rebot_control.ik.IKResult

Joint angles that bring the TCP to target_pos (and target_rot unless it is None).