# PID and Kalman filters

Both PID and Kalman filters are used extensively in Robotics. I gather, Kalman filters for sensing and PID for control. What is the mathematical, statistical or other relationship between them?

There isn't really a relationship between them, unless you're asking how the dynamics feed each other when combined into a system.

If that's the case, then I would suggest maybe starting with a review of the Luenberger observer. It's typically taught as the "dual" of the state feedback control problem - state feedback controls attempt to drive the system states to zero, and the observer design "rephrases" the problem to make feedback error the state and then attempts to drive the feedback error to zero with the same "pole placement" mechanic.

The filter has some error dynamics, and that dynamic error will get sent to the PID controller. The PID controller acts on the feedback + error dynamics and the resulting control signal gets sent to the plant.

I suggested starting with the Luenberger observer because IMO it's easier to look at with regards to error dynamics than the Kalman filter (try this, starting at equation 25). The process for evaluating the effect of the error is otherwise the same - filter generates feedback error until the filter states converge, and that error is fed to the controller.

This may be way off your intent with your question too, though. Please let me know if this is along the lines of what you're asking.

• Thank you. I am just barely following the math behind the Kalman filter, although I think I follow the concept. And it just seemed like PID was doing something similar and I asked the question to further my understanding. – pitosalas Sep 21 '18 at 13:30
• @pitosalas - The Kalman filter is closely related to state feedback controls and the Luenberger observer. The PID controller is a "dumb" controller that only acts on error. The state space filters and controllers all have some underlying system model, but the PID controller doesn't. If your system/plant changes, you can just update the state matrix for the state space objects, but you'll need to (typically manually) re-tune your PID controller. – Chuck Sep 21 '18 at 13:34
• A good example here might be something like cargo weight or inclination angle. If those are parameters that are used in a state space model, then you can update the state matrix and the state feedback controller or Kalman filter updates itself (assuming you're approximately LTI). For the PID system, though, there's nothing you can do - you have to re-tune the controller for each scenario, and maybe your best case scenario there is some lookup table of control gains based on plant parameters. – Chuck Sep 21 '18 at 13:37

The Kalman filter optimizes the estimate of the system state in the presence of measurement errors and model errors. PID tries to drive a particular model/measurement system to a chosen state.

• Close, but not quite. There are two kinds of error I mentioned, a reference error, which is the input to the PID controller, and then also a measurement error, which is the difference your sensor reading and reality. The measurement error makes its way back to the PID controller because the reference error is generally $e_{ref} = u_{ref} - y_{fbk}$, but the feedback signal is "corrupted" with the measurement error $y_{fbk} = y_{reality} + e_{fbk}$. You wind up with $e_{ref} = (u_{ref} - u_{reality}) + e_{fbk}$, and then the PID controller acts on the combination of errors. – Chuck Sep 21 '18 at 23:32