# Dynamic Stability of an Electric Monowheel System Using LQG-Based Adaptive Control
## 5 Kalman Filter Estimation and LQG Control  
The Kalman Filter is an algorithm that helps in the determination of the estimated values of unknown variables using known measurements observed over some time. It is an optimal predictor-corrector type estimator. Observed over time, using a series of realistic measurements involving disturbances such as statistical noise, the Kalman Filter essentially minimizes the estimated error covariance while the initially assumed conditions are satisfied. Over each time interval, estimating a joint probability distribution gives the approximations of unknown variables [34; 35]. These estimates are a great deal more accurate than those derived with only a single measurement. Since the mean-squared errors of estimated values are minimized for linear stochastic systems, the approach is also called the linear least mean squares estimator (LSME). The Kalman filter determines the monowheel position state vector because both the velocity and angle can be measured using predefined sensors. At the same time, it is challenging to find out the exact value of position using this approach. However, it is possible to estimate position values accurately since this state is both controllable and observable, as already established earlier. Kalman filters estimate states based on linear dynamical systems. The mathematical equation that represents the evolution of the state from time \(k_{1}\) to \(k\) is given by the following process model:  
\[x_{k}=Ax_{k-1}+Bu_{k}+w_{k}.\]  
Here, the state transition matrix is given by \(A\). This matrix is then applied to \(x_{k-1}\), which is the vector of the state in the previous time interval. The control-input matrix is given by B, where \(u_{k}\) is the input. \(w_{k-1}\) represents the process noise, which has covariance \(Q\) and is assumed to be zero-mean Gaussian. The relationship between the state and the measurement is shown by the coupling of the process and measurement models together. At a time step \(k\), it is given as  
\[z_{k}=H\,x_{k}+v_{k}.\]  
Here, the measurement vector is given as \(z_{k}\), while the measurement matrix is given as \(H\). The measurement noise vector is given by \(v_{k}\), and it is assumed to be zero-mean Gaussian with covariance \(R\). At time \(k\), the Kalman filter provides an estimate of states \(x_{k}\), when  
Figure 7: State responses, where \(x\) is position, \(\theta\) is angle of pendulum from cart, \(x^{\prime}\) is velocity, and \(\theta^{\prime}\) is angular velocity. \(x_{0}\)--i.e., the initial condition is known--as well as values such as the series of measurement \(z_{1},z_{2},\ldots,z_{k}\), and system information, represented by \(A,B,H,Q,\) and \(R\), are known. In our case, assuming a rider mass \(m=80\) kg, \(R=1\), \(N=zeros(length(F),length(F))\),  
\[A_{ref}= \begin{bmatrix}0&0&1&0\\ 0&0&0&1\\ 0&12.6676&-0.0152&-0.0001\\ 0&30.3496&-0.0206&-0.0003\end{bmatrix} ,\;\;B_{ref}= \begin{bmatrix}0\\ 0\\ 0.0444\\ 0.0601\end{bmatrix} ,\]  
\[G= \begin{bmatrix}1&0&0&0\\ 0&0&0&0\\ 0&0&0&0\\ 0&0&0&0\end{bmatrix} ,\;\;Q= \begin{bmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix} .\]  
The two stages of [PERSON] filter algorithm are prediction and update. Appropriate code was formulated in MATLAB and tested on the Simulink model to implement the stages. Figures 8 and 9 show a comparison between the estimated value and the measured value of vehicle position and velocity, respectively. With a steady increment in velocity, the estimated value of position is close to the true value; i.e., the error is minimum. In the velocity estimate, upon a sudden change in velocity, there is a significant difference between the actual value and the estimated value for that particular instance. This estimation analysis considers the rider's mass to be 80 kg. With a change in weight, the estimation would also change. For this, a mass-adaptive system is under formulation. Since the system has some noise in it, a second approach is explored using LQG control. The aim is to provide control with minimum noise.