Software · paused
MATLAB for Robotics Concepts
A chapter-wise collection of MATLAB scripts for building intuition around robotics fundamentals: spatial transformations, manipulator kinematics and inverse kinematics, Jacobians, dynamics, trajectory planning, and linear/nonlinear/force control. It follows John Craig’s Introduction to Robotics and Bruno Siciliano’s Robotics: Modelling, Planning and Control, and pairs each script with a step-by-step animation rather than just equations on a page.
Textbooks are good at the algebra and bad at the picture. A DH table or a Jacobian is easy to write down and hard to see. Each script here takes one idea, builds it from scratch with no toolboxes where possible, and draws it: frames you can rotate, arms that animate along their trajectories, and sliders that update the plots live as you change a gain or a joint angle.
What’s in it
About 6,000 lines of MATLAB across 28 scripts, organised by chapter:
| Chapter | Scripts |
|---|---|
| Spatial descriptions & transformations | Vectors and frames, Euler angles, fixed angles, angle-axis |
| Manipulator kinematics | 2-DOF planar arm, forward kinematics from DH, DH table → frames, UR5 6-DOF arm, workspace |
| Inverse kinematics | 2-DOF analytical IK, numerical (Jacobian) IK, workspace boundary |
| Jacobians | Manipulability, singularity detection, geometric vs analytical Jacobian |
| Dynamics | Lagrangian dynamics, Newton-Euler vs Lagrange, M/C/G matrix visualisation |
| Trajectory planning | Cubic and quintic polynomials, via points, joint vs Cartesian paths |
| Linear control | PID joint control, interactive PID tuning, root locus |
The figures below are what a few of the scripts produce with their default inputs. These renders come from a Python port of the plotting code, and they show the final frame of each animation.
Forward kinematics: a UR5-like arm
UR5_6DOF_arm.m builds the full chain from the UR5’s standard DH table, draws the links and the
intermediate coordinate frames, and compares two joint configurations side by side. The live
version then animates the arm from one pose to the other.

Trajectory planning with via points
via_points_trajectory.m has a 2-DOF arm carry a part
over an obstacle. A naive joint-space move from pick to place cuts straight through the obstacle,
and the collision points are marked in red. Adding via points and fitting a cubic spline through
them in joint space lifts the path clear.

Control: PID gain tuning
PID_gain_tuning.m models a single robot joint as G(s) = 1/(Js² + Bs) and gives you sliders for
Kp, Ki and Kd. The step response, closed-loop pole-zero map and live metrics (rise time, overshoot,
settling time) all update as you drag. The build-up panel shows what each term adds: P alone rings,
D damps it, and I removes the steady-state error.

With the defaults (Kp = 40, Ki = 8, Kd = 4), the joint rises in about 0.15 s, overshoots by about 12%, and settles within 2% in about 0.6 s.
Still a work in progress, chapter by chapter. Nonlinear control, force control and modelling are next.