## 4 Study Cases in the Mechanism Synthesis for Lower Limb Rehabilitation
### Case 1: Four-Bar Linkage Mechanism  
The four-bar linkage mechanism has been used in lower limb rehabilitation for adults and children with cerebral palsy [9; 16]. The dimensional synthesis design problem consists of finding the link lengths that approximate the coordinates \([x_{p}^{i},y_{p}^{j}]\) of the coupler link point \(P\) to the coordinates \([\hat{x}_{p}^{i},y_{p}^{j}]\) of the ankle trajectory in a standard gait cycle. The schematic representation of the four-bar mechanism is presented in Figure 2.  
According to Figure 2, the vector of design variables comprises the lengths of the links \(r_{1}\), \(r_{2}\), \(r_{3}\), \(r_{4}\), the ground link angle \(\theta_{1}\), the initial position of the mechanism \([x_{0},y_{0}]\) with respect to the coordinate system \(x-y\), and the crank angles \(\theta_{2}^{i}\)\(\forall i=\{1,2,...n_{f}\}\). The vector of design variables is defined as:  
\[x=\left[r_{1},r_{2},r_{3},r_{4},\theta_{1},x_{0},y_{0},r_{c_{x}},r_{c_{y}}, \theta_{2}^{1},\theta_{2}^{2},\ldots,\theta_{2}^{n_{f}}\right] \tag{24}\]  
The optimization problem for the dimensional synthesis of the mechanism is presented in (25)-(29), where the constant values \(w_{1}=1\) and \(w_{2}=0.01\) weight the design goals.  
\[\underset{x}{\text{Min}}\;w_{1}\sum_{i=1}^{n_{f}}[(x_{p}^{i}-\bar{x}_{p}^{i})^{2} +(y_{p}^{j}-\bar{y}_{p}^{j})^{2}]+w_{2}\sum_{i=1}^{n_{f}}(\theta_{2}^{i}-\bar{ \theta}_{2}^{i})^{2} \tag{25}\]  
subject to:  
\[g_{1}(x)\leq 0:\;\;r_{2}+r_{1}-r_{3}-r_{4}\leq 0 \tag{26}\] \[g_{2}(x)\leq 0:-r_{4}-r_{1}+r_{2}+r_{3}\leq 0\] (27) \[g_{3}(x)\leq 0:-r_{3}-r_{1}+r_{2}+r_{4}\leq 0\] (28) \[x_{min}\leq x\leq x_{max} \tag{29}\]  
The first design goal refers to the error between the desired precision points \([\bar{x}_{p}^{i},\bar{y}_{p}^{j}]\) related to the ankle trajectory and the path \([x_{p}^{i},y_{p}^{i}]\) of the mechanism's coupler link point. The second design goal refers to the angular displacement error between the desired angles \(\bar{\theta}_{2}^{i}\) and the crank angles \(\theta_{2}^{i}\). In this problem, the desired angles \(\bar{\theta}_{2}^{i}\) are defined by (30).  
\[\bar{\theta}_{2}^{i}=\theta_{2}^{1}+2\pi\frac{i-1}{n_{f}-1}\;\forall\;i=\{1,2,...,n_{f}\} \tag{30}\]  
The precision (desired) points \([\bar{x}_{p}^{i},\bar{y}_{p}^{i}]\) are defined based on the standard ankle trajectory, these points are shown in Table A1 of Appendix A, and are obtained in [16]. On the other hand, according to Figure 2, the points generated by the coupler link \([x_{p}^{i},y_{p}^{i}]\) are defined by (31), where \(\theta_{2}\) is the angle of the crank link (input link), and \(\theta_{3}\) is shown in (32). This is obtained by the Freudenstein equation. It is important to note that both solutions in \(\theta_{3}\) (related to the sign of the root) are computed, and the solution that provides a better objective function is chosen. Thus, with the selection of \(\theta_{3}\), the resulting mechanism can be an open (\(+\)) and crossed (\(-\)) four-bar mechanism.  
\[\begin{bmatrix}x_{p}\\ y_{p}\end{bmatrix}=\begin{bmatrix}x_{0}+r_{2}\cos\theta_{2}+r_{c_{x}}cos\theta _{3}-r_{c_{y}}sin\theta_{3}\\ y_{0}+r_{2}\sin\theta_{2}+r_{c_{x}}sin\theta_{3}+r_{c_{y}}cos\theta_{3}\end{bmatrix} \tag{31}\]  
\[\theta_{3}=2\;atan2\Big{(}-B\pm\sqrt{B^{2}+A^{2}-C^{2}},C-A\Big{)} \tag{32}\]  
Figure 2: Four-bar linkage mechanism.  
where \(A=-2r_{1}r_{3}\cos\theta_{1}+2r_{2}r_{3}\cos\theta_{2}\), \(B=-2r_{1}r_{3}\sin\theta_{1}+2r_{2}r_{3}\sin\theta_{2}\), and \(C=r_{1}^{2}+r_{2}^{2}+r_{3}^{2}-r_{4}^{2}-2r_{1}r_{2}\cos(\theta_{1}-\theta_{ 2})\).  
The design problem has three inequality constraints (26)-(28) that define a crank-rocker mechanism according to the Grashof criterion [56]. The design variables vector \(x\in R^{23}\) is bounded by its corresponding limit \(x_{min}\) and \(x_{max}\). In Table 2 the limit values used in this work are shown. These values are obtained by [16].