In this tutorial, we provide a brief introduction to open-loop observers. In this tutorial, you will learn
- The concept of observability.
- How to estimate an initial state of a linear dynamical system by using an open-loop observer.
- How to properly understand the concept of numerical observability.
The motivation for creating this tutorial comes from the fact that students often have difficulties understanding the concept of observability and they often do not understand the need for observers. This comes from the fact that the concept of observability is often first taught by assuming continuous-time systems. The mathematics needed to describe continuous-time systems is more complex than the mathematics necessary to describe discrete-time systems. It involves integrals applied to vector and matrix expressions that often involve matrix exponentials. These concepts might be difficult to understand for an average engineering student.
Instead of introducing the concept of observability by assuming a continuous-time system, we will present this concept by assuming a discrete-time system. In this way, we significantly simplify the mathematics necessary to understand the basic concepts.
So let us immediately explain the need for observability analysis by considering the example shown in the figure below.
The above figure illustrates a prototypical model of two masses connected with springs and dampers. There is a force
In our previous post, whose link is given here, we have derived a state-space model of this system. The states are:
(1)
In order to develop a feedback control it is often necessary to obtain information about all the states:
- Is it possible to reconstruct the full state vector (all state variables
and ) by only measuring the position of the first mass over time? That is, is it possible to reconstruct time series and by only observing the time series of ? - If it is not possible to reconstruct all other state variables by only measuring
, then how many state variables do we need to observe to reconstruct the full state vector?
Consider the following linear discrete-time system
(2)
where
Note that we have assumed that the inputs are not affecting our system dynamics. This is done for presentation clarity since the inputs do not affect the system observability. We can also easily modify our approach to include the system’s inputs.
Let us consider the following problem. Our task is to estimate the system’s initial state
So how to mathematically formulate and solve this problem?
By propagating the state equation of the system (2) in discrete-time, we have
(3)
Combining these equations with the output equation, we obtain
(4)
These equations can be written in the vector-matrix form
(5)
The last equation can be written compactly
(6)
where
(7)
When
The notation
(8)
The last equation is important since it shows us that the observability problem is to determine the initial state
- The number of observation samples
is larger than or equal to , where is the system state order. . This means that the observability matrix has full rank.
Here, a few important things should be kept in mind. Condition (1) is stated for the most general case. However, it might happen that the output dimension
(9)
where
Let us assume that the conditions (1) and (2) are satisfied. We can multiply the equation (8) from left by
(10)
Then, since the matrix
(11)
The equation (11) is the solution to the observability problem. We have obtained an initial state estimate as a function of the observations:
Now that we have informally introduced the concept of observability, we can give a formal definition:
Observability Definition: The system (2) is observable, if any initial state
We can also state the observability rank condition:
Observability rank condition: The system (2) is observable if and only if
From everything being said, it follows that we can check the observability condition by investigating the rank of the matrix
However, this criterion has the following issue. Namely, formally speaking, the matrix might have a full rank, however, it might be close to the singular matrix. That is, its condition number might be very large or its smallest singular value might be close to zero. This implies that in order to investigate the observability of the system it is usually more appropriate to compute the condition number or the smallest singular value.
Let us numerically illustrate all these concepts by using the example from the beginning of this post. In our previous post, explaining the subspace identification method, we have introduced this example This example is briefly summarized below. For completeness, we repeat the figure illustrating this example.
The state-space model is given below
(12)
We assume that only the position of the first object can be directly observed. This can be achieved using for example, infrared distance sensors. Under this assumption, the output equation has the following form
(13)
The next step is to transform the state-space model (12)-(13) in the discrete-time domain. Due to its simplicity and good stability properties we use the Backward Euler method to perform the discretization. This method approximates the state derivative as follows
(14)
where
(15)
where
(16)
We neglect the input and without the loss of generality, we shift the time index from
(17)
Next, we introduce the MATLAB code. First, we define the model parameters and other variables
clear,pack,clc
% model parameters
k1=10, k2=20, d1=0.5, d2=0.3, m1=10, m2=20
% discretization constant
h=0.1
% simulate the system
simulationTime=500
% number of time steps for estimating the initial state
M=5
%% system matrices
Ac=[0 1 0 0;
-(k1+k2)/m1 -(d1+d2)/m1 k2/m1 d2/m1;
0 0 0 1;
k2/m2 d2/m2 -k2/m2 -d2/m2]
C=[1 0 0 0]
[s1,s2]=size(C)
% discrete-time system
A=inv(eye(4)-h*Ac)
% select the initial state to be estimated
x0=[0.5;0.1;0; -0.4];
First, we define the model parameters such as damping, stifness and masses. We use a discretization constant of
Next, we simulate the system response. The following code lines simulate the system response and form the obeservability matrix
%% simulate the system
stateVector=zeros(4,simulationTime+1);
outputVector=zeros(s1,simulationTime+1);
stateVector(:,1)=x0;
outputVector(:,1)=C*x0;
for i=1:simulationTime
stateVector(:,i+1)=A*stateVector(:,i);
outputVector(:,i+1)=C*stateVector(:,i+1);
end
% form the M-steps observability matrix
for i=1:M
Obs{i,1}=C*A^(i-1); % M-steps observability matrix
Y{i,1}=outputVector(:,i); % Lifted output vector
end
Obs=cell2mat(Obs);
Y=cell2mat(Y);
% plot the response
simulationTimeVector=0:h:h*simulationTime;
figure(1)
plot(simulationTimeVector,outputVector,LineWidth=2)
xlabel('time')
ylabel('output')
grid
The system response is shown in the figure below.
Next, we estimate the initial state by using the equation (11). Then we compare the estimate with the initial state by computing the relative estimation error. Then, we compute the singular values of the observability matrix and compute the condition number.
% estimate the initial state
x0Est=inv(Obs'*Obs)*Obs'*Y
% compute the relative error
norm(x0Est-x0,2)/norm(x0,2)
% compute the singular value decomposition
[U,S,V] = svd(Obs);
% singular values
diag(S)
% condition number
cond(Obs)
You can modify this code by changing the structure of the C matrix. For example, you can investigate the effect of observing some other variable (for example, what happens when