First Controller¶
Let's take a simplified version of our car model. The dynamic and output equations are
Here we chose to have the total traveled distance, \(s\), as the output instead of velocity. Thinking ahead this would be useful for more complex tasks than just standard cruise control, for example this could represent deviation from a known trajectory (e.g. distance behind the car in front). Here the mass \(m_0\) is constant and the control \(u\) represents the total thrust. Written in matrix form this corresponds to
where
Verify that the more general model from the homework simplifies to this case when the control variable is the thrust, steering control \(\delta w = 0\) and the mass is constant.
Let's write down the open loop transfer for this case. Recall that
where \(N(s) = 1/m_0\) and \(D(s) = s^2\) in terms of the notation in the previous lecture.
For example if our control is \(u = 4\) m/s, with the corresponding Laplace transform \(U(s) = 4/s\), then
Assuming zero initial conditions and taking the inverse Laplace Transform gives
We could have of course simply integrated the original equation \(\ddot{s} = u/m_0\) twice to obtain the same result. Before writing down a control system for this model we note that the open-loop control has one undesirable characteristic, lack of asymptotic stability. For a constant coefficient linear system this is characterized by not all of the poles of the transfer function having negative real parts (in the above case there is a pole at \(s=0\) of multiplicity 2). For precise mathematical definitions of asymptotic stability refer to ODE Notes, or any dynamical systems textbook. Intuitively asymptotic stability of a critical point means that without the nonhomogeneous forcing term (\(u\) in our case) the solution will converge to the critical point (\([0, 0]\) in our case). For linear constant coefficient systems this is simply the consequence of the solution having the form
where one can show from the definition of the matrix exponential that for any \(\epsilon > 0\), there exists a positive constant \(M\) such that
for all \(\zeta \in \mathbb{R}^n\), \(t \ge 0\), where \(b = \max_{1 \le i \le n} \{ Re(\lambda_i)\}\) and \(\lambda_i\) are the eigenvalues of \(F\). Stated more simply the operator norm of the matrix exponential satisfies
Hence if all eigenvalues are negative and we have appropriate bounds on the control we can always find an \(\epsilon\) to show that the norm of \(x(t)\) converges to \(0\) as \(t \rightarrow \infty\).
The lack of asymptotic stability has an unfortunate consequence that even a minuscule initial velocity or a very short duration application of the control could have the effect of taking us very far from the starting position as time moves forward (or from a nominal trajectory, like following a car). You can independently verify this for our example by solving the original equation with nonzero initial conditions and/or the nonhomogeneous term \(u\) in a piecewise defined form
Of course we did not include friction in the simplified model. The addition of a damping term would have a positive effect of making even the open-loop control stable. In either case, the benefit of adding a closed loop control is that it can potentially stabilize an unstable system or improve stability characteristics of a stable one (note that the convergence in the exponential bound above will improve the more negative we make the real parts of the eigenvalues).
Let's return the the transfer function
and come up with a tracking controller with a slightly more general form
where \(e(t) = y_d(t) - y(t)\) is the tracking error (see Week 4 Lecture 1). This is called a PID (Proportional, Integral, Derivative) controller. Note the addition of two constants \(k_i\) and \(k_d\). Mathematically this will give more parameters in the resulting closed-loop transfer function to improve stability. Intuitively the control takes into account not just the current error, but how fast it is changing and the time integral of the error. The last term can be important for example if the error is small and is decreasing, but not decreasing fast enough (think of the integral of \(1/t\) vs \(1/t^2\) as \(t \rightarrow \infty\)). In the frequency domain
and as before we may calculate
and solving for \(Y(s)\),
So in general the closed-loop transfer function is
For the PID control the transfer function becomes
We note several facts. In the limit as \(k_p\), \(k_d\), and \(k_i\) approach \(0\) the nonzero poles of \(T_c\) converge to the poles of \(T_o\). In the limit as \(k_p, k_d, k_i\) approach \(\pm \infty\), \(m\) of the poles of \(T_c\) converge the \(m\) zeros of \(T_o\), with \(T_c\) potentially having more poles (counting according to multiplicity), which have to go to infinity.
For our 1D car example
We end with a particularly useful feature of the integral control (i.e. \(k_i \ne 0\)). Not only does this term ensure that there are no poles at the origin, but in general it is the property of Laplace Transforms that the steady-state error \(\lim_{t\rightarrow \infty} (y_d(t) - y(t))\) is given by
In particular if \(Y_d(s) = c/s\) as is the case for the step input it is enough to have \(T_c \rightarrow 1\) as \(s \rightarrow 0\) to ensure zero steady-state error. This is guaranteed for the PID control if \(k_i \ne 0\). The idea is to tune \(k_p, k_i\), and \(k_d\) to 'place' the poles of the transfer function at the desired location. The difficulty is of course that we now have three parameters instead of one.
Try It in CCST
Define the 1D car plant and design a PID controller in the toolbox below:
ss [[0,1],[0,0]] [[0],[1]] [[1,0]] [[0]] -> car1d
pid car1d y 1.0 0.5 0.0 -> car_pid
poles car_pid -> pid_poles
gdisplay pid_poles
Simulate the closed-loop step response to track a position setpoint:
Try tuning \(k_p\), \(k_i\), \(k_d\) to see their effect on overshoot and settling time. For example, compare a PI controller (pid car1d y 1.0 0.5 0.0) with a PID controller (pid car1d y 1.0 0.5 0.3).
You can check your work using the interactive Cloud Control Toolbox: