Development and implementation of a new approach for posture control of a hexapod robot to walk in irregular terrains

Abstract The adaptability of hexapods for various locomotion tasks, especially in rescue and exploration missions, drives their application. Unlike controlled environments, these robots need to navigate ever-changing terrains, where ground irregularities impact foothold positions and origin shifts in contact forces. This dynamic interaction leads to varying hexapod postures, affecting overall system stability. This study introduces a posture control approach that adjusts the hexapod’s main body orientation and height based on terrain topology. The strategy estimates ground slope using limb positions, thereby calculating novel limb trajectories to modify the hexapod’s angular position. Adjusting the hexapod’s height, based on the calculated slope, further enhances main body stability. The proposed methodology is implemented and evaluated on the ATHENA hexapod (All-Terrain Hexapod for Environment Adaptability). Control feasibility is assessed through dynamic analysis of the hexapod’s multibody model on irregular surfaces, using computational simulations in Gazebo software. Environmental complexity’s impact on hexapod stability is tested on both a ramp and uneven terrain. Independent analyses for each scenario evaluate the controller’s effect on roll and pitch angular velocities, as well as height variations. Results demonstrate the strategy’s suitability for both environments, significantly enhancing posture stability.


Introduction
Over the few years, the problem of dynamic modeling and analysis of hexapod robots has been studied for estimating the foot-ground interactions and locomotion optimization.Jin et al. [1] defined the equations of motion of a heavy-weight hexapod using Kane's dynamic formulation to study the influence of spring-damper models in the main body's acceleration, for a regular surface.A similar strategy is proposed by Liu et al. [2] for the study of the feet contact forces and the design of active suspension models for the legs in heavy-weight hexapod.The dynamic modeling analysis has also been used for the study of underwater tasks.Considering the seabed as a soft terrain, Ding et al. [3] implemented the dynamic model of a limb and hydrodynamic forces to study the contact forces of the foot when the robot crawls on the sea.In a similar approach, Wang et al. [4] presented the hexapod robot dynamic model for the design of passive and active suspension models in the legs, considering the robot's landing in the seabed.Burkus et al. [5] developed the multibody model of a hexapod robot using Simscape and MATLAB to optimize its locomotion in terms of energy consumption, mass, and joints actuation.Deepa et al. and Xue et al. [6,7] also studied the locomotion efficiency of a hexapod robot using the dynamic simulation software CoppeliaSim.Using the Euler-Lagrangian dynamic formulation, Chang and Lin [8] presented the study of running and turning gaits for a hexapod with spring-loaded inverted pendulum C The Author(s), 2023.Published by Cambridge University Press.limbs.The same dynamic formulation is implemented by Chávez and Alcántara [9] in order to evaluate the energy consumption and trajectory of a hexapod walking across a plane.In a different application of the hexapod's dynamic model, Ouyang et al. [10] proposed a Reinforcement Learning algorithm to generate locomotion using the joints' torque and velocity, and the torso's orientation.By defining the Lagrange equations of motion for each limb, the work presented by Zhang et al. [11] discusses the torso stability during the hexapod navigation across a plane.The Lagrange formulation is also used to study the motion of a hexapod's legs and estimate the slippage between the foot and the ground in the work presented by Liu et al. [12].Similarly, He et al. [13] presented a simplified multibody model of a hexapod robot to study the normal and tangential contact forces of the feet in order to predict the sinking and slippage of these bodies in a soft terrain.Due to formulation complexity, the majority of presented studies only consider the limbs dynamic model to study the robot's behavior.Besides, hexapod locomotion is mainly studied in regular surfaces, despite the terrain stiffness.However, the dynamic formulation of a hexapod robot can provide an insight into the robot's behavior in different terrain topologies and assess the robot's design and control.
In turn, the control strategies commonly used in hexapods aim at developing efficient and adaptive locomotion [14][15][16].Several studies employ Artificial Intelligence (AI) for the efficient gait generation in regular surfaces [17][18][19].The study of gait generation aims at developing path planning algorithms based on the hexapod's behavior, for more complex environments [20].In the design of exploration hexapod robots, Simultaneous Localization and Mapping techniques have been studied for the navigation across unknown environments and identification of human-hostile areas [6].Regarding rescue and scouting missions, the implementation of image processing and AI in hexapod robots is also proposed for human recognition [21].The drawback of the presented works is considering that the hexapod walks across regular surfaces.For locomotion across irregular terrains, the usage of kinematics approaches for the generation of adaptive locomotion prevails.Zhao et al. [22] discussed the implementation of adaptive impedance models combined with a terrain classification method in a hexapod, to walk across different terrain topologies.The usage of impedance models is also proposed by Yin et al. [23] to adapt the foothold positions based on terrain cost map estimation, which reduces the torso's oscillation during locomotion.Nonetheless, the terrain's inclination influences the gait efficiency, and thus the torso's orientation must be adjusted to ensure the system's stability and improve its performance.
From the discussion described above, it is clear that there is additional room for researching the control and implementation of hexapod robots for irregular terrains, in terms of stability and posture control.It can be mentioned that the study of the hexapod's dynamic model in complex environments is worthy of investigation, since most studies implement the presented control in the physical prototype without estimating the robot's behavior through computational simulations.Thus, it can be observed that there is a gap in the thematic literature in terms of studying the dynamic modeling of hexapod robots as well as their posture control to walk in irregular terrains.Hence, the main purpose of this work is twofold.The first objective is to model the full multibody of a hexapod robot and describe the equations of motion that are used to evaluate the robot's locomotion in irregular terrains from the dynamic point of view.The second goal of this work is to propose a posture control for generating stable locomotion in irregular terrains, regarding the data provided by the defined dynamic model for the control's feasibility assessment.
By and large, there are three main methodologies to deal with the problem associated with ground discontinuities or irregularities, namely the virtual model control (VMC), the foothold planning approach, and the AI-enhanced methodology.In the VMC, the animal's reflexive behavior is mimicked to adjust the hexapod robot's posture based on the foot force distribution.By using virtual springs and dampers, the VMC aims at estimating the limbs' joints torque to estimate the torso center of mass position.Nelson and Quinn [24] utilized the VMC for the position adjustment of a hexapod when an external load is applied to the torso.These authors showed that the implementation of the VMC ensures that the hexapod's main body remained horizontal during the system's navigation across complex environments.In turn, Tikam et al. [25] combined the VMC with virtual suspension models to adapt the system's response to the torso height, roll, and pitch deviations.The VMC was assessed for the correction of a commercially available hexapod's standing posture in an irregular environment.The proposed control ensures that the torso remains horizontal and that all limbs are in contact with the ground during the gait phase transition.Liu et al. [26] presented a similar strategy to control the hexapod posture when climbing stairs.For the tested running scenario, the methodology obtained a maximum offset value of 11.0 • and 3.2 • for the torso's pitch and roll angles.The system's stability potentially increases with the implementation of the VMC with impedance controllers on the legs, to compensate for the height deviation that occurs during the foot collision with the ground [26].In the study presented by Zhang et al. [27], the combined strategy obtained a reduction of 53.0% and 54.0% of the roll and pitch angle variation when walking across irregular surfaces.Kim et al. [28] also adopted the VMC approach and considered the hexapod Little Crabster as an inverted pendulum with spring and damper elements to control the rotation of the system's center of pressure.Besides being limited to the force sensor accuracy, the VMC effectiveness depends on complex mathematical models for the motion estimation, which implies a higher computational accuracy.The design of the virtual elements depends on the studied terrain topology.Hence, the damping and stiffness coefficients must be constantly adjusted, to avoid a large compensation of the foot forces.
In the foothold planning scientific approach, the control posture is obtained by developing gait planning methods to adapt the foothold position according to the ground discontinuities [29][30][31][32][33].The presented method can be implemented by using the data provided by a gyroscope or an Inertial Measurement Unit (IMU) as input of a kinematic-based control for the limbs' actuation [32,[34][35][36][37]. Instead of calculating the torso orientation, the robot's relative height can be obtained through the estimation of the plane formed by the supporting limbs [38,39].The advantage of the main body leveling method is not resorting to external sensors to estimate the hexapod state.Xia et al. [40] proposed a body leveling method based on the detection of contact forces between the limbs.In a different approach, Chen et al. [41] proposed a proportional control to adjust the hexapod posture based on the relation between the feet and the torso's linear and angular velocities.More recently, Chen et al. [42] also used the robot's kinematic model to obtain a mathematical relation between the joints and the torso angular velocities and designed a nonsingular fast terminal sliding mode control to adjust the angular deviations.Along with studying the hexapod's kinematic model for posture correction, the limbs' kinematic configuration can be also adjusted to increase their mobility [43,44].Nonetheless, this solution has some limitations in terms of design complexity and energy autonomy.
The methodology of AI-enhanced posture control has received little attention in the literature.Azayev and Zimmerman [45] proposed a Reinforcement Learning methodology with a Recurrent Neural Network for the terrain classification to adjust the torso and gait velocities.Due to the fact that convergence studies are conducted in computational simulations, the main drawback of the presented methodology is the transferring of the designed model into the physical prototype.
Building upon the literature review, it is clear that planning the torso and feet trajectories provides a simpler control system and generates better responses to gait fluctuations.This work discusses the implementation of a kinematic-based approach for the control and online path planning of a hexapod mobile robot for the execution of scouting tasks in rescue missions.In more detail, an adaptive posture controller that regulates the torso's height and roll and pitch orientation through the real-time planning of the feet' coordinates is developed.The proposed methodology is implemented in the hexapod ATHENA, which aims at generating adaptive and autonomous locomotion for unstructured environments.Since the limbs' actuation of ATHENA is periodic, the developed approach for the robot posture control estimates the terrain slope through the system's kinematic model.With the resultant relative coordinates, the angular deviation between the torso and the ground is determined, and the foothold positions are adjusted to maintain the torso's posture stability.The proposed method also calculates the hexapod's adequate height regarding the ground's slope, to ensure that the main body does not collide with obstacles during the motion performed.The control methodology is adaptable to the environment by adjusting the system's response for the height and posture correction.This work presents contributions for the adaptive locomotion of legged robots designed for tasks in complex environments.The most relevant advantage of the proposed methodology is providing a generalized posture control approach which can be optimized in terms of torso's height and orientation regarding the type of scenario the hexapod robot must navigate.The designed control only requires information of the existence of contact forces on the hexapod's feet, the angular position of each joint, and the torso's height.Subsequently, the low number of required sensors for the system's control is another advantage in terms of energy consumption.The exclusion of exteroceptive sensors, such as vision sensors, for the ground estimation decreases the method's volatility, since the data collected by this type of sensor depends on the environment conditions.The control method feasibility is assessed in the dynamic simulation Gazebo software, considering the multibody model of the hexapod.Furthermore, the hexapod is evaluated in two different scenarios, namely a 10-degree ramp and an irregular terrain.The objective of the two computational simulations is to determine the control response in different conditions in terms of terrain topology and slope variation.The height and posture adjustment methods are evaluated.In each case, the height and posture adjustment methods are compared against the outcomes obtained with a nonadaptive controller.The results show the improvement of the torso stability in both scenarios.
The structure of this paper is organized as follows.Section 2 provides a description of the ATHENA robot and discusses its implementation in Gazebo.Section 3 presents the equations of motion and establishes the contact strategy to evaluate the system's dynamic behavior, as well as the used kinematic model to describe and control the robot's locomotion.Section 4 discusses the proposed methodology for posture and height control.Section 5 presents the main outcomes from the computational simulations performed in the different scenarios.Finally, Section 6 contains the concluding remarks of this work.

Hexapod model description 2.1. System analysis
In this section, a description of the hexapod robot ATHENA considered in this study is presented.The physical prototype of the ATHENA robot is depicted in Fig. 1.From the mechanical point of view, the robot is composed of 25 rigid bodies, which are interconnected by 24 kinematic joints, as can be observed in the corresponding multibody model illustrated in Fig. 2. In this model, body b is the torso, being the remaining bodies axisymmetrically distributed around it.Each limb includes three revolute joints that are actuated by servo motors with a stall torque of 1.89 N•m.The revolute joints aim at connecting the torso with the coxa, femur, and tibia segmentsc i , f i , and t i -which are, respectively, named Thorax-Coxa (TC), Coxa-Trochanterofemur (CTr), and Femur-Tibia (FTi).Besides that, the parameter p i represents the hexapod feet, which are linked with t i through prismatic joints.The passive connection between the two bodies aims at controlling the feet's relative displacement caused by their interaction with the ground, using compression springs with a spring rate of 9.28 × 10 3 N•m.The displacement associated with the compression spring does not provide significant position deviations in the foot trajectory.These two components are combined, and the relative motion between them is considered to be null.The inertia properties of the bodies of the ATHENA robot are listed in Table I.The presented principal and secondary moments of inertia are estimated using the local reference frame of each body, which is attached to the respective center of mass.

Model design for the computational analysis
In order to have an efficient and accurate contact formulation between the feet and the ground, a simplified multibody model of the robot was developed and implemented in the Gazebo software.Bearing in mind that the goal of this work is to examine the presented posture control in inclined surfaces, the system geometry does not have a significant influence on the results, as long as the inertial properties are equivalent to the physical prototype.Therefore, the hexapod was modeled in Gazebo using simple geometries, such as spheres and planes (see Fig. 3).Most of the components were converted into prisms.On the contrary, the feet were modeled as spheres and therefore, during the collision with the ground, there is only one contact point, which is also beneficial for the computational point of view.All revolute joints were set to a maximum torque of 1.89 N•m, to simulate the selected servo motors and the connection between the tibia and the foot is assumed fixed.Table II lists the model dimensions and the respective inertial properties.The presented principal and secondary moments of inertia are estimated using the local reference frame of each body, which is attached to the respective center of mass.

Problem formulation 3.1. Equations of motion
This section discusses the defined equations of motion for the hexapod robot that are used to assess the control behavior.The computational simulations performed in Gazebo resort to the external library Open Dynamics Engine (ODE) to estimate the motion and forces applied to a system.The general equations of motion involving contact-impact events are expressed as [46]: in which M (150,150) is the system's global mass matrix, q(150) denotes the vector that contains the bodies' linear and angular accelerations, the matrices N n , N t ∈ R 150×n contain respectively the normal and tangent vectors with respect to the contact surfaces, and f n , f t ∈ R n are respectively the n-dimensional vector of the normal and tangential contact forces.It must be mentioned that the dimension of f n and f t depends on the number of contacting points.The equations of motion are calculated at the impulse level.In each time step, contact-impact events are detected and the equations of motion of the model are evaluated with respect to the bodies' velocities.The numeric simulation's time discretization is based on the Moreau's time-stepping methodology [47].
In turn, the contact resolution closely follows the approach proposed by Stewart-Trinkle [48] and Anitescu-Potra [49], which is formulated as a Linear Complementarity Problem (LCP).This type of formulation can be expressed as: where A (n,n) and b (n) are constants with n-dimension,and x and y denote the system's unknowns [46].In order to obtain the quantities of x and y, the following complementary conditions must be verified [46]: This methodology is implemented for the calculation of the normal contact forces.In this strategy, the normal contact forces are modeled using Newton's impact law, which considers the existence of compression and restitution phases during the collision between two bodies.When the compression phase takes place, there is impulse conservation.The model's equations of motion are expressed at level velocity and impulse level can be formulated as [48,49]: where the superscript 0 denotes the end of the compression phase and q− is the pre-collision velocity.
The variables fn and ft denote the impulses of the normal and tangential contact forces, respectively.During the restitution phase, the bodies move in opposite directions, and the equations of motion at the velocity and impulse level are expressed as: in which q+ is the post-collision velocity.The vector fr , which represents the impulsive force, can be defined as: where ξ ∈ [0, 1] is the coefficient of restitution.In this study, ξ equals 0.5.In order to solve the Newton's impact law as an LCP, the following complementary conditions are defined [48,49]: These conditions evaluate both the normal relative distance between bodies and the consequent existence of a normal contact force.If N n q is null, there is a collision, and a positive normal contact force exists.On the contrary, if the N n q is positive, then the bodies are separated, and the normal contact force is null.
A similar strategy is implemented for the tangential contact analysis.In this study, the tangential contact forces are modeled using Coulomb's friction law.In order to increase the model accuracy, the isotropic friction model is approximated to a polyhedral [50].The complementary conditions that are set to solve the friction forces as an LCP are expressed as: where λ denotes the Lagrange multipliers, and μ is the friction coefficient, which is equal to 0.9.The presented inequalities state that if λ is greater than 0, there is sliding between the two surfaces.Otherwise, there is stick slippage between the surfaces [46].

Kinematic model
This section presents the kinematic modeling process to control the robot.The implementation of the proposed method requires obtaining the relation between the joints' angular positions and the robot's feet coordinates.Considering the models presented in refs.[37,51], the torso's center of mass is defined as the reference for all calculations.The kinematic model of one limb is depicted in Fig. 4. The angles θ r 2 , θ r 3 , and θ r 4 are the relative angles of the TC, CTr, and FTi joints, respectively.The hexapod motion is studied by setting the motion range of the TC joint to θ r 2 ∈ [−0.612, 0.612] rad, and the angular position of the remaining joints is constrained to θ r 3 , θ r 4 ∈ [−1.484, 1.484] rad.The locomotion control requires two different estimations from the kinematic model: (i) get the current feet coordinates based on the joints' angular positions to verify if the desired motion is within the system's workspace, and (ii) calculate the joints' configuration according to the trajectory applied to the feet.In the first analysis, the Denavit-Hartenberg convention is used to obtain the relative position of the foot w.r.t. the reference frame B. Using the Denavit-Hartenberg parameters presented in Table III, the relative transformation between B and the hexapod feet can be established as: where the vector p B i = {x B p , y B p , z B p } T , i ∈ 1, . . ., 6 contains the feet' relative coordinates, which are expressed as: The limb's inverse kinematics calculation is essential to control the driven joints' positions.The inverse kinematics formulation uses the feet's position to obtain the relative angular positions of the joints.For this matter, the value of θ r 1 is constant and depends on the leg position as: Table III.Denavit-Hartenberg parameters for all relative transformations between the reference frame B and the hexapod's foot p i .The calculation of θ r 2 depends on the fixed reference frame Q, which is placed on the TC joint (see Fig. 5).Thus, the angular position of this driven joint is defined as: in which T denotes the relative position of p i w.r.t.Q, and is expressed as: where T 0 1 is the transformation matrix between the reference frames B and Q.The estimation of the remaining angular positions requires knowing the position of the reference frame U, which is placed on the CTr joint.Using the Denavit-Hartenberg convention, the position of U w.r.t.Q is defined as: Considering the vector s p between the reference frame U and the foot, the value of the CTr and the FTi joints is as follows: where z U and z p represent, respectively, the vertical position of the reference frame U and the foot.
The presented equations of motion and kinematic model of the ATHENA robot contain fundamental concepts for the design and assessment of the developed posture control strategy.

Control strategy for the locomotion of ATHENA across inclined surfaces 4.1. Gait generation
The locomotion of the ATHENA robot adopts the tripod gait.Among the commonly adopted gaits in hexapod robots, the tripod pattern provides the highest velocity of the main body, despite decreasing the system's stability due to the number of supporting limbs.If the designed control for the posture adjustment provides good results for the tripod gait, then the methodology is considered assessed for other locomotion types.Considering the gait state, the limbs execute a different motion.In the swing phase, the feet reach a new foothold position by executing a cubic Bézier trajectory expressed as: where n represents to the number of control points, t g is the trajectory's time interval, and p B i,j denote the control points of the trajectory.The first control point corresponds to the foot's initial position p B i,0 which is defined by Eq. ( 12).The remaining control points are determined as: where h is the maximum height and s denotes the stride.
In the stance phase, the feet are in contact with the ground while propelling the torso forward.Thus, the foot's trajectory is defined as: In both phases, the result of the foot trajectory must be converted into motor commands, using the inverse kinematics model established in Section 3.2.

Posture adjustment
The aforementioned footpath planning of the limbs considers that the hexapod robot walks across a regular and smooth surface.Thus, the displacement of the torso's height and orientation is neglected, and consequently the system is stable.Nonetheless, the variation of the terrain topology affects the hexapod's achievable foothold positions and corresponding torso's posture.The terrain complexity increases the displacement of the torso's position, which constrains the hexapod's ability to surmount inclined surfaces.Bearing that in mind, the proposed strategy aims at adjusting the hexapod's height and orientation by estimating the ground inclination.
The terrain perception is estimated by the relative position of the feet w.r.t. the torso, which is given by Eq. (12).For this purpose, the control evaluates the relative coordinates of the feet, which are in contact with the ground.Using the relative coordinates of the supporting feet, the terrain can be approximated to a characteristic plane expressed as: in which a p , b p , c p , and d p are constants, and x, y, z ∈ R f are f -dimensional vectors that contain the coordinates of the supporting feet.With the values of a p , b p , c p , and d p , the norm vector of the plane g is obtained.The developed algorithm for the detection of the supporting limbs, and the calculation of the norm vector, is described by the following steps (see Fig. 6).In each gait cycle, the algorithm reads the  normal contact forces using the force sensors placed on each foot.In a regular surface, there are exactly three legs with positive normal contact forces; hence, the ground plane equation can be estimated using Eq.(24).Nonetheless, the number of supporting limbs changes with the terrain irregularities.If the terrain topology forces the hexapod to have more than three supporting limbs, a random subset with three of the legs in contact with the ground is applied for the estimation of the ground plane.In case of having less than three legs in the stance phase, the algorithm searches among the remaining limbs which should be in contact with the ground, and their trajectory is extended until a positive normal contact force is read by the force sensors.After that, there are sufficient supporting limbs to estimate the terrain's characteristic plane using Eq. ( 24). Figure 7 shows a generic configuration of the ATHENA hexapod walking across an inclined and irregular surface.Considering the torso's local reference, and a two-dimensional representation of g in the ηζ and ξζ planes, the angular displacement of the pitch and roll angles is determined as: where δ α represents the pitch displacement, n ζ denotes a unitary vector, and δ β is the angular deviation in the roll orientation.The terrain's inclination affects the relative motion between the torso and the ground.Figure 8 shows the angular displacement performed by the ATHENA hexapod climbing a 10-degree ramp in Gazebo, without controlling the torso posture.From the analysis of this plot, it can be observed that in each gait cycle, the transition between gait phases causes an abrupt change of the roll and pitch angles due to  the alternation between the supporting limbs and consequent inaccurate planning of the foothold positions.Thus, it is of paramount importance to ensure that during the gait phase transition, all limbs are in contact with the ground and their height is adjusted to the estimated surface plane.Subsequently, the results variation of the roll and pitch angles in each gait cycle assess the torso's instability when the hexapod climbs the ramp.The posture variation is influenced by the limbs' trajectory in the stance phase, which is responsible for adjusting the torso's angular positions.Considering the outcome from the computational simulation with simple control, it can be concluded that the proposed control strategy is able to adjust the feet' coordinates regarding the torso's orientation and height.Since the swing phase is mainly influenced by the torso's height, the final control point of the cubic Bézier trajectory is defined as: where k z is a control parameter, and δ z denotes the height displacement, being the difference between the relative height w.r.t. the ground measured by an infrared sensor placed on the torso, and the reference height, which denotes the torso's height considering the hexapod's standing posture.Regarding the stance phase, the control strategy requires an adjustment using Eq. ( 23) according to the torso orientation in inclined surfaces.Thus, the feet's final position in the stance phase is expressed as follows: where t r denotes the transformation vector, that are expressed by: t r = R (4,4)   x (k α δ α ) R (4,4)   y k β δ β T (4,4) where R x and R y denote the rotation matrix along the axes x and y, respectively, k α and k β are the corresponding control parameters for the pitch and roll angles, and T is the transformation matrix defined as: T (4,4) = I (3,3) t Bearing in mind that the transformation of p O i,f , the stance phase is defined as:

Computational simulations 5.1. Computational setup
The proposed computational procedure to control the ATHENA robot has been implemented and evaluated in the Gazebo software.The ODE library is considered in the computational simulations with a time step equal to 50 ms to solve the equations of motion and provide data regarding the torso posture.The controller implementation in the Gazebo environment uses a ROS-based client-server infrastructure with a rate of 20 Hz to simulate real-time data acquisition.An IMU and an infrared sensor are placed on the hexapod's torso, to assess the body's angular velocities and height, which are estimated by the ODE library.The computational simulations are performed for a 10-degree ramp and an irregular terrain.The two scenarios are presented in Fig. 9.The surface's inclination defined for the ramp scenario is representative and is appropriate to assess the control methodology (see Fig. 9(a)).A similar strategy is utilized in the testbed scenario portrayed in Fig. 9(b).The second situation contains blocks with different heights between 0.04 m and 0.13 m and aims at studying the proposed control in a more demanding scenario in terms of terrain topology variation.In both computational cases, the hexapod adopts a tripod gait with t g = 1 s, and the kinetic friction coefficient is set to 0.9.For the height adjustment, the hexapod's standing posture, which is used as reference for the infrared sensor readings, is set when θ r 2 = 0 rad, θ r 3 = 0 rad, and θ r 4 = − π 2 rad.

Discussion
In each environment, the influence of the parameters k z , k α , and k β on the control system's response is analyzed.It must be noticed that the value of the parameters can be defined by an infinite number of combinations.The main goal of this work is to assess the feasibility of the proposed control; hence, k z , k α , and k β are restrained to a set of discrete values (k z , k α , k β ∈ {0.0, 0.2, 0.4, 0.6, 0.8, 1.0}), which provides a general overview into the influence of the constants k z , k α , and k β in the posture stability in the two defined scenarios.The hexapod's posture is evaluated according to the torso's height w.r.t. the ground and the angular velocities in the roll and pitch directions.In each computational simulation, the root-mean-square value of the aforementioned variables is estimated per gait cycle, and the resultant variation is examined.

Ramp scenario
The first computational simulations that were performed consider k α = k β = 0.0 and k h ∈ {0.0, 0.2, 0.4, 0.6, 0.8, 1.0}.If k z = 0.0 takes place, the control system does not adjust the torso's height, and when k z = 1.0, there is full implementation of the estimated δ z in the limbs' trajectories.The obtained results for the relative height and angular velocities are presented in Fig. 10.Using the simple control as reference (k z = 0.0), it can be observed that the implementation of the height adjustment improves the hexapod robot's stability due to the significant decrease of the height's interquartile range when k z > 0.0 (see Fig 10(a)).In comparison to the median value for k z = 0.0, which corresponds to 0.068 m, there is, on average, an increase of 58.42% in the torso's height when the proposed control strategy is implemented.Although the highest median value occurs when k z = 1.0, which corresponds to 0.112 m, the height variation is smaller when k z ∈ {0.6, 0.8}.The height adjustment does not affect the torso's orientation and angular velocity.Figure 10(b) depicts the plots for the pitch velocity.The obtained results show that the pitch velocity's median increases when k z = 1.0.Thus, it can be concluded that, for the maximum height, the variation of the torso's pitch angle increases, and the hexapod's posture becomes unstable.For the remaining cases, k z ∈ {0.2, 0.4, 0.6, 0.8}, the hexapod's stability improves, since there is has an average reduction of 18.91% of the median value, and a decrease of the interquartile range.Among the obtained results for the pitch velocity, the robot achieves its stable configuration when k z = 0.8, due to the smallest interquartile range and median value, which corresponds to 0.064 rad/s.Regarding the roll angle, the implementation of k z = 1.0 increases the variation of the angular velocity, which penalizes the robot's stability (see Fig. 10(c)).However, in the remaining cases, an improvement of the velocity variation is observed, corresponding to a decrease of 30.74% of the median value.In this case study, the smallest variation is observed when k z ∈ {0.2, 0.8}.A similar strategy is implemented for the analysis of the computational simulations performed considering k z = k β = 0.0 and k α ∈ {0.0, 0.2, 0.4, 0.6, 0.8, 1.0} (see Fig. 11).Taking the simple control (k α = 0.0) as a reference, the adjustment of the torso's pitch orientation does not have a significant influence on the height's variation (see Fig. 11(a)).However, for the results regarding the angular velocities in the pitch and roll directions, the configuration k α = 0.6 provides a good improvement in the system's stability, both in terms of the interquartile range and the median value, which decreases 39.56% and 35.7%, respectively, in the pitch and roll velocities (see Fig. 11(b) and (c)).
Although control of the torso's roll angle is not important for the tested environment, the computational simulations considering k z = k α = 0.0 and k β ∈ {0.0, 0.2, 0.4, 0.6, 0.8, 1.0} were also performed.Figure 12 shows the outcome of the computational simulations performed.Similarly to the results presented for k α , the control of the torso's roll angle does not have a significant effect on the height variation (see Fig. 12(a)), despite the considerable decrease of the median value when k β ∈ {0.2, 0.6}.Regarding pitch velocity, the interquartile range between configurations is considered identical, which means that there is no improvement in the system's stability (see Fig. 12(b)).Nonetheless, the minimum median value takes place when k β = 0.4 and corresponds to 0.077 rad/s.In terms of the results for the roll velocity, which is plotted in Fig. 12(c), the variable's median improves for k β ∈ {0.4,0.6, 1.0}, which corresponds to a decrease respectively of 14.54%, 2.32%, and 15%.Nonetheless, by analyzing the maximum values and interquartile ranges, it is not possible to conclude that the implementation of k β > 0.0 provides good results for the hexapod's posture in the ramp environment.

Irregular terrain scenario
In comparison to the study presented to the previous section, a similar approach to the performance of the computational simulations is implemented in the testbed scenario.In this case, it is expected to observe a higher instability of the torso due to the terrain irregularities.The first analysis takes into account that k α = k β = 0.0 and k z ∈ {0.0, 0.2, 0.4, 0.6, 0.8, 1.0}.Figure 13 depicts the outcome of the computational simulations performed.Considering the simple control (k z = 0.0) as a reference for this analysis and observing the interquartile ranges, the implementation of the torso's height control significantly improves the hexapod robot stability (see Fig.   Without considering k z = 0.2, the average increase of the pitch velocity's median value corresponds to 66.66%.Regarding the roll velocity, the maximum torso's instability takes place when k z ∈ {0.2, 0.8}, and the most stable configuration occurs when k z = 0.4.Thus, despite ensuring a more stable height of the torso, the correction of the feet' relative height increases the variation of the hexapod's orientation. Similarly to the ramp, the influence of k α on the torso posture does not provide significant enhancement in terms of height stability control (see Fig. 14(a)).Considering k α = 0.0 as a reference and observing the height variation, the optimal configuration corresponds to k α = 0.4.By observing the results depicted in Fig. 14(b), the control of the torso's pitch angle decreases the hexapod's stability.The most unstable configurations take place when k α ∈ {0.8, 1.0}, which means that the torso cannot have the same inclination as the ground.Nonetheless, if k α ∈ {0.4,0.6}, the median roll velocity of the torso decreases, respectively, 8.43% and 16.00%, providing a possible improvement of the system's stability (see Fig. 14(c)).
The influence of the roll angle control is studied by considering k z = k α = 0.0 and k β ∈ {0, 0.2, 0.4, 0.6, 0.8, 1.0}.The implementation of this parameter does not have a significant effect on the height variation (see Fig. 15(a)), despite the decrease of 14.85% of the median value when k β = 0.2.The roll control provides good results in terms of the variation of the pitch velocity (see Fig. 15(b)).When k β ∈ {0.2, 0.4} is considered, the median value decreases respectively 20.39% and 38.80%.Additionally, there is a consequent decrease in the interquartile range, which shows evidence that the hexapod's locomotion is adjusted to the terrain topology.Regarding the roll velocity, the interquartile range is improved when compared to k β = 0.0, except for k β = 0.2.Thus, in comparison to the ramp environment, it is concluded that the roll angle control plays a key role in the hexapod's stability for more complex scenarios.

Enhanced posture control for the ramp and irregular terrain scenarios
Considering the results obtained in the previous sections, in that follows computational simulations for two demonstrative applications of the designed posture control.In each analysis, the values of k z , k α , and k β are selected and compared against the outcome of a simple control (k z = k α = k β = 0.0).For the ramp environment, the control of the torso's height and pitch orientation has a higher impact on the system's stability than the roll orientation control.Thus, k β is considered null.Considering the height stability, the  value of k z which presents the most stable results for the height variation also has a negative influence on the torso's angular velocities.Thus, the ideal value for k z is 0.8.Regarding the pitch orientation, k α does not influence the height displacement.This parameter is selected according to its impact on the torso's orientation.Among the collected data, k α = 0.6 provides good results for both the pitch and roll velocities.Therefore, the final configuration of the control strategy for the ramp scenario is defined as k z = 0.8, k α = 0.6, and k β = 0. Figure 16 presents the performed computational simulations.Overall, the torso's posture and stability improved when compared to the locomotion with simple control.The height's median increased by 60.77% and the interquartile range significantly reduced, which means that the hexapod had a similar height throughout the entire simulation (see Fig. 16(a)).The implementation of the proposed control strategy caused a reduction of 11.92% and 35.98%, respectively, of the median of the pitch and roll angular velocities (see Fig. 16(b) and (c)).Therefore, the angular displacement of the torso decreased, and the gait can be considered optimized.
In the irregular terrain environment, the selection of the control parameters takes into account that the hexapod robot must have a stable height to overcome the terrain.Bearing that in mind, the value of k z is selected regardless of its influence on the torso's angular velocities.Thus, the adequate value for the height adjustment's control parameter is 0.6.The value of k α does not affect the variation of the height and pitch velocity.Nonetheless, k α is set to 0.4.In opposite to the ramp scenario, roll control is relevant for ensuring the correct adaptation of the hexapod's gait to the terrain.The variable k β is set to 0.4 due to the stability improvement for all variables.The obtained results are presented in Fig. 17.The proposed control shows a different behavior in terms of the control of the torso's orientation due to the terrain irregularities.When compared against a simple control, the height variation drastically reduced, and the median raised from 0.03 to 0.01 m (see Fig. 17(a)).Nonetheless, the results for the angular velocities were a problem (see Fig. 17(b) and (c)).For the pitch velocity, there is an increase of 54.33% in the median value, and the roll velocity's median is 82.16% higher.Despite the adjustments of the control strategy, the terrain irregularity causes a higher variation of the torso's position due to the variation of the surface's position.With the simple control, the torso collided with the ground due to an insufficient height.On the contrary, with the developed posture the torso had a collision-free navigation.Bearing that in mind, it can be concluded that with posture control, the hexapod is less prone to collide with the terrain, and thus the posture becomes stable.
Considering that the physical prototype of the hexapod robot is currently under development, and it is not possible to examine the designed control method in real-world conditions, the posture control validation follows the Zero-Moment-Point (ZMP) approach, that is commonly found in the literature [52][53][54].The presented methodology evaluates the locomotion stability by measuring the distance between the ZMP projection and the edges of the support polygon in each time step.If the ZMP coordinates are close to the polygon's center, the robot is considered stable.Since the equations of motion of the Gazebo software are modeled at the velocity level, the ZMP cannot be calculated using the linear acceleration of the torso.Thus, for the computational simulations, the ZMP is estimated using the following expression [52,53]: where n represents the number of limbs, f n,i denotes the normal contact force of the ith limb, and {x p i , y p i } are the relative of each foot.The stability margin is given by [52]: where d i represents the distance of the ZMP toward the edges of the support polygon and e denotes the number of edges of the support polygon.The hexapod robot stability improves when the quantity of s ZMP increases.For the posture control validation, the deviation of the ZMP and the support polygon's center and the stability margin are compared against a simple locomotion control.In Fig. 18(a), the variance of the displacement between the ZMP and the support polygon's center is presented for the ramp environment.With the implementation of the enhanced posture control, there is a significant decrease in the interquartile range of the ZMP distance to the polygon's center, which supports the stability improvement of the locomotion.In comparison to the simple control, the variation of the median quantity is considered negligible.The adjustment of the torso's pitch and roll angles affects the final coordinates of the feet, which causes the amplitude growth observed in the posture control.In terms of stability margin, the parameter's median improves, and the data oscillation decreases (see Fig. 18(b)).Subsequently, the ZMP is within the support polygon, and it is considered that the hexapod robot improves its stability with the developed posture control.
In the testbed environment, the terrain topology causes higher locomotion instability when compared to the ramp scenario.The distance between the ZMP and the polygon's center in each time step is portrayed in Fig. 19(a).Despite the augmentation of torso's instability regarding the roll orientation, the implementation of the enhanced posture control reduces drastically the variance of the distance between the ZMP and the polygon's center.The fact that the torso's position is adjusted to the terrain topology affects the force distribution of each foot, which supports the results observed.Similarly to the ramp environment, the posture control decreases the interquartile range of the stability margin and the median quantity increases.From the two parameters examined, there is a strong improvement in the hexapod robot's stability.

Concluding remarks
This work presents a control approach for the torso's height and posture of the hexapod ATHENA.The proposed method takes advantage of the system's kinematic model to estimate the ground plane formed by the limbs in the stance phase.Through the evaluation of the plane's norm vector, the relative pitch and roll slopes between the ground and the torso are determined for each gait cycle.The control strategy adjusts the torso's orientation through the adjustment of the limbs' trajectory in the stance phase, regarding the obtained angular displacement.Besides, the torso's height is controlled during the swing and stance phases, in order to avoid its collision with the ground.The proposed method considers the hexapod's standing posture as a reference to adjust the foothold positions of each limb.The method's feasibility is assessed through several computational simulations performed in the Gazebo software, in which the normal and tangential contact forces are evaluated using Newton's impact law and Coulomb's friction law, respectively.
The computational simulations performed in this study are divided into three different cases.In the first studies, the control parameters for the height, pitch, and roll adjustments are studied in a 10-degree ramp and an irregular terrain, respectively.The selected inclinations of the environments are representative and aim at assessing the control strategy in scenarios with an intermediate level of difficulty in terms of the hexapod's posture changes.For each case, the value of the control parameters is within the range {0.0, 0.2, 0.4, 0.6, 0.8, 1.0}.Since the goal is to achieve optimal locomotion in terms of the torso's posture and stability, the main body's relative height and angular velocities are calculated.In the ramp environment, the variation k z causes a significant reduction of the height and posture oscillations, which means that there is an improvement in terms of the torso's posture.Although the variation of k α did not have a strong influence on the height stability, when k α = 0.6 takes place, the torso's angular velocities achieve their minimum variation.Thus, the hexapod robot achieved an optimal orientation for the terrain inclination.Regarding the studies performed for k β , it can be concluded that the interquartile ranges and median values obtained similar results for all configurations.Therefore, the roll variation does not

Figure 1 .
Figure 1.General view of the physical model of the ATHENA robot.

Figure 2 .
Figure 2. Schematic representation of the multibody model of the ATHENA robot.

Figure 3 .
Figure 3. Computational multibody model of the ATHENA robot used in the dynamic analysis.

Figure 4 .
Figure 4. Schematic representation of the joints' angular motion.

Figure 6 .
Figure 6.Schematic representation of the contact detection algorithm.

Figure 7 .
Figure 7. Schematic representation of the plane formed by the supporting limbs.

Figure 8 .
Figure 8. Angular displacement between the torso and the ground with simple control methodology.

Figure 9 .
Figure 9. Environments tested in the computational simulations: (a) Ramp with 10-degree slope and (b) Irregular terrain.

Figure 10 .
Figure 10.Results obtained for the height control in the ramp scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 11 .
Figure 11.Results obtained for the pitch angle control in the ramp scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 12 .Figure 13 .
Figure 12. Results obtained for the roll angle control in the ramp scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 14 .
Figure 14.Results obtained for the pitch angle control in the irregular terrain scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 15 .
Figure 15.Results obtained for the roll angle control in the irregular terrain scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 16 .
Figure 16.Results obtained for the ramp scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 17 .
Figure 17.Results obtained for the irregular terrain scenario: (a) Height variation; (b) Pitch velocity variation; and (c) Roll velocity variation.

Figure 18 .
Figure 18.Results obtained for the stability analysis in the ramp scenario: (a) Displacement of the ZMP with respect to the geometric center of the support polygon and (b) Stability margin.

Figure 19 .
Figure 19.Results obtained for the stability analysis in the testbed scenario: (a) Displacement of the ZMP with respect to the geometric center of the support polygon and (b) Stability margin.

Table I .
Inertial properties of ATHENA robot.

Table II .
Geometrical and inertial properties of the simplified model.