Skip to main content

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.

Planar SCARA end-effector trajectory with representative robot configurations

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 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]
Gravity9.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 error0.000e+00
Minimum eigenvalue of D(q) over tested q₂ sweep3.947361 × 10⁻⁴
Mass-matrix symmetryPASS
Positive definiteness over tested sweepPASS

Planar motion and computed-torque demonstration

Desired and actual planar SCARA trajectory with representative robot snapshots
Figure 1. Planar end-effector motion with representative SCARA configurations. The desired and simulated end-effector paths are shown together with several robot configurations sampled during the motion.

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

Desired and actual trajectories for all four SCARA joints
Figure 2. Desired and actual joint trajectories. The four panels show tracking for the two planar revolute joints, the vertical prismatic joint, and the wrist revolute joint.
Tracking errors for the four SCARA generalized coordinates
Figure 3. Joint-space tracking errors. The error is largest during the imposed initial mismatch and then rapidly decays under the exact-model computed-torque controller.
Tracking metric Value
Joint 1 RMSE0.003388 rad (0.194°)
Joint 2 RMSE0.021569 rad (1.236°)
Joint 3 RMSE6.718 mm
Joint 4 RMSE0.006507 rad (0.373°)
Cartesian RMSE10.001 mm
Maximum Cartesian error71.114 mm
End-effector yaw RMSE0.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

Computed generalized control torques and prismatic force for the SCARA simulation
Figure 4. Generalized control inputs. Revolute-joint torques and the prismatic-joint force generated by the computed-torque tracking demonstration are shown over the simulated trajectory.

Jacobian and singularity analysis

SCARA task-Jacobian determinant magnitude and minimum singular value versus second joint angle
Figure 5. Task-Jacobian singularity analysis. The determinant magnitude and minimum singular value are evaluated over the second-joint sweep to identify loss of rank in the 4-DOF task mapping.

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

Geometric planar workspace generated by sweeping the first two SCARA joint angles
Figure 6. Geometric planar workspace. The first two revolute coordinates are swept over their full numerical range to visualize the reachable planar region of the two-link arm.

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

Desired and actual three-dimensional SCARA end-effector trajectories
Figure 7. Three-dimensional end-effector trajectory. The desired and simulated Cartesian paths show the combined planar revolute motion and vertical prismatic motion during the tracking experiment.

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.