# Quadrupedal Robots' Gaits Identification via Contact Forces Optimization
## 3 Optimization Model  
Usually, in the legged locomotion, the stability of a gait is guaranteed by using a criterion such as zero-moment point [27; 28]. Other studies face the stability problem with the Poincare map [29; 30] or ground reference points [31]. In this paper, unlike the classical approaches, the gait stability is guaranteed by satisfying periodic limit cycle conditions. The optimization operates over a single period \(T\) using a genetic algorithm (GA) which provides the stride length, frequency, and velocity, and additionally the time history of the contact forces. Therefore, a vector of gait parameters \(p_{GA}\) is optimized by using the GA algorithm. Let us explicitly set \(\boldsymbol{p}_{GA}\). The relative phases of the leg motion are \(t_{i}\), the normalized time duration \(T_{i}\) of the CP is \(\boldsymbol{\beta}_{i}=\frac{T_{i}}{T}\), the time history of the normal, longitudinal and lateral contact forces are determined by the interpolation of the points \(P_{ji}\) and \(Q_{ji}\) with \(j=1,2,3\), respectively. Therefore:  
\[\boldsymbol{p}_{GA}\ =\ \big{[}t_{i},\beta_{i},P_{ji},Q_{ji}\big{]} \tag{7}\]  
The structure of the optimization process involves the optimal vector \(\boldsymbol{p}_{GA}\) and, using several constraints derived from the equations of motion, it looks for solutions that minimize a multi-objective cost function related to the dissipated energy and looking for smooth forces trends. Let us examine in detail these constraints. Note, as a preliminary consideration, that we can impose the continuity kinematic conditions over the stride period:  
\[ \begin{array}{c}y(0)=y(T);\quad\ z(0)=z(T)\\ \dot{x}(0)=\dot{x}(T);\quad\dot{y}(0)=\dot{y}(T);\ \ \dot{z}(0)=\dot{z}(T)\\ \phi(0)=\phi(T);\ \ \dot{\theta}(0)=\theta(T)\\ \dot{\phi}(0)=\dot{\phi}(T);\ \ \dot{\theta}(0)=\dot{\theta}(T)\end{array}  \tag{8}\]  
Moreover, the average speeds over the period \(T\) are \(\overline{\dot{x}}=V\), \(\overline{\dot{y}}=0\), \(\overline{\dot{z}}=0\), \(\overline{\dot{\theta}}\)=0, \(\overline{\dot{\phi}}=0\), where \(V\) is the average longitudinal speed of the quadruped body. We start with the vertical equation of motion (an identical procedure applies to the other equations of motion) that produces:  
\[m\ddot{z}=\sum_{i}F_{z_{i}}\big{(}P_{ji}\big{)}-mg\quad\quad\to\quad\dot{z}= \frac{1}{m}\int_{0}^{t}\sum_{i}F_{z_{i}}\big{(}P_{ji}\big{)}\ dt-gt+C \tag{9}\]  
Figure 4: Point of application of the leg force FR and distances \(\Delta x_{FR}\) and \(\Delta z_{FR}\) referred to the center of gravity \(G\). where \(g\) is the gravity acceleration and \(C\) is an integration constant. Therefore:  
\[\dot{z}(T)=\frac{1}{m}\int_{0}^{T}\sum_{i}F_{z_{i}}\big{(}P_{j_{i}}\big{)}\ dt-gT+C \tag{10}\]  
and  
\[\dot{z}(0)=C \tag{11}\]  
Using the condition \(\dot{z}(0)=\dot{z}(T)\), it follows:  
\[\frac{1}{T}\int_{0}^{T}\sum_{i}F_{z_{i}}\big{(}P_{j_{i}}\big{)}\ dt=mg \tag{12}\]  
The force-time history is set by randomly selecting the point \(P_{j_{i}}\) by the GA and using a spline interpolation. Further integration of Equation (10) produces:  
\[ \begin{split}\dot{z}(t)=\frac{1}{m}\int_{0}^{t}\sum_{i}& F_{z_{i}}\big{(}P_{j_{i}}\big{)}\ d\tau-gt+\dot{z}(0)\to z(t)\\ =\frac{1}{m}\int_{0}^{t}\int_{0}^{\tau}(\sum_{i}F_{z_{i}}(P_{j_{i }})-mg\ )\ dtd\tau+\dot{z}(0)t+z(0)\end{split}  \tag{13}\]  
and:  
\[z(T)=\frac{1}{m}\int_{0}^{T}\int_{0}^{\tau}(\sum_{i}F_{z_{i}}\big{(}P_{j_{i}} \big{)}-mg\ )dt\ d\tau+\dot{z}(0)T+z(0) \tag{14}\]  
Using the periodicity condition \(z(0)=z(T)\), it follows:  
\[\dot{z}(0)=-\frac{1}{mT}\int_{0}^{T}\int_{0}^{\tau}\left(\sum_{i}F_{z_{i}} \big{(}P_{j_{i}}\big{)}-mg\right)dtd\tau \tag{15}\]  
Equation (15) automatically satisfies the condition of zero average speed \(\vec{z}=0\). In fact:  
\[ \begin{split}\dot{z}(t)=\frac{1}{m}\int_{0}^{t}& \sum_{i}F_{z_{i}}\big{(}P_{j_{i}}\big{)}\ d\tau-gt+\dot{z}(0)\ \rightarrow\ \ \vec{\dot{z}}\\ =\frac{1}{mT}\int_{0}^{T}&\int_{0}^{\tau}\left( \sum_{i}F_{z_{i}}(P_{j_{i}})-mg\right)dt\ d\tau+\dot{z}(0)=0\end{split}