# A Turning Brake System for Motorcycles via an Autoregulative Optimal Slip Ratio
## 4 Roll Angle Estimation Based on Kalman Filter
### Roll Angle Estimation Method
Let the sampling time be \(\Delta t\), and the integral equation of the roll angle at time \(k\) is shown as follows:  
\[\phi_{g,k}=\phi_{g,k-1}+\omega_{xm,k}\Delta t \tag{9}\]  
In the above equation, \(\phi_{g,k-1}\) is the roll angle at \(k-1\) obtained by the integral expression. There is measurement noise in the angular velocity signal from IMU, and the integral easily accumulates error. Therefore, the error between the integral angle and the true roll angle \(\phi_{k}\) is \(d_{k}\), and the relation is shown in Equation (10). \[d_{k}=\phi_{g,k}-\phi_{k} \tag{10}\]  
Suppose that the error between the yaw rate and the \(Z\)-axis angular velocity \(\omega_{zm,k}\) measured by IMU is \(e_{k}\), as shown in Equation (11). \[e_{k}=\omega_{zm,k}-\dot{\psi}_{k} \tag{11}\]  
The system state is defined as \(x_{k}= \begin{bmatrix}\phi_{g,k}&d_{k}&\dot{\psi}_{k}&e_{k}\end{bmatrix} ^{ \mathsf{T}}\). The system input is defined as \(u_{k}= \begin{bmatrix}\omega_{xm,k}&\omega_{zm,k}\end{bmatrix} ^{\mathsf{T}}\). The system state equation and measurement equation are expressed as follows:  
\[x_{k}=\text{A}\mathbf{x}_{k-1}+\text{B}\mathbf{u}_{k}+\mathbf{W}_{k-1} \tag{12}\]  
\[y_{1,k}=\text{C}_{1}\mathbf{x}_{k}+\mathbf{V}_{1,k} \tag{13}\]  
\[y_{2,k}=\text{C}_{2}\mathbf{x}_{k}+\mathbf{V}_{2,k} \tag{14}\]  
Equation (12) is the state equation and Equations (13) and (14) are measurement equations. A is the system matrix and B is the control matrix, as shown in Equation (15). \(\mathbf{W}_{k-1}\) is the system noise vector and C1 and C2 represent the measurement matrix, as shown in Equation (16). \(\mathbf{V}_{1,k}\) and \(\mathbf{V}_{2,k}\) are the yaw rate measurement noise and the roll angle measurement noise, respectively. The system noise and the measurement noise are Gaussian white noise sequences with a zero mean:  
\[\text{A}= \begin{bmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&0&-1\\ 0&0&0&1\end{bmatrix} ,\text{ B}= \begin{bmatrix}\Delta t&0\\ 0&0\\ 0&1\\ 0&0\end{bmatrix} . \tag{15}\]  
\[\text{C}_{1}= \begin{bmatrix}0&0&1&0\end{bmatrix} ,\text{ C}_{2}= \begin{bmatrix}1&-1&0&0\end{bmatrix} . \tag{16}\]  
The variation matrix for measurement noise \(\mathbf{V}_{1,k}\), \(\mathbf{V}_{2,k}\) and system noise \(\mathbf{W}_{k-1}\) is calculated as:  
\[R_{1}=\text{  
The first measurement update is used to estimate the yaw rate. The angular velocity around the x and z axes from the IMU is used to calculate the measured value for the yaw rate. The gain matrix \(K_{k}^{-}\) and the error variance matrix \(\mathrm{P}_{k}^{-}\) are calculated. The yaw rate measurement and the gain matrix \(K_{k}^{-}\) are then substituted into the state estimation iterative formula to produce the state estimation \(\hat{\mathbf{x}}_{k}^{-}\). The second measurement update estimates the roll angle. The state estimate \(\hat{\mathbf{x}}_{k}^{-}\) from the first measurement update is used to calculate the estimated yaw rate. The lateral acceleration and the vertical acceleration that is measured by IMU, and the speed that is measured by the wheel speed sensor, are applied to calculate the measured value for the roll angle. The gain matrix \(K_{k}^{+}\) and the error variance matrix \(\mathrm{P}_{k}^{+}\) are calculated, respectively. The state estimate \(\hat{\mathbf{x}}_{k}^{-}\) from the first measurement update is then used as the initial predicted value, and the measured value for the roll angle \(\phi_{a,k}\) and the gain matrix \(K_{k}^{+}\) are substituted into the state estimate iterative equation to calculate the state estimate, \(\hat{\mathbf{x}}_{k}^{+}\) and then calculate the estimated roll angle \(\hat{\phi}_{k}\). Figure 9: Flow chart for roll angle estimation.