# Whole-Body Motion Generation for Balancing of Biped Robot
## 4 Generation of Arm Motion
### Momentum Control Using Optimization  
Using the momentum equation and optimization, the arm motion that minimizes the angular momentum of a biped robot can be obtained. Since forward kinematics allow the calculation of joint angles and position information, MPC could be applied over multiple steps, as with COM. However, due to the high computational cost, optimization was applied only to a single step. With control step time \(T_{s}\), the arm joint angle state \(\theta_{arm,k}\) at time instance \(k+1\) is represented by control input \(\mathbf{u}_{k}\), which corresponds to the angular acceleration of the arm joint \(\mathbf{\dot{\theta}}_{arm,k}\):  
\[\mathbf{\theta}_{arm,k+1}=\mathbf{\theta}_{arm,k}+T_{s}\mathbf{\dot{\theta}}_{arm,k}+\frac {T_{s}^{2}}{2}\mathbf{u}_{k} \tag{28}\]  
\[\mathbf{\dot{\theta}}_{arm,k+1}=\mathbf{\dot{\theta}}_{arm,k}+T_{s}\mathbf{u}_{k} \tag{29}\]  
From Equation (27),  
\[\mathbf{H}_{k}=\mathbf{H}_{arm,k}\mathbf{\dot{\theta}}_{arm,k}+\mathbf{D}_{k} \tag{30}\]  
where \(D_{k}\) represents the angular momentum contribution from the base and the legs at time instance \(k\):  
\[\mathbf{D}_{k}=\left|\mathbf{I}_{r}\mathbf{\omega}_{B}+\sum_{i=1}^{2}\mathbf{H}_{leg,i}\mathbf{ \dot{\theta}}_{leg,i}\right|_{k}\]  
Large movements of the arm can negatively affect balance, so the objective function was designed to generate minimal arm motions that reduce the angular momentum. Since the angular momentum varies across different axes, a selection matrix \(\mathbf{S}\) was introduced to prevent any single axis from becoming dominant. Additionally, by adjusting the elements of this selection matrix, it is possible to choose which axes to control. The objective function with selection matrix be:  
\[ \begin{split}\min_{\mathbf{u}_{k}}\frac{\alpha_{A}}{2}|\mathbf{u}_{k}|^{ 2}+\frac{\beta_{A}}{2}|\mathbf{\dot{\theta}}_{k+1}|^{2}+\frac{\gamma_{A}}{2}\Big{|} \mathbf{S}\mathbf{H}_{k+1}-\mathbf{S}\mathbf{H}_{k+1}^{ref}\Big{|}^{2}+\frac{\delta_{A}}{2} \Big{|}\mathbf{\dot{\theta}}_{k+1}-\mathbf{\theta}_{k+1}^{ref}\Big{|}^{2}\\ =\min_{\mathbf{u}_{k}}\frac{1}{2}\mathbf{u}_{k}^{T}\mathbf{Q}_{A}\mathbf{u}_{k}+f_{ A}^{T}\mathbf{u}_{k}\end{split}  \tag{31}\]  
where\[\mathbf{Q}_{A}=\alpha_{A}\mathbf{E}_{+}\beta_{A}T_{s}^{2}+\gamma_{A}T_{s}^{2} \left(\mathbf{SH}_{arm,k+1}\right)^{T}\left(\mathbf{SH}_{arm,k+1}\right)+\delta_{A}\frac {T_{s}^{4}}{4}\] \[\mathbf{f}_{A}=\beta_{A}T_{s}\mathbf{\hat{\theta}}_{arm,k}+\gamma_{A}T_{s} \left(\mathbf{SH}_{arm,k+1}\right)^{T}\left(\mathbf{SH}_{arm,k+1}\right)\theta_{k}+\mathbf{ SD}_{k+1}-\mathbf{SH}_{k+1}^{ref}\right)\] \[+\delta_{A}\frac{T_{s}^{2}}{2}\left[\left(\theta_{k}-\theta_{k+1 }^{ref}\right)+T_{s}\theta_{k}\right]\] \[\mathbf{S}=\left[ \begin{array}{ccc}\alpha_{R}&0&0\\ 0&\alpha_{P}&0\\ 0&0&\alpha_{Y}\end{array} \right]\]  
where \(\alpha_{A}\) is the acceleration gain, \(\beta_{A}\) is the velocity gain, \(\gamma_{A}\) is the momentum gain, and \(\delta_{A}\) is the angle gain. The value \(0\leq\alpha_{R},\alpha_{P},\alpha_{Y}\leq 1\) represent the roll, pitch, and yaw gains, respectively, and are used to adjust their influence. The objective function in Equation (31) is designed to generate arm motions that actively contribute to the balance of the robot while ensuring the movements are smooth and natural. Minimizing joint acceleration encourages fluid changes in arm velocity and reduces control effort. Penalizing excessive joint velocity helps prevent overly fast or jerky arm movements that could otherwise destabilize the robot. The core of the objective function is the angular momentum tracking term, which drives the arms to generate compensatory momentum, thereby stabilizing the overall robot posture. Including an angle error term helps to keep the arm joints near a reference configuration, preventing them from undesirable postures.