# Valkyrie--Design and Development of Gaits for Quadruped Robot Using Particle Swarm Optimization
## 5 Experimental Results and Discussions  
Determining the joint angles in an efficient way during dynamic locomotion is a challenging task. As the robot traverses through the terrains, the joint angle limits are not going to be the same. Each leg will require a desired joint angle depending on various constraints such as the frame of the robot, stability, and the compensation of the angle on each leg due to angle requirement on other legs of the robot. The novelty of this paper lies in the development of a PSO algorithm considering kinematic solutions to achieve an optimal joint angle in an efficient manner. The algorithm is implemented in Python programming language using Visual Studio Code/Python Editor through Linux OS (Ubuntu Version 18.04). Table 3 gives the proposed PSO algorithms parameters. Since each leg consists of 2 DoF, the dimension of each particle is 2. The acceleration coefficients (\(C_{1}\), \(C_{2}\)) define the magnitude of the influence on the particles velocity in the directions of the local and the global optima. To have a better balance of search space between local and global exploration, it is good to assign a value between 1.0 and 2.0. Similarly, inertia weight(\(\omega\)), plays a major role in determining the proportional relationship between local and global convergence. Since a larger inertia weight tends to facilitate global exploration, whereas a smaller inertia weight facilitates local exploration, the value is set to be 0.5. Using Pyswarms's built-in optimizer function, the objective function (Equation (15)) is optimized, and the constraints are passed as its arguments. The algorithm is made to run for 1000 iterations and the best cost and the optimal joint variables to reach the target position of (10,0,0) are obtained as 1.14 \(\times\) 10\({}^{-14}\) and [13.34, 17.29], respectively. Figure 4a,b shows the movement of the swarm towards the global best (marked in the red cross) where the x and y-axis correspond to the joint variables \(\theta_{1}\) and \(\theta_{2}\) in degrees, respectively, and Figure 5 shows the experimental setup. In addition, a graph between the number of iterations and cost is shown in Figure 6, where the best cost was found to decrease. To understand the convergence rate of the algorithm, the distance the robot travels, and computational time, the code is made to run five times for different target positions and be implemented in the robot. The results are tabulated in Table 4, where the target is given as (10,0,0) and (20,0,0), which describes the movement of the robot on the x-axis for a distance of 10 mm and 20 mm. Thus, it is understood that the algorithm was able to achieve the best/global cost of 1.14 \(\times\) 10\({}^{-14}\) for the target value of (10,0,0) and 1.00 for (20,0,0), respectively. This ensures that the algorithm was able to achieve global convergence. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline No. of particles (or) swarm size & 20 \\ Dimension of a particle & 2 ([\(\theta_{1}\), \(\theta_{2}\)]) \\ Max iterations & 1000 \\ Learning rates (C\({}_{1}\), C\({}_{2}\)) & 1.5 \\ Inertia weight \(\omega\) & 0.5 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: PSO parameters. Figure 4: (**a**) Initial location of the swarm; (**b**) Final location of swarm after convergence ([[https://drive.google.com/file/d/1c500m2](https://drive.google.com/file/d/1c500m2) ocqiqzBCHhs6 DjpV4 Vy83q07 HK/view]([https://drive.google.com/file/d/1c500m2](https://drive.google.com/file/d/1c500m2) ocqiqzBCHhs6 DjpV4 Vy83q07 HK/view), accessed on 10 August 2021). Figure 5: Experimental setup. Figure 6: Iteration vs. cost. It is seen that the run time of the algorithm is around 1.80 s which proves the algorithm to be computationally efficient. In addition, it is understood that for a target value of 10, the robot moves 10 mm forward in a single step, and similarly, for a target value of 20, the robot moves 20 mm in a single step.