Control Systems · Part 1B

UR5e Controller Design, Benchmarking & Robustness

Building on the validated and characterized UR5e plant from Part 1A, I designed and evaluated PID, computed-torque, discrete LQR, and constrained MPC controllers on one common nonlinear benchmark. The study progresses beyond nominal tracking to diagnose controller-specific behavior, validate Python–C++ implementations, measure computation, and test robustness under persistent payload mismatch and a transient external disturbance.

UR5ePIDComputed TorqueLQRMPCRobustnessOSQPC++

View source on GitHub →

4Controller architectures on one common nonlinear benchmark
0.00124°Computed-torque nominal overall joint RMSE
2Robustness cases separating model mismatch and external disturbance
Engineering objective: compare controller assumptions and trade-offs rather than select a universal “best” controller. Nominal accuracy, robustness, computation, model dependence, and implementation behavior are evaluated separately.

1. Common Benchmark

All controllers use the same validated nonlinear rigid-body plant, initial condition, reference trajectory, 2 ms sampling period, and modeled torque limits. The 4 s quintic trajectory moves from [0, -90, 90, -90, -90, 0]° to [20, -60, 60, -70, -70, 20]°. Part 1A established that this trajectory is dynamically meaningful without being saturation dominated.

ControllerJoint RMSETCP Position RMSETCP Orientation RMSE
PID0.469844°5.835795 mm1.527910°
Computed Torque0.001244°0.004139 mm0.002883°
LQR0.015502°0.418511 mm0.037763°
MPC0.048474°0.378424 mm0.129772°

2. PID — Feedback Baseline and Dynamic Diagnosis

The joint-space PID was tuned through effective-inertia-based bandwidth, damping, and integral-gain studies. The final design uses ωn = 20 rad/s, ζ = 3, and αi = 18. Instead of treating the remaining J4 error as a generic gain problem, I decomposed the dynamics and found that the behavior was primarily gravity dominated rather than saturation or coupling dominated.

PID Bandwidth Sweep
Figure 1 — PID Bandwidth SweepSystematic bandwidth study before final damping and integral-action selection.
PID Damping Selection
Figure 2 — PID Damping SelectionFinal damping comparison used to control transient behavior.
PID Integral-Gain Selection
Figure 3 — PID Integral-Gain SelectionIntegral action was introduced after the PD structure was established.
Final PID Joint Tracking
Figure 4 — Final PID Joint TrackingCommon 4 s benchmark tracking with the final PID design.
PID Joint Error
Figure 5 — PID Joint ErrorNominal overall joint RMSE: 0.469844°.
PID Commanded Torque
Figure 6 — PID Commanded TorqueThe nominal response remains well inside the adopted torque limits.
J4 Dynamic Decomposition
Figure 7 — J4 Dynamic DecompositionThe largest PID tracking issue was diagnosed as gravity dominated rather than saturation dominated.

3. Computed Torque — Nominal Accuracy and Model Dependence

Computed-torque control uses the nominal rigid-body model to cancel the modeled dynamics and impose second-order error behavior. With the controller model and plant exactly matched, it achieved 0.001244° overall joint RMSE and 0.004139 mm TCP position RMSE.

τ = M(q)[q̈d + Kdė + Kpe] + c(q,q̇) + g(q)

The commanded torque closely reproduces the Part 1A inverse-dynamics benchmark. I therefore treated the exceptional nominal result as a reason to test model sensitivity rather than as proof of universal superiority. The 2 kg payload case later exposes that dependence directly.

The measured Python computation time is dominated by the current numerical Coriolis implementation and is not interpreted as an intrinsic timing limit of computed-torque control.

4. Discrete LQR — Diagnosing the Feedforward Structure

The first local LQR implementation performed poorly on the nonlinear trajectory. The result was retained as a diagnostic step. A fixed equilibrium gravity term did not follow the changing reference configuration. The final design uses exact ZOH discretization, a DARE solution, Bryson-style normalization, ρu = 100, and reference-dependent gravity feedforward.

τ = g(qref) − K [ q − qref ; q̇ − q̇ref ]
LQR Gravity Feedforward — TCP
Figure 8 — LQR Gravity Feedforward — TCPReference-dependent gravity feedforward substantially improved nonlinear trajectory tracking.
LQR Gravity Feedforward — Orientation
Figure 9 — LQR Gravity Feedforward — OrientationThe result showed that feedforward structure mattered more than repeatedly retuning the same fixed-gravity formulation.
LQR Input-Weight Sweep
Figure 10 — LQR Input-Weight SweepGain and closed-loop pole behavior were examined before nonlinear selection.
LQR Nonlinear Sweep — TCP
Figure 11 — LQR Nonlinear Sweep — TCPCandidate input penalties were evaluated on the nonlinear plant.
LQR Nonlinear Sweep — Orientation
Figure 12 — LQR Nonlinear Sweep — OrientationNonlinear evaluation connected the local design to full-trajectory behavior.
Final LQR Joint Tracking
Figure 13 — Final LQR Joint TrackingFinal overall joint RMSE: 0.015502°.
Final LQR Joint Error
Figure 14 — Final LQR Joint ErrorLow error was achieved with one fixed nominal linearization plus reference-dependent gravity feedforward.
Final LQR Commanded Torque
Figure 15 — Final LQR Commanded TorqueThe common benchmark remains within the modeled torque limits.

5. Constrained MPC — Prediction and Runtime Architecture

The final linear MPC uses Np = 160 (320 ms), Nc = 40 (80 ms), ρu = 10, and explicit joint-torque constraints in an OSQP quadratic program. Profiling showed that known reference-dependent QP terms were being rebuilt online. I separated the gradient into state-dependent and known reference-dependent components and moved the latter offline, preserving the controller mathematics while reducing online computation.

MPC Prediction-Horizon Sweep
Figure 16 — MPC Prediction-Horizon SweepPrediction length was selected from measured tracking and computation behavior.
MPC Control-Horizon Sweep
Figure 17 — MPC Control-Horizon SweepA shorter independent control horizon reduces optimization dimension while retaining a longer prediction window.
MPC Solver-Tolerance Study
Figure 18 — MPC Solver-Tolerance StudySolver accuracy and computation were evaluated together.
MPC Joint Error Metrics
Figure 19 — MPC Joint Error MetricsFinal overall joint RMSE: 0.048474°.
MPC TCP Metrics
Figure 20 — MPC TCP MetricsNominal TCP position/orientation RMSE: 0.378424 mm / 0.129772°.
MPC Torque Utilization
Figure 21 — MPC Torque UtilizationConstraints are included in the QP, but the nominal benchmark does not activate them.
MPC Computation Optimization
Figure 22 — MPC Computation OptimizationProfiling motivated an offline/online algebraic decomposition without changing the controller objective.
MPC Python–C++ Timing
Figure 23 — MPC Python–C++ TimingC++ mean online time ≈ 0.96 ms with Python–C++ torque agreement ≈ 2 × 10⁻¹⁰ Nm.

6. Robustness Methodology

Nominal accuracy and robustness were intentionally separated. Final controller parameters were frozen and two different perturbation mechanisms were applied to the actual plant.

R1 — Persistent Model Mismatch

A 2.0 kg point payload is placed 0.10 m along tool-frame +Z. The actual plant changes inertia and gravity while every controller continues to use its nominal bare-arm design model.

R2 — External Disturbance

A +20 Nm generalized torque is applied to Joint 2 for 200 ms from t = 2.0 s. The nominal plant itself is unchanged and the controller is not informed of the disturbance.

7. Robustness Results

Joint Tracking Robustness
Figure 24 — Joint Tracking RobustnessNominal, 2 kg payload mismatch, and J2 disturbance results.
TCP Position Robustness
Figure 25 — TCP Position RobustnessCartesian position tracking reveals sensitivity not visible from nominal joint RMSE alone.
TCP Orientation Robustness
Figure 26 — TCP Orientation RobustnessPersistent model mismatch affects all four controller architectures.
Tracking Degradation Relative to Nominal
Figure 27 — Tracking Degradation Relative to NominalRelative degradation is interpreted together with absolute error, especially when the nominal denominator is near zero.
Control Effort Under Robustness Tests
Figure 28 — Control Effort Under Robustness TestsNone of the robustness cases is saturation dominated.
ControllerCaseJoint RMSE [deg]TCP Position [mm]TCP Orientation [deg]
PIDNominal0.4698445.8357951.527910
PIDPayload1.20530911.9634383.585649
PIDDisturbance0.4724166.0322061.531076
Computed TorqueNominal0.0012440.0041390.002883
Computed TorquePayload3.68447520.5621349.174375
Computed TorqueDisturbance0.5045130.9002200.907051
LQRNominal0.0155020.4185110.037763
LQRPayload1.56428928.2938324.533704
LQRDisturbance0.1630664.2465700.406142
MPCNominal0.0484740.3784240.129772
MPCPayload1.41237812.3801913.659589
MPCDisturbance0.0856701.5036110.209132

8. Engineering Conclusions

Nominal Precision ≠ Robustness

Computed torque is exceptionally accurate under exact model match, while persistent payload mismatch exposes the sensitivity of model cancellation. The two tests measure different properties.

Transient ≠ Persistent Uncertainty

The J2 pulse disappears after 200 ms while the payload mismatch persists. Separating the cases prevents disturbance rejection and model robustness from being treated as the same engineering problem.

Constraints Were Not the Story Here

MPC includes explicit torque constraints, but none of the current tests activates them. The present results therefore support conclusions about tracking, computation, and robustness—not a demonstrated constraint-handling advantage.

Implementation Matters

PID exposed update-order details, LQR exposed feedforward structure, and MPC exposed the distinction between controller mathematics and online software architecture. Python–C++ cross-validation ensured implementation changes preserved the intended controller.

Part 1B conclusion: the useful comparison is not a single controller ranking. PID, computed torque, LQR, and MPC make different assumptions about feedback, model fidelity, prediction, constraints, and computation. Those assumptions become visible only when nominal tracking, model mismatch, disturbance rejection, and implementation behavior are examined together.

9. Technical Reports

Integrated Part 1B Report

Full controller-design, nominal-benchmark, computation, Python–C++ validation, and robustness assessment.

View Full Part 1B Report

PID Controller Report

Detailed tuning, final benchmark, J4 dynamic diagnosis, and implementation analysis.

View PID Report

LQR Controller Report

Discrete design, gravity-feedforward diagnosis, nonlinear tuning, and Python–C++ validation.

View LQR Report

MPC Controller Report

QP formulation, horizon/tolerance studies, computation profiling, offline/online restructuring, and C++ runtime validation.

View MPC Report

← Previous: Part 1A Back to Projects →

Project by Sooyong Kim · Robotics Control Portfolio