Skip to content
Dilara Caglar
CourseworkCompleted course assignment

PID Tuning, LQR and Trajectory Optimization

Hand-tuned PID versus LQR on a saturated quadrotor, plus acrobot swing-up by direct transcription.

My contribution

I tuned P, PD and PID gains by hand, derived an analytic PID by pole placement, implemented the discrete Riccati iteration for LQR, computed the performance metrics and wrote the conceptual analysis.

Affiliation
Computational Design of Cyber-Physical Systems
Dates
Spring 2026
Role
Individual assignment on course starter notebooks
Topics
Optimization and Simulation
Tools
JAX, Python
Contents
  1. The problem
  2. My contribution
  3. Constraints
  4. Design decisions
  5. What was difficult
  6. Evidence
  7. Current status
  8. What I would change next

01

The problem

I compared three ways to make a dynamic system do what you want: hand-tuned feedback, model-based optimal control and learning from reward. The test cases were a quadrotor holding altitude against a constant disturbance and an acrobot swinging itself upright, which stand in for drone flight control and underactuated robot motion.

02

My contribution

I tuned P, PD and PID gains by hand, derived an analytic PID by pole placement, implemented the discrete Riccati iteration for LQR, computed the performance metrics and wrote the conceptual analysis. For the acrobot I implemented the direct-transcription objective and dynamics constraints in the course's JAX notebook. I also did the REINFORCE and value-iteration derivations by hand. The course provided the plant models, simulation loop and animation code.

03

Constraints

The actuator was saturated at |u| ≤ 2 for the quadrotor and |u| ≤ 10 for the acrobot, against a constant disturbance d = 0.25. The acrobot trajectory had 61 knots at Δt = 0.05 s, which bounds the resolution of the swing-up.

04

Design decisions

For the analytic PID I matched the closed loop to a dominant second-order pair plus a fast pole: a 1 s rise time gives ωn = 1.8, with ζ = 0.8 and the third pole at 5ωn, which yields Kp = 29.16, Kd = 11.88 and Ki = 29.16. For the acrobot I chose direct transcription because it handles the torque bound and the upright-at-rest endpoint as constraints.

05

What was difficult

The analytic PID met its linear specs on paper but overshot by 98%. The reason is saturation: the design asked for about 29 units of control against a limit of 2, so the integrator wound up. LQR also kept a small steady-state error, and I showed it is exactly d/K₁ = 0.25/6.92 = 0.036, a structural bias from having no integral action rather than a tuning problem.

06

Evidence

LQR reached 4.6% overshoot with a 0.94 s rise time and RMS effort 0.618, the only controller that was both fast and well damped. The manual PD and PID were damped but slow (rise about 5.5 s), and plain P overshot 137.8%. The acrobot converged in 12 SLSQP iterations to an objective of 3417.59 with constraint residual 1.7 × 10⁻¹¹; a later re-run reproduced this exactly, and the torque sat at its limit for 18 of 60 intervals.

07

Current status

Simulation: a completed course assignment.

08

What I would change next

I would add anti-windup to the analytic PID and integral action or a disturbance feedforward to LQR to remove the 0.036 bias. For the acrobot, the next step would be tracking the optimized trajectory with LQR feedback so it survives model error.

Related work