# Adaptive Cruise Control for Intelligent City Bus Based on Vehicle Mass and Road Slope Estimation
## 3 Problem Formulation
### State Space for Vehicle Mass and Road Slope Estimating  
Usually, the road slope cannot be obtained directly. In addition, the mass of the bus is not constant because of passengers constantly getting on and off. As important parameters of the vehicle longitudinal dynamic model, the vehicle mass and road slope should be determined. The EKF algorithm is used to estimate the two variables in this section. The state variables are defined as \(\mathbf{x}=\left[v,m,\theta\right]^{T}\). Considering the nonlinear relationship between the road slope and vehicle mass, the road slope can be regarded as zero in a relatively short time interval. Combining with Equation (1), the differential equations can be given as:  
\[\left\{ \begin{array}{l}\dot{v}(t)=\frac{T_{EM}(t)i_{g}t_{g}}{m(t)r}-gf-\frac {1}{2m(t)}C_{D}A\rho v^{2}(t)-g\theta(t)\\ \dot{m}(t)=0\\ \dot{\theta}(t)=0\end{array} \right. \tag{8}\]  
The EKF algorithm is based on discrete state space equation, and the forward Euler method is used to the discrete Equation (8). It can be obtained as follows:  
\[\left\{ \begin{array}{l}v_{k}=v_{k-1}+\Delta t\left(\frac{T_{EM}(t_{k-1})i_{ g}t_{g}}{m_{k-1}r}-gf-\frac{1}{2m_{k-1}}C_{D}A\rho v_{k-1}^{2}-g\theta_{k-1} \right)\\ m_{k}=m_{k-1}\\ \theta_{k}=\theta_{k-1}\end{array} \right. \tag{9}\]  
Therefore, the state of the system can be written as follows:  
\[\left[ \begin{array}{c}v_{k}\\ m_{k}\\ \theta_{k}\end{array} \right]=\left[ \begin{array}{c}v_{k-1}+(\dot{v}(t_{k-1}) )\Delta t\\ m_{k-1}\\ \theta_{k-1}\end{array} \right]+\mathbf{W}_{k-1} \tag{10}\]  
where:  
\[\dot{v}(t_{k-1})=\frac{T_{EM}(t_{k-1})i_{g}i_{0}\eta}{m_{k-1}r}-gf-\frac{1}{2m _{k-1}}C_{D}A\rho v_{k-1}^{2}-g\theta_{k-1} \tag{11}\]  
The observed equation can be written as:  
\[z_{k}=\left[ \begin{array}{ccc}1&0&0\end{array} \right]\left[ \begin{array}[] {c}v_{k}\\ m_{k}\\ \theta_{k}\end{array} \right]+\mathbf{V}_{k} \tag{12}\]Combining with Equation (10), the state space can be expressed as follows:  
\[\left\{ \begin{array}{l}x=f(x_{k-1})+\mathbf{W}_{k-1}\\ z_{k}=\mathbf{H}x_{k}+\mathbf{V}_{k}\end{array} \right. \tag{13}\]  
where \(\mathbf{H}=\left[ \begin{array}{ccc}1&0&0\end{array} \right]\) is the measuring matrix \(\mathbf{W}\) and \(\mathbf{V}\) are noise vector, which are independent white Gaussian noise with zero mean. The EKF algorithm that employed to estimate the vehicle mass and road slope includes two processes: the time update and the measuring update. The equations of updating time can be described as follows:  
\[\left\{ \begin{array}{l}\hat{x}_{k}^{-}=f(\hat{x}_{k-1}^{-})\\ \mathbf{P}_{k}^{-}=\mathbf{A}(k)\mathbf{P}_{k-1}\mathbf{A}(k)^{T}+\mathbf{Q}_{k-1}\end{array} \right. \tag{14}\]  
where \(\hat{x}_{k}^{-}\), \(\hat{x}_{k-1}^{-}\), \(\mathbf{P}_{k}^{-}\), \(\mathbf{P}_{k-1}\), and \(\mathbf{Q}_{k-1}\) are the optimal prediction of observer estimation, the optimal estimation of state variables of last step, error covariance matrix estimated from the last matrix, the error covariance matrix of last step, and covariance matrix of noise process, respectively. \(\mathbf{A}(k)\) is the state transition matrix and it is the Jacobian matrix obtained as follows:  
\[\mathbf{A}(k)=\frac{\partial f(\hat{x}(k))}{dx}=\left[ \begin{array}{ccc}\mathbf{A}_ {1}&\mathbf{A}_{2}&\mathbf{A}_{3}\\ 0&1&0\\ 0&0&1\end{array} \right], \tag{15}\]  
where \(\mathbf{A}_{1}\), \(\mathbf{A}_{2}\), \(\mathbf{A}_{3}\) can be described as follows:  
\[\left\{ \begin{array}{l}\mathbf{A}_{1}=1-\frac{\mathcal{C}_{D}A\rho\upsilon}{2m} \Delta t\\ \mathbf{A}_{2}=\frac{\mathcal{C}_{D}A\rho\upsilon^{T}-2\mathcal{T}_{EH}\hat{x}_{ k}\omega\eta}{2m^{2}r}\\ \mathbf{A}_{3}=-g\Delta t\end{array} \right.. \tag{16}\]  
The measuring updating equation is defined as follows:  
\[\left\{ \begin{array}{l}\mathbf{K}_{k}=\mathbf{P}_{k}^{-}\mathbf{H}^{T}(\mathbf{H}\mathbf{P}_{k} ^{-}\mathbf{H}^{T}+\mathbf{R}_{k})^{-1}\\ \mathbf{P}_{k}=(\mathbf{I}-\mathbf{K}_{k}\mathbf{H})\mathbf{P}_{k}^{-}\\ \hat{x}_{k}=\hat{x}_{k}^{-}+\mathbf{K}_{k}(z_{k}-\mathbf{H}\hat{x}_{k}^{-})\end{array} \right.