Step 1
Cubic trajectories
Stream your own setpoints: fit a cubic to four boundary conditions and drive the arm through three moves.
Opening the box
In Pick & Place, arm.move_joints(q, duration) glided the arm for you. Under the hood it sent a new target to the PD controllers every 10 ms. In this lesson you generate that setpoint stream yourself, so move_joints and move_to are switched off.
Four conditions, four coefficients
A move from to that takes seconds should start and end at rest:
Four conditions pin down the four coefficients of a cubic. With and :
The formula works on the whole joint vector at once, because each joint just gets its own . The speed peaks halfway through, at .
Streaming setpoints
Industrial controllers work the same way: a trajectory generator hands the servo loop a fresh setpoint every cycle.
for i in range(n + 1): # n = T / 0.01
arm.set_joint_targets(cubic(q0, qf, T, i * 0.01))
sim.wait(0.01)
Open the Plots tab after a run. The measured shoulder angle trails the commanded one slightly, because the PD controller needs a moment to catch up. That's why the graders in this lesson check your commands, not the measured angles.
Your task
- Implement
cubic(q0, qf, T, t).q0andqfhold 4 joint angles each. Clamp to , so times before the start return and times after the end return . - The starter already streams the three 1.5 s moves in
CONFIGSand labels themphase("move 1")to"move 3". For nowcubicjust returnsqf. Run it and watch the targets jump.
The graders test cubic on random inputs. They also check that each move lasts 1.5 s and never commands more than the cubic's peak speed.