Every vision-guided picker meets the same arithmetic trap sooner or later: the wrist that just took a 20° nudge suddenly spins 340° the other way, the gripper's air line wraps around the tool, and the cycle time jumps. The cause is the way vision reports angles, not the mechanics. Part angle arrives in a −180° to +180° window, and the raw difference between two picks can cross that cut and point the wrist the long way round. This guide gives you the wrap formula, a worked example with the arithmetic shown, the pick-sequence changes that follow from it, and the bench checks that prove the wrist turns the short way on every pick.
Why the wrist turns the long way
Part orientation from vision is an Euler angle: the yaw of the part about the vertical axis, reported inside a −180° to +180° window. The window is bookkeeping. An orientation of −170° and one of +190° are the same physical pose, 360° apart, and the wrist joint itself has no window: it rotates continuously and goes whichever way the commanded angle implies.
The detour happens when consecutive picks sit on opposite sides of the ±180° cut. Last part read +170°, this one reads −170°: the poses are 20° apart in reality, but the raw difference of −170° − 170° = −340° orders the wrist around the long side of the circle. On a packaging line that shows up as vacuum tubing wound around the gripper head, and a flange that is most of a turn away from where you think it is. If a cell has already collected full extra turns and a tangled dress pack, the gripper rotation diagnosis for full turns sorts out the mess; the wrap below keeps it from coming back.
One distinction worth keeping: the reported yaw is the pick target's orientation in the taught frame, not the wrist's joint angle — the tool mounting and the conveyor frame shift it. Use the vision yaw for the wrap and the controller's own joint data for limits.
Wrap the delta, not the part angle
The fix is three lines of arithmetic, applied once per pick. Take the difference between the new part angle and the angle you last commanded, wrap that difference into −180° to +180°, and add it to the last command:
round() is the nearest-integer function, so the wrapped delta always lands between −180° and +180° and the wrist never turns more than half a circle. A delta of exactly ±180° can legitimately go either way; pick a convention and keep it.
The same logic as a branch test in pseudo-code:
// degrees, doubles; set nYawCmd to 0 when you home the wrist
nYawPart := YawFromVision(PickTarget); // -180 to +180, from the vision result
nDelta := nYawPart - nYawCmd; // raw step across the +/-180 cut
IF nDelta > 180 THEN
nDelta := nDelta - 360;
ELSEIF nDelta < -180 THEN
nDelta := nDelta + 360;
ENDIF
nYawCmd := nYawCmd + nDelta; // command as tool rotation about Z
nYawPart, nDelta and nYawCmd are illustrative names for the three doubles the job needs; YawFromVision stands for whatever your controller's vision interface calls the yaw read. The branch form is enough while the raw delta stays inside ±540°. Once the running angle can wind past one turn, use the round() form, which is correct at any magnitude.
Worked example: +170° to −170° in a 20° step
Home the wrist and set the running command to 0°. Pick 1 arrives with a part yaw of +170°: delta = +170° − 0° = +170°, already inside ±180°, so the command is +170°.
Pick 2 arrives at −170°:
- raw delta: −170° − (+170°) = −340°
- wrapped delta: −340° + 360° = +20°
- command: +170° + 20° = +190°
+190° is the same pose as −170°, so the grip is correct and the wrist physically turns +20° instead of −340°. At an example programmed wrist speed of 90°/s, that replaces 340° / 90°/s = 3.8 s of travel with 20° / 90°/s = 0.2 s: 3.6 s back in the cycle, and nothing wound round the head.
| Pick | Part yaw | Raw delta | Wrapped delta | Command | Wrist travel |
|---|---|---|---|---|---|
| 1 | +170° | +170° | +170° | +170° | +170° |
| 2 | −170° | −340° | +20° | +190° | +20° |
Pick 3 back at +170° gives delta = +170° − 190° = −20°, command +170°, travel −20°: short in both directions, which is the property that survives a whole shift of random part angles.
Wire the wrap into the pick sequence
- Add a persistent double, nYawCmd, in degrees, and set it to 0° when the wrist is homed — homed, not merely powered, so the running value matches the physical flange.
- Read each vision result's part yaw into nYawPart, and confirm the sign once: turn a part physically +10° and check the reported yaw reads +10°, not −10°.
- Compute nDelta with the wrap and update nYawCmd := nYawCmd + nDelta.
- Command the pick with nYawCmd as the tool rotation about Z, or equivalently with nDelta as a relative rotation from the current pose. Both give the same motion; the running variable is what makes winding visible later.
- Build the approach and depart points relative to the pick target, so the wrapped rotation carries through the whole move instead of only the grip moment.
- Log nYawCmd every cycle. When the same step applies the full vision correction of X, Y and angle, keep the logged angle beside the position correction so a change in one never hides a change in the other.
Stop the wrist winding up over a shift
Wrapped deltas keep every individual turn short, but the running angle can still walk one way all shift. Eight picks in a row at +20° take the command from +190° to +330°, and the flange is nearly a full turn wound even though no single pick looked wrong. Two remedies:
Unwind while empty. When the gripper holds nothing, command the equivalent angle inside ±180°: with nYawCmd = +330°, the home command is 330° − 360° × round(330° / 360°) = +330° − 360° = −30°. The wrist makes one clean −360° return swing with nothing in the gripper. Unwind at cycle end, or whenever the running angle crosses ±360°.
Respect the joint's window. Some wrists tolerate only a limited range of continuous rotation; a window of −360° to +360°, for instance, gives two full turns before the dress pack or a limit says stop. On those arms, unwind between picks as the running angle nears the edge, or regrip the part at a neutral orientation to reset the count.
Fold the angle when the part has symmetry
A square part gripped on opposite flats is the same part every 90°, and that symmetry shrinks the wrap: fold the yaw into a −45° to +45° window and no pick can ask for more than 90° of travel.
folded = ((aYaw + 45°) mod 90°) − 45°
Use the floored modulo, so the result is 0° to 90° before the subtraction. For aYaw = −170°: −170° + 45° = −125°; −125° + 2 × 90° = +55°; +55° − 45° = +10°. The grip pose sits at +10°, and the delta between any two folded angles stays inside ±90°.
Round parts go further: with no visible heading there is nothing to track and the rotation stage drops out entirely — see keeping the tool orientation fixed on round parts. Fold only when every step of the symmetry is genuinely equivalent for grip and place. A part with a label direction, a chamfer or a connector keeps the full ±180° wrap and lets the deltas do the work.
Common mistakes
- Normalizing the target instead of the delta. The target −170° is already inside −180° to +180°, so wrapping the target alone changes nothing; the 340° detour lives in the difference.
- One branch test where a modulo is needed. The two-line IF unwraps a single turn; a running angle wound past ±540° needs a loop or the round() form.
- Sign flipped by the frame convention. If the tool frame's Z axis points opposite the camera frame's Z, every delta inverts and the wrist short-turns to the wrong pose. The +10° physical test in the steps above catches this in a minute.
- Reading the vision yaw as the joint angle. They differ by the tool mounting and the conveyor frame; wrap with the vision yaw, watch limits with the joint data.
- No running variable, no winding alarm. Without nYawCmd logged every cycle, a dress-pack wrap is discovered by the tubing, not by the log.
Keep the taught frame fixed
The wrap assumes the yaw you read is the yaw that is there, which holds only while the camera over the line has not moved. A bumped bracket shifts every reading by the same offset, and the wrist faithfully short-turns to slightly wrong poses. Mount the pick camera on a stand you can lock, align it once with a slide, and treat any collision as a recalibration trigger. A slide-table stand like the one below holds an overhead camera at line height, lets you trim its position, then locks it down.
- Type
- Camera stands
Stands, slide stages and brackets
265 models · from $69.00To pair a stand with your camera directly, use the camera stand step of the system configurator; the accessories finder filters stands and slide stages by type.
Bench checks before production
- Home the wrist and set nYawCmd to 0°.
- Part at 0°: command reads 0° and the wrist does not move.
- Part at +170°: command +170°, travel +170°.
- Part at −170°: command +190°, travel +20° — the whole fix in one line.
- Alternate the last two ten times. Every commanded step must stay at or under 180° in magnitude; a step above that is a wrap bug to fix before production.
- Turn a part physically +10° from reference: the wrist must follow +10°, which proves the sign and the frame in one move.
- Run 50 mixed-angle picks, then inspect the dress pack and the log: no wraps, and an nYawCmd trend that matches the parts actually fed.
Position that is still off after a correct rotation is a different fault: the vision pick error under rotation diagnosis walks that step by step. For the guides that surround this one on the cell side, see the systems topic page, and when you want a pick sequence checked against your own part and line rate, the contact page reaches the applications team.
Questions
Does the commanded angle have to stay between −180° and +180°?
No. Orientation repeats every 360°, so a command of +190° reaches the same pose as −170°. Most controllers accept any angle on a relative rotation. Keep the running value bounded only to protect the wrist: unwind by commanding angle − 360° × round(angle / 360°) while the gripper is empty. If the wrist has a limited window, for example −360° to +360°, unwind before you reach the edge or regrip the part.
Why does my modulo formula return the delta unchanged?
In many languages the remainder keeps the sign of the dividend: −340 mod 360 evaluates to −340, not +20, so the wrap does nothing. Use a floored modulo (result always 0° to 360°), add 360° inside a loop until the delta lands in range, or keep the two IF branches from this guide. Test the routine on −340°, +340° and 0° before running it on the line.
How much cycle time does the shortest turn save?
It saves the arc you avoid. In the worked example the wrist turns 20° instead of 340°; at an example programmed wrist speed of 90°/s that is 0.2 s instead of 3.8 s, about 3.6 s saved on every pick that crosses the ±180° cut. Picks on the same side of the cut gain nothing, and randomly oriented parts cross the cut regularly, so the saving shows up as fewer wrapped air lines and steadier cycle times.
Can I command fixed approach angles instead of wrapping the delta?
Fixed approach and depart angles solve clearance, not turn length; the rotation at the pick point itself is untouched. Wrap the delta for the turn, and fold the angle into the part's symmetry window when one exists: a square part grips identically every 90°, so wrap its yaw into −45° to +45° and no pick needs more than 90° of travel. Skip folding if the place station needs the part's true heading.
Does wrapping the delta also fix pick position drift?
No. The wrap corrects only the rotation command. If the part still lands offset after a turn, look upstream: a stale hand-eye calibration, a grip offset that does not rotate with the tool, or a conveyor frame that is not square to the robot base. Rotation drift and position drift have different fixes, and mixing them makes both harder to trace.
