Step 6 (bonus)
Bonus: build your own IK
Replace the black box. Derive the analytic inverse kinematics with the law of cosines and run a full pick with it.
Opening the black box
arm.ik() and arm.move_to() are locked in this step. You'll write the solver yourself. For an arm like this one there's a neat closed-form solution, built from the same geometry you used for FK.
1. Base angle
Seen from above, the arm has to point at the target:
2. Find the wrist
The gripper points straight down, so the wrist sits exactly above the target. Measured from the shoulder:
3. Elbow: law of cosines
The upper arm, the forearm and the line from shoulder to wrist form a triangle:
If the triangle can't close, which means the target is out of reach. Raise ValueError or return None.
Otherwise . Taking the positive root gives the elbow-up solution.
4. Shoulder
The angle to the wrist, minus the angle the forearm adds (both measured from vertical):
5. Wrist
Point the gripper straight down, which means the tilts must sum to :
Your task
- Implement
inverse_kinematics(p), returning[q0, q1, q2, q3]. - The starter program already contains a pick-and-place that uses your IK through
goto(). Once your IK is right, the red ball goes into the cup.
The grader tests 20 random targets for position and gripper orientation, plus two targets that are out of reach.