Jacobians & Velocity Control, step 5
Singularities & damped least squares
Stretch the arm to its limit, watch the pseudo-inverse blow up, and tame it with damping.
Builds on Least squares: fitting noisy data, from the free Foundations.
Write and run this step in the simulator with ProWhen the Jacobian loses rank
Stretch the arm out straight and ask the gripper to move further away. No joint speed can do it: every column of is now perpendicular to the arm, so has lost a direction. That's a singularity.
Close to one, still returns joint speeds, but huge ones. To gain a millimetre in the almost-impossible direction it spins the joints very fast. Aim at a point out of reach and it asks for well over 100 rad/s.
Measuring it
Manipulability tells you how close you are:
It is proportional to the volume of gripper velocities that unit joint speeds can produce, and it falls to 0 at a singularity.
Damped least squares
Instead of solving exactly, balance the error against the size of the step:
Far from singularities is tiny next to , so this is almost . Near one, the damping caps the gain: no direction gets more than times its error. You give up a little accuracy for bounded, safe speeds. The same step, used for IK, is called Levenberg–Marquardt.
Your task
- Implement
dls_step(J, e, lam). Usenp.linalg.solverather than inverting the matrix. - In
phase("reach")the program drives the gripper toward for 2 s, commanding at 100 Hz. That point is out of reach: the arm is only 0.67 m long. Replace itsnp.linalg.pinvstep withdls_step(J, e, LAM).
Run the starter first and look at the Plots tab: falls as the arm straightens, and the joint speeds explode. To pass, keep every commanded joint speed below 5 rad/s and end within 3 cm of full stretch toward the target.