Hexapod Robot Gait Switching for Energy Consumption and Cost of Transport Management Using Heuristic Algorithms

: Due to the prospect of using walking robots in an impassable environment for tracked or wheeled vehicles, walking locomotion is one of the most remarkable accomplishments in robotic history. Walking robots, however, are still being deeply researched and created. Locomotion over irregular terrain and energy consumption are among the major problems. Walking robots require many actuators to cross different terrains, leading to substantial consumption of energy. A robot must be carefully designed to solve this problem, and movement parameters must be correctly chosen. We present a minimization of the hexapod robot’s energy consumption in this paper. Secondly, we investigate the reliance on power consumption in robot movement speed and gaits along with the Cost of Transport (CoT). To perform optimization of the hexapod robot energy consumption, we propose two algorithms. The heuristic algorithm performs gait switching based on the current speed of the robot to ensure minimum energy consumption. The Red Fox Optimization (RFO) algorithm performs a nature-inspired search of robot gait variable space to minimize CoT as a target function. The algorithms are tested to assess the efﬁciency of the hexapod robot walking through real-life experiments. We show that it is possible to save approximately 7.7–21% by choosing proper gaits at certain speeds. Finally, we demonstrate that our hexapod robot is one of the most energy-efﬁcient hexapods by comparing the CoT values of various walking robots.


Introduction
The decrease of energy usage is recognized as one of the principal goals in industrial and manufacturing areas for economic and climate change mitigation reasons [1]. Energy consumption saving in mechatronic and robotic systems has attracted much interest in both industry and academia [2] due to the need to develop energy-efficient and sustainable infrastructure. The existing approaches for increasing energy efficiency include the development of more efficient energy storage technologies for mobile platforms [3], the use of renewable energy resources [4], and also the deployment of innovative computing techniques for controlling digital infrastructure [5].
Mobile robots serve as a great platform for many various tasks that are difficult, dangerous, or even impossible for humans such as space exploration, underground mining, landmine removal, or disaster relief [6,7]. Such tasks require robots to act autonomously in most cases and their work environment is incredibly diverse [8]. The nature of such diversity in environments dictates that mobile robots must adapt to these environments and not only to one type but a great variety of the terrains. The problem of energy efficiency has been addressed by many different types of robot designs such as flexible (snake-like robots) [9], quadruped robots [10], rovers [11], paddle-driven robots [12], and humanoid robots [13,14].
In some studies, vertebrates and invertebrates were observed leading to results stating that oxygen consumption linearly depends on their locomotion speed [39]. A study on modeling the energy consumption of insects [40] and rats [41] suggests that the main reason for changing gaits is to minimize energy consumption. These results were applied to a 2 g mobile robot by [42] and investigated by calculating the cost of transport (CoT). This parameter assesses energy efficiency to transport any type of animal, insect, fish, bird, vehicle or robot from one point to another. CoT allows comparison of different biological or non-biological systems because it is a dimensionless parameter, and thus is widely used in robotics and biology. However, results obtained from experiments with a 2 g mobile robot [42] showed that CoT is significantly larger than in the existing walking robots when an alternating tripod gait is used. In their next work, they presented results of the locomotion and trajectory control technique for microrobots weighing 1.27 g [43]. The Harvard Ambulatory Micro Robot VP series (HAMR-VP) obtained a CoT of 109 which is still a rather large number.
In [44], a method is presented on how to estimate and minimize CoT for legged locomotion. The results of these studies show that it is very important to choose optimal gait to minimize energetic cost. With optimal parameters, CoT is below 1.0 at speeds ranging from 0.1 m/s to 0.35 m/s, but there are no real experiments carried out with either robots or insects. It is difficult to say whether or not results would be the same for walking robots.
Real-time control is proposed in [45] where the authors present a model of a realistic quadrupedal walking machine. The investigation results show that CoT could be reduced by choosing a small duty factor and optimal walking velocity. Also, CoT depends highly on the stroke distance and is less when a stroke is longer. Authors say that the wave gait is only appropriate for low walking speed, and different gaits should be used for higher-speed locomotion. So, to save energy it is very important to select the proper gait.
Additional research, including a duty factor evaluation, was done by [46]. Analysis of the energy usage of a six-legged robot during its locomotion over flat terrain was presented. The results of this investigation showed that the lowest duty factor of the wave gait gives the lowest energy consumption.
CoT depends on the terrain type. Irregular terrain would require more energy expenses than plain terrain. Paper [47] presented a method to optimize the energy use of a hexapod robot on irregular terrain. When the foot trajectories of the legged robot are calculated to minimize energy use during every half a locomotion cycle, it is possible to save about 3.21% of the energy.
The energy efficiency of a hexapod robot wave gait was analyzed in [48]. The author used a simulation model to obtain walking measurements using different modes and varying gait parameters. The results presented in this paper suggest that using a wave gait with different leg sequences is better than using a basic wave gait, although using only wave gait is not efficient, overall, as it is only used for the lower speeds as mentioned before [45].
The analysis of the torque distribution algorithm to decrease the energy cost of the hexapod robot (only for wave gait) is presented in [15]. The proposed scheme allowed reducing energy use from 22% to 39% with the use of fitting robot walking speed and duty factor.
The advantages of gait switching for statically-stable locomotion of a hexapod robot over various terrain types while using a tripod, amble (tetrapod), and wave gaits were explored in [16]. The results showed that on a hard smooth surface at low speeds (up to~0.1 m/s) the wave gait has higher CoT than the tripod gait. At speeds of~0.1 m/s, the tripod gait has the lowest CoT, and increasing speed further decreases CoT (at 0.3 m/s CoT =~15). A similar investigation was done in [49], where locomotion on different surfaces was tested by changing the leg's joint compliance. During each experiment, the robot walked the same distance and the current was measured during its locomotion. Best achieved CoT was 17.2 at a speed of 0.039 m/s. Wang et al. [50] employed energy usage optimization by introducing equality constraints of dynamic force and moment equilibrium, and inequality constraints of joint torque. Then, they obtained ideal foot forces by solving a quadratic programming (QP) problem.
The novelty and contributions of this paper are as follows: (1) A heuristic gait-switching algorithm to minimize the energy consumption of the hexapod robot. (2) Adoption of a novel nature-inspired Red Fox Optimization (RFO) for gait parameter selection to minimize the CoT value of the hexapod robot, which has been never done before. (3) Experimental study of both algorithms.
The remaining parts of the paper are summarized as follows. Section 2 describes the materials and methods used in our research. Section 3 presents the results of our experiments. Section 4 discusses the results and presents conclusions.

Hexapod Robot
For our research, we used an 18 degrees-of-freedom (DoF) six-legged walking robot HexaV4 (Vincross Inc., Beijing, China) ( Figure 1) with STM32 microcontroller (STMicroelectronics, Geneva, Switzerland) and Dynamixel AX-12 (ROBOTIS, Seoul, Korea) servo motors. Servo motors are controlled via universal asynchronous receiver-transmitter (UART) by sending them position angles that are calculated from feet coordinates using inverse kinematics. Each servo's motion is controlled via an internal servo controller that is set to default parameters. The robot's body is hexagon shaped to sustain better stability and is made from plastic for lower overall mass (the total weight of the robot is~1.5 kg). The size of the robot is small: length is 250 mm; width at the front and the back is 100 mm; width at the middle is 190 mm. Since 3D printing is a very useful tool for prototyping the early stages of the robot [51,52], each leg is 3D printed for better durability and divided into three parts: coxa-50 mm; femur-82 mm; tibia-120 mm.
Due to a large variety of different gaits, only four basic hexapod gaits were used for all experiments: tripod gait, wave gait, tetrapod gait, and ripple gait [53]. Used gait time diagrams and leg sequencing is shown in Figure 1b, where the black line represents the leg support phase, and the dashed gap line represents the transfer phase. Due to a large variety of different gaits, only four basic hexapod gaits were used for all experiments: tripod gait, wave gait, tetrapod gait, and ripple gait [53]. Used gait time diagrams and leg sequencing is shown in Figure 1b, where the black line represents the leg support phase, and the dashed gap line represents the transfer phase.

Average Energy Consumption Measurement
To accurately evaluate the energy consumption of the hexapod robot, we chose to measure current ( ) for each speed (even if there is a small difference). First, we measured current values only for each separate robot movement speed, and then calculated the average current value (only for that particular speed). The average value can be calculated by: As our measurements give us current samples at constant time steps, the average consumed current can be calculated by averaging the measured current samples . . . : Then we can express the average power as: Here is the nominal voltage.

Heuristic Algorithm for Minimum Energy Consumption
To obtain the minimum energy consumption of the hexapod robot, we developed a heuristic algorithm ( Figure 2). Since in Section 2.2 we only described experiments where we measured energy consumption dependence on separate robot movement speeds, the algorithm was developed to measure the energy consumption of robots in a realistic movement situation. The algorithm controls how a robot moves using both tripod and wave gaits at certain speed intervals without an additional load. This algorithm was developed for our hexapod robot model, but it could be used as a baseline algorithm for any

Average Energy Consumption Measurement
To accurately evaluate the energy consumption of the hexapod robot, we chose to measure current I avg (t) for each speed (even if there is a small difference). First, we measured current values only for each separate robot movement speed, and then calculated the average current value I avg (only for that particular speed). The average value can be calculated by: As our measurements give us current samples at constant time steps, the average consumed current can be calculated by averaging the measured current samples I 1 . . . I n : Then we can express the average power P avg as: Here U is the nominal voltage.

Heuristic Algorithm for Minimum Energy Consumption
To obtain the minimum energy consumption of the hexapod robot, we developed a heuristic algorithm ( Figure 2). Since in Section 2.2 we only described experiments where we measured energy consumption dependence on separate robot movement speeds, the algorithm was developed to measure the energy consumption of robots in a realistic movement situation. The algorithm controls how a robot moves using both tripod and wave gaits at certain speed intervals without an additional load. This algorithm was developed for our hexapod robot model, but it could be used as a baseline algorithm for any type of hexapod robot. The only changes that would need to be done to the algorithm are changing the robot's maximum speed and gait changing speed. type of hexapod robot. The only changes that would need to be done to the algorithm are changing the robot's maximum speed and gait changing speed. Tripod and wave gaits were selected after conducting a series of tests. During these tests, all four gaits were used with all possible step lengths along with different joint speeds to obtain various robot movement speeds. Each time, the robot's current was measured to estimate energy consumption. The results showed that neither tetrapod nor ripple gaits are energetically efficient. The results also showed that 0.046 m/s speed is the most optimal speed for changing from wave to tripod gait because otherwise, the energy consumption increases. The maximum speed of the robot is 0.33 m/s. The parameters of the algorithm are set to the minimum: step length is set to 1 cm and servo speeds are set to 12 rpm. These parameters set robot movement speed to 0.00042 m/s. Gait is set to wave gait. After setting initial parameters, the robot starts to move forward. After making 3 full gait cycles, the algorithm increases the robot's movement speed by increasing servo speeds or step length. If movement speed is equal to or greater than 0.046 m/s, the gait type is switched to the tripod gait, otherwise, the robot continues moving forward with the wave gait and further increases speed in the same manner. Gait switching is done using a fixed threshold and is initiated at the end of the gait period to ensure that the previous gait is complete. When tripod gait is selected, the robot moves forward, increasing speed until it reaches a speed of 0.33 m/s, which is maintained until the end of the experiment. Each experiment took 2 min and during the whole time the robot's current was measured using the current shunt sensor mounted on the robot's control system. Over the 2 min, 1500 current values were obtained. This means that the instantaneous current value was measured every 80 ms. Such a sampling rate is adequate to measure current consumption during robot locomotion.

Calculation of Cost of Transport (CoT)
In mechatronics, it is common to evaluate energy efficiency by verifying CoT [54]. It shows how much power a machine or robot needs to transport itself a certain distance at a certain speed. It is more useful than just evaluating power consumption because the power alone does not provide information about the overall efficiency. In some cases, Figure 2. Algorithm for switching between wave and tripod gaits. Wave gait is used when the movement speed is lower than 0.046 m/s; tripod gait is used when the movement speed is higher than 0.046 m/s until the speed reaches a maximum value of 0.33 m/s. Tripod and wave gaits were selected after conducting a series of tests. During these tests, all four gaits were used with all possible step lengths along with different joint speeds to obtain various robot movement speeds. Each time, the robot's current was measured to estimate energy consumption. The results showed that neither tetrapod nor ripple gaits are energetically efficient. The results also showed that 0.046 m/s speed is the most optimal speed for changing from wave to tripod gait because otherwise, the energy consumption increases. The maximum speed of the robot is 0.33 m/s. The parameters of the algorithm are set to the minimum: step length is set to 1 cm and servo speeds are set to 12 rpm. These parameters set robot movement speed to 0.00042 m/s. Gait is set to wave gait. After setting initial parameters, the robot starts to move forward. After making 3 full gait cycles, the algorithm increases the robot's movement speed by increasing servo speeds or step length. If movement speed is equal to or greater than 0.046 m/s, the gait type is switched to the tripod gait, otherwise, the robot continues moving forward with the wave gait and further increases speed in the same manner. Gait switching is done using a fixed threshold and is initiated at the end of the gait period to ensure that the previous gait is complete. When tripod gait is selected, the robot moves forward, increasing speed until it reaches a speed of 0.33 m/s, which is maintained until the end of the experiment. Each experiment took 2 min and during the whole time the robot's current was measured using the current shunt sensor mounted on the robot's control system. Over the 2 min, 1500 current values were obtained. This means that the instantaneous current value was measured every 80 ms. Such a sampling rate is adequate to measure current consumption during robot locomotion.

Calculation of Cost of Transport (CoT)
In mechatronics, it is common to evaluate energy efficiency by verifying CoT [54]. It shows how much power a machine or robot needs to transport itself a certain distance at a certain speed. It is more useful than just evaluating power consumption because the power alone does not provide information about the overall efficiency. In some cases, using more power will allow traveling longer distances at a higher speed, but in other cases, low power consumption might mean slow movement and shorter travel distances. CoT can be calculated by Equation (4): where m is the weight of the robot/machine with no additional load added [kg], P avg is the average power consumption [W], g-is gravitational force [m/s 2 ], and v is movement speed [m].

CoT Optimization Using Red Fox Optimization (RFO) Algorithm
To perform CoT optimization, we adopted the Red Fox Optimization (RFO) algorithm [55]. RFO is a nature-inspired heuristic algorithm that is based on the metaphor of red fox hunting behavior. When crossing the area, the fox takes every opportunity for food and creeps up to the hidden prey until he gets close enough to strike effectively. Exploration of territory in search of food was modeled as a global search when the fox spots the prey in the distance. Before the attack was modeled as a local hunt, the fox traverses through the habitat to get as close as possible to the prey.
The RFO algorithm performs a global search by modeling solution space exploration as the search of food when the fox spots the prey in the distance, whereas local search is modeled as territory traversal aiming to get as close as possible to the prey before attacking it. Formally, the algorithm is described as follows. Let f ∈ R n be the target function of n variables in the solution space, and let (x) (i) = (x 0 ) (i) , (x 1 ) (i) , . . . , (x n−1 ) (i) mark each point in the space a, b n , where a, b ∈ R. Then (x) (i) is the optimal solution, if the value of function f (x) (i) is a global optimum on a, b .
The search process consists of two stages: variable space exploration and convergence of the solution. The RFO algorithm is summarized in Algorithm 1. For our problem of finding the best gait type and gait parameter of the robot, we defined the search space in terms of three independent variables: where x 1 is the step length [mm], x 2 is gait resolution, and x 3 is gait type (one of Tripod, Tetrapod, Ripple, or Wave). Optimization aims to find the minimum value of CoT. Therefore, the fitness function is defined by Equation (4).

Power Consumption Measurement Results
The hexapod robot step height and body elevation were set to 1 cm and 10 cm accordingly. These values are the standard configuration for hexapod robot movement and 1 cm is the minimum step height required to execute leg transfer. All experiments were carried out on flat terrain with a soft surface for better contact between the feet and the ground to minimize leg slippage.
The first experiment was done without using any additional load on the robot. The average current dependence on robot movement speed and different gaits is shown in Figure 3a. The speed at which the gait must be switched to sustain the minimal current usage is v = 0.046 m/s (Figure 3b). Wave gait is the most energetically efficient for low speeds (0-0.046 m/s) and tripod gait is more efficient for faster movement (0.046-0.33 m/s). The power consumption at low speeds is~12-13 W (wave gait), and at faster speeds is 13-28 W (tripod gait). Using proposed gait switching between wave and tripod gaits, 7.7-21% of energy can be saved. To make sure that the recurrence is stable and does not change depending on conditions, we repeated the experiment with 1.16 kg and 2.9 kg loads placed on the top of the robot. Results are shown in Figure 4. All curves for different gaits with 1.16 kg load were arranged in the same way as with no load. The point of gait switching decreased (v = 0.028 m/s). Only with a 2.9 kg load does the arrangement of curves start to change. This shows that energy consumption depends on the robot's weight. With increased robot's weight, gait switching speed decreases, i.e., the tripod gait becomes more effective at slower speeds with increased load.

Verifying Overall Energy Efficiency
To evaluate our hexapod robot's dependence of CoT on robot movement speed, we applied Equation (5) for each gait, speed, and each obtained power consumption result presented in Figure 5. As we can see from Figure 5a, CoT does not depend on gait type. Even if we take a particular speed, CoT remained the same for each gait. The only difference is that gaits vary in speed intervals. The results in Figure 5b show that the CoT value decreases when the movement speed increases. This means that to obtain lower CoT, it is necessary to switch to the gait with a higher speed interval (e.g., tripod gait). These results along with Equation (4) can be used to optimize the energy consumption according to robot speed. Using only the logarithmic scale, we cannot define the working space of our hexapod robot that is energetically efficient. This is the reason for using the linear scale also (Figure 5b). The robot should be programmed to move only at speeds higher than 0.04 m/s due to CoT having the lowest values in that interval. Between the speed of 0.04 m/s and 0.33 m/s, the value of CoT decreases from ~25 to ~5.75, whereas between the speed of 0.04 m/s down to 0.00042 m/s, the value of CoT rises from ~25 up to ~2000. The tripod gait was the most efficient because it used the least energy, while the robot can reach the highest speed.

Verifying Overall Energy Efficiency
To evaluate our hexapod robot's dependence of CoT on robot movement speed, we applied Equation (5) for each gait, speed, and each obtained power consumption result presented in Figure 5. As we can see from Figure 5a, CoT does not depend on gait type. Even if we take a particular speed, CoT remained the same for each gait. The only difference is that gaits vary in speed intervals. The results in Figure 5b show that the CoT value decreases when the movement speed increases. This means that to obtain lower CoT, it is necessary to switch to the gait with a higher speed interval (e.g., tripod gait). These results along with Equation (4) can be used to optimize the energy consumption according to robot speed.

Verifying Overall Energy Efficiency
To evaluate our hexapod robot's dependence of CoT on robot movement speed, we applied Equation (5) for each gait, speed, and each obtained power consumption result presented in Figure 5. As we can see from Figure 5a, CoT does not depend on gait type. Even if we take a particular speed, CoT remained the same for each gait. The only difference is that gaits vary in speed intervals. The results in Figure 5b show that the CoT value decreases when the movement speed increases. This means that to obtain lower CoT, it is necessary to switch to the gait with a higher speed interval (e.g., tripod gait). These results along with Equation (4) can be used to optimize the energy consumption according to robot speed. Using only the logarithmic scale, we cannot define the working space of our hexapod robot that is energetically efficient. This is the reason for using the linear scale also (Figure 5b). The robot should be programmed to move only at speeds higher than 0.04 m/s due to CoT having the lowest values in that interval. Between the speed of 0.04 m/s and 0.33 m/s, the value of CoT decreases from ~25 to ~5.75, whereas between the speed of 0.04 m/s down to 0.00042 m/s, the value of CoT rises from ~25 up to ~2000. The tripod gait was the most efficient because it used the least energy, while the robot can reach the highest speed. Using only the logarithmic scale, we cannot define the working space of our hexapod robot that is energetically efficient. This is the reason for using the linear scale also (Figure 5b). The robot should be programmed to move only at speeds higher than 0.04 m/s due to CoT having the lowest values in that interval. Between the speed of 0.04 m/s and 0.33 m/s, the value of CoT decreases from~25 to~5.75, whereas between the speed of 0.04 m/s down to 0.00042 m/s, the value of CoT rises from~25 up to~2000. The tripod gait was the most efficient because it used the least energy, while the robot can reach the highest speed.
To evaluate the efficiency of our hexapod robot, we compared its CoT with different walking robots and micro-robots (Table 1): medium-sized high mobility hexapod robot RHex, Gregor I six-legged robot, a resilient high-speed hexapod robot DASH, tiny quadruped robot MEDIC (Millirobot Enabled Diagnostic of Integrated Circuits), micro hexapod robot HAMR2 from Harvard University, and larger hexapod robot AMOS (Advanced Mobility Sensor Driven-Walking Device). Low CoT value for the HexaV4 robot was obtained due to the good trade-off between the robot's mass, current consumption, and movement speed. In our case, the servos' current was minimal during all experiments (each servo can consume up to~0.9 A, but the total current consumption of the robot did not exceed 3.5 A).  [56]; Gregor I hexapod [57]; DASH hexapod [58]; MEDIC quadruped robot [59]; HAMR2 hexapod microrobot [42]; AMOS hexapod robot [50]; HexaV4 hexapod robot; Big Dog robot [60].

Maintaining Minimum Energy Consumption
The algorithm shown in Figure 2 was implemented and tested with the hexapod robot several times with and without an additional delay time between speed changes. The speed was increased by the algorithm and the current was measured throughout the tests. The example of the results of the algorithm test is shown in Figure 6. We also varied the delay time to obtain better intervals for calculating the average current. No additional load was used during the experiments. The current time diagram of the full program run without the delay is shown in Figure 7. Due to a large amount of noise, a filter was applied. We used smooth signal processing and the percentile filter method (50%) with 3 points of the window. To evaluate the efficiency of our hexapod robot, we compared its CoT with different walking robots and micro-robots (Table 1): medium-sized high mobility hexapod robot RHex, Gregor I six-legged robot, a resilient high-speed hexapod robot DASH, tiny quadruped robot MEDIC (Millirobot Enabled Diagnostic of Integrated Circuits), micro hexapod robot HAMR2 from Harvard University, and larger hexapod robot AMOS (Advanced Mobility Sensor Driven-Walking Device). Low CoT value for the HexaV4 robot was obtained due to the good trade-off between the robot's mass, current consumption, and movement speed. In our case, the servos' current was minimal during all experiments (each servo can consume up to ~0.9 A, but the total current consumption of the robot did not exceed 3.5 A).  [56]; Gregor I hexapod [57]; DASH hexapod [58]; MEDIC quadruped robot [59]; HAMR2 hexapod microrobot [42]; AMOS hexapod robot [50]; HexaV4 hexapod robot; Big Dog robot [60].

Maintaining Minimum Energy Consumption
The algorithm shown in Figure 2 was implemented and tested with the hexapod robot several times with and without an additional delay time between speed changes. The speed was increased by the algorithm and the current was measured throughout the tests. The example of the results of the algorithm test is shown in Figure 6. We also varied the delay time to obtain better intervals for calculating the average current. No additional load was used during the experiments. The current time diagram of the full program run without the delay is shown in Figure 7. Due to a large amount of noise, a filter was applied. We used smooth signal processing and the percentile filter method (50%) with 3 points of the window.  By calculating the average current for each interval, we managed to obtain power consumption dependence on the speed of a full program run with a gait switching algorithm. We can see from Figure 7 that power consumption changes from~12 W to~24 W. The same results and curve form can be seen in Figure 3, where each result was obtained by a separate experiment. This demonstrates that our proposed method leads to power consumption minimization. By calculating the average current for each interval, we managed to obtain power consumption dependence on the speed of a full program run with a gait switching algorithm. We can see from Figure 7 that power consumption changes from ~12 W to ~24 W. The same results and curve form can be seen in Figure 3, where each result was obtained by a separate experiment. This demonstrates that our proposed method leads to power consumption minimization.

Maintaining Minimum Cost of Transport Using Red Fox Optimisation
The algorithm shown in Algorithm 1 was implemented and tested with the hexapod robot several times to calculate the average CoT value. No additional load was used during the experiments. The variable search space and corresponding CoT values are shown in Figure 8. The application of the RFO algorithm allows finding an optimal combination of gait step length and gait resolution for minimal CoT. In our experiment, the optimal solution found corresponds to the step length of 100 mm, resolution of 12 mm, and wave gait type.

Maintaining Minimum Cost of Transport Using Red Fox Optimisation
The algorithm shown in Algorithm 1 was implemented and tested with the hexapod robot several times to calculate the average CoT value. No additional load was used during the experiments. The variable search space and corresponding CoT values are shown in Figure 8. The application of the RFO algorithm allows finding an optimal combination of gait step length and gait resolution for minimal CoT. In our experiment, the optimal solution found corresponds to the step length of 100 mm, resolution of 12 mm, and wave gait type. By calculating the average current for each interval, we managed to obtain power consumption dependence on the speed of a full program run with a gait switching algorithm. We can see from Figure 7 that power consumption changes from ~12 W to ~24 W. The same results and curve form can be seen in Figure 3, where each result was obtained by a separate experiment. This demonstrates that our proposed method leads to power consumption minimization.

Maintaining Minimum Cost of Transport Using Red Fox Optimisation
The algorithm shown in Algorithm 1 was implemented and tested with the hexapod robot several times to calculate the average CoT value. No additional load was used during the experiments. The variable search space and corresponding CoT values are shown in Figure 8. The application of the RFO algorithm allows finding an optimal combination of gait step length and gait resolution for minimal CoT. In our experiment, the optimal solution found corresponds to the step length of 100 mm, resolution of 12 mm, and wave gait type.

Discussion and Conclusions
The problem of high energy consumption has always limited the wide-spread use of multi-legged walking robots. The benefits to be achieved by rising task time without upgrading the power supply unit mean that optimization of energy efficiency is an area of significant importance.
In this paper, we analyzed and proposed a method for optimizing the hexapod robot's energy consumption. We performed experiments with different gaits and speeds with no load, 1.16 kg, and 2.9 kg loads. Energetically efficient gaits were selected using power consumption diagrams. Cost of transport dependence on speed was calculated and a hexapod robot working space was established. A robot movement algorithm was also developed for power consumption minimization.
Our results show that neither ripple nor tetrapod gaits are energetically efficient. Only wave gait for slower speeds and tripod gait for fast movement should be used. Maintaining minimum energy consumption requires optimal gait switching. For our hexapod robot, the optimal gait switching speed is 0.046 m/s with no load, and 0.028 m/s with 1.16 kg additional load. By using the gait switching algorithm during movement, we were able to decrease energy consumption by~7.7-21%. We adopted Red Fox Optimization (RFO) algorithm to find the best combination of gait step length and gait resolution for minimal CoT. In our experiment, the optimal solution found corresponds to the step length of 100 mm, resolution of 12 mm, and wave gait type.
System resilience in engineering, and especially in robotics, has become an important topic nowadays because even in case of failure, a system is capable of recovering [61]. Walking robots have a wide selection of gaits which makes them resilient to failure; e. g. the ability to move even with one or several damaged legs. In the scope of this research, the hexapod robot can still maintain minimum energy consumption with one or more damaged legs if the correct gait is selected considering the robot's movement speed.
Finally, we observed that the stability of the robot slightly decreased when the movement speed was increased, which is a limitation of the proposed method. However, since the hexapod robot always has at least three legs resting on the surface, the stability criterion [62] is always satisfied.