Robotics Foundations capstone
A planar arm that reaches and holds: kinematics to PID
Specify, model and control a simulated two-link planar arm: map its workspace, solve inverse kinematics for a set of targets, and tune a PID controller for each joint that copes with saturation and delay.
About 14 hours · 6 milestones · Self-assessed · Free · Download brief (CC BY 4.0)
Why this project
Almost every robot arm, from a factory welder to a small desktop kit, has to answer two questions over and over: where must my joints go to put the tip there? and how do I drive the joints so they actually get there, quickly and without overshooting? In this capstone you will answer both for a simulated two-link planar arm, using only Python, paper and a calculator. No hardware is needed.
You will act as the engineer who has been asked to show that a proposed arm can reach a set of points on a table and settle on each one. Your evidence will be your own calculations and simulations, clearly labelled as such.
The arm
Choose your own link lengths between 0.15 m and 0.40 m, and write them down before you begin. Each joint is revolute and has limits you choose (for example, the elbow cannot fold back past ±150°). Each joint is driven by an actuator modelled as a simple first-order system with a maximum speed, so your controller cannot command infinite motion.
What you will do
1. Write a short specification
Using what you learned about reading a robot specification, write a half-page spec for your arm: reach, workspace shape, joint limits, the maximum joint speed you assume, and what "settled" means (for example, tip within 5 mm of the target and staying there). Distinguish accuracy from repeatability and say which one your simulation can and cannot tell you about.
2. Forward kinematics and the workspace
Implement forward kinematics. Here is a starting point you can copy:
import math
def forward(l1, l2, t1, t2):
"""Tip position of a planar two-link arm (angles in radians)."""
x = l1 * math.cos(t1) + l2 * math.cos(t1 + t2)
y = l1 * math.sin(t1) + l2 * math.sin(t1 + t2)
return x, y
x, y = forward(0.30, 0.20, math.radians(30), math.radians(45))
print(f"x = {x:.4f} m, y = {y:.4f} m")Running it prints x = 0.3116 m, y = 0.3432 m. Check this value by hand before trusting the code. Then sweep both joints across their limits and record which tip positions are reachable. Sketch the workspace on paper, marking the inner and outer boundaries, and explain how your joint limits change its shape.
3. Inverse kinematics for real targets
Pick six target points: four comfortably inside the workspace, one on the outer boundary and one outside it. Solve inverse kinematics for each, giving both elbow-up and elbow-down solutions where they exist. For every solution, run it back through forward and report the error. For the unreachable target, your code should say so rather than crash or return nonsense. Note which target sits closest to a singular configuration, and use the planar Jacobian to explain what happens to tip speed there.
4. Joint control
Now drive each joint from its current angle to the angle your inverse kinematics produced. Start with proportional control alone and show its steady-state error when you add a constant disturbance (gravity-like torque on one joint). Add integral and then derivative action. Follow the systematic tuning procedure from the feedback-control module and keep a log of every gain you try and what you observed: rise time, overshoot, settling time and steady-state error.
5. Make it realistic
Add the practical problems: clamp the actuator command to a maximum (saturation), add one or two time steps of sensing delay, and add small random noise to the measured angle. Show integrator windup happening, then fix it with a simple anti-windup rule, and show the difference.
6. Draw the system
Finish with a block diagram of the whole loop: target, inverse kinematics, two joint controllers, actuators, joint sensors and the feedback path. Label each arrow with what flows along it and its rate.
What good work looks like
Good work states its assumptions, checks code against hand calculations, and reports what the simulation showed without claiming more. A simulated arm settling nicely does not prove a real arm will. Say which real-world effects you left out, such as link mass, friction and backlash, and which way each would probably push your results.
Every number in your report should come from your own calculation or your own simulation run, and should say which.
Milestones
- 01
Specification and assumptions
Half-page spec with link lengths, joint limits, maximum joint speed, the definition of 'settled', and a note on accuracy versus repeatability.
- 02
Forward kinematics and workspace map
Working forward-kinematics function checked against at least two hand calculations, plus a labelled workspace sketch showing the effect of joint limits.
- 03
Inverse kinematics for six targets
Elbow-up and elbow-down solutions where they exist, round-trip errors through forward kinematics, graceful handling of the unreachable target, and a Jacobian-based comment on the near-singular target.
- 04
PID joint control with a tuning log
P, PI and PID responses to a step with a constant disturbance, and a tuning log recording each gain change and the resulting step-response metrics.
- 05
Saturation, delay, noise and anti-windup
Simulations showing the effect of each practical issue, a demonstration of integrator windup, and a before-and-after comparison with anti-windup.
- 06
Block diagram and report
A labelled system block diagram and a short report that separates simulated results from real-world expectations.
What you hand in
- A Python script (or notebook) containing forward kinematics, inverse kinematics and the joint-control simulation, with comments.
- A labelled workspace sketch on paper or as a plot.
- A tuning log, written as a list or code block, recording each gain set tried and the measured rise time, overshoot, settling time and steady-state error.
- A labelled block diagram of the full control loop.
- A 2–4 page report covering the specification, method, simulated results, limitations and what you would test on real hardware.
Rubric
Read this before you start. Each criterion has four levels of performance.
Kinematics correctness
- Beginning
- Forward kinematics has errors or is not checked against any hand calculation.
- Developing
- Forward kinematics is correct; inverse kinematics works for some targets but misses the second solution or crashes on the unreachable target.
- Proficient
- Both solutions found where they exist, round-trip errors below 1 mm reported, unreachable target detected and reported.
- Exemplary
- As Proficient, plus joint limits are enforced in the solver and the near-singular target is analysed with the Jacobian, with a correct explanation of the loss of tip speed in one direction.
Control design and tuning
- Beginning
- Only one controller is shown and gains are chosen without explanation.
- Developing
- P, PI and PID are all shown, but the tuning log is incomplete or metrics are not measured.
- Proficient
- Tuning follows a stated procedure; every gain change is logged with rise time, overshoot, settling time and steady-state error.
- Exemplary
- As Proficient, plus the final choice is justified against the specification's 'settled' definition and a trade-off (for example, speed versus overshoot) is explicitly discussed.
Practical issues
- Beginning
- Saturation, delay and noise are not modelled.
- Developing
- At least one practical issue is modelled but its effect is not explained.
- Proficient
- Saturation, delay and noise are all modelled; windup is demonstrated and fixed with an anti-windup rule, with a before-and-after comparison.
- Exemplary
- As Proficient, plus the student finds the largest delay their tuned controller tolerates before oscillating and explains why in terms of acting on old information.
System thinking and diagram
- Beginning
- No diagram, or a diagram with unlabelled blocks.
- Developing
- Diagram shows the main blocks but arrows are unlabelled or the feedback path is missing.
- Proficient
- Every block and arrow is labelled with what flows and at what rate; the feedback path is clear.
- Exemplary
- As Proficient, plus the diagram marks where delay and noise enter and is used in the report to explain a result.
Honest reporting
- Beginning
- Results are claimed to apply to a real arm with no caveats.
- Developing
- Some assumptions are listed but simulated and real-world claims are mixed together.
- Proficient
- All assumptions are stated, every number is labelled as calculated or simulated, and at least three omitted real-world effects are named.
- Exemplary
- As Proficient, plus the report predicts the likely direction of each omitted effect and proposes a specific test on real hardware to check one of them.
Going further
Add a straight-line trajectory: move the tip from one target to another along a straight line at constant speed by converting a desired tip velocity into joint velocities with the inverse of the Jacobian, and show what happens to the joint speeds as the path passes near a singular configuration.
Lessons this builds on
- Joints, degrees of freedom and workspaceIntroduction to robotics
- Reading a robot specificationIntroduction to robotics
- Drawing a system block diagramRobotic system architecture
- Forward and inverse kinematics of a two-link armMathematical foundations of movement
- Inverse kinematics and the workspaceMathematical foundations of movement
- Velocity kinematics and the JacobianMathematical foundations of movement
- Integral action and steady-state errorIntroduction to feedback control
- Derivative action and dampingIntroduction to feedback control
- Tuning a PID controller systematicallyIntroduction to feedback control
- Practical control: saturation, windup, noise and delayIntroduction to feedback control