# Research on an Energy Recovery Strategy for Fuel Cell Commercial Vehicles Based on Slope Estimation
## 3 The Adaptive Kalman Filter
### Construction of Strong Tracking Filter Factors  
In practice, traditional adaptive filtering is prone to noise interference, leading to a decrease in measurement accuracy. In order to improve the accuracy of adaptive filtering, an adaptive fading factor can be added to achieve and correct the prediction error covariance matrix. Among them, \(e_{k}^{T}e_{k}\) can represent the true estimation error, and the variance matrix \(E\big{[}e_{k}^{T}e_{k}\big{]}\) can represent the theoretical prediction error, which is expressed as:  
\[E\Big{[}e_{k}^{T}e_{k}\Big{]}=HP_{k|k-1}H^{T}+R \tag{22}\]  
The judgment criteria are:  
\[e_{k}^{T}e_{k}\leq\gamma tr\Big{(}E\Big{[}e_{k}^{T}e_{k}\Big{]}\Big{)} \tag{23}\]  
The variable \(\gamma\) is an adjustable coefficient. When \(\gamma\geq 1\), \(P_{k|k-1}\) can be expressed as:  
\[P_{k|k-1}=\left\{\begin{array}{c}FP_{k-1}F^{T}+Q,\ e_{k}^{T}e_{k}\leq\gamma tr \big{(}E\big{[}e_{k}^{T}e_{k}\big{]}\big{)}\\ \lambda_{k}FP_{k-1}F^{T}+Q,\ other\end{array}\right. \tag{24}\]  
In the formula, when \(\lambda_{k}\) is an adjustable coefficient, and \(\lambda_{k}\geq 1\), it can be calculated using the following equation:  
\[\lambda_{k}=\left\{\begin{array}{c}1,\ \lambda_{0}<1\\ \lambda_{0},\ \lambda_{0}\geq 1\end{array}\right. \tag{25}\]  
\[\lambda_{0}=\frac{tr(N_{k+1})}{tr(M_{k+1})} \tag{26}\]\[N_{k+1}=V_{k+1}-H_{k+1}Q_{k}H_{k+1}^{T}-\beta R_{k+1} \tag{27}\]  
\[M_{k+1}=H_{k+1}F_{k}Q_{k}F_{k}^{T}H_{k+1}^{T} \tag{28}\]  
In the formula, \(V_{k+1}\) represents the covariance matrix of the residual vector, \(\beta\) is the suppression factor, and tr(\(\cdot\)) denotes the trace of a matrix. \(V_{k+1}\) can be expressed as:  
\[V_{k+1}=\frac{(1-\zeta)u_{k+1}+\left(\zeta-\zeta^{k+1}\right)V_{k}}{1-\zeta^{ k+1}} \tag{29}\]  
where \(\zeta\) is the forgetting factor and \(u_{k+1}\) represents the sliding window, it can be expressed as:  
\[u_{k}=\frac{1}{p}\sum_{i=1}^{p}e_{k}^{T}e_{k} \tag{30}\]  
where \(p\) is the sliding window size type.  
Constructing an Adaptive Factor Three-Stage Equation  
To obtain the optimal estimation from adaptive Kalman filtering, it is necessary to calculate the corresponding covariance matrix and adaptive factor. [PERSON] et al. [21] proposed four error discrimination statistics for constructing the adaptive factor \(\alpha_{k}\), including the state inconsistency statistic, the prediction residual statistic, the variance component ratio statistic, and the velocity inconsistency statistic. In this study, to mitigate the impact of unreliable observation information on \(\alpha_{k}\), the state inconsistency statistic is selected and a three-stage construction is employed for the adaptive factor. It can be expressed as:  
\[\alpha_{k}=\left\{\begin{array}{c}1,\;\Delta x_{k}\leq c_{0}\\ \frac{c_{0}}{\Delta x_{k}}\left(\frac{c_{1}-\Delta x_{k}}{c_{1}-c_{0}}\right),\;c_{0}<\Delta x_{k}\leq c_{1}\\ 0,\;\Delta x_{k}>c_{1}\end{array}\right. \tag{31}\]  
In the formula, \(1\leq c_{0}\leq 1.5\), \(3\leq c_{1}\leq 4.5\), \(\Delta x_{k}\) is the statistical measure of inconsistent values in state statistics, expressed as:  
\[|\Delta x_{k}|=\sqrt{\frac{tr(u_{k})}{tr\left(E\left[e_{k}^{T}e_{k}\right] \right)}} \tag{32}\]  
Therefore, the filtering gain \(K_{g}\) and the posterior error covariance \(P_{k}\) can be reexpressed as:  
\[K_{g}=\frac{1}{\alpha_{k}}P_{k|k-1}H^{T}\bigg{(}\frac{1}{\alpha_{k}}HP_{k|k-1 }H^{T}+R_{k}\bigg{)}^{-} \tag{33}\]  
\[P_{k}=\frac{1}{\alpha_{k}}\left(I-K_{g}H\right)P_{k|k-1} \tag{34}\]  
The optimized algorithm in this study combines the modified decay factor and adaptive factor from the strong tracking Kalman filter, updating the original Kalman gain and posterior error covariance matrix. This eliminates filter divergence and increases the accuracy and stability of the algorithm estimation, compared to the previous adaptive algorithm. The algorithm process is shown in Figure 4