# Design and Implementation of Model Predictive Control for a Gyroscopic Inverted Pendulum
## 4 Control Results and Discussion
### Simulation Results
#### 4.2.2 Circular Motion  
When a bicycle turns into a corner in a curve of constant radius at a particular longitudinal speed, it can be considered to be in circular motion. In this situation, the centrifugal forces that act on the pendulum-like bicycle are shown in Figure 2. The moment equilibrium condition of the system at the contact points is:  
\[mgh_{c}\sin\theta=F_{c}h_{c}\cos\theta. \tag{33}\]  
When riding a bicycle, to stabilize it and turn into a curve, a rider needs to lean his/her bike at a roll angle to the inner side of the corner. Using this roll angle, the gravitational force becomes a counteracting force to the centrifugal force, which prevents the bicycle from being pulled out of its trajectory.  
The magnitude of the centrifugal force is calculated as:  
\[F_{c}=\frac{mv^{2}}{r}. \tag{34}\]  
For each value of centrifugal force, the required roll angle is calculated by applying the equilibrium condition (33):  
\[\theta_{r}=\mathrm{atan}\frac{F_{c}}{mg}. \tag{35}\]  
Substituting Equation (34) into Equation (35) gives  
\[\theta_{r}=\mathrm{atan}\frac{v^{2}}{rg}. \tag{36}\]  
In practice, the centrifugal force can be determined by measuring the lateral acceleration using a sensor or by measuring the instantaneous turning radius for the longitudinal speed via a Global Positioning System (GPS) device. Therefore, it is possible to calculate the centrifugal force and the  
Figure 10: Simulation results for case 1: (**a**) lean angle; (**b**) gimbal angles; and (**c**) gimbal torques.  
corresponding reference roll angle \(\theta_{r}\) using Equations (34) and (36). This information on the turning is used to enhance the controller's performance.  
To determine the behaviour of the controller for this case by using the inverted pendulum system with a real-time simulator, the centrifugal force is modelled as a constant force that acts at the centre of mass of the system. For the initial conditions of longitudinal speed of 15 km/h and a turning radius of 5 m, the magnitude of the calculated centrifugal force is 101.01 N and the equilibrium roll angle \(\theta_{r}\) is 19.51\({}^{\circ}\). The equilibrium roll angle is used as the reference signal for \(\theta\) and the value of \(F_{c}\) is fed into the MPC as a measured disturbance as shown in Figure 7.  
The inverted pendulum in this case is controlled by a MPC that uses the same prediction and control horizon as the first case. However, to reduce the overshoot in the transient response, weighting matrices that have smaller ratio between \(\mathbf{Q}\) and \(\mathbf{R}\) are used:  
\[\mathbf{Q}=\left[\begin{array}{ccc}125&0&0\\ 0&90&0\\ 0&0&90\\ \end{array}\right]\text{, }\mathbf{R}=\left[\begin{array}{cc}1&0\\ 0&1\\ \end{array}\right]\text{.} \tag{37}\]  
Figure 11 shows the control results for this case. The setting time for the roll angle is 0.35 s and the overshoot value is 14.10%. After 3 s, the inverted pendulum reaches the desired equilibrium point with the steady-state error of 0.002\({}^{\circ}\). The maximum gimbal angle during the transient time is 49.7\({}^{\circ}\). When the pendulum is at the equilibrium point, the gimbal angles revert slowly back to the zero positions. At 3 s, the gimbal angles \(\alpha_{1}\) and \(\alpha_{2}\) are at the zero position.