Controls Fundamentals Notes

I’m learning Continuous Time Stochastic Modeling (CTSM) for a research project. This relies on the Extended Kalman Filter (EKF) to work. I’m in the process of writing notes to solidify my intuition of control theory fundamentals. This also serves as a reference for my future self.

Autonomous Systems

A function is a mapping from an input to an output.

f(x)=x2f(x) = x^2

If we want to describe an object, we often need more than one variable. These can all be stored in xx, making it a vector. This is known as the state. The state of a pendulum for example is:

x=[θ,θ˙]Tx = [\theta, \dot{\theta}]^T

What if we want a function that describes the state of an object over time? This would take the form x(t)x(t). However, functions like these are often incredibly difficult to derive. It’s often much easier to write a function that describes what’s happening to a state at any point in time.

x˙=f(x)\dot{x} = f(x)

This is known as the dynamics of an object. An object with dynamics is known as a system. The dynamics of the pendulum, for example, is just one function:

θ¨=gLsin(θ)\ddot{\theta} = -\frac{g}{L}\sin(\theta)

This means that the velocity of the pendulum changes as a function of the position. To define the state of the pendulum, we only include variables we care about. Looking at the dynamics, we need the angle θ\theta. However, we also need the θ˙\dot{\theta}, since this controls how position evolves. You can see this if you try to integrate θ¨\ddot{\theta}: the constant θ˙(0)\dot{\theta}(0) appears.

Why not include angular acceleration? A state can include any number of variables like acceleration, jerk, snap, the earth’s velocity, magnetic flux, etc. However, we typically only include the variables that govern how the object evolves. In the case of a pendulum, we don’t need to know angular acceleration in order to determine what happens next.

A state space is the collection of all possible states a system might have. In the case of the pendulum, the state space is:

[[0,2π)×R][[0, 2\pi) \times \mathbb{R}]

Linear Systems

Earlier, we said that it’s helpful to describe our system with one or more differential equations:

x˙=f(x)\dot{x} = f(x)

However, these equations are unwieldy when you have a lot of state vectors. When your system is linear (every variable evolves as a scalar times a combination of other variables), you can describe your dynamics with a matrix, A:

x˙=Ax\dot{x} = Ax

A is known as the state matrix. It must be an n×nn \times n matrix because it’s transforming xx of size nn into the change in xx, also of size nn.

Controllability

Up until now, we’ve been describing an autonomous system. If the system has an external influence, it’s known as a controlled system. The ways a system is influenced can be described in an input (or control) vector uu. The input vector usually contains different variables than the state vector. It also changes over time, making it a function of tt, just like xx. Unlike the state vector, it’s described without a differential equation, since it’s not determined by the system. The input vector on a controlled pendulum might be the torque on the pivot:

u(t)=[τ(t)]u(t) = [\tau(t)]

Our equation now needs to account for this input vector.

x˙=f(x,u)\dot{x} = f(x, u)

If our system is linear we can write this as:

x˙=Ax+Bu\dot{x} = Ax + Bu

B is known as the input matrix, how the state changes as a result of the input. It must be an n×mn \times m matrix because it’s transforming uu of size mm into xx of size nn.

So what does controllability mean? It turns out there’s a very precise definition: A system is controllable if you can get to any state, from any state, given a finite time. An uncontrollable system means there are some states you can’t get to no matter how long you have. For example, in a system of two pendulums with one torque driving both identically, you can never reach a state where the two pendulums have different angles or different angular velocities.

How do you prove a system is controllable? Consider the input matrix BB. By choosing your input carefully, you can get to the direction BuBu. Since uu is any input, we can consider the set of achievable directions to just be the span of BB‘s columns. However, in most cases, this isn’t enough to get to every state in your state space. In our earlier example, you need to arrive at any target angle and any target angular velocity given a single torque input. This means you want to control two state variables using one input. This is only possible due to the way the system evolves over time.

If you consider how the dynamics act on BB over time, you get ABAB, the first order term of how the input’s reach develops. If you consider how the dynamics act on this new matrix, you get A2BA^2B, the second order term of how the input’s reach develops. This process can be continued for any number of AAs.
Multiplying by A either adds a new direction or the direction is contained in the current span. As soon as the direction is contained in the current span, the span is closed under AA, so further multiplying AA can’t increase the dimension. Since the state space is nn-dimensional, the closure happens within nn blocks, so An1BA^{n-1}B is the last block that can increase the rank. Therefore, once you reach AnBA^nB, this can be written as a combination of lower order terms. This is an application of the Cayley-Hamilton theorem, which states that AnA^n is a combination of lower order powers. As a result, any matrix from AnBA^{n}B and beyond doesn’t tell you anything about whether your system is controllable.

BB, ABABAn1BA^{n-1}B are all n×mn \times m matrices and all tell us something. We care about whether the span of all these possible directions let us reach our full state space. To do this, we can put them into a single matrix, known as the controllability matrix. This is n×nmn \times nm.

C=[BABA2BAn1B]\mathcal{C} = \begin{bmatrix} B & AB & A^2B & \cdots & A^{n-1}B \end{bmatrix}

The columns of C\mathcal{C} are possible directions achievable by the system. The total space of achievable directions is simply any combination of these directions, with a dimension of rank(C)\text{rank}(\mathcal{C}) This space only covers the full state space when rank(C)=n\text{rank}(\mathcal{C}) = n In other words: If our C\mathcal{C} is full rank, the system is controllable.

Observability

How do you know what your system is actually doing? One way to answer this question is to take readings of your system using sensors like encoders. These readings can be stored in an output vector yy. yy usually has different variables than xx or uu. The output yy is a function of the state xx, which means as the state changes, the output also changes.

y=g(x)y = g(x)

yy can also be expressed as a linear function:

y=Cxy = Cx

C is known as the output matrix. It must be a k×nk \times n matrix because it’s transforming the xx of size nn into yy of size kk.

So what does observability mean? A system is observable if you can construct the full state based on the output yy over a finite time. A system is unobservable if you can’t construct a full state, no matter how long you have. An unobservable system might be two identical pendulums with a sensor that measures the sum of their angles. In this case, if the pendulums are decoupled, it’s impossible to determine what their individual angles are.

How to prove a system is observable? There’s an interesting duality between observability and controllability. Consider the output matrix CC. To provide you with the output for a given xx, the state is multiplied by CC to produce the direction CxCx. In many cases, this vector isn’t enough information to determine your original state. Like uu, yy often has fewer variables than xx, making yy underdetermined. To continue our pendulum example, the hinge might have a single gyroscope providing you with angular velocity. As a result, you need to construct both angle and angular velocity from a single angular velocity variable.

If you consider how CC acts on the dynamics, you get CACA, the map from xx to y˙\dot{y}. If you consider how this new map acts on the dynamics you get CA2CA^2, the map from xx to y¨\ddot{y}. Just like when determining controllability, this process can be continued for any number of AAs. Similarly, once you reach CAnCA^n, this can be written as a combination of the maps. In another application of Cayley-Hamilton, any matrix from CAnCA^{n} and beyond doesn’t tell you anything about whether your system is observable.

CC, CACACAn1CA^{n-1} are all k×nk \times n matrices and all tell us something. We care about whether the span of the rows can jointly distinguish every state. To do this, we can put them into a single matrix, known as the observability matrix O\mathcal{O}. This is nk×nnk \times n. O\mathcal{O} stacks rows rather than columns.

O=[CCACA2CAn1]\mathcal{O} = \begin{bmatrix} C \\ CA \\ CA^2 \\ \vdots \\ CA^{n-1} \end{bmatrix}

Like C\mathcal{C}, the rows of O\mathcal{O} are directions in state-space measurable by the system. The span of these rows is simply any combination of these directions, with a dimension of rank(O)\text{rank}(\mathcal{O}) This space only covers the full state space when rank(O)=n\text{rank}(\mathcal{O}) = n. In other words: If our O\mathcal{O} is full rank, the system is observable. The symmetry between C\mathcal{C} and O\mathcal{O} is undeniable!