Skip to main content
  • Original Article
  • Open access
  • Published:

Smart Gait: A Gait Optimization Framework for Hexapod Robots


The current gait planning for legged robots is mostly based on human presets, which cannot match the flexible characteristics of natural mammals. This paper proposes a gait optimization framework for hexapod robots called Smart Gait. Smart Gait contains three modules: swing leg trajectory optimization, gait period & duty optimization, and gait sequence optimization. The full dynamics of a single leg, and the centroid dynamics of the overall robot are considered in the respective modules. The Smart Gait not only helps the robot to decrease the energy consumption when in locomotion, mostly, it enables the hexapod robot to determine its gait pattern transitions based on its current state, instead of repeating the formalistic clock-set step cycles. Our Smart Gait framework allows the hexapod robot to behave nimbly as a living animal when in 3D movements for the first time. The Smart Gait framework combines offline and online optimizations without any fussy data-driven training procedures, and it can run efficiently on board in real-time after deployment. Various experiments are carried out on the hexapod robot LittleStrong. The results show that the energy consumption is reduced by 15.9% when in locomotion. Adaptive gait patterns can be generated spontaneously both in regular and challenge environments, and when facing external interferences.

1 Introduction

Legged robots have great off-road abilities. The quadrupeds like Spot [1], ANYmal [2, 3], HyQ [4] and MIT Cheetah series [5,6,7,8], and hexapods like Octopus[9] and Qingzhui [10, 11] showed major progress in locomotion control of legged robots, and demonstrated their applications in challenging terrains. However, there are still two deficiencies of legged robots. First, the legged robot requires repetitive limb motions to move around. This leads to high energy consumption. Second, human designed periodic gait patterns are stiff and rigid, unable to achieve flexible behaviors as natural animals. Specifically, hexapods have more gait patterns due to the extra legs, predefined gaits could not fully leverage all the advantages of hexapods and limit their application in challenging environments. As these issues are related to the gait control of legged robots, here we propose the Smart Gait framework for hexapods, introducing three sub modules for gait optimization to address these deficiencies.

1.1 Related Works

The commonly used swing leg trajectories for legged robots are geometrically designed, like spline [12] or cycloid [13]. But these trajectories didn’t consider the dynamics of the leg. MIT Cheetah [14] and its follower [15] used a Bezier curve for swing trajectory. They gave out the design principles but without the criterions in detail. Other energy based optimizations [16, 17] achieved success in swing trajectory design but they stopped to further discuss the relations between their results and the biological swing trajectories.

For gait patterns, formerly we have summarized that the relations between gait parameters and travel speed in consideration of energy expenditures [18], and also demonstrated several gait adaptation methods on irregular terrains [11, 19] or in fault-tolerant cases [20]. Central Pattern Generators (CPGs) [21,22,23] are powerful tools to generate different gait patterns but still limited to periodic movement. To make up for this, Feasible Impulse Set (FIS) [24] was first proposed on MIT Cheetah 3 robot. By considering the impulse that can be delivered by each leg, it coordinated adaptive lift-off and touch-down events of the legs without preset gait patterns. However, due to the computing complexity of the convex set, it can only response to single dimensional movements with fixed leg swing time. Our original idea of Smart Gait was inspired by this scheme and we further developed it. Our Smart Gait can handle 3D locomotion with adaptive swing time.

Gait planning in 3D environments is important for legged robots. Free Gait [25] or TOWR [26] are good frameworks for route planning, which can generate both body and swing leg trajectories under the constrain of preset gait parameters and terrain features. Similar research is carried out on a hexapod [27] using quasi-static gaits. By setting a target point, the robot can exert its trafficability after the whole-body planning is solved. However, they didn’t talk about unexpected external interferences on the robot. Differently, our Smart Gait framework is based on online state of the robot but not targeting on a final point. It concentrating on the energy consumption and the biological flexibility, that generates the gaits without preset parameters instructed by human. More specifically, Smart Gait decides whether a certain leg in contact stage should lift or not at each moment, rather than repeating obstinate step cycles before the final target. Moreover, as Smart Gait is online state based, it can handle external interference as well.

1.2 Contributions

Legged animals can generate vivid gait patterns or swing leg trajectories spontaneously based on their motion states or terrains without precise clock or trajectories in their organisms. To catch up with these natural animals’ characteristics, here we propose the Smart Gait framework, making it possible for the hexapod robot to decide its own gaits and swing leg trajectories based on its online motion states or terrains. We propose three modules of gait optimization pregressively in our Smart Gait framework. The contributions of Smart Gait framework are summarized as follows.

  • (A). Swing trajectory optimization. By considering the full dynamics of the leg linkages and the impulse loss, it reduces the energy consumption and inertial counterforce on the fuselage during the swing phase. To our knowledge, we are the first to generate a swing trajectory conforming to the biological one.

  • (B). Period & Duty optimization. By considering the swing trajectory loss and the centroid dynamics of the robot, it can adjust the swing and contact time according to different travel speeds. It helps to reduce energy consumption and leads to a human intuition consistent gait pattern.

  • (C). Gait sequence optimization. By considering the swing legs loss and centroid dynamics of the robot, along with the body balance and leg workspace loss, it allows the robot itself to decide leg lifting timing according to its online state, to obtain the elegance and flexibility as a living animal. To our knowledge, we are the first to develop this idea in 3D motion of legged robots in real time.

This paper is constructed as follows. Section 2 introduces our hexapod robot LittleStrong. Section 3 proposes the three modules of our Smart Gait framework progressively. Section 4 carries out five experiments to verify the feasibility of the sub-modules of the Smart Gait framework. And lastly Section 5 draws the conclusions.

2 Robot Overview

The bionic designed LittleStrong [28] is a hexapod robot inspired by insects as shown in Figure 1. Its six legs are symmetrically distributed on both sides of the body, named as Back-Right leg (BR), Back-Left leg (BL), Middle-Left leg (ML), Front-Left leg (FL), Front-Right leg (FR), Middle-Right leg (MR), respectively. In order to avoid leg collisions during movement, the middle legs are installed a little farther from the sagittal plane. The robot is about 0.4 m in height, 0.68 m in length and 0.46 m in width when standing. For each leg, there are 3 DoFs, serially constructed as hip, thigh and shank joints. Therefore, LittleStrong has 18 joints in total. Each joint is driven by a brushless electric motor with a planetary gear set and an embedded encoder. The onboard computer adopts the GNU/Linux with the Xenomai [29] real-time patch, communicating with 18 drivers and an Inertial Measurement Unit (IMU) through EtherCAT protocol, and getting remote commands through ZeroMQ [30]. It runs a Whole-Body Control (WBC) [31] algorithm for motion control.

Figure 1
figure 1

The hexapod robot LittleStrong, photograph (left), configuration (right), and coordinate systems

The coordinate systems are also defined in Figure 1. The World Coordinate System (WCS) is fixed with the ground, where the most locomotion planning is in. The Body Coordinate System (BCS) is fixed at the center of its body, and all variables listed in BCS will be marked with a left superscript {B}. Each leg has its own Leg Coordinate System (LCS), which is fixed with the BCS but takes the particular leg’s hip joint as its origin. All variables in the LCS will be marked with a left superscript {L}. The right subscript {i} is for the leg number in the following sections.

3 Gait Optimization

The architecture of Smart Gait is shown in Figure 2. The offline swing leg trajectory optimization (module A) and gait period & duty optimization (module B) parameterize the results and store them for online call. The online Gait Adaptor (module C) takes the real-time state of the robot for the gait sequence optimization. Gait sequence contains a signal that shows whether a certain leg in contact phase should be lifted. The Gait Scheduler uses the optimized gait period & duty and the sequence signal to generate the gait rhythm. After that, the gait rhythm and the reference swing trajectories are handed to WBC [31] to generate the joint commands for the motors.

Figure 2
figure 2

Architecture of Smart Gait framework

3.1 Trajectory Optimization for Swing Legs

The swing leg trajectory is the curve connecting the lifting point and the landing point of the swing leg’s tip. Traditionally, there are cycloid or symmetric polynomial trajectories. These trajectories are constructed based on simple geometric features and are convenient to use. However, without considering the dynamic characteristics, the movements of the swing leg would consume more energy and have greater impact on the fuselage due to the inertial reaction forces brought by unpleasant accelerations and decelerations.

Here, a two-segmented 4th order Bezier curve is used for the swing trajectory. First, it has enough optimization intervals without being too complicated. Second, when approaching the middle time of swing process, the junction of two sub-Bessel curves helps to reach the preset step height. The swing trajectory is a 3D spatial curve, and the optimization is carried out in the LCS. Figure 3 shows the two segments of the 4th order Bezier curve for the right leg (red and blue thick solid line) and its control nodes (red and blue solid points {LN1 ~ LN9}). The thin lines are the leg links that tracking over the trajectory. The expression of each segmented Bezier curve is:

$$\begin{array}{*{20}c} {{}_{{}}^{{\text{L}}} {\varvec{p}}_{{{\text{sw}}}} (t) = \mathop \sum \limits_{k = 0}^{n} C_{n}^{k} \cdot \left( {1 - r_{\sigma } (t)} \right)^{n - k} \cdot \left( {r_{\sigma } (t)} \right)^{k} \cdot {}_{{}}^{{\text{L}}} {\varvec{N}}_{k + \sigma } ,} \\ \end{array}$$
$$C_{n}^{k} = \frac{n!}{{k!(n - k)!}}, \, C_{n}^{0} = 1,$$
$$\begin{array}{*{20}c} {\sigma = \left\{ {\begin{array}{*{20}c} {0, \, t < T_{{{\text{sw}}}} /2}, \\ {5, \, t \ge T_{{{\text{sw}}}} /2}, \\ \end{array} } \right.} \\ \end{array}$$
$$r_{\sigma } (t) = \left\{ {\begin{array}{*{20}c} {2t/T_{{{\text{sw}}}} , \, t < T_{{{\text{sw}}}} /2}, \\ {2t/T_{{{\text{sw}}}} - 1, \, t \ge T_{{{\text{sw}}}} /2}, \\ \end{array} } \right.$$

where n = 4, LNk+σ is the (k+m)th control node of Bezier curve; is the combinatorial number; Tsw is the swing duration; rσ(t)[0,1] is the gait rhythm, a normalized mapping of swing time t. The subscript {σ} is used to distinguish the two segments of the Bezier curve.

Figure 3
figure 3

Segmented 4th order Bezier curve to be optimized in LCS

According to the leg swing trajectory Lpsw(t), the generalized force τ(t) is calculated from the inverse kinematics and the floating base dynamics of the leg:

$${\varvec{q}}_{{\text{J}}} (t) = {\varvec{IK}}\left( {{}_{{}}^{{\text{L}}} {\varvec{p}}_{{{\text{sw}}}} (t)} \right),$$
$$\begin{array}{*{20}c} {\dot{\user2{q}}_{{\text{J}}} (t) = {\varvec{J}}_{{\text{v}}}^{ - 1} \left( {{\varvec{q}}_{{\text{J}}} (t)} \right) \cdot {}_{{}}^{{\text{L}}} \dot{\user2{p}}_{{{\text{sw}}}} (t),} \\ \end{array}$$
$$\begin{array}{*{20}c} {\ddot{\varvec{q}}_{{\text{J}}} (t) = \dot{\user2{J}}_{{\text{v}}}^{ - 1} \left( {{\varvec{q}}_{{\text{J}}} (t)} \right) \cdot {}_{{}}^{{\text{L}}} \dot{\user2{p}}_{{{\text{sw}}}} (t) + {\varvec{J}}_{{\text{v}}}^{ - 1} ({\varvec{q}}_{{\text{J}}} (t)) \cdot {}_{{}}^{{\text{L}}} {{\ddot{\varvec{p}}}}_{{{\text{sw}}}} (t),} \\ \end{array}$$
$$\begin{array}{*{20}c} {{{\varvec{\tau}}}(t) = {\varvec{M}}\left( {{\varvec{q}}(t)} \right) \cdot {{\ddot{\varvec{q}}}}(t) + {\varvec{h}}\left( {{\varvec{q}}(t),\dot{\user2{q}}(t)} \right) + {\varvec{g}}\left( {{\varvec{q}}(t)} \right),} \\ \end{array}$$

where \({\varvec{q}}_{{\text{J}}} (t) \in {\mathbb{R}}^{3}\) is the vector of joint angles, obtained from the leg’s inverse kinematics \({\varvec{IK}}\left( {{}_{{}}^{{\text{L}}} {\varvec{p}}_{{{\text{sw}}}} (t)} \right)\). \({\varvec{J}}_{{\text{v}}} \left( {{\varvec{q}}_{{\text{J}}} (t)} \right)\) is the leg’s Jacobian. \({\varvec{q}}(t) = \left[ {\begin{array}{*{20}c} {{}_{{}}^{{\text{L}}} {\varvec{q}}_{{{\text{FB}}}}^{{\text{T}}} } & {{\varvec{q}}_{{\text{J}}}^{{\text{T}}} (t)} \\ \end{array} } \right]^{{\text{T}}}\) is a generalized vector, in which \({}_{{}}^{{\text{L}}} {\varvec{q}}_{{{\text{FB}}}} \in {\mathbb{R}}^{6}\) is the generalized coordinate (position and rotation) of the floating base for the leg. As this swing trajectory is expressed in the LCS, thus \({}_{{}}^{{\text{L}}} {\varvec{q}}_{FB} \equiv 0\) (the floating base never moves in its own coordinate system). \({\varvec{M}}\left( {{\varvec{q}}(t)} \right) \in {\mathbb{R}}^{9 \times 9}\) is the generalized inertial matrix; \({\varvec{h}}\left( {{\varvec{q}}(t),\dot{\user2{q}}(t)} \right) \in {\mathbb{R}}^{9}\) is the vector for the nonlinear terms; \({\varvec{g}}\left( {{\varvec{q}}(t)} \right) \in {\mathbb{R}}^{9}\) is for the gravity; \({\varvec{\tau}}(t) = \left[ {\begin{array}{*{20}c} {{\varvec{\tau}}_{{{\text{FB}}}}^{{\text{T}}} (t)} & {{\varvec{\tau}}_{{\text{J}}}^{{\text{T}}} (t)} \\ \end{array} } \right]^{{\text{T}}}\) is the vector of generalized forces/torques, where \({\varvec{\tau}}_{{{\text{FB}}}}^{{}} (t) \in {\mathbb{R}}^{6}\) is for the floating base and \({\varvec{\tau}}_{{\text{J}}}^{{}} (t) \in {\mathbb{R}}^{3}\) is for the joints. Namely, \({\varvec{\tau}}_{{{\text{FB}}}}^{{}} (t)\) is the vector of reaction force / torque of the leg on the fuselage.

Then, by building and minimizing the cost function that tracking the swing trajectory, the control nodes of Bessel curve can be obtained as:

$$\begin{array}{*{20}c} {{}_{{}}^{{\text{L}}} {\varvec{N}}^{*} = \arg \mathop {\min }\limits_{{\varvec{N}}} J_{{{\text{sw}}}} \left( {{}_{{}}^{{\text{L}}} {\varvec{N}}} \right),} \\ \end{array}$$
$$\begin{array}{*{20}c} {J_{{{\text{sw}}}} \left( {{}_{{}}^{{\text{L}}} {\varvec{N}}} \right) = \mathop \smallint \nolimits_{0}^{{T_{{{\text{sw}}}} }} \left( {\alpha \left\| {{\varvec{\tau}}_{{\text{J}}} (t)} \right\|^{2} + \beta {\varvec{\tau}}_{{\text{J}}}^{{\text{T}}} (t) \cdot \dot{\user2{q}}(t) + \gamma \left\| {{\varvec{\tau}}_{{{\text{FB}}}} (t)} \right\|^{2} } \right)\text{d}t,} \\ \end{array}$$
$$\begin{array}{*{20}c} {\text{s.t.,}\,\left\{ {\begin{array}{*{20}c} {{}_{{}}^{{\text{L}}} {\varvec{p}}_{{{\text{sw}}}} (0) = {}_{{}}^{{\text{L}}} {\varvec{p}}_{0} }, \\ {{}_{{}}^{{\text{L}}} {\varvec{p}}_{{{\text{sw}}}} (t_{{\text{f}}} ) = {}_{{}}^{{\text{L}}} {\varvec{p}}_{{\text{f}}} }, \\ {{}_{{}}^{{\text{L}}} \dot{\user2{p}}_{{{\text{sw}}}} (0) = {}_{{}}^{{\text{L}}} {\varvec{v}}_{{\text{d}}} }, \\ {{}_{{}}^{{\text{L}}} \dot{\user2{p}}_{{{\text{sw}}}} (t_{{\text{f}}} ) = {}_{{}}^{{\text{L}}} {\varvec{v}}_{{\text{d}}} }, \\ {z\left( {{}_{{}}^{{\text{L}}} {\varvec{p}}_{{{\text{sw}}}} (t_{{\text{m}}} )} \right) = - h_{{{\text{body}}}} + h_{{{\text{step}}}} }, \\ {{}_{{}}^{{\text{L}}} \dot{\user2{p}}_{{{\text{sw}}}} (t_{{\text{m - }}} ) = {}_{{}}^{{\text{L}}} \dot{\user2{p}}_{{{\text{sw}}}} (t_{{\text{m + }}} )}, \\ \end{array} } \right.} \\ \end{array}$$
$$\begin{array}{*{20}c} {\left\{ {\begin{array}{*{20}c} {{}_{{}}^{{\text{L}}} {\varvec{p}}_{f} = - {}_{{}}^{{\text{L}}} {\varvec{p}}_{0} = \left[ {\begin{array}{*{20}c} {\frac{{v_{{\text{x}}} T_{{{\text{sw}}}} }}{2}} & {\frac{{v_{{\text{y}}} T_{{{\text{sw}}}} }}{2}} & { - h_{{{\text{body}}}} } \\ \end{array} } \right]^{{\text{T}}} }, \\ {{}_{{}}^{{\text{L}}} {\varvec{v}}_{{\text{d}}} = \left[ {\begin{array}{*{20}c} { - v_{{\text{x}}} } & { - v_{{\text{y}}} } & 0 \\ \end{array} } \right]^{{\text{T}}} }, \\ \end{array} } \right.} \\ \end{array}$$

where the cost function of Eq. (7) is composed of three integral items: equivalent electrical power loss (joint torque is proportional to the driver’s current), mechanical power loss, and body impact reaction force during the swing phase. {α, β, γ} are their corresponding weights. The swing trajectory shall satisfy the constraints in Eq. (8), namely starting position Lp0, ending position Lpf, starting and ending velocity Lvd, midpoint height, and midpoint velocity continuity. As hbody is the height of the robot body; hstep is the step height; {vx, vy} are the translational velocity of the robot in horizontal directions. This nonlinear optimization equation is solved by LM [32] method. After obtaining the control nodes, the segmented Bessel curve, namely the swing trajectory, can be reconstructed as Eq. (1).

The above process is carried out offline. We store the working condition parameters and build a swing trajectory library, and then it can be called online to get the control nodes for the swing trajectory due to different translational velocities of the robot. Since the locomotion control is carried out in the WCS, the transformation of the swing trajectory from the LCS to the WCS can be expressed as:

$$\begin{array}{*{20}c} {{\varvec{p}}_{{{\text{sw}},i}} (t) = {\varvec{p}}_{{{\text{body}}}} \left( t \right) + {\varvec{R}}(t)\left( {{}_{{}}^{{\text{B}}} {\varvec{p}}_{{{\text{hip}},i}} + {}_{{}}^{{{\text{L}}_{{\varvec{i}}} }} {\varvec{p}}_{{{\text{sw}}}} (t)} \right),} \\ \end{array}$$

where pbody and R represent the position and rotation of the robot, Bphip,i is the ith hip position relative to the body, \({}_{{}}^{{{\text{L}}_{{\varvec{i}}} }} {\varvec{p}}_{{{\text{sw}}}} (t)\) is the ith leg swing trajectory under its own LCS.

Figure 4 shows the comparisons of several groups of different swing trajectories in the WCS. As cycloid and symmetric cubic polynomial are all curves constructed based on simple geometric features, they are all in the same vertical plane coinciding the starting point and the end point. While the optimized trajectory is a spatial curve not in this plane.

Figure 4
figure 4

Energy cost of Period & Duty at different given speeds (The flat area will exceed the leg workspace thus not considered)

In addition, as shown in Figure 5, when the knee bending direction is consistent with the travel direction, the first half of the optimized swing trajectory is higher than the second half; and when the knee’s bending direction is opposite to the travel direction, the second half of the of the trajectory is higher than the first half. This is consistent with the corresponding relationship between the biological configurations and swing trajectories. In Figure 5, we track the swing trajectories with a red tag fixed on the side of the experimenter’s shoes when moving forward (knee forward) and moving back off (knee opposite), respectively. The experimenter only uses the heel to walk in order to match the configuration of the robot’s leg (a three-linkage-model with hip, thigh and shank). Regardless of the compression and rebound caused by the elasticity of the shoes’ soles (circled in green), our optimized swing trajectories is very consistent with the trend of the biological ones. We conducted experiments on the robot in Section 4.1. It proved that our optimized trajectory has lower energy consumption and softer reaction force to the fuselage.

Figure 5
figure 5

Comparison between biological swing trajectories and optimized swing trajectories

3.2 Period & Duty Optimization for Gait Cycles

The gait cycle of each leg is determined by three parameters: period, duty, and phase-difference when leaving contact phase to swing phase. The period T is the time duration for a complete step (swing time + contact time, T = Tsw + Tc). Duty λ is the percentage of the contact phase to the period (contact time/period, λ= Tc/T). The phase-difference between different legs determines the gait patterns. Figure 6 shows the Tripod-trot [33] gait pattern commonly used by hexapod robots.

Figure 6
figure 6

Tripod-trot gait pattern for hexapods (The white in the sequence diagram represents the swing phase; the red and blue represent the contact phase, respectively)

When in a given moving speed, different gait parameters will greatly affect the energy consumption of the robot. This subsection will optimize the gait period & duty under the tripod-trot gait pattern (fixed phase-differences). Phase-differences optimization will be discussed in next subsection.

For the swing legs, the energy consumption comes from the motion of the leg, namely the dynamic items as calculated in Eq. (7). But for the energy consumption of contact legs, it contains two parts. One part is for the motion of the leg itself, and another part is the support force for the body. Both leg-dynamics and body-support items need to be considered at the same time. When the robot moves with a given speed, in the BCS, the trajectory Bli(t) of the contact leg is considered as a uniform line that connects the foot-landing point to the foot-lifting point of next step cycle (regardless of turning). The leg-dynamics subitem of the energy consumption for the contact leg can be obtained in the same way as in Eq. (5). For the body-support subitem, we get the joints’ torques by distributing body gravity to each contact leg with a simplified Centroid Balance Control (CBC)[34] method.

$$\begin{array}{*{20}c} {\left\{ {\begin{array}{*{20}c} {\sum\limits_{1}^{{{\varvec{c}}\left( t \right)}} {{\varvec{J}}_{{{\text{v}},i}}^{{ - {\text{T}}}} (t) \cdot {\varvec{\tau}}_{{{\text{c}},i}} (t)} = m{\varvec{g}}}, \\ {\sum\limits_{1}^{{{\varvec{c}}\left( t \right)}} {{}_{{}}^{{\text{B}}} {\varvec{l}}_{{\text{i}}} (t) \times \left( {{\varvec{J}}_{{{\text{v}},i}}^{{ - {\text{T}}}} (t) \cdot {\varvec{\tau}}_{{{\text{c}},i}} (t)} \right)} = 0}, \\ \end{array} } \right.} \\ \end{array}$$
$$\begin{array}{*{20}c} {\underbrace {{\left[ {\begin{array}{*{20}c} {{\varvec{J}}_{{{\text{v}},1}}^{{ - {\text{T}}}} (t)} & \ldots & {{\varvec{J}}_{{{\text{v}},6}}^{{ - {\text{T}}}} (t)} \\ {\left[ {{}_{{}}^{{\text{B}}} {\varvec{l}}_{1} (t)} \right]_{ \times } {\varvec{J}}_{{{\text{v}},1}}^{{ - {\text{T}}}} (t)} & \ldots & {\left[ {{}_{{}}^{{\text{B}}} {\varvec{l}}_{6} (t)} \right]_{ \times } {\varvec{J}}_{{{\text{v}},6}}^{{ - {\text{T}}}} (t)} \\ \end{array} } \right]}}_{{{\varvec{A}}\left( t \right)}}\underbrace {{\left[ {\begin{array}{*{20}c} {{\varvec{\tau}}_{{{\text{c}},1}} (t)} \\ \vdots \\ {{\varvec{\tau}}_{{{\text{c}},6}} (t)} \\ \end{array} } \right]}}_{{{\varvec{\tau}}_{{\text{c}}} \left( t \right)}} = \underbrace {{\left[ {\begin{array}{*{20}c} {m{\varvec{g}}} \\ 0 \\ \end{array} } \right]}}_{{\varvec{b}}},} \\ \end{array}$$

where m is the mass of the robot and g stands for the gravity. Jv,i(t) is the Jacobian matrix for each leg; c(t) represents the legs in contact phase; τc(t) is used to represent the supporting torques of the contact leg; Bli(t) is the ith leg tip position in BCS. For the simplification of the optimization problem, rotation is not considered in the offline optimization. Eq. (11) is rewritten to Eq. (12) as the matrix form. [*]× represents an antisymmetric matrix operator. Since the contact state of each leg is constantly changing during walking, the torques of contact legs’ joints are distributed by solving a quadratic programming (QP) problem as:

$$\begin{array}{*{20}c} {{\varvec{\tau}}_{{\text{c}}}^{*} (t) = \arg \mathop {\min }\limits_{{{\varvec{\tau}} \in {\mathbb{R}}^{18} }} \left( {\left\| {{\varvec{A}}(t) \cdot {\varvec{\tau}}_{{\text{c}}} (t) - {\varvec{b}}} \right\|_{{\varvec{W}}}^{2} + \left\| {{\varvec{\tau}}_{{\text{c}}} (t)} \right\|^{2} } \right),} \\ \end{array}$$

\(\text{s.t.,}\,\left\{ {\begin{array}{*{20}c} {{\varvec{C}}(t) \cdot {\varvec{J}}_{{{\text{v}},i}}^{{ - {\text{T}}}} (t) \cdot {\varvec{\tau}}_{{{\text{c}},i}} (t) \le {\varvec{f}}_{{{\text{lim}},i}} }, \\ {\left| {{\varvec{\tau}}_{{\text{c}}} (t)} \right| \le {\varvec{\tau}}_{{{\text{max}}}} }, \\ \end{array} } \right.\)

$${\varvec{f}}_{{{\text{lim}},i}} = \left\{ {\begin{array}{*{20}c} {{\varvec{f}}_{{{\text{lim}}}} ,{\text{ leg }}i{\text{ in stance}}}, \\ {0,{\text{ leg }}i{\text{ in swing}}}, \\ \end{array} } \right.$$

where W is the weight matrix of the quadratic term, and the inequality constraints represent the friction cone [34] and the extreme values of joint torques respectively. After getting the joint torques \({\varvec{\tau}}_{c}^{*} \left( t \right)\), we build the energy cost of walking process as:

$$\begin{array}{*{20}c} \begin{gathered} J_{{{\text{st}}}} \left( {v,T,\lambda } \right) = 6 \cdot J_{{{\text{sw}}}} \left( {{}_{{}}^{{\text{L}}} {\varvec{N}}^{*} } \right) \hfill \\ \, + \mathop \smallint \nolimits_{0}^{T} \left( {\alpha \left\| {{\varvec{\tau}}_{{{\text{J}},{\text{c}}}} (t) + {\varvec{\tau}}_{{\text{c}}}^{*} (t)} \right\|^{2} + \beta \left( {{\varvec{\tau}}_{{{\text{J}},{\text{c}}}} (t) + {\varvec{\tau}}_{{\text{c}}}^{*} (t)} \right)^{{\text{T}}} \cdot \dot{\user2{q}}(t)} \right)\text{d}t. \hfill \\ \end{gathered} \\ \end{array}$$

The single leg’s swing phase cost Jsw(LN*) is obtained from the previous subsection, and it needs to multiply the number of legs by “6”. The second integral item is similarly combined as equivalent electrical power cost and mechanical power cost. \({\varvec{\tau}}_{{{\text{J}},{\text{c}}}} (t)\) is the torque for leg-dynamics, obtained in the same way as Eq. (5); \({\varvec{\tau}}_{{\text{c}}}^{*} (t)\) is body support torques as previously defined.

Figure 7 shows how the period & duty parameters influence on energy cost at different given speeds of the robot. Note that the cost value is displayed in logarithmic coordinates. The flat area at the lower right corner of each figure represents that this Period & Duty combination will exceed the leg workspace and cannot be considered.

Figure 7
figure 7

Energy cost of Period & Duty at different given speeds (The flat area will exceed the leg workspace thus not considered)

Figure 8 shows the relationship between the optimal period & duty at different speeds. Back in Figure 7, we notice that the gradient around the optimal period & duty is very small. Therefore, we add an adjustment region in Figure 8, in which the optimal cost is allowed to fluctuate by 1%. When in a lower speed, the allowed period floating range is large, but as the duty is already at a large level, the duty floating range is small. As the target speed increases, the period and duty tend to be unchanged, but from Figure 7, there appears another local minima in λ<0.5 area, which corresponds to a running gait with flying phase. This is completely consistent with our human’s intuition that when the speed increases to a certain stage, the walking gait should be replaced by the running gait. However, for the high-speed conditions, the workspace limitation will become a major constraint factor, and the adjustments of period & duty will be greatly limited. Therefore, this paper will not discuss the high-speed gait (v>1 (m/s) and λ<0.5). Relevant comparative experiments are given in Section 4.2.

Figure 8
figure 8

Relations between speed and optimal gait period & duty

3.3 Gait Sequence Optimization for Leg Lifting Events

The phase-difference of each leg is determined by the timing that lifting this leg from contact stage to swing stage. When should the lifting event be taken is the gait sequence concerned. In fact, it is hard to build a gait sequence library like previous modules due to the enlarged state parameters scale, and it is difficult to cover the potential online states of the robot either. So, we here adopt the online Gait Adapter as shown in Figure 9, which can process the 3D motion of the robot to generate the optimal leg lifting sequence.

Figure 9
figure 9

Scheme of online Gait Adapter for gait sequence optimization

We define a set \({\mathbf{\mathcal{S}}}\) to represent the combination of the legs’ current stages:

$$\begin{array}{*{20}c} {{\mathbf{\mathcal{S}}}{:} = \left\{ {{\varvec{s}} = \left[ {\begin{array}{*{20}c} {s_{1} } & \cdots & {s_{6} } \\ \end{array} } \right]^{{\text{T}}} {|}s_{i} = \left\{ {\begin{array}{*{20}c} {1,{\text{ C}}_{1} }, \\ {0{\text{, C}}_{2} }, \\ \end{array} } \right.i \in \left\{ {1, \ldots ,6} \right\}} \right\},} \\ \end{array}$$
$$\left\{ {\begin{array}{*{20}c} {{\text{C}}_{{1}} {\text{ : leg }}i{\text{ in swing stage}}{,}} \\ {{\text{C}}_{{2}} {\text{ : leg }}i{\text{ in contact stage}}{.}} \\ \end{array} } \right.$$

Then the next action of the robot (ideal combination of legs’ stages in the next moment) should be determined by the current robot state:

$$\begin{array}{*{20}c} {{\varvec{s}}_{k + 1} \sim \left( {{\varvec{p}}_{{{\text{body}}}} ,{\varvec{R}},{\varvec{v}}_{{{\text{body}}}} ,{\varvec{\omega}}_{{{\text{body}}}} ,{\varvec{p}}_{{{\text{foot}}}} ,{\varvec{T}}_{{{\text{sw}}}}^{*} ,{\varvec{s}}_{k} } \right),} \\ \end{array}$$
$${\mathbf{s}}_{k} ,{\mathbf{s}}_{k + 1} \in {\mathbf{\mathcal{S}}}.$$

That is, which leg should enter the swing stage in the next moment is related to the robot's position, rotation, velocity, angular velocity, feet positions, legs swing time and legs stages at present.

For the swing leg, there is a fact that for natural myriapod animals, each leg’s swing time is not fixed and even varies between legs in a single step cycle according to different motion states. Encouraged by this fact, we adjust each leg’s swing time by the current state of the robot. The benchmark of the leg’s swing time is obtained from the previous section (based on tripod-trot gait). Although the optimized leg lifting sequence may not conform to the beat of tripod-trot, but considering that the swing phase only takes a small proportion in the walking energy cost in Eq. (14), this does not affect the optimization result too much. Here we design the relationship between the leg swing time and the balance state of the fuselage. When the robot tends to topple to one side or fails to reach the preset state, we shorten the leg swing time on the corresponding side, then this swing leg can enter contact phase in time to correct the body balance error:

$$\begin{array}{*{20}c} {T_{{{\text{sw}},i}}^{*} = T_{{{\text{sw}}}} - \Delta t_{i}^{*} ,} \\ \end{array}$$
$$\Delta t_{i}^{*} = \left\{ {\begin{array}{*{20}c} {0,} \\ {\Delta t_{i} {,}} \\ {\Delta t_{{{\text{max}}}} {,}} \\ \end{array} \begin{array}{*{20}c} {\Delta t_{i} \le 0}, \\ {0 < \Delta t_{i} \le \Delta t_{{{\text{max}}}} }, \\ {\Delta t_{{{\text{max}}}} < \Delta t_{i} }, \\ \end{array} } \right.$$
$$\begin{array}{*{20}c} {{}_{{}}^{{\text{B}}} \dot{\user2{\omega }} = {\varvec{K}}_{{\text{P}}} \left( {\hat{\user2{R}}^{{\text{T}}} \log \left( {{\varvec{R}}_{{\text{d}}} \hat{\user2{R}}^{{\text{T}}} } \right)} \right) + {\varvec{K}}_{{\text{D}}} \left( {{}_{{}}^{{\text{B}}} {\varvec{\omega}}_{{\text{d}}} - {}_{{}}^{{\text{B}}} \hat{\user2{\omega }}} \right),} \\ \end{array}$$
$$\begin{array}{*{20}c} {{}_{{}}^{{\text{B}}} {\varvec{n}} = \left[ {\begin{array}{*{20}c} {\frac{{{}_{{}}^{{\text{B}}} v_{{\text{x}}} }}{{\left\| {\varvec{v}} \right\|}}} & {\frac{{{}_{{}}^{{\text{B}}} v_{{\text{y}}} }}{{\left\| {\varvec{v}} \right\|}}} & 1 \\ \end{array} } \right]^{{\text{T}}} ,} \\ \end{array}$$
$$\begin{array}{*{20}c} {\Delta t_{i} = \left( {{}_{{}}^{{\text{B}}} {\varvec{l}}_{i} \times {}_{{}}^{{\text{B}}} {\varvec{n}}} \right){}_{{}}^{{\text{B}}} \dot{\user2{\omega }},} \\ \end{array}$$

where Tsw is the benchmark of leg swing time obtained in the previous subsection; \(\Delta t_{i}^{*}\) is the adjust time; ∆tmax is the maximum allowable adjustment; \({}_{{}}^{{\text{B}}} \dot{\user2{\omega }}\) is the attitude correction vector derived from a PD control; Rd and Bωd are the body target posture and angular velocity; \(\hat{\user2{R}}\) and \({}_{{}}^{{\text{B}}} \hat{\user2{\omega }}\) are the estimated body posture and angular velocity. The log(*) operator maps SO(3) to \({\mathbb{R}}^{3}\). {KP, KD} are positive definite diagonal matrices of corresponding weights, respectively; Bn is the generalized target velocity direction and Bli is for the tip position of the ith leg in the BCS. Then the swing time adjustment ∆ti reflects how much earlier the ith swing leg needs to enter contact phase, so that can generate more driving force for the correction vector to keep the body balance.

For the contact leg, we use the idea of model predictive control for the decisions of leg lifting timing for the gait sequence. At each moment, all the potential leg stage combinations are traversed to find the best combination for execution. The cost function of leg stage combination s is as follows:

$$\begin{array}{*{20}c} {J_{{\text{s}}} ({\varvec{s}}) = J_{{{\text{st}}}}^{*} \left( {{\varvec{s}},{\varvec{T}}_{{{\text{sw}}}}^{*} } \right) + \mathop \smallint \nolimits_{0}^{{T_{{\text{h}}} }} E(t)\text{d}t,} \\ \end{array}$$
$$E(t) = \left\| {\user2{\ddot{e}}_{{\text{b}}} (t)} \right\|_{{{\varvec{Q}}_{{\text{a}}} }}^{2} + \left\| {\dot{\user2{e}}_{{\text{b}}} (t)} \right\|_{{{\varvec{Q}}_{{\text{v}}} }}^{2} + \left\| {{\varvec{e}}_{{\text{b}}} (t)} \right\|_{{{\varvec{Q}}_{{\text{p}}} }}^{2} + \mathop \sum \limits_{i}^{{{\varvec{c}}(t)}} \left\| {{}_{{}}^{{\text{L}}} {\varvec{e}}_{{{\text{l}},i}} (t)} \right\|_{{{\varvec{Q}}_{{\text{l}}} }}^{2} ,$$
$${\ddot{\varvec{e}}}_{{\text{b}}} (t) = {\varvec{A}}(t){\varvec{\tau}}(t) - {\varvec{b}},$$
$$\dot{\user2{e}}_{{\text{b}}} = \mathop \smallint \nolimits_{0}^{{T_{{\text{h}}} }} \, {{\ddot{\varvec{e}}}}_{{\text{b}}} (t)\text{d}t,$$
$${\varvec{e}}_{{\text{b}}} = \mathop \smallint \nolimits_{0}^{{T_{{\text{h}}} }} \, \dot{\user2{e}}_{{\text{b}}} (t)\text{d}t,$$
$${}_{{}}^{{\text{L}}} {\varvec{e}}_{{{\text{l}},i}} (t) = \left\{ {\begin{array}{*{20}c} {0{, }\,\,{}_{{}}^{{\text{L}}} {\varvec{l}}_{i} (t) \le {}_{{}}^{{\text{L}}} {\varvec{l}}_{{{\text{lim}}}} }, \\ {{}_{{}}^{{\text{L}}} {\varvec{l}}_{i} (t) - {}_{{}}^{{\text{L}}} {\varvec{l}}_{{{\text{lim}}}} , \, {}_{{}}^{{\text{L}}} {\varvec{l}}_{i} (t) > {}_{{}}^{{\text{L}}} {\varvec{l}}_{{{\text{lim}}}} }, \\ \end{array} } \right.$$

where the first item \(J_{{{\text{st}}}}^{*} \left( {{\varvec{s}},{\varvec{T}}_{{{\text{sw}}}}^{*} } \right)\) is a function similar to Eq. (14), but the target leg stage combination s is used instead of a fixed Tripod-Trot gait pattern, and the swing time \({\varvec{T}}_{{{\text{sw}}}}^{*}\) mentioned above is adopted. Th is the prediction horizon. Usually, Th should be set greater than one step period (ThTsw+Tc). The second integral item is to predict the cost of body balance and leg workspace. \({{\ddot{\varvec{e}}}}_{{\text{b}}} (t)\) is the predictive generalized acceleration deviation of body balance after Eq. (12). Correspondingly, \(\dot{\user2{e}}_{{\text{b}}} (t)\) and \({\varvec{e}}_{{\text{b}}} (t)\) are the generalized velocity and position deviation. And {Qa, Qv, Qp} are their weighting matrices. \({}_{{}}^{{\text{L}}} {\varvec{e}}_{{{\text{l}},i}} (t)\) is the deviation of the predicted tip position of each contact leg that beyond the workspace constraint in the LCS, with \({}_{{}}^{{\text{L}}} {\varvec{l}}_{i} (t)\) for the tip position and \({}_{{}}^{{\text{L}}} {\varvec{l}}_{{{\text{lim}}}}\) for the leg workspace. Ql is the corresponding weighting matrix.

Considering that not all leg stage combinations are reasonable for execution when the robot is running, a set \({\mathbf{\hat{\mathcal{S}}}}\) is defined to represent the allowable leg lifting combinations due to the current leg stages for each moment:

$$\begin{array}{*{20}c} {{\mathbf{\hat{\mathcal{S}}}}{:} = \left\{ {\hat{\user2{s}}_{k} \in {\mathbf{\mathcal{S}}}{|}\hat{s}_{k,i} = \left\{ {\begin{array}{*{20}c} {1,{\hat{\text{C}}}_{1} }, \\ {0,{\hat{\text{C}}}_{2} }, \\ \end{array} } \right.i \in \left\{ {1, \cdots ,6} \right\}} \right\},} \\ \end{array}$$
$$\left\{ {\begin{array}{*{20}c} {{\hat{\text{C}}}_{{1}} {\text{: leg }}i{\text{ in swing stage, or ready to swing}}{,}} \\ {{\hat{\text{C}}}_{{2}} {\text{: leg }}i{\text{ in contact stage, and will hold still}}{.}} \\ \end{array} } \right.$$

By traversing \(\forall \hat{\user2{s}}_{k} \in {\mathbf{\hat{\mathcal{S}}}}\), we get the optimal leg lifting combination as:

$$\begin{array}{*{20}c} {{\varvec{s}}_{c}^{\user2{*}} = \arg \mathop {\min }\limits_{{\varvec{s}}} J_{{\text{s}}} \left( {\hat{\user2{s}}_{k} } \right).} \\ \end{array}$$

Now, \({\varvec{s}}_{c}^{\user2{*}}\) is just the optimal leg stage under the current state, whether it is the optimal stage in the full-time-domain can be further compared with the next forecast moment:

$$\begin{array}{*{20}c} {{\varvec{s}}^{\user2{*}} = \left\{ {\begin{array}{*{20}c} {{\varvec{s}}_{{\text{c}}}^{\user2{*}} {, }\,J_{{\text{s}}} ({\varvec{s}}_{{\text{c}}}^{\user2{*}} ) < J_{{\text{s}}}^{ + } ({\varvec{s}}_{{\text{c}}}^{\user2{*}} )}, \\ {{\varvec{s}}_{{\text{c}}} , \, J_{{\text{s}}} ({\varvec{s}}_{{\text{c}}}^{\user2{*}} ) \ge J_{{\text{s}}}^{ + } ({\varvec{s}}_{{\text{c}}}^{\user2{*}} )}. \\ \end{array} } \right.} \\ \end{array}$$

\(J_{{\text{s}}}^{ + } ({\varvec{s}}_{{\text{c}}}^{\user2{*}} )\) represents the cost value that keep still the leg stage sc at the current moment but lifting the leg according to \({\varvec{s}}_{{\text{c}}}^{\user2{*}}\) in the next forecast moment. If the cost of \(J_{{\text{s}}} ({\varvec{s}}_{{\text{c}}}^{\user2{*}} )\) is less than \(J_{{\text{s}}}^{ + } ({\varvec{s}}_{{\text{c}}}^{\user2{*}} )\), it means that \({\varvec{s}}_{{\text{c}}}^{\user2{*}}\) is the optimal leg lifting selection and can be executed; otherwise, maintain the current leg stage sc.

The three modules of Smart-Gait framework are fully established. Experiments are taken in the next section.

4 Experiments and Results

We conducted several experiments on LittleStrong to verify each module of our Smart Gait framework. Experiment (4.1) is to verify the energy consumption of the optimized swing trajectory (Additional file 1); Experiment (4.2) is to verify the outcome of Period & Duty optimization in tripod-trot gait (Additional file 2). Experiments (4.3) (Additional file 3), Experiments (4.4) (Additional file 4), Experiments (4.5) (Additional file 5) are to verify the gait transitions of the online Gait Adapter.

4.1 Swing Trajectories Comparison

This experiment is to verify the energy consumption of the optimized swing trajectory. The robot moves with different swing leg trajectories under the same gait pattern, as Figure 10 shows. We compared the energy consumption between cycloid, symmetric cubic polynomial, and our optimized swing trajectories.

Figure 10
figure 10

Robot moves with different swing trajectories

As shown in Figure 11, the relevant test data of the robot's back-right leg is shown. The joints velocities and torques of the cycloidal trajectory are the largest, followed by the symmetric cubic polynomial trajectory, and the joints velocities and torques of our optimized trajectory are the smallest. In addition, the angular velocity changing amplitude of the optimized trajectory is also the smallest. That is, the required acceleration and deceleration are gentler, which reduces the inertial impact force on the fuselage, and benefits to the stability of the robot.

Figure 11
figure 11

Joint velocities and torques of the Back-Right leg of the robot under different swing trajectories (The horizontal axis is the tip position; thus, the contact phase will be compressed)

Since the electric system’s impedance parameters are not obtained, we compare them with normalized relative energy consumption (The average of the current magnitude of the swing leg’s motors). As shown in Table 1, the normalized energy consumption with cycloid trajectory is defined as 100%. Our optimization trajectory performs best in terms of energy consumption.

Table 1 Normalized energy consumption of different swing trajectories

4.2 Period & Duty Comparison

This experiment is to verify the benefit of Period & Duty optimization. The robot walks on ground as Figure 12 shows, first using a fixed period & duty, and again using the optimized period & duty of Section 3.2. results are shown in Figure 13.

Figure 12
figure 12

Screenshot of the experiment for period & duty comparison

Figure 13
figure 13

Results of optimized period & duty experiment: (a1), (a2) The estimated velocity and angular velocity of the robot, (b1), (b2) Period & duty, (c1), (c2) Gait cycle, (d) The real time and the average torque squared

We designed a movement process containing varying velocities. The control group used fixed gait parameters (Figure 13 (a1) for the velocity, Figure 13(b1) for period & duty, and Figure 13(c1) for gait sequence. Period=0.7 s, Duty=0.52). The experimental group used the optimized gait period & duty based on the robot state (Figure 13(a2) for the velocity, Figure 13(b2) for period & duty, and Figure 13(c2) for gait sequence). For simplification, we did not consider turning in our optimization model, so in this experiment we converted the equivalent step size of turning to the translation velocity. The experiment proves that at the given speed, the average joint power (Figure 13(d)) of the optimized gait period & duty is smaller, reduced by 15.9%.

4.3 Gait Adaptor for Stroll

This experiment is to verify the feasibility of the Gait Adaptor for online gait sequence optimization. We carried out a strolling experiment with the Gait Adaptor proposed in Section 3.3, that all step cycles are launched automatically. The motion commands are randomly generated by a handle remoter. The gait patterns at different stages are shown in Figure 14. This experiment proves that our Smart Gait algorithm can generate adaptive gait sequences of 3D motions. As can be seen in Figure 15, the gait of the robot is not in a fixed or preset pattern, but totally determined by the current state of the robot and contains a variety of gait transitions, which shows out vivid characteristics as living myriapods.

Figure 14
figure 14

Screenshots of different gait stage from the stroll (Circles for swing phase and rods for contact phase)

Figure 15
figure 15

Estimated velocity of the robot and Smart Gait cycle for the strolling

4.4 Gait Adaptor for Disturbance Recovery

This experiment is to verify the anti-interference of the Gait Adaptor for online gait sequence optimization. When challenged by an external interference, the robot needs to take an adaptive gait to maintain its balance. The easiest way is to set a state switch by an <if…else…> judgement, but this human designed script is just a technical method rather than driven by the inherent essence. Here by hiring our Smart Gait framework, the robot successfully makes instinctive responses to two challenges of external interference.

In the first challenge, as shown in Figure 16, when the front-right leg of the robot is dragged out, the Smart Gait will make the robot automatically lift the leg back to the original position. And as the balance of the robot body is also affected by the dragging, the robot voluntarily lifts the diagonal back-left leg to maintain its symmetrical balance.

Figure 16
figure 16

Disturbance recovery from foot drags

In the second challenge, as shown in Figure 17, the robot was impacted by a side kick when standing statically, and the Smart Gait quickly makes an adaptive leg raising motion response. Figure 17(e) shows the gait sequence of the robot, which shows the Smart Gait can handle unexpected interferences online based on the robot’s real-time state.

Figure 17
figure 17

Disturbance recovery from body kicks: (a)–(d) Screenshots of different gait stages, (e) Smart Gait cycle

4.5 Gait Adaptor for Trench Crossing

This challenge is to verify the uneven terrain adaptability of the Gait Adaptor for online gait sequence optimization. As shown in Figure 18 and Figure 19, the gap between these two boards is 0.25 m’s width, with a virtual safe margin of 0.05 m for both sides. So, the virtual trench is 0.35 m’s width, a little wider than half of the robot’s length. In this experiment, the position of the trench is pre-known by the robot. The robot moves forward in 0.4 m/s to cross the trench (Figure 18), and again, moves back off in 0.5 m/s (Figure 19).

Figure 18
figure 18

Moving forward to cross a trench (0.4 m/s): (a) Approaching, (b) Holding and gearing up, (c) Striding with middle legs, (d) Striding with back leg, (e) Smart Gait cycle

Figure 19
figure 19

Moving back off to cross a trench (0.5 m/s): (a) Striding with middle legs, (b) quasi jump with front legs, (c) Smart Gait cycle

When the robot approaches the trench, it stops at its feet and leans forward to accumulate strength. Then it uses two front legs to stride across the trench, after that two middle legs lift and swing in the same phase, and the back legs transition to staggered phases to stride over again. The gait cycle is shown in Figure 18, in which the coherent movements of the robot are very similar to the cross-trench actions as an organism does. Even more, as Figure 19 shows, when using a faster speed moving back, the robot performs a quasi-jump to overcome the limitation of the leg working space, as the living animals often does. These actions are totally generated by the Smart Gait without any human modification (Additional file 6).

5 Conclusions

  1. (1)

    This paper has presented the Smart Gait framework, a meaningful work for gait optimization of hexapod robots. The Smart Gait has three modules: the swing trajectory optimization, the period & duty optimization, and the online Gait Adapted for gait transition.

  2. (2)

    Smart Gait enables the hexapod robot LittleStrong to save more energy during locomotion. Promising results are shown in the experiments. Swing trajectory optimization reduces energy consumption of the swing leg to 81.96%. Period & duty optimization saves 15.9% of the energy consumption of the robot.

  3. (3)

    Gait sequence optimization helps the robot to perform smart behaviors like living-creatures, rather than repeating stubborn steps. It helps to generate adaptive gait patterns both in regular and challenge environments in 3D movements for the first time. It also can generate adaptive actions for the hexapod when facing external interferences.

  4. (4)

    In the future, we will introduce environmental awareness to our Smart Gait framework, enabling the robot to adapt to more complex terrains, and further improve the bionic behavior intelligence of legged robots.

Availability of Data and Materials

All data generated or analysed during this study are included in this published article.


  1. S C Niquille. Regarding the pain of SpotMini: Or what a robot's struggle to learn reveals about the built environment. Architectural Design, 2019, 89(1): 84-91.

    Article  Google Scholar 

  2. M Hutter, C Gehring, D Jud, et al. ANYmal - A highly mobile and dynamic quadrupedal robot. 2016 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), 2016.

  3. T Miki, J Lee, J Hwangbo, et al. Learning robust perceptive locomotion for quadrupedal robots in the wild. Science Robotics, 2022, 7(62): eabk2822.

    Article  Google Scholar 

  4. C Semini, N G Tsagarakis, E Guglielmino, et al. Design of HyQ – a hydraulically and electrically actuated quadruped robot. Proceedings of the Institution of Mechanical Engineers, Part I: Journal of Systems and Control Engineering, 2011.

  5. S Seok, A Wang, Y C Meng, et al. Design principles for highly efficient quadrupeds and implementation on the MIT Cheetah robot. IEEE, 2013.

  6. H W Park, P M Wensing, S Kim. High-speed bounding with the MIT Cheetah 2: Control design and experiments. International Journal of Robotics Research, 2017, 36(2): 027836491769424.

    Article  Google Scholar 

  7. G Bledt, M J Powell, B Katz, et al. MIT Cheetah 3: Design and control of a robust, dynamic quadruped robot. IEEE International Conference of Intelligent Robots (IROS) 2018, 2018.

  8. B Katz, J D Carlo, S Kim. Mini Cheetah: A platform for pushing the limits of dynamic quadruped control. 2019 International Conference on Robotics and Automation (ICRA), 2019.

  9. P Yang, F Gao. Leg kinematic analysis and prototype experiments of walking-operating multifunctional hexapod robot. ARCHIVE Proceedings of the Institution of Mechanical Engineers Part C Journal of Mechanical Engineering Science 1989-1996 (vols 203-210), 2014, 228(12): 2217-2232.

  10. Y Zhao, F Gao, Q Sun, et al. Terrain classification and adaptive locomotion for a hexapod robot Qingzhui. Frontiers of Mechanical Engineering, 2021, 16: 271–284.

    Article  ADS  Google Scholar 

  11. L Mao, F Gao, Y Tian, et al. Novel method for preventing shin-collisions in six-legged robots by utilising a robot–terrain interference model. Mechanism and Machine Theory, 2020, 151: 103897.

    Article  Google Scholar 

  12. C Gehring, S Coros, M Hutler, et al. Practice makes perfect: An optimization-based approach to controlling agile motions for a quadruped robot. IEEE Robotics & Automation Magazine, 2016, 23(1): 34-43.

    Article  Google Scholar 

  13. G Bhardwaj, U Mishra, N Sukavanam, et al. Planning adaptive brachistochrone and circular arc hip trajectory for a toe-foot bipedal robot going downstairs. Journal of Physics: Conference Series, 2021, 1831(1): 012032.

    Google Scholar 

  14. D J Hyun, S Seok, J Lee, et al. High speed trot-running: Implementation of a hierarchical controller using proprioceptive impedance control on the MIT Cheetah. International Journal of Robotics Research, 2014, 33(11): 1417-1445.

    Article  Google Scholar 

  15. X Zeng, S Zhang, H Zhang, et al. Leg trajectory planning for quadruped robots with high-speed trot gait. Applied Sciences, 2019, 9(7): 1508.

    Article  Google Scholar 

  16. T Liao, S Ye, L Chen, et al. Energy efficient swing leg trajectory planning for quadruped robots walking on rough terrain. 2019 IEEE International Conference on Robotics and Biomimetics (ROBIO), 2019: 2128-2133.

  17. R Khusainov, A Klimchik, E Magid. Swing leg trajectory optimization for a humanoid robot locomotion. International Conference on Informatics in Control, Automation and Robotics, 2016, 3: 130-141.

  18. X B Chen, F Gao. Energy expenditure of trotting gait under different gait parameters. Chinese Journal of Mechanical Engineering, 2017, 30(4): 943-950.

    Article  ADS  CAS  Google Scholar 

  19. Z Chen, F Gao, Q Sun, et al. Ball-on-plate motion planning for six-parallel-legged robots walking on irregular terrains using pure haptic information. Mechanism and Machine Theory, 2019, 141: 136-150.

    Article  Google Scholar 

  20. Z Chen, Q Xi, F Gao, et al. Fault-tolerant gait design for quadruped robots with one locked leg using the GF set theory. Mechanism and Machine Theory, 2022, 178: 105069.

    Article  Google Scholar 

  21. Y Fukuoka, Y Habu, T Fukui. A simple rule for quadrupedal gait generation determined by leg loading feedback: A modeling study. Scientific Reports, 2015, 5(1): 1-11.

    Article  Google Scholar 

  22. A J Ijspeert. Central pattern generators for locomotion control in animals and robots: A review. Neural Networks, 2008, 21(4): 642-653.

    Article  PubMed  Google Scholar 

  23. W Ouyang, H Chi, J Pang, et al. Adaptive locomotion control of a hexapod robot via bio-inspired learning. Frontiers in Neurorobotics, 2021, 15: 627157.

    Article  PubMed  PubMed Central  Google Scholar 

  24. C Boussema, M J Powell, G Bledt, et al. Online gait transitions and disturbance recovery for legged robots via the feasible impulse set. IEEE Robotics & Automation Letters, 2019, 4(2): 1611-1618.

    Article  Google Scholar 

  25. P Fankhauser, C D Bellicoso, C Gehring, et al. Free gait—An architecture for the versatile control of legged robots. 2016 IEEE-RAS 16th International Conference on Humanoid Robots (Humanoids), 2016: 1052-1058.

  26. A W Winkler, C D Bellicoso, M Hutter, et al. Gait and trajectory optimization for legged systems through phase-based end-effector parameterization. IEEE Robotics and Automation Letters, 2018, 3(3): 1560-1567.

    Article  Google Scholar 

  27. D Valouch, J Faigl. Gait-free planning for hexapod walking robot. 2021 European Conference on Mobile Robots (ECMR), 31 Aug.-3 Sept. 2021, 2021: 1-8, doi:

  28. Y P Yin, Y G Xiao, F Gao, Footholds optimization for legged robots walking on complex terrain. Frontiers of Mechanical Engineering 2023, 18(2): 26.

    Article  ADS  Google Scholar 

  29. P Gerum. Xenomai-Implementing a RTOS emulation framework on GNU/Linux. White Paper, Xenomai, 2004: 81.

  30. P Hintjens. ZeroMQ: messaging for many applications. O'Reilly Media, Inc., 2013.

  31. C D Bellicoso, F Jenelten, P Fankhauser, et al. Dynamic locomotion and whole-body control for quadrupedal robots. IEEE/RSJ International Conference on Intelligent Robots & Systems, 2017.

  32. A Ranganathan. The levenberg-marquardt algorithm. Tutoral on LM Algorithm, 2004, 11(1): 101-110.

    Google Scholar 

  33. Q Sun, F Gao, X B Chen. Towards dynamic alternating tripod trotting of a pony-sized hexapod robot for disaster rescuing based on multi-modal impedance control. Robotica, 2018, 6(7): 1048-1076.

    Article  Google Scholar 

  34. M Focchi, A Del Prete, I Havoutis, et al. High-slope terrain locomotion for torque-controlled quadruped robots. Autonomous Robots, 2017, 41(1): 259-272.

    Article  Google Scholar 

Download references


Not applicable.


Supported by National Key Research and Development Program of China (Grant No. 2021YFF0306202).

Author information

Authors and Affiliations



FG was in charge of the whole trial; YY wrote the manuscript; YX, YZ and QS assisted with sampling and laboratory analyses. All authors read and approved the final manuscript.

Corresponding author

Correspondence to Feng Gao.

Ethics declarations

Ethics Approval and Consent to Participate

Not applicable.

Consent for Publication

Not applicable.

Competing Interests

The authors declare no competing financial interests.

Supplementary Information

Additional file 1. 

Joint velocities and torques of the Back-Right leg of the robot under different swing trajectories for Experiment 4.1.

Additional file 2. 

Results of optimized period & duty for Experiment 4.2.

Additional file 3. 

Estimated velocity of the robot and Smart Gait cycle for the strolling for Experiment 4.3.

Additional file 4. 

Gait stages of the disturbance recovery with body kicks for Experiment 4.4.

Additional file 5. 

Gait stages of moving forward and back off to cross a trench for Experiment 4.5.

Additional file 6. Video of the introduction and experiments of the Smart Gait.

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Yin, Y., Gao, F., Sun, Q. et al. Smart Gait: A Gait Optimization Framework for Hexapod Robots. Chin. J. Mech. Eng. 37, 15 (2024).

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • DOI: