## 4 Control-Law Design
### Design of Comparison Scheme for the First Group of Controllers  
#### 4.1.1 Design of Model Predictive Control  
This section focuses on implementing MPC for a 2-DOF single-leg system with constrained contact. The feedback linearization method linearizes wholly or partially nonlinear dynamic systems, making complex system analysis more intuitive and easy to design. Hence, we linearized the nonlinear system model (Equation (3)) and subsequently utilized the linear model to design the MPC scheme. Let the second derivative of \({{}^{\prime}}{{Y}^{\prime}}\) be equal to \(v\). Hence, we obtain the Laplace transform and feedback linearization control in Equation (13):  
\[\left\{\begin{array}{l}v_{i}(s)={Y}_{i}(s)s^{2}\\ =\dot{\theta}_{i}(s)s^{2},\;\;i=1,2\\ \tau=M(\theta)v+C\Big{(}\theta,\dot{\theta}\Big{)}\dot{\theta}+G(\theta)+\tau _{f}\end{array}\right., \tag{13}\]  
Substituting Equation (13) into Equation (3) yields the decoupled linear system (Equation (14)):  
\[\ddot{\theta}_{i}=v_{i},\;i=1,2, \tag{14}\]  
Based on Reference [30], we designed an MPC for a single-leg robot with restricted motion. Considering the similarity between the first and second joints, we rewrite decoupled linear systems (Equation (14)) into the state equation form for a single joint as follows:  
\[\dot{x}_{2}=\ddot{x}_{1}=\ddot{Y}_{1}=v_{1}, \tag{15}\]  
where \(\begin{bmatrix}x_{1}&x_{2}\end{bmatrix}^{\mathsf{T}}=\begin{bmatrix}\theta_{1} &\dot{\theta}_{1}\end{bmatrix}^{\mathsf{T}}\), and \(\
u_{1}\) is the control vector. We assume that \(\
u_{1}(t)=\
u_{c}\) remains constant over the time interval \(\begin{bmatrix}t&t+\Delta t\end{bmatrix}\), and \(\Delta t\) is the prediction horizon. Using Equation (15), we obtained the prediction model in Equation (16), where \(\varpi\) is the cost function for the system stability, \(e_{r1}(t+\Delta t)=\theta_{1d}-\theta_{1}(t+\Delta t)\) is the predicted angle error, and \(\dot{e}_{r1}(t+\Delta t)=0-\dot{\theta}_{1}(t+\Delta t)\) is the predicted velocity error. The horizontal time \(\Delta t\) and weight factor \(\mu\) are positive parameters.  
\[\left\{\begin{array}{l}\dot{\theta}_{1}(t+\Delta t)=\
u_{1}\Delta t+\dot{ \theta}_{1}(t)\\ \theta_{1}(t+\Delta t)=1/2\big{(}\
u_{1}\Delta t^{2}\big{)}+\dot{\theta}_{1}(t )\Delta t+\theta_{1}(t)\\ \varpi=\dot{e}_{r1}^{2}(t+\Delta t)+\mu\dot{e}_{r1}^{2}(t+\Delta t)\end{array}\right., \tag{16}\]  
Minimizing the \(\varpi\) concerning \(\
u_{1}\), we obtained the MPC controller in Equation (17):  
\[\left\{\begin{array}{l}v_{1}(t)=k_{3}\theta_{1d}-k_{1}\theta_{1}(t)-k_{2} \dot{\theta}_{1}(t)\\ k_{1}=k_{3}=2/\left(\Delta t^{2}+4\mu\right)\\ k_{2}=\left(2\Delta t^{2}+4\mu\right)/\left(\Delta t^{3}+4\mu\Delta t\right) \end{array}\right., \tag{17}\]  
The joint-angle variation curve was obtained using Equations (16) and (17), whereas the information regarding the joint-torque and contact-force variations is derived from Equations (9), (10) and (13). According to the horizontal time \(\Delta t=0.36\) and weight factor \(\mu\to 0\), the gains of the MPC controller are: \(k_{1}=15.42,k_{2}=5.55,k_{3}=k_{1}\). By selecting these parameters, we obtain better system performance. The MPC scheme undergoes rigorous mathematical derivation and design and is compared with the subsequently designed SMC scheme through simulation to verify their differences in tracking performance for joint angles.