Robot Hand-Eye Calibration
Move a wrist-mounted camera around a stationary target. The camera-to-wrist transform must explain every view with the same rigid mounting geometry.
Why Does This Exist?
A camera locates a bolt accurately in its own coordinates, yet the arm reaches beside it. The missing quantity may be the camera's position and orientation relative to the wrist. Hand-eye calibration estimates that fixed rigid transform from synchronized robot poses and camera observations. Naming frames correctly does not measure the mount.
A transform rotates and translates point coordinates between frames; composition chains those changes. Coordinate frames introduces that algebra. Here the transform is unknown. Intrinsic camera calibration instead measures projection and distortion inside the camera; dynamics identification measures another part of the system entirely.
Think of It Like This
A torch taped to a hinged ruler
Tape a torch at an unknown offset from a ruler's hinge. Turn and move the ruler while aiming at one mark on the wall. The offset rotates with the ruler, while the wall mark stays still. Find the attachment geometry that makes all the sightings agree. The ruler maps to the robot wrist, the torch to the camera and the wall mark to a calibration target. The analogy stops at the measurements: a camera estimates a full target pose from several known marks, not just the direction of a light beam.
How It Actually Works
Which transform is unknown?
Write for the homogeneous transform that takes coordinates from frame into frame . Let be gripper-to-base pose at capture , camera-to-gripper mount, and target-to-camera pose. The superscripts identify base, gripper, camera and target frames. In an eye-in-hand setup, the target is fixed in the base frame, so
Multiplying by inverses gives , with and . Both represent relative motion, in different frames. Reversing both motion-pair directions consistently gives another valid convention; reversing just one does not.
OpenCV's calibrateHandEye contract accepts gripper-to-base and target-to-camera pose arrays and returns camera-to-gripper. Its documentation derives the relative-motion equation and requires rotations about nonparallel axes for a spatial calibration. An eye-to-hand setup has a fixed camera and moving target; derive its chain before reusing an API call.
Recover an offset in a planar fixture
For a transparent calculation, restrict motion to a plane and suppose the mount rotation is already known to be identity. Let the relative wrist motion have rotation , a counterclockwise quarter-turn, and translation m. Observations imply and m. Expanding the translation part of gives
The two rows say and , giving m. The determinant is 2, so this restricted translation problem has a unique solution. It does not solve an unknown spatial mount from one motion.
Set absolute wrist poses and . The camera origins become and m; the second camera rotates 90 degrees. A fixed target at m appears at translation in camera 1 and in camera 2. Composing each chain recovers . The diagram uses equal x/y scales: equal-length solid mounts rotate with the wrist, and dashed observations meet at the same diamond. The line segments show origins and sightings; camera optical directions are omitted.
What makes real captures informative?
The rotational equation is ; translation is solved after or jointly with rotation. Pure translation leaves zero and cannot determine the mount offset this way. Repeated turns about one axis leave spatial ambiguity. Acquire diverse, well-separated rotations with the target visible, rather than many nearly identical poses. More pairs from the same captures do not become independent measurements just because a solver accepts them.
Evaluate held-out captures by comparing across views, separating translation error in metres and rotation error in radians. Do not add them without an explicit weight or characteristic length. Then check a physical target in the working volume: kinematic error, target dimensions, focus changes and wrist flex can produce a consistent but physically wrong solution. Extra calibration effort buys a measurable mapping; a bolted fixed fixture measured directly can be simpler for a narrow task.
Code
This dependency-free Python solves the restricted translation fixture and exposes an incorrect mount through its closure residual. Rotation is given, not estimated.
from math import hypot
def solve2(a: float, b: float, c: float, d: float, u: float, v: float) -> tuple[float, float]: det = a*d - b*c if abs(det) < 1e-12: raise ValueError("Translation is not identifiable from this pair") return ((d*u-b*v)/det, (a*v-c*u)/det)
def closure_error(tx: float, ty: float) -> float: # AX translation is R90*tX+tA; XB translation is tX+tB. return hypot(-ty+0.3-tx, tx-ty+0.1)
tx, ty = solve2(-1.0, -1.0, 1.0, -1.0, -0.3, -0.1)print(f"mount: {tx:.3f}, {ty:.3f} m")assert closure_error(tx, ty) < 1e-12print(f"wrong mount residual: {closure_error(tx+0.02, ty):.6f} m")The recovered mount is 0.100, 0.200 m; the offset perturbation produces a
0.028284 m relative-motion closure residual. That residual is not directly the
tool's target-position error.
Watch Out For
A plausible inverse solves the wrong frame chain
Residuals depend strongly on pose or the mapped point moves when the stationary target does not. Write each transform's source and destination beside it. Check API directions, robot flange versus tool frame, units and pose conventions. A transform and its own inverse always round-trip; that alone cannot verify physical calibration.
Many captures hide uninformative motion
The solver changes dramatically when one view is removed, despite many samples. Add rotations around distinct axes and inspect held-out chain disagreement. Pair each image with the pose at exposure time; motion during capture creates a timing error that more static-pose fitting cannot remove.
The Quick Version
- Hand-eye calibration estimates a rigid sensor mount from matched robot and target poses.
- The fixed-target chain yields only with consistent relative-motion directions.
- The planar example recovers a 0.1 m by 0.2 m offset with known mount rotation.
- Spatial calibration needs informative rotations, synchronized captures and held-out checks.
- Low algebraic residual does not establish physical targeting accuracy.