A nonlinear-control course project that designs, proves, and simulates two controllers for the classic Spong (1987) single-link flexible-joint robot arm — an exact-input–output feedback-linearizing (FBL) controller and a sliding-mode (SMC) controller — and compares their robustness to parameter mismatch, matched disturbances, actuator saturation, and chattering.
The elastic transmission decouples the motor angle from the link angle, which makes the plant a genuine relative-degree-4, fourth-order nonlinear system with no zero dynamics — a textbook benchmark for putting exact feedback linearization head-to-head against sliding mode control.
📄
Report.pdf— the full written report (46 pages): modeling, control design with proofs, simulation results, and the MATLAB listings.Full plant derivation, Lie-derivative algebra, stability proofs, and a data-driven Simulation Results section also live in
docs/flexible_joint_FBL_SMC.md.
Both controllers reconstruct the output derivatives through the model's Lie
derivatives (no numerical differentiation), share the symbolically-verified
-
Symbolically verified model. Every Lie derivative
(
$L_fh,\dots,L_f^4h,;L_gL_f^3h$ ) is re-derived from scratch with the Symbolic Math Toolbox and checked term-by-term against the hand derivation; relative degree$= 4$ and$b(x)=k/(IJ)=\text{const}$ are confirmed automatically. - Two controllers, one plant. FBL via 4th-order pole placement (≈2 s settling); SMC via a 3rd-order sliding surface + boundary-layer reaching law.
- Honest robustness study. Nominal, ±20 % parameter perturbation (several combinations), and a 1 N·m matched disturbance — controllers always use the nominal model.
- The punchline (matched disturbance): FBL keeps a fixed 0.090 rad (≈5.2°) steady offset; SMC rejects the same torque to 2.7×10⁻⁵ rad — ~3300× smaller.
-
Reproducible. Pure
.mfiles (ode45+ fixed-step ZOH), no Simulink; every figure and number in the docs is generated bymain_simulation.m.
| Tracking error (nominal · perturbed · disturbed) | RMS error & control effort |
|---|---|
![]() |
![]() |
.
├── src/
│ ├── plant_dynamics.m # Nonlinear ODE f(t,x,u,params) + saturation + matched disturbance (Sec 2.2)
│ ├── params_flexible_joint.m # Nominal parameter struct (Sec 2.3 table)
│ ├── reference_trajectory.m # C-smooth quintic 0->pi/2 move + 4 analytic derivatives (Sec 5)
│ ├── symbolic_verification.m # Re-derives & verifies the Lie algebra, exports a(x) (Sec 3)
│ ├── controller_FBL.m # u = (IJ/k)(v - a(x)), pole-placement error law (Sec 3.2)
│ ├── controller_SMC.m # sliding surface + equivalent control + reaching law (Sec 4)
│ ├── main_simulation.m # Runs all scenarios, plots, and the phi sweep (Tasks 6-8)
│ └── a_of_x_gen.m # AUTO-GENERATED verified a(x) (created on first run)
├── figures/ # Generated PNGs (committed for the docs/README)
├── docs/
│ └── flexible_joint_FBL_SMC.md # Derivation, proofs, and Simulation Results
└── Report.pdf # Final written report (LaTeX sources not tracked)
Requirements: MATLAB (developed on R2023b) with the Symbolic Math Toolbox. No Simulink.
cd src % all source lives in src/
main_simulationThis will, in order:
- run
symbolic_verification.m(prints PASS/FAIL for each Lie derivative and writes the verifieda_of_x_gen.m), - simulate FBL and SMC across all scenarios,
- save every figure to
figures/and print a metrics summary table, - sweep the boundary-layer thickness
$\phi$ .
To verify the math alone:
cd src
symbolic_verification(true);All gains and scenario definitions are collected in a single tunable
configuration block at the top of main_simulation.m (FBL pole, SMC sliding
poles
Feedback linearization (Sec 3.2) — cancels the drift exactly and places a Hurwitz quadruple pole:
Sliding mode (Sec 4) — equivalent control plus a boundary-layer switching term that dominates bounded matched uncertainty:
Both build the error derivatives from the measured state through the model's Lie derivatives, so no noisy numerical differentiation is required.
| Nominal tracking | Finite-time reaching of the surface |
|---|---|
![]() |
| Actuator saturation & chattering | Chattering-vs-accuracy tradeoff |
|---|---|
![]() |
![]() |
| Scenario | FBL RMSE [rad] | SMC RMSE [rad] |
|---|---|---|
| Nominal | 0.041 | 0.036 |
| ±20 % parameter mismatch | 0.214 | 0.106 |
| 1 N·m matched disturbance | 0.076 | 0.036 |
See docs/flexible_joint_FBL_SMC.md#6-simulation-results
for the full tables, steady-state numbers, and discussion.
- Because relative degree
$=$ system order, all parametric uncertainty is matched; SMC's switching term therefore helps under mismatch as well as disturbance, but both controllers share a small residual from reconstructing$\ddot y,,y'''$ with the nominal model. - Chattering is a sampled phenomenon: in continuous time the boundary layer
keeps the SMC torque smooth; in a digital (ZOH) loop it re-appears once
$\phi \lesssim K/f_s$ . The$\phi$ -sweep makes this tradeoff quantitative.
M. W. Spong, "Modeling and Control of Elastic Joint Robots," ASME J. Dyn. Syst. Meas. Control, 1987.
Released under the MIT License — see LICENSE.





