## 3 Controller Design
### Control Allocation  
Weighted pseudo inverse with constraints [47] is used to obtain the distributed brake forces at four wheels. The DYM command \(M_{z,r}\) can be expressed as follows.  
\[M_{z,r}=\textbf{B}_{CA}\textbf{F}_{x} \tag{41}\]  
where \(\textbf{F}_{x}\) is the tire force vector that consists of four tire forces.  
\[\textbf{F}_{x}=\begin{bmatrix}F_{x,fl}&F_{x,rl}&F_{x,fr}&F_{x,rr}\end{bmatrix}^ {T} \tag{42}\]  
where the subscripts \(fl\), \(rl,ft\), and \(rr\) denote quantities at front-left, rear-left, front-right, and rear-right tires, respectively.  
The pseudo inverse solution is a two-norm solution to the \(CA\) problem that can be formulated as follows.  
\[\underset{\textbf{F}_{x}}{min}\mathcal{I}_{CA}=\underset{\textbf{F}_{x}}{min} \frac{1}{2}(\textbf{F}_{x}+\textbf{C}_{CA})^{T}\textbf{W}_{CA}(\textbf{F}_{x} +\textbf{C}_{CA}) \tag{43}\]  
subject to:  
\[M_{z,r}=\textbf{B}_{CA}\textbf{F}_{x} \tag{44}\]  
\[\textbf{F}_{x,min}\leq\textbf{F}_{x}\leq 0 \tag{45}\]  
where \(\textbf{C}_{CA}\) is the offset vector used to represent off-nominal condition with one or more tire forces; \(\textbf{F}_{x,min}\) is the vector used to represent the minimum allowable tire forces. The maximum allowable tire forces are set to be 0 such that only braking forces are used. The optimal distribution can then be obtained as follows.  
\[\textbf{F}_{x}=-\textbf{C}_{CA}+\textbf{B}_{CA}^{\#}(M_{z,r}+\textbf{B}_{CA} \textbf{C}_{CA}) \tag{46}\]  
\[\textbf{B}_{CA}^{\#}=\textbf{W}_{CA}^{-1}\textbf{B}_{CA}^{T}\Big{(}\textbf{B} _{CA}\textbf{W}_{CA}^{-1}\textbf{B}_{CA}^{T}\Big{)}^{-1} \tag{47}\]  
where \(\textbf{B}_{CA}^{\#}\) is the pseudo inverse of \(\textbf{B}_{CA}\). The \(\textbf{C}_{CA}\) is zero in the normal condition, so (44) can be simplified as follows.  
\[\textbf{F}_{x}=\textbf{B}_{CA}^{\#}M_{z,r} \tag{48}\]  
where the diagonal weighting matrix \(\textbf{W}_{CA}\) is designed with elements equal to the estimated tire workload ratios as follows [42] to prevent saturating tire forces. The larger the ratio is, the closer to saturation the corresponding tire force is. Thus, tire forces that are needed for generating the desired DYM are distributed to tires with lower tire work load ratios.  
\[\textbf{W}_{CA}=\begin{bmatrix}\hat{\rho}_{fl}&0&0&0\\ 0&\hat{\rho}_{rl}&0&0\\ 0&0&\hat{\rho}_{fr}&0\\ 0&0&0&\hat{\rho}_{rr}\end{bmatrix} \tag{49}\]  
where \(\hat{\rho}\) is the estimated tire workload ratio of each tire that can be obtained as follows [42].  
\[\hat{\rho}=\sqrt{\frac{\hat{F}_{x}^{2}+\hat{F}_{y}^{2}}{\hat{F}_{z}^{2}}} \tag{50}\]  
where \(\hat{F}_{x}\), \(\hat{F}_{y}\) and \(\hat{F}_{z}\) are the estimated tire forces at longitudinal, lateral and normal directions, respectively. If the ith element of \(\textbf{F}_{x}\) exceeds the boundary values, the corresponding ith element in \(\textbf{C}_{CA}\) is set to be the opposite number of the boundary value and the corresponding ith element in \(\textbf{B}_{CA}\) is set to be zero. The adjusted vectors \(\textbf{B}_{CA,a}\) and \(\textbf{C}_{CA,a}\) can be obtained using the Algorithm 1 as shown below.  
After obtaining the adjusted vectors, we can replace \(\textbf{B}_{CA}\) and \(\textbf{C}_{CA}\) with \(\textbf{B}_{CA,a}\) and \(\textbf{C}_{CA,a}\), respectively, and obtain the adjusted tire force vector using Equations (44) and (45).  
The four-wheel brake pressure command \(\textbf{P}_{b,r}\) can be expressed as follows.  
\[\textbf{P}_{b,r}=\textbf{F}_{x}diag\Big{(}\begin{bmatrix}\frac{r_{w}}{C_{b,f}} &\frac{r_{w}}{C_{b,r}}&\frac{r_{w}}{C_{b,f}}&\frac{r_{w}}{C_{b,r}}\end{bmatrix} \Big{)} \tag{51}\]  
where \(G_{b,f}\) and \(G_{b,r}\) are the brake gains of front and rear wheels, respectively; \(r_{w}\) is the wheel radius; diag is a function that creates a square diagonal matrix with the input elements on the main diagonal. The EHB module is used to generate four-wheel brake pressure \(\textbf{P}_{b}\).