Jacobians & Velocity Control, bonus step
Bonus: Use the spare joint
Four joints, three coordinates: spend the leftover freedom on keeping the gripper vertical while it moves.
Builds on Linear systems: calibrate a camera, from the free Foundations.
Write and run this step in the simulator with ProA joint to spare
The grasp point has 3 coordinates but the arm has 4 joints. For most positions there's a whole curve of configurations that put the grasp point in the same place. Moving along that curve changes the arm's shape but not the grasp point. Those joint velocities form the null space of : .
Resolved-rate control with ignores this freedom and always takes the smallest . As a side effect, the gripper's tilt drifts as it moves.
Adding a second goal
The matrix projects any joint velocity onto the null space, so anything you pass through it leaves the grasp point where it is. That lets you add a second term:
The first term does the task. The second does whatever else you like without disturbing the task.
Keeping the gripper vertical
The gripper points straight down when the pitches sum to . Penalise the deviation with and move downhill on it:
A gain of works well.
Your task
In phase("trace"), move the grasp point along the straight line from to in 3 s while keeping the gripper vertical.
The starter already traces the line with plain and plots the tilt: run it and watch the tilt wander. Then add the null-space term to rate_step. It works during the approach too, levelling the gripper before the trace starts.
To pass, reach both ends, stay within 5 mm of the line, and keep the tilt under 5° throughout the trace.