## Balance Control  
Due to the differences in body configuration and weight distribution between the human demonstrator and the humanoid robot, direct application of the human joint angles as the target joint angles of the robot may cause it to fall down, especially when the robot is in the single-support phase. To maintain balance, the center of mass of the robot must be kept centered over the support polygon. The support polygon here is the convex hull of the footprint. Because of the difference in dynamic features between the robot and the human body, and, for simplicity, we discuss only the problem of balance control under the action of gravity, and the imitation process is treated as a quasi-static process; i.e., the state in each moment is considered to be a static state. The balance control strategy we have used is based on the quadratic programming (QP) method. We suppose that \(\mathbf{\Theta_{T}}\) denotes the joint angle vector of a target pose for imitation. The joint angles of the target pose are acquired from the pose of the human skeleton model using the GA-LVVJ method and the head motion mapping method. The joint angle vector of a stable pose is denoted as \(\mathbf{\Theta_{S}}\), which is obtained through the balance control. The stable pose will directly applied to the robot instead of the target pose. To ensure that \(\mathbf{\Theta_{S}}\) is close to \(\mathbf{\Theta_{T}}\), the problem can be described as a QP problem on the velocity level, i.e.,  
\[\text{min.} \frac{1}{2}\left\|\dot{\mathbf{\Theta}}-\dot{\mathbf{\Theta_{T}}} \right\|_{2}^{2}, \tag{34}\] \[\text{s.t.} A^{T}\dot{\mathbf{\Theta}}=\mathbf{B},\] (35) \[C^{T}\dot{\mathbf{\Theta}}\geq\mathbf{D}, \tag{36}\]  
where \(\dot{\mathbf{\Theta}}\in\mathbf{R^{n}}\) denotes the unknown joint angle velocity vector, \(\dot{\mathbf{\Theta_{T}}}\in\mathbf{R^{n}}\) denotes the joint angle velocity vector of the target pose acquired from the derivative of \(\mathbf{\Theta_{T}}\in\mathbf{R^{n}}\); \(A\in R^{n\times l}\) is a matrix that expresses linear equality constraints, \(B\in R^{l}\) is a vector that expresses linear equality constraints; \(C\in R^{n\times m}\) is a matrix that expresses linear inequality constraints, and \(D\in R^{m}\) is a vector that expresses linear inequality constraints. \(n\) is the dimension of the joint space, \(l\) is the dimension of the equality constraints, and \(m\) is the dimension of the inequality constraints. The equality constraints are used to keep the feet fixed or in a plane, and the inequality constraints are used to constrain the projection of the center of mass within the corresponding support polygon. Taking the single support as an example, to keep the projection of the center of mass (COM) in the support polygon, the convex hull of the robot support foot can be simplified as an rectangle. As the support foot is fixed during single-support phase, the link frame of the support foot can be set as the world frame, and each side of the rectangle is parallel to the \(x\)-axis or the \(y\)-axis of the world frame. The position of the robot COM in the world frame can be expressed as:  
\[r_{\text{G}}= \begin{bmatrix}r_{\text{Gx}}\\ r_{\text{Gy}}\\ r_{\text{Gz}}\end{bmatrix} . \tag{37}\]  
Using the Jacobian matrix \(J_{\text{G}}\in R^{3\times n}\) introduced in [54], the velocity of the COM (referred as center of gravity in [54]) \(\dot{r}_{\text{G}}\in R^{3\times 1}\) can establish relations with the velocity of joint angles \(\dot{\mathbf{\Theta}}\):  
\[\dot{r}_{\text{G}}=J_{\text{G}}\dot{\mathbf{\Theta}}. \tag{38}\]  
By defining \(J_{\text{Gx}}\in R^{1\times n}\), \(J_{\text{Gy}}\in R^{1\times n}\) and \(J_{\text{Gz}}\in R^{1\times n}\) as the row vectors of \(J_{\text{G}}\), Equation (38) can be expressed as:  
\[\dot{r}_{\text{G}}= \begin{bmatrix}J_{\text{Gx}}\dot{\mathbf{\Theta}}\\ J_{\text{Gy}}\dot{\mathbf{\Theta}}\\ J_{\text{Gz}}\dot{\mathbf{\Theta}}\end{bmatrix} .