Inverse Kinematics Intro
Accessible geometric IK for a planar 2–3 link arm, then notes on extending toward 6DOF pose.
Learning objectives
- Contrast forward vs inverse kinematics conceptually
- Solve a 2-link planar arm with law of cosines
- Understand workspace and unreachable targets
- See how orientation joints finish a 6DOF pose
Lesson
Forward kinematics (FK): given joint angles, compute tool position. Inverse kinematics (IK): given a desired tool position (and maybe orientation), compute joint angles. Hobby arms often use geometric IK for the first three joints (positioning) and set wrist joints from desired orientation.
For a 2-link planar arm with lengths L1, L2 targeting (x, y):
r² = x² + y²cos(θ2) = (r² − L1² − L2²) / (2·L1·L2) — clamp to [−1, 1]θ2 = ±acos(...) (elbow-up / elbow-down)θ1 = atan2(y, x) − atan2(L2·sin(θ2), L1 + L2·cos(θ2))Convert radians ↔ degrees carefully in firmware or on the host.
If |cos(θ2)| > 1 after calculation, the point is outside the reachable workspace. Fail gracefully — do not NaN your servos.
Full 6DOF analytic IK depends on your exact DH parameters. Many learners compute planar IK for J2/J3 (and base yaw from atan2), then aim the wrist with simpler heuristics. Libraries (e.g., on a host PC) can refine this later.
Components for this chapter
No chapter-specific parts — see the Global BOM or prior chapters.
Step-by-step
- 1
Measure L1 and L2 precisely
Use the link lengths recorded in Chapter 3. Remeasure shoulder-axis to elbow-axis (L1) and elbow-axis to wrist-pitch-axis (L2) in mm.
- 2
Implement planar IK on paper, then code
Pick a reachable (x, y) in the arm plane. Solve θ1, θ2 by hand. Then implement the same math in a small function on the MCU or in Python that prints angles.
- 3
Command the arm to the solved angles
Send J2/J3 (and J1 if using base yaw) via your serial protocol. Compare actual tool position with a ruler — expect small error from backlash and unmodeled offsets.
- 4
Handle unreachable targets
Intentionally request a point beyond max reach. Confirm your code rejects it and leaves the arm where it is (or moves to the nearest reachable point intentionally).
- 5
Add a trivial wrist aim (optional)
For demos, set wrist pitch so the gripper stays roughly level: `wrist = world_level − (θ1 + θ2)` with sign conventions matching your build.
Tips, safety & pitfalls
Finished this chapter?
Sign in to save progress to your account and pick up on any device.