Week 8 — Control Systems Implementation
Day 7 of 7 | Summary & Preview


What We Covered This Week

DayTopicCore Skill
1Control system architectureUnderstand the hierarchy: task → trajectory → motion → motor
2PID controller designTune gains, implement anti-windup, handle saturation
3State-space control & LQRMulti-joint optimal control via Riccati equation
4ROS2 architectureBuild modular pub/sub control stacks
5Sensor fusion with EKFFuse encoders, IMU, and vision into a single state estimate
6Python practiceFull ROS2 + Gazebo control loop with PID

Key Formulas Cheat Sheet

PID Control (Discrete)

$$u_k = K_p e_k + K_i \sum e_j T_s + K_d \frac{e_k - e_{k-1}}{T_s}$$

LQR Optimal Gain

$$K = R^{-1} B^T P \quad \text{where} \quad A^T P + PA - PBR^{-1}B^T P + Q = 0$$

Kalman Filter Predict

$$\hat{x}{k|k-1} = F \hat{x}{k-1|k-1} + B u_k, \quad P_{k|k-1} = F P_{k-1|k-1} F^T + Q$$

Kalman Filter Update

$$K_k = P_{k|k-1} H^T (H P_{k|k-1} H^T + R)^{-1}$$ $$\hat{x}{k|k} = \hat{x}{k|k-1} + K_k (z_k - H \hat{x}_{k|k-1})$$


Common Pitfalls (Learned the Hard Way)

PitfallWhy It HappensFix
Integral windupIntegrator accumulates error while motor is saturatedImplement clamping or back-calculation
Derivative noise amplificationDerivative of noisy signal is unusableFilter the derivative term; use derivative-on-measurement
LQR linearization driftLinearized model only valid near operating pointRe-linearize online, or use nonlinear MPC
EKF divergenceBad initialization, wrong Q/R, or outlier measurementsMahalanobis gating, adaptive Q/R, reset covariance
ROS2 message dropsDefault QoS is best-effort, not reliableSet reliability=RELIABLE for control topics
Control loop jitterNon-real-time OS, competing processesUse RT-PREEMPT kernel, isolate CPU cores

The Big Picture

This week connected the pieces from Weeks 5–7:

A robot without control is a sculpture. Control is what makes it useful.


Preview: Week 9 — Advanced Motion Planning

Week 9 moves from control (how to follow a path) to planning (how to find a path):

DayTopic
1Configuration space and collision detection
2Graph search: A*, Dijkstra, D*
3Sampling-based planning: RRT, RRT*, PRM
4Trajectory optimization: CHOMP, STOMP, TrajOpt
5Dynamic constraints and kinodynamic planning
6Python practice: Implement RRT* for a 2-DOF arm
7Week 9 summary

We’ll build on the control foundation: once a planner generates a trajectory, the controller (from this week) executes it.


Exercise Before Week 9

Challenge: Take the Week 8 Day 6 ROS2 stack and replace the sine-wave planner with a point-to-point planner:

  1. Accept a target position via ROS2 service call.
  2. Plan a smooth trajectory (e.g., cubic polynomial) from current to target.
  3. Feed the trajectory into the PID controller.
  4. Verify the arm reaches the target with < 1% overshoot.

Hint: A cubic polynomial trajectory has the form: $$q(t) = a_0 + a_1 t + a_2 t^2 + a_3 t^3$$

Solve for $a_0, a_1, a_2, a_3$ using boundary conditions:


End of Week 8. See you in Week 9 — Motion Planning!