4-DOF SCARA Kinematics, Dynamics & Computed-Torque Tracking
MATLAB project for 4-DOF SCARA forward kinematics, task-Jacobian analysis, Lagrangian dynamics, workspace visualization, model consistency checks, and computed-torque trajectory tracking.
This MATLAB project studies a 4-DOF SCARA manipulator with two planar revolute joints, one vertical prismatic joint, and one wrist revolute joint. The public implementation consolidates the original academic kinematics and Lagrangian equation-of-motion work into a single reproducible runner, then adds numerical model checks, Jacobian analysis, workspace visualization, and a computed-torque tracking demonstration.
The complete implementation and generated results are available here: GitHub repository
The cleaned version intentionally does not use the unfinished legacy Simulink controller block. Instead, it evaluates one internally consistent 4-DOF model derived from the original Lagrangian formulation and clearly separates that source-derived mechanical model from the newer tracking demonstration used for reproducibility.
Robot model
The generalized coordinates are q = [q1, q2, q3, q4]ᵀ. The first, second, and fourth coordinates are revolute joints, while q3 is the vertical prismatic displacement and is defined positive downward. The task coordinates are Cartesian position [x, y, z] together with end-effector yaw φ.
| Model parameter | Value |
|---|---|
| First link length, L₁ | 0.32 m |
| Second link length, L₂ | 0.26 m |
| Base vertical offset, d₁ | 0.40 m |
| Link/body masses, [m₁ m₂ m₃ m₄] | [2.0 1.5 0.5 0.1] kg |
| Viscous coefficients, B | [0.3 0.3 0.5 0.2] |
| Gravity | 9.81 m/s² |
The dynamics are evaluated in standard manipulator form as D(q)q̈ + h(q,q̇) + G(q) + Bq̇ = u. The runner also checks the mass matrix numerically over a full q2 ∈ [−π, π] sweep before carrying out the tracking experiment.
| Dynamic-model check | Result |
|---|---|
| Maximum mass-matrix symmetry error | 0.000e+00 |
| Minimum eigenvalue of D(q) over tested q₂ sweep | 3.947361 × 10⁻⁴ |
| Mass-matrix symmetry | PASS |
| Positive definiteness over tested sweep | PASS |
Planar motion and computed-torque demonstration
For the reproducibility experiment, I added a computed-torque trajectory-tracking law around the cleaned dynamic model. The controller and simulated plant use the same nominal dynamics, so this is an implementation and trajectory-tracking demonstration rather than a robustness study. A deliberate initial-condition mismatch is included to make the transient response visible.
Joint-space tracking
| Tracking metric | Value |
|---|---|
| Joint 1 RMSE | 0.003388 rad (0.194°) |
| Joint 2 RMSE | 0.021569 rad (1.236°) |
| Joint 3 RMSE | 6.718 mm |
| Joint 4 RMSE | 0.006507 rad (0.373°) |
| Cartesian RMSE | 10.001 mm |
| Maximum Cartesian error | 71.114 mm |
| End-effector yaw RMSE | 0.018447 rad (1.057°) |
The maximum errors should be interpreted together with the imposed initial offset. They are not steady-state tracking errors and they are not measurements of physical robot accuracy.
Generalized control inputs
Jacobian and singularity analysis
For the task coordinates used here, the Jacobian determinant is proportional to −L1 L2 sin(q2). The expected planar elbow singularities therefore appear at q2 = 0 and q2 = ±π within the tested sweep.
Planar workspace
This is a geometric workspace illustration using unrestricted q1, q2 ∈ [−π, π]. It does not impose manufacturer joint limits, collision constraints, or an application-specific operating envelope.
3-D end-effector trajectory
Scope and limitations
This project is a simulation and numerical modelling study. The computed-torque experiment uses the same nominal dynamic model in the controller and plant; no parameter uncertainty, external disturbance, actuator saturation, sensor noise, or hardware dynamics are included. The results therefore should not be interpreted as robustness or experimental validation.
The mass-matrix properties are numerical consistency checks over the documented second-joint sweep, not a general formal proof for every possible parameter set. Likewise, the workspace analysis is geometric rather than manufacturer-validated, and no collision checking is included.
The original archived project contained multiple SCARA exercises and an unfinished legacy Simulink implementation with inconsistent dimensionality. The public repository intentionally preserves the technically consistent 4-DOF Lagrangian model and does not claim validation of that legacy block.
Reproducibility
The repository contains a self-contained MATLAB entry point, model notes, generated figures, CSV metrics, and a text summary. Running run_scara_project.m regenerates the analysis and exported results. The cleaned runner was tested with MATLAB R2022b and does not require Simulink or the Symbolic Math Toolbox.