Minimizing the Energy Consumption for a Hexapod Robot Based on Optimal Force Distribution

Legged robots have demonstrated significant achievements in recent years. Some legged robots have considerable flexibility and movement abilities. However, certain obstacles restrict the practical application of legged robots, such as their high energy consumption. The energy consumption of a legged robot is significantly higher than that of a wheel robot of the equivalent size for the same walking distance. Reducing the energy consumption of legged robots is important for their practical application and further development. This study proposes a quadratic-programming force-distribution controller, which minimizes the energy consumption of hexapod robots. The controller reduces the energy consumption by optimizing the instantaneous power of the robot at each time step. In a simulation environment, the proposed method reduced the energy consumption by up to 9.43% and 6.30% in flat terrain and sloped terrain, respectively, compared with two other methods. In hexapod robot experiment, the proposed method can reduce energy consumption by 5.72% compared with position control.


I. INTRODUCTION
With the rapid development of mobile robot technology, many types of robots have been produced, including wheeled [1], legged [2]- [4], and tracked [5] robots. Compared with wheeled and tracked robots, legged robots are more suitable for walking tasks in rough terrain, but are also more complex and difficult to control. In recent years, research on legged robots, including on their structure and control, has seen tremendous progress. ANYmal is equipped with an SEA (series elastic actuator) drive in each joint, and is fully torque controllable [3]. It can execute walking gaits, dynamically trot at a moderate speed, and perform special maneuvers to stand up or crawl up very steep stairs. Cheetah 2 achieved efficient trotting in planar experiments, and high-speed dynamic bounding using a bounding controller [6], [7]. This robot also has the ability of traversing cluttered environments [8]. The latest version of cheetah 3 is The associate editor coordinating the review of this manuscript and approving it for publication was Zhonglai Wang . demonstrated by a low Cost of Transport (CoT) over multiple gaits at moderate speeds, with the lowest CoT of 0.45 found during trotting [9]. However, there are theoretical problems that restrict the application of legged robots. In particular, compared with other types of robots the high energy consumption of legged robots significantly restricts their application.
Researchers have employed various methods to reduce the energy consumption of legged robots, including, a) designing a special robot structure that can reduce the energy consumption [10], [11], b) optimizing the gait parameters [12], c) optimizing the foot contact force [13], [14] and d) planning energy-efficient trajectory for irregular terrain [15]. Roy et al. studied the influence of the gait parameters of robots on the energy consumption. Their contact-force distribution algorithm is a pseudo-inverse algorithm, and the contact variable is the joint force or contact force. To compare the energy consumptions of the two distribution methods, they established an energy-consumption model for a hexapod robot [13]. The energy-consumption model of the hexapod employs a piecewise function. This is because the joint of a directcurrent (DC) motor is an energy-consuming component, which cannot store energy when performing negative work. The objective of the present study is to design an optimal force controller according to this energy-consumption model. Gonzalez et al. established a DC-motor energy-consumption model to optimize the energy consumption of a hexapod robot [14]. In their study, gains from power regeneration by the DC motors were not considered in the optimization problem. Kar et al. utilized sequential quadratic programming (QP) to determine the foot force distribution to minimize the energy consumption of a walking robot [16].
Due to overconstraint of hexapod robot, the robot can produce internal forces between the contact points which has no influence on the robot acceleration. By using only position control without force distribution, the joint torque is easily out of range and the mechanical structure is easily to be damaged, the contacted foot is more likely to slip with the ground. The force distribution algorithm can solve these problems and effectively improve the performance of the hexapod robot: increase climbing angle, maintain dynamic stability, and avoid foot slip in the rugged terrain, etc.
Conventional force-distribution methods can be roughly divided into two categories: the pseudo-inverse and optimization methods. The former is a common method for solving the redundancy problem. It has a high calculation speed, and is very suitable for real-time control of legged robots. Jiang et al. introduced a friction duty factor pseudo-inverse formulation for the real-time control of the foot-force distribution of multi-legged walking machines to minimize the risk of foot-slip [17]. Hyon et al. calculated the external force applied to the body to ensure the dynamic balance of a biped robot called SARCOS [18]. Subsequently, they employed the pseudo-inverse method to distribute the desired external force over the contact feet. Mistry et al. obtained an analytically correct solution using orthogonal decomposition to project the robot dynamics onto a reduced dimensional space, independently of the contact forces [19]. They calculated the control torque via the pseudo-inverse method, to achieve the inverse dynamic control of a biped robot.
The optimization method represents an alternative force distribution method. As the controller calculation speed increases, legged robots increasingly employ optimization algorithms to solve the distribution problem [20]. Most of these optimization problems are transformed into convex optimization problems. Galvez et al. proposed a force-distribution algorithm based on the static equilibrium equation for the SILO4 quadruped robot [21]. The inequality constraints of the algorithm include friction-cone constraints and joint-torque limits. Righetti et al. developed an inversedynamics controller for floating-base robots under contact constraints. This controller can minimize any combination of linear and quadratic costs of the contact constraints and commands [22]. Their method can guarantee the minimization of the contact forces to reduce slipping on difficult terrains, while ensuring a strong tracking performance for the desired motion. Vaillant et al. proposed a multi-objective QP controller for the humanoid robot HRP-2, which can climb vertical industrial ladders [23]. Hutter et al. demonstrated that the behavior of a complex robotic machine can be described by a set of least-squares problems with different priorities, including motion, torque, and force optimization [24]. They described a legged robotic system as simultaneously executing multiple tasks that can be classified into three categories: motion, joint-torque, and contact-force tasks. Siyuan et al. designed a real-time walking controller for a three-dimensional full-size humanoid robot with online optimization [25]. The low-level controller solves the fullbody floating-base inverse dynamics by formulating them as a quadratic-programming problem, and the high-level controller guides the robot using trajectories that are optimized online using simplified models. For the low-level control, they employed an inverse-dynamics approach to identify the torques that best satisfy the desired motion. Focchi et al. proposed a planning/control framework for the quasi-static walking of quadrupedal robots, which was implemented for a demanding application in which the regulation of ground reaction forces was crucial [26]. The motion-control module was a QP controller. Experimental results indicated that a 75 kg quadruped robot (HYQ) was able to walk between two highly sloped (50 • ) V-shaped walls. Grandia et al. proposed a new formulation for learning the dynamics of legged robots performing locomotion tasks that could improve the tracking performance of HyQ [27].
Although the aforementioned force-distribution algorithms have been verified through simulations and experiments, they have not targeted the energy consumption. This study focuses on the problem of the energy consumption of hexapods, aiming to reduce the energy consumption via the force-distribution method. The contributions of this study are summarized as follows. 1) We derive an instantaneous power model for hexapod robots, based on a single-DC motor energy model. According to the instantaneous power model, a new inverse-dynamics optimization controller is proposed, which can reduce the energy consumption of hexapod robots by optimizing the instantaneous power. 2) We develop a hexapod-robot control framework, in which the optimization controller is embedded in the hexapod robot for real-time control.
The remainder of this paper is organized as follows. Section II describes the construction of the rigid-body dynamics model for hexapod robots. In Section III, the energy optimization algorithm is presented, and the efficiency of the proposed algorithm is analyzed via a numerical simulation. Section IV introduces the control architecture of the simulated hexapod. Section V discusses the results of simulation experiments, and finally the conclusions are presented in Section VI.

II. INVERSE DYNAMICS OF HEXAPOD ROBOTS
A schematic of the mechanism of a hexapod robot is presented in Fig. 1 where q is the vector of joint positions and base positions and orientations; M is the inertia matrix; h is the sum of the gravitational, centrifugal, and Coriolis forces; S is a selection matrix, whose top six rows are zeros and correspond to the floating base, with the remainder being an identity matrix; τ is the vector of joint torques; λ is the vector of k linearly independent constraint forces; and the support Jacobian is the Jacobian matrix for all contacts. The Jacobian has two forms: J b is the robot-body Jacobian matrix, and J r is the robot-joint Jacobian matrix. The leg of a hexapod robot has a 3R configuration, and the foot is a spherical hinge that can bear ground contact forces but does not bear contact torques. The dimension of J c is 3u, where u is the number of supporting legs. To achieve static and stable walking, the hexapod robot must ensure that the number of contact feet is ≥3 at each time step. According to Table 1 [24], n c > 3, which is the degree of overconstrained for hexapod robot. Thus, the robot is an over-constrained system at each time step. There are an infinite number of solutions for τ that achieve perfect tracking ofq d . Thus, the joint torques can be used for optimization and distribution to improve the performance of the hexapod robot. Given the desired generalized accelerationq d , which is set by the motion planner, the joint torque can be calculated using the pseudo-inversion [28], and is expressed as (2)

III. ENERGY OPTIMIZATION ALGORITHM A. ENERGY-CONSUMPTION MODEL FOR HEXAPOD ROBOTS
The energy consumption of a hexapod robot depends mainly on the energy consumption of the joints of each leg, as all joints are driven by a DC motor. Roy et al. analyzed the energy consumption of the DC motor of a hexapod robot [13]. The energy consumed by a single motor during a time interval T is given as where U a is the applied voltage and I a is the armature current. The behaviors of a DC motor can be explained by the torque and voltage equations: where τ m is the torque of the rotor; K t is the torque constant; K v is the voltage constant;θ m is the angular velocity of the rotor; R is the armature resistance; L is the armature inductance, because pure inductor store energy in the form of magnetic field and does not consume any energy, so consider it to be null [13], [14]; and U e is the induced voltage in the armature windings opposing the applied voltage. Considering the transmission ratio and efficiency of the joint, the driving torque and joint angular velocity can be expressed as where N is the speed ratio of the transmission mechanism, ω is the angular velocity of joints, and η is the transmission efficiency. The energy consumption of a single joint of a hexapod robot in the time interval T is expressed as where R j , η j , K Vj and K Tj are the armature resistance, the transmission efficiency, the voltage constant and the torque constant of VOLUME 8, 2020 jth joint respectively. ω ij and τ ij are the angular velocity and joint torque of ith leg, jth joint respectively. Equation (11) represents a piecewise function because alternating positive and negative work occurs in each joint during the walking process of a hexapod robot. However, the motor is an energydissipating element, and thus the negative work does not recover the consumed energy [13]. According to (10), the energy consumption of a hexapod robot in the time interval T can be expressed as The instantaneous power of a hexapod robot is determined by differentiating (12) with respect to time: The energy-consumption characteristics are difficult to compare for different mobile-robot configurations. The unit mass and unit walking distance are used as parameters for evaluating the energy-consumption characteristics. Here, this research employs the cost of transport (CoT) to evaluate the energy-consumption characteristics [29]. This is expressed as where E s is the energy required for a vehicle with weight W to travel a distance L s , P is the consumed power, and v is the vehicle speed. The CoT is useful for comparing the efficiencies of different types of vehicles, and it considers the power consumed per unit mass and unit speed.

B. OPTIMAL FORCE DISTRIBUTION ALGORITHM CONTROLLER
Because the energy consumption is given by the integral of the power consumption with respect to time, it is decreased if the instantaneous power consumption is minimized for each time step. However, the energy-consumption model for legged robots is a piecewise function, which does not conform to the standard form of QP. We expect our algorithm to exhibit an inverse-dynamics optimization form based on QP [22]. To adopt QP, this section analyzes the energy-consumption model of the robot and converts it to a quadratic form, which can be employed as the objective function of the QP algorithm.

1) ENERGY OPTIMIZATION
For a specific hexapod robot, the mass is constant and the velocity is set by the motion planner. According to (14), the energy consumption can be reduced by minimizing the instantaneous power for each time step. The piecewise function (x) in (11) can also be expressed as By substituting (15) into (13), the instantaneous power function can be expressed as Because this function contains an absolute-value function, it does not conform to the standard form of QP. For τ ij , u ij > 0 and v ij > 0 satisfy the following: If ω ij ≥ 0, then If ω ij < 0, then According to (19) and (20), the instantaneous power (16) can be expressed as This instantaneous power function can be used as the objective function for energy optimization, and can be expressed as where 2) EQUALITY CONSTRAINT The energy optimization algorithm distributes joint torques and contacts under the condition that the joint angles and joint speeds are known. According to the dynamic model of the hexapod, the equality constraint can be expressed as By substituting (18) into (28), the equality constraint of the dynamics can be expressed as where

3) INEQUALITY CONSTRAINT
There are also inequality constraints for describing the complex behavior of legged robots. The inequality constraints of hexapod robots are discussed in the following.

a: JOINT-TORQUE INEQUALITY CONSTRAINT
The driving torque of the motor of the robot is limited, and this limitation is related to the motor parameters of the robot. The actuator constraint can be expressed as where τ andτ are the upper and lower limits of the driving torque, respectively, which depend on the motor parameters and the preset safety factor.

b: CONTACT FORCE DIRECTION CONSTRAINT
Because the foot of the hexapod robot cannot grasp the ground, it can only generate a repulsive force, and cannot produce traction. The normal contact force constraints can be expressed as where F Ni is the normal contact force of thei th contact.

c: FRICTION-INEQUALITY CONSTRAINT
The contact force of a single leg should be limited to the friction cone, to prevent slippage at the contact position. The friction-cone constraint is widely employed in forcedistribution research. It is a nonlinear constraint that is linearized and can be expressed as where where µ i is the ith leg's coefficient of friction. F Txi and F Tyi are the friction force in x and y direction. The mechanical and geometric parameters of this hexapod robot are presented in Table 2.  In the numerical simulation, we assume that the robot has no frictional energy loss, i.e., the mechanical efficiency of the robot is 100%. In addition, to eliminate the influence of different motion conditions of the hexapod robot set by the motion planner, a pre-planned identical trajectory curve and a constant gait are be employed in the numerical analysis. This simulation stipulates that the hexapod robot uses VOLUME 8, 2020 a triangle gait to walk forward, and the forward distance of each step is 0.1m. In addition, the foot-end swing trajectory uses a pre-planned cycloid trajectory. This research employ torque optimization [19] and pseudo inverse dynamics [24] as the comparison algorithms to analyze and compare the effectiveness of the proposed energy optimization algorithm. Fig. 4 illustrates the energy-consumption characteristics (average power and CoT) of three algorithms for hexapod robots at different speeds on flat terrain. As shown in Fig. 4(a), the average power of the energy optimization method is reduced compared with the other two methods. The pseudo inverse dynamics algorithm achieves a better energy-saving effect than torque optimization, but is inferior to the energy optimization algorithm under the same velocity. In addition, as the speed increases the power increases for all the algorithms. Fig. 4(b) shows the CoT for the different algorithms at different walking speeds. It can be observed that the energy optimization algorithm reduces the CoT parameters under different walking-speed conditions compared with the other two algorithms. Fig. 5 depicts the instantaneous power of ElSpider on flat terrain at three speeds. The instantaneous power values optimized by energy optimization are the lowest among the three algorithms at each step time.
Righetti et al. previously employed the ratio of the tangential to the normal force to evaluate the distribution characteristics of contact forces [33]. We adopt a similar method to analyze the contact characteristics of our force-distribution algorithm. Our hexapod robot (ElSpider) has a perfectly symmetrical configuration with its six legs evenly distributed around the cylindrical base and contact forces also have symmetrical distribution characteristics. According to the contact forces of six legs, the front legs' contact forces (normal and tangential) and hind legs' contact forces are symmetrical, and middle legs' contact forces are the average of the forces on the front and hind legs. Therefore, the leg contact forces of the entire robot can be revealed by the contact forces of LF and RH legs. So the LF leg and the RH leg are selected as the object of the foot force analysis in context. Fig. 6 shows the distribution of the foot contact force for the LF and RH legs on flat terrain. As shown in Fig. 6(a), the ratios of Ft/Fn obtained using the pseudo inverse dynamics method for the LF and RH legs are 0.006 and 0.003, respectively, indicating that this force-distribution algorithm can reduce the tangential force distribution on flat terrain. The Ft/Fn ratios optimized by torque optimizations are 0.407 and 0.410 for the LF and RH legs, respectively, which indicates that the foot end is prone to slippage. The Ft/Fn values for energy optimization are 0.1043 and 0.1126 for the LF and RH legs, respectively, which are between those of the other two algorithms.
The energy-consumption and contact-force characteristics on terrain with a 20 • slope also be analyzed, where the hexapod robot system is subject to tangential forces. Again, the energy optimization algorithm decreases the energy consumption compared with the other two methods, as shown in Fig. 7. The average power of the energy optimization algorithm at 0.5 m/s is 698.2 W. The energy consumption of the torque optimization algorithm is 746.3 W at the same speed, implying that the proposed algorithm reduces the average energy consumption by 6.45% compared with torque optimization. Fig. 8 shows the curve of the instantaneous power variation at three speeds. It can be observed that the instantaneous power for the energy optimization algorithm is the lowest among the three algorithms at each time step. Fig. 9 illustrates the distribution of the foot contact force for the LF and RH legs. Fig. 9(a) shows that the proportions for the torque optimization method and energy optimization method are essentially equal, satisfying the friction-cone constraints while proportions of the pseudo inverse dynamics method exceed the friction-cone constraints, it's because the inequality constraints cannot be considered in pseudo inverse dynamics method. All three algorithms satisfy the frictioncone constraints in Fig. 9(b). The average ratio for torque optimization in this case reaches 0.610, and is larger than that for the LF leg. Table 3 presents the results for the average power and CoT on flat and sloped terrain for torque optimization, pseudo inverse dynamics, and energy optimization. The power consumed by the robot increases with the walking speed, and the power of the robot is significantly higher on the sloped terrain than on the flat terrain at the same walking speed. The average CoT values for torque optimization, pseudo inverse dynamics, and energy optimization are respectively 0.231, 0.167, and 0.156 for flat terrain and 0.435, 0.424, and 0.407 for sloped terrain. Thus, the energy optimization method achieves the smallest CoT of the three algorithms.
With the increased climbing angles, the CoT parameter will continue to increase regardless of which method is used. In order to show that our force distribution algorithm is also effective when climbing a slope compared to comparison methods, we explore the relationship between the climbing angle and the CoT of three force distribution method (Fig. 10). We found that among the three comparison methods, the CoT parameter of the energy optimization method is the smallest, which indicates that the energy consumption optimization method can reduce the energy consumption of the hexapod robot at different slope angles. We also found that this energy saving effect is getting smaller as the climbing angle increases. If walking on the ground, energy optimization method can save energy by 32.8% compared to torque optimization. If the slope is 20 degrees, the energy optimization method can save energy by 6.4% compared with the torque optimization.

IV. CONTROL ARCHITECTURE OF HEXAPOD ROBOTS
This section describes the motion planner, control algorithm, and simulation architecture. The motion planner plans the movement of the body and legs based on the gait parameters. The control algorithm implements the control of all joints of ElSpider. The simulation for ElSpider, built by ROS (Robot Operating System) and Gazebo, combines the motion planner and control algorithm.

A. MOTION PLANNER
For some quadruped robots, the centroid position must be adjusted during static walking to ensure stability [34], [35]. Because the configuration of the legs of the hexapod robot is symmetrical and the number of landing legs is at least three, it is easy to ensure that the projection of the center of gravity of the robot is located in the supporting polygon. Therefore, a linear trajectory can be planned for hexapod robots. The motion planning of a hexapod robot consists of two levels: the planning of the body trajectory and the planning of the trajectories of all the legs.

1) BODY-MOTION PLANNING
Various walking gaits have been proposed by researchers, such as the central pattern generator (CPG) [36] and free gait [37]- [39]. Only three supporting legs can support the hexapod statically; the other three legs either swing to achieve a high speed or serve as supporting legs to increase the  walking stability. Thus, there are three typical gaits for ElSpider, as shown in Fig. 11: the (a) tripod, (b) quadruped, and (c) one-by-one gaits. During a single period of walking with these three typical gaits, the state of each leg changes once between the swing and support states.
The S-curve is employed to generate the body trajectory for ElSpider from the start posture to the end posture during  each phase. This can generate a smooth trajectory, which prevents unexpected acceleration of ElSpider. The position, velocity, and acceleration function curves of the body are depicted in Fig. 12, where T S is the constant jerk time, T A is the constant acceleration time, and T M is the time from the middle of the acceleration process to the middle of the deceleration process. The distance can be easily calculated as S = v max T M . At the start of a phase, the motion planner of ElSpider calculates the body trajectory for this phase, and at the end of the phase ElSpider waits for all swinging legs to land on the ground and calculates the body trajectory for the next phase. VOLUME 8, 2020 2) LEG-MOTION PLANNING There are two states for a single leg: swing and support. After the body trajectory of ElSpider is generated, the next step is to generate the trajectories of the six legs. The trajectories of the supporting legs are easy to calculate according to the body trajectory and the kinematics of ElSpider. The walking of legged robots depends on the movement of each supporting leg. To achieve the planned movement of the body, the trajectories of the supporting legs must be planned. In Fig. 13, G , B0 , and Bi represent the ground coordinate, starting trajectory point coordinate, and coordinate of the i th trajectory point, respectively; G B0 T and G Bi T are the transformation matrices between these coordinates; and G F p, B0 F p, and Bi F p represent the positions of the foot in these respective coordinates. Assuming that there is no slippage, the coordinate transformation matrix satisfies the following relationship: Combining (38) and (39) yields Using (40), a foot trajectory can be planned according to the initial body posture, initial foot position, and desired trajectory of the body. Thus, the body of the robot can execute the planned motion. The trajectory of a specific swinging leg is divided into two parts: the transition and full-swing. During the transition part, the foot position rises or falls between the preset height and the ground. During the full-swing part, the foot position traverses to the anterior extreme position (AEP), and the path is generated by a polynomial designed to smooth the motion without accidental loading.

B. CONTROL ALGORITHM
A feedforward control algorithm similar to that utilized by Mistry to control the motion of hexapod robots is employed [16]. However, we replace the first item of the controller with several different force-distribution algorithms, including the pseudo-inverse dynamics controller, torque optimal controller, and energy optimal controller, to verify the proposed force-distribution algorithm. The feedforward controller is expressed as (41) where K P and K D are proportional-derivative (PD) feedback gain matrices, S is a selected matrix, and Opt() is the force-optimization algorithm term.

C. SIMULATION ARCHITECTURE
A dynamic simulation is employed to verify the proposed force-distribution algorithm. The simulation platform for the hexapod robot is based on Gazebo and ROS, produced by the Open Source Robotics Foundation. We utilize the torque-control plugin of ros_control to control the joint torques of the hexapod robot in the simulation. The designed control framework is illustrated in Fig. 14. This includes the motion-planning, trajectory-execution, PD-controller, and optimal-controller modules. The motion-planning module plans the gait parameters of the robot and the motion of the trunk. The gait parameters include the walking distance and rotation angle for one step. The module plans the trunk trajectory according to the gait parameters. The trajectory module plans the trajectories of all legs according to information obtained from the motion planner module, including all the swinging and supporting legs. The PD-controller module controls the joint-position errors and produces a torque array τ PD . The optimal controller has three built-in controllers, as previously mentioned, and generates the optimized joint torque τ opt .

V. EXPERIMENTS AND DISCUSSION
Simulation experiments are used to illustrate the advantages of the energy optimization algorithm. We employ the proposed algorithm and two others for the hexapod-robot simulation. To ensure the consistency of the movement process, the same motion-planning parameters are utilized in the walking processes of the three force-distribution algorithms. The controller PC's 4 core CPU Processor Base Frequency is 1.8 GHz. The average calculation time of torque optimization method, pseudo inverse dynamics method, and energy optimization method are 1.4ms, 18.5 ms, and 1.5ms.  First, we analyze the energy consumption characteristics of a hexapod robot on flat terrain. The movement process of this hexapod robot is illustrated in Fig. 15. Fig. 16 shows the relationship between time and energy consumption for the three force-distribution methods. It can be observed that the energy consumption of the energy optimization algorithm is the lowest among the three algorithms for the entire walking process. Additionally, we observe that the energy-consumption curve of the robot exhibits a step shape. This is because when the foot states alternate between the support and swing states, the velocity of the robot decreases to 0. Thus, each step in the figure indicates that the robot has moved forward by one step. The average speed of the hexapod robot in this simulation is 0.133 m/s. The average powers for the torque optimization, energy optimization, and pseudo-inverse dynamics methods are 405.3, 367.1, and 394.6 W, respectively, over the entire moving process. The CoT parameters corresponding to these three methods are 0.972, 0.881, and 0.947, respectively. We analyze the contact characteristics of the force-distribution algorithm, similar to Section 3. The contact characteristics of the three methods are depicted in Fig. 17. Fig. 17(a) shows the contact-force distribution of the LF leg. The average ratios for the pseudo inverse dynamics, energy optimization, and torque optimization methods are 0.106, 0.149, and 0.369, respectively. Fig. 17(b) shows the contact-force distribution of the RH leg. The average ratios for the three force-distribution algorithms are 0.131, 0.156, and 0.388, respectively.
We also perform a hexapod simulation for sloped terrain to analyze the energy consumption characteristics of these force-distribution methods, as illustrated in Fig. 18. Under this condition, the robot is subjected to the tangential forces of each supporting leg. Similar to the previous flatterrain simulation, we ensure that the different foot forcedistribution algorithms employ the same trajectory-planning parameters. Fig. 19 depicts the relationship between the time and energy consumption for the hexapod robot on the slope. As shown, the energy optimization algorithm reduces the energy consumption compared with the other two methods over the entire walking progress. The torque optimization method exhibits the highest energy consumption, which is consistent with the previous numerical simulation results. The average walking speed of the robot is 0.133 m/s, which is similar to that in the flat-terrain simulation. The average powers for the torque optimization, energy optimization, and pseudo-inverse dynamics methods are 447.3, 477.4, and 468.6 W, respectively, over the entire moving process. The CoT parameters corresponding to the three methods are 1.073, 1.145, and 1.124, respectively. We analyze the characteristics of the force-distribution algorithm in the sloped environment for each method, as shown in Fig. 20. Fig. 20(a) shows the contact-force distribution of the LF leg. The CoT values of the three force-distribution algorithms are 0.221, 0.262, and 0.300, respectively. Fig. 20(b) shows the contact-force distribution of the RH leg. The average ratios   for the force-distribution algorithms are 0.191, 0.346, and 0.486, respectively.
The simulation results are presented in Table 4. For the flat terrain, the energy optimization algorithm reduces the energy  consumption by 6.97% compared with the pseudo inverse dynamics method and 9.43% compared with the torque optimization algorithm. For the sloped terrain, the energy optimization algorithm reduces the energy consumption by 4.55% compared with the pseudo inverse dynamics method and by 6.30% compared with the torque optimization algorithm.
The authors validated the effectiveness of the proposed energy optimization algorithm on ElSpider hexapod robot: position control and energy optimization control. The gait, walking speed and walking distance of ElSpider robot are consistent in these experiments (Fig. 1). The instantaneous power of ElSpider hexapod robot could be calculated by joint torque and joint speed during walking. The results of the instantaneous power of two methods are shown in Fig. 2 (a). It can be seen from the results that the instantaneous power using energy optimization is less than pure position control. We integrate the instantaneous power with time and obtain the energy consumption with time during the whole movement progress (Fig. 2 (b)). The results show that the energy optimization algorithm can reduce energy consumption by 5.72% compared to position control during the entire walking process.

VI. CONCLUSION
We focused on the problem of energy consumption for hexapod robots. A DC-motor model was constructed to analyze robot energy consumption. Then, an instantaneous-power objective function in a QP form was derived from the system energy-consumption model. Our method minimizes the energy consumption of a hexapod robot by optimizing the instantaneous power at each time step. To verify the validity of the energy optimization algorithm, we performed a numerical simulation under the assumption of zero mechanical energy loss and robot prototype experiment named ElSpider. We designed the control framework using ROS, which includes different optimal-force algorithms in the control architecture. We performed a dynamic simulation using Gazebo to verify the energy optimization algorithm compare with other methods. The results of the numerical analysis and dynamic simulation demonstrate the effectiveness of the energy optimization algorithm, which reduces the energy consumption and CoT compared with two other algorithms. We also implement a prototype experiment which shows that this method can reduce energy consumption compared to position control.