1 Introduction

The autonomous hexapod robot has been considered to be more flexible than the wheeled robot and tracked robot. In particular, the hexapod robot has the powerful ability for obstacle crossing and landform adaptation. However, the design and control of the hexapod robot are complicated. The structure is important for the design of the hexapod robot. In addition, the gait planning, which is relevant to the static stability and walking speed, is important for the control of the hexapod robot.

Some research has considered different shapes of the hexapod robot such as hexagon and rectangle. It has been proved that the hexapod robot of hexagon shape has longer walking pace, better walking stability and larger turning angle [1]. The omnidirectional gait has been proposed for a hexapod robot of hexagon shape such that the robot can change the heading direction without turning its body [2]. The leg moving range for the walking gait of the hexapod robot is analyzed in [35]. Furthermore, the work [5] proposes the process to obtain the stable turning angle and gait. Besides, by observing the natural multi-pedal insects, tripod gait, wave gait and ripple gait are acquired for the hexapod robot [6]. Within these three types of gaits, walking with the tripod gait is fastest.

The walking stability has always been a significant research topic for the hexapod robot. Robots have two ways to keep walking stably, one way is the statically stable walking [7] and the other way is dynamically stable walking [8]. The statically stabile walking is generally much more stable than dynamically stable walking. The statically stable walking is to maintain the vertical projection of the center of gravity (COG) in the stability region, which is the support polygon. The hexapod robot falls down when its COG goes outside support polygon. Therefore, it is important to control the COG lying inside support polygon such that the hexapod robot can walk stably. For this purpose, adaptive gait [9], follow-the-leader gait [10] and improved wave gait [11] have been proposed.

The stability margin is defined as the shortest distance from the horizontally projected COG to the edge of the support polygon [12]. The stability margin is applied to design the fault-tolerant gait of the hexapod robot [13]. Furthermore, the study [14] compares the stability margin between the hexagonal model robot and rectangular model robot. It is noted that the stability margin value is in direct ratio to the walking stability of hexapod robot.

Some studies have applied the fuzzy control to design the controller for the hexapod robot [15, 16]. The studies [15] apply fuzzy control to design the fault-tolerant gait for the multi-leg robot when its motor shutdowns. The wall-following hexapod robot is also designed by fuzzy control [16].

Besides the walking stability on the flat ground, some studies have focused on how the hexapod robot walking on the incline and rugged terrain [1723]. The stability margin for a hexapod robot of tripod gait is analyzed, and the stability range is measured by the pace distance and COG position [17]. The study [18] designs the gait of multi-legged robot imitating a crab and tests the walking stability on inclines of different slopes. However, the modification of COG is not considered in [18]. The zero-moment point (ZMP) and force-angle stability margin (FASM) are applied to analyze the walking stability on the incline and rugged terrain [19]. In the study [20], one more degree of freedom (DOF) is added such that the hexapod robot can walk on the incline and rugged terrain by adjusting the angle between leg and ground. By adjusting positions of legs, the study [21] simulates a hexapod robot successfully walking on the rugged terrain. Stable gaits for a hexapod robot walking up and down inclines are proposed in [22]. The fuzzy controller has also proposed to control the gait of the multi-legged robot such that the robot can walk on inclines of different slopes [23]. However, one of the inputs of the fuzzy controller in [23] is the friction force that is not easy to be obtained.

The main purpose of this paper is to design a fuzzy controller such that the hexapod robot can stably walk on an incline. The tripod gait is applied for relatively fast walking. Moreover, according to the slope of incline, the proposed fuzzy control strategy modifies the posture of the hexapod robot such that the vertical projection of COG maintains in the support polygon. We apply Denavit–Hartenberg (D–H) convention and forward kinematics to calculate the positions of motors and end points of legs in the coordinate system of robot’s body. An inertial measurement unit is settled on the center of robot’s body such that the rotation matrix for calculating the vertical projection of COG can be obtained when the robot is walking on an incline. Then, we design a fuzzy controller to adjust the motor angles of supporting legs for maintaining the vertical projection of COG close to the COG of support polygon. The stability margin of the hexapod robot is maximized by the proposed fuzzy control strategy; hence, the robot can stably walk on an incline.

This paper is organized as follows: Section 2 introduces the hardware architecture of hexapod robot. A fuzzy control strategy for the hexapod robot walking on an incline is proposed in Sect. 3. Experimental results are given in Sect. 4. Finally, concluding remarks are given in Sect. 5.

2 Hardware Architecture of the Hexapod Robot

The top view of the designed hexapod robot is shown in Fig. 1. There are eighteen motors on the robot as shown in Fig. 2. Figure 2 shows that each leg is constructed of three motors and six legs of the hexapod robot are indicated as FL1, FL2, FL3, FR1, FR2 and FR3. In each leg, the first and third motors are the type of RX-28 and the second motor is the type of RX-64, because the second motor needs a relatively larger torque for moving and supporting the body. The range of rotation degree for each motor is given in Table 1 (the rotation direction of each motor is given in Sect. 3). Figure 3 shows the whole moving range of a robot leg in three-dimensional space. The body of the hexapod robot is a hexagon with the length of each side is 5, and the length of each leg is 21 cm. The hexapod robot can stand with the maximum height of 22 cm and with the minimum height of 15 cm. Moreover, the total weight of hexapod robot is 2.8 kg.

Fig. 1
figure 1

Top view of the hexapod robot

Fig. 2
figure 2

Configuration of motors

Table 1 Rotation degree range of each motor in a leg
Fig. 3
figure 3

Moving range of a robot leg in three-dimensional space. a The range of single leg(xz). b The range of single leg(xy)

We use the embedded board of LattePanda to serve as the control center for the hexapod robot. Windows 10 is applied to be the operation system of the control board, and Visual Studio 2015 is used to build the graphical user interface (GUI) and develop the control interface between human and robot. Therefore, we can use the remote control to monitor and update the system by the wireless keyboard with a wireless receiver. Furthermore, USB2Dynamixel is applied to transmit control signals from LattePanda board to motors RX-28 and RX-64 via the RS485 communication interface. The IMU sensor JY-901, which is composed of a three-axis gyroscope, a three-axis electronic compass and a three-axis accelerometer, can measure the posture (or the slope of robot body) of the robot at any instance. The posture data are received by an Arduino Leonardo embedded board and transmitted to LattePanda board through UART format. Figure 4 shows a hardware configuration of the hexapod robot.

Fig. 4
figure 4

Hardware configuration of the hexapod robot

3 Fuzzy Control Strategy for the Hexapod Robot Walking on an Incline

This section presents the fuzzy control strategy for the hexapod robot walking on an incline. In this paper, the tripod gait is utilized to the designed hexapod robot for relatively fast walking. Moreover, for relatively high walking stability, the statically stable walking is applied for the hexapod robot walking on an incline. Furthermore, the fuzzy controller is designed to adjust the motor angles of supporting legs for maintaining the vertical projection of COG close to the COG of supporting polygon.

3.1 Tripod Gait for the Hexapod Robot

This subsection presents the tripod gait for the designed hexapod robot as shown in Fig. 5. In step 1 as shown in Fig. 5a, the robot stands by six feet at first. The legs of FR1, FL2 and FR3 are designated as set A. Moreover, the legs of FL1, FR2 and FL3 are designated as set B. The direction of motion is pointed out by the arrow. In step 2 as shown in Fig. 5b, the robot starts moving forward; the legs of set A stride forward, and the legs of set B are the supporting legs. In step 3 as shown in Fig. 5c, the legs of set B stride forward, and the supporting legs of set A thrust backward such that the COG of hexapod robot moves forward. In step 4 as shown in Fig. 5d, the legs of set A lift for reverting to the state of step 2, and the body of the hexapod robot is moved forward by the supporting legs of set B. Then, by moving the legs of set B reverting to the state of step 2 with the supporting legs of set A, all legs of the hexapod robot return to step 2. The hexapod robot keeps walking forward by repeating steps 2, 3 and 4. Moreover, from step 2, the hexapod robot returns to strand by moving the legs of set A reverting to the state of step 1 with the supporting legs of set B. Figure 6 shows the state machine diagram for the tripod gait of a hexapod robot.

Fig. 5
figure 5

Tripod gait of a hexapod robot. a Step 1. b Step 2. c Step 3. d Step 4

Fig. 6
figure 6

State machine diagram for the tripod gait of a hexapod robot

3.2 Statically Stable Walking on an Incline for the Hexapod Robot

This subsection presents the statically stable walking on an incline for the designed hexapod robot. For relatively high walking stability, the designed hexapod robot applies the statically stable walking. The walking hexapod robot is statically stable if the vertical projection of COG is inside the support polygon, which is formed by the robot support points as shown in Fig. 7.

Fig. 7
figure 7

Statically stable for the walking hexapod robot. a Top view. b Side view

Since the statically stable walking is applied for the designed hexapod robot, it is important to calculate the vertical projection of COG for the current state of the hexapod robot. For calculating the COG of the hexapod robot, the D–H convention [24] and forward kinematics is applied. Figure 8 shows the links and joints of the hexapod robot. The robot has six identical limbs; each limb can be viewed as a 4-DOF robot arm. Figure 9 shows one of the robot limbs with coordinate frames attached conforming to D–H convention. The robot reference frame {0} is located at joint 0 that is the center of the chest of hexapod robot; Y 0 is the direction of motion for the hexapod robot; {G} indicates the global reference frame that is also located at the center of the chest of the hexapod robot; the reference frame {1} is located at joint 1 that is the motor RX-28 in the circle shown in Fig. 2; the reference frame {2} is located at joint 2 that is the motor RX-64 shown in Fig. 2; the reference frame {3} is located at joint 3 that is the motor RX-28 in the rectangle shown in Fig. 2, and the reference frame {4} is located at the end point of the limb. The D–H parameters are given in Table 2, where θ i is the joint angle; d i is the link offset; a i is the link length and α i is the link twist. The D–H transformation matrix for adjacent coordinate frames, i and i − 1, is given as:

$$\begin{aligned} {}^{i - 1}T_{i} & = \left[ {\begin{array}{*{20}l} {\cos \theta_{i} } \hfill & { - \sin \theta_{i} \cos \alpha_{i} } \hfill & {\sin \theta_{i} \sin \alpha_{i} } \hfill & {a_{i} \cos \theta_{i} } \hfill \\ {\sin \theta_{i} } \hfill & {\cos \theta_{i} \cos \alpha_{i} } \hfill & { - \cos \theta_{i} \sin \alpha_{i} } \hfill & {a_{i} \sin \theta_{i} } \hfill \\ 0 \hfill & {\sin \alpha_{i} } \hfill & {\cos \alpha_{i} } \hfill & {d_{i} } \hfill \\ 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right] \, , \\ i & = 1,2,3,4 \\ \end{aligned}$$
(1)

In Table 2, it can be obtained that

$${}^{0}T_{1} = \left[ {\begin{array}{*{20}l} {\cos \theta_{1} } \hfill & 0 \hfill & {\sin \theta_{1} } \hfill & {L_{1} \cos \theta_{1} } \hfill \\ {\sin \theta_{1} } \hfill & 0 \hfill & { - \cos \theta_{1} } \hfill & {L_{1} \sin \theta_{1} } \hfill \\ 0 \hfill & 1 \hfill & 0 \hfill & 0 \hfill \\ 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right],\quad {}^{1}T_{2} = \left[ {\begin{array}{*{20}l} {\cos \theta_{2} } \hfill & 0 \hfill & {\sin \theta_{2} } \hfill & {L_{2} \cos \theta_{2} } \hfill \\ {\sin \theta_{2} } \hfill & 0 \hfill & { - \cos \theta_{2} } \hfill & {L_{2} \sin \theta_{2} } \hfill \\ 0 \hfill & 1 \hfill & 0 \hfill & 0 \hfill \\ 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right],$$
$${}^{2}T_{3} = \left[ {\begin{array}{*{20}l} {\cos \theta_{3} } \hfill & { - \sin \theta_{3} } \hfill & 0 \hfill & {L_{3} \cos \theta_{3} } \hfill \\ {\sin \theta_{3} } \hfill & {\cos \theta_{3} } \hfill & 0 \hfill & {L_{3} \sin \theta_{3} } \hfill \\ 0 \hfill & 0 \hfill & 1 \hfill & 0 \hfill \\ 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right],\quad {}^{3}T_{4} = \left[ {\begin{array}{*{20}l} {\cos \theta_{4} } \hfill & { - \sin \theta_{4} } \hfill & 0 \hfill & {L_{4} \cos \theta_{4} } \hfill \\ {\sin \theta_{4} } \hfill & {\cos \theta_{4} } \hfill & 0 \hfill & {L_{4} \sin \theta_{4} } \hfill \\ 0 \hfill & 0 \hfill & 1 \hfill & 0 \hfill \\ 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right].$$
Fig. 8
figure 8

Links and joints of the hexapod robot

Fig. 9
figure 9

Robot limbs with coordinate frames conforming to D–H convention

Table 2 D–H parameters for joints of each leg

Therefore, the transformation matrix from the reference frame {0} to the end point frame {4} is calculated as:

$${}^{0}T_{4} = {}^{0}T_{1} {}^{1}T_{2} {}^{2}T_{3} {}^{3}T_{4}$$
(2)

In Eq. (2), the position (x q , y q , z q ) of the end point of limb, which is the original point in the end point frame {4}, in the reference frame {0} can be obtained by:

$$ \left[ {\begin{array}{*{20}c} {x_{q} } & {y_{q} } & {z_{q} } & 1 \\ \end{array} } \right]^{T} = {}^{\it{0}}T_{\it{4}} \left[ {\begin{array}{*{20}c} {\it{0}} & 0 & 0 & 1 \\ \end{array} } \right]^{T} $$
(3)
$$\begin{aligned} x_{q} & = L_{4} \cos \theta_{4} \left( {\cos \theta_{1} \cos \theta_{2} \cos \theta_{3} + \sin \theta_{1} \sin \theta_{3} } \right) \\ & \quad - L_{4} \sin \theta_{4} \left( {\cos \theta_{1} \cos \theta_{2} \sin \theta_{3} - \sin \theta_{1} C\theta_{3} } \right) \\ & \quad + \left( {\cos \theta_{1} \cos \theta_{2} L_{3} \cos \theta_{3} + \sin \theta_{1} L_{3} S\theta_{3} } \right. \\ & \quad \left. { +\, L_{2} \cos \theta_{1} \cos \theta_{2} + L_{1} \cos \theta_{1} } \right) \\ \end{aligned}$$
(4)
$$\begin{aligned} y_{q} & = L_{4} \cos \theta_{4} \left( {\sin \theta_{1} \cos \theta_{2} \cos \theta_{3} - \cos \theta_{1} \sin \theta_{3} } \right) \\ & \quad - L_{4} \sin \theta_{4} \left( {\sin \theta_{1} \cos \theta_{2} \sin \theta_{3} + \cos \theta_{1} \cos \theta_{3} } \right) \\ & \quad + \left( {\sin \theta_{1} \cos \theta_{2} L_{3} \cos \theta_{3} - \cos \theta_{1} L_{3} \sin \theta_{3} } \right. \\ & \quad \left. { + \sin \theta_{1} L_{2} \cos \theta_{2} + L_{1} \sin \theta_{1} } \right) \\ \end{aligned}$$
(5)
$$\begin{aligned} z_{q} & = L_{4} \cos \theta_{4} \left( {\sin \theta_{2} \cos \theta_{3} } \right) - L_{4} \sin \theta_{4} \left( {\sin \theta_{2} \sin \theta_{3} } \right) \\ & \quad + \left( {\sin \theta_{2} L_{3} \cos \theta_{3} + L_{2} \sin \theta_{2} } \right) \\ \end{aligned}$$
(6)

If the robot is on the flat ground with the direction of motion toward to the same direction of the coordinate Y G, the reference frame {0} of the robot is identical to the global reference {G}. However, if the robot is walking on an incline, the reference frame {0} of the robot will no longer be identical to the global reference {G} as shown in Fig. 10. In this case, the rotation matrix is required to transform the position

$$\begin{aligned} R_{p} & = \left[ {\begin{array}{*{20}l} {\cos \phi \cos \beta } \hfill & {\cos \phi \sin \beta \sin \gamma - \sin \phi \cos \gamma } \hfill \\ {\sin \phi \cos \beta } \hfill & {\sin \phi \sin \beta \sin \gamma + \cos \phi \cos \gamma } \hfill \\ { - \sin \beta } \hfill & {\cos \beta \sin \gamma } \hfill \\ 0 \hfill & 0 \hfill \\ \end{array} } \right. \\ & \quad \left. {\begin{array}{*{20}l} {\cos \phi \sin \beta \cos \gamma + \sin \phi \sin \gamma } \hfill & 0 \hfill \\ {\sin \phi \sin \beta \cos \gamma - \cos \phi \sin \gamma } \hfill & 0 \hfill \\ {\cos \beta \cos \gamma } \hfill & 0 \hfill \\ 0 \hfill & 1 \hfill \\ \end{array} } \right] \\ \end{aligned}$$
(7)

in the robot reference frame {0} to the position in the global reference frame {G}, where the rotation angles γ around X-axis, β around Y-axis and ϕ around Z-axis can be measured by the IMU sensor settled at the center of the chest of the hexapod robot as shown in Fig. 11. By the rotation matrix, the position (\(\hat{x}_{q}\), \(\hat{y}_{q}\), \(\hat{z}_{q}\)) of end point of limb in the global reference frame can be calculated by:

$$ \left[ {\begin{array}{*{20}l} {\hat{x}_{q} } \hfill & {\hat{y}_{q} } \hfill & {\hat{z}_{q} } \hfill & 1 \hfill \\ \end{array} } \right]^{T} = R_{p} \left[ {\begin{array}{*{20}l} {x_{q} } \hfill & {y_{q} } \hfill & {z_{q} } \hfill & 1 \hfill \\ \end{array} } \right]^{T} $$
(8)
Fig. 10
figure 10

Hexapod robot on an incline

Fig. 11
figure 11

Rotation angles measured by the IMU sensor

Defining COG ij to be the COG of jth limb of ith leg, the position \( \left[ {\begin{array}{*{20}l} {X_{{{COG}_{ij} }} } \hfill & {Y_{{{\text{COG}}_{ij} }} } \hfill & {Z_{{{\text{COG}}_{ij} }} } \hfill \\ \end{array} } \right]^{T} \) of each COG ij in the global reference frame {G} can be obtained applying 0 T 1, 1 T 2, 2 T 3, 3 T 4 and R p . Taking the first leg as an example, Fig. 12 shows that the position of COG11 is at the position \( \left[ {\begin{array}{*{20}l} { - {bias}_{\it{1}} } \hfill & 0 \hfill & 0 \hfill \\ \end{array} } \right]^{T} \) in reference frame {2} where bias1 is the distance between COG11 and the original point of reference frame {2}. Therefore, the position \( \left[ {\begin{array}{*{20}l} {X_{{{COG}_{\it{11}} }} } \hfill & {Y_{{{\text{COG}}_{11} }} } \hfill & {Z_{{{\text{COG}}_{11} }} } \hfill \\ \end{array} } \right]^{T} \) of COG11 in the global reference frame {G} can be calculated by:

$$ \left[ {\begin{array}{*{20}l} {X_{{{COG}_{\it{11}} }} } \hfill & {Y_{{{\text{COG}}_{11} }} } \hfill & {Z_{{{\text{COG}}_{11} }} } \hfill & 1 \hfill \\ \end{array} } \right]^{T} = R_{p} {}^{\it{0}}T_{\it{1}} {}^{\it{1}}T_{\it{2}} \left[ {\begin{array}{*{20}l} { - {bias}_{\it{1}} } \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right]^{T} $$
(9)
Fig. 12
figure 12

First leg with COG11, COG12 and COG13

By the same analysis, the position \( \left[ {\begin{array}{*{20}l} {X_{{{COG}_{\it{12}} }} } \hfill & {Y_{{{\text{COG}}_{12} }} } \hfill & {Z_{{{\text{COG}}_{12} }} } \hfill \\ \end{array} } \right]^{T} \) of COG12 in the global reference frame {G} can be calculated by:

$$ \left[ {\begin{array}{*{20}l} {X_{{{COG}_{\it{12}} }} } \hfill & {Y_{{{\text{COG}}_{12} }} } \hfill & {Z_{{{\text{COG}}_{12} }} } \hfill & 1 \hfill \\ \end{array} } \right]^{T} = R_{p} {}^{\it{0}}T_{\it{1}} {}^{\it{1}}T_{\it{2}} {}^{\it{2}}T_{\it{3}} \left[ {\begin{array}{*{20}l} { - {bias}_{\it{2}} } \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ \end{array} } \right]^{T} $$
(10)

where bias2 is the distance between COG12 and the original point of reference frame {3}. The position \(\left[ {\begin{array}{*{20}l} {X_{{COG_{13} }} } \hfill & {Y_{{COG_{13} }} } \hfill & {Z_{{COG_{13} }} } \hfill \\ \end{array} } \right]^{T}\) of COG13 in the global reference frame {G} can be calculated by:

$$ \left[ {\begin{array}{*{20}l} {X_{{{COG}_{\it{13}} }} } \hfill & {Y_{{{\text{COG}}_{13} }} } \hfill & {Z_{{{\text{COG}}_{13} }} } \hfill & 1 \hfill \\ \end{array} } \right]^{T} = R_{p} {}^{\it{0}}T_{\it{4}} \left[ {\begin{array}{*{20}l} {\it{0}} \hfill & 0 \hfill & {{\text{bias}}_{3} } \hfill & 1 \hfill \\ \end{array} } \right]^{T} $$
(11)

where bias3 is the distance between COG13 and the original point of reference frame {4}. With the position of each COG ij , the position \( \left[ {\begin{array}{*{20}l} {X_{COG} } \hfill & {Y_{\text{COG}} } \hfill & {Z_{\text{COG}} } \hfill \\ \end{array} } \right]^{T} \) of COG of the hexapod robot can be obtained by:

$$\left\{ {\begin{array}{*{20}l} {X_{\text{COG}} = \frac{{m_{0} \cdot X_{0} + \sum\nolimits_{i = 1}^{6} {\sum\nolimits_{j = 1}^{3} {X_{{{\text{COG}}_{ij} }} \cdot m_{ij} } } }}{{m_{0} + \sum\nolimits_{i = 1}^{6} {\sum\nolimits_{j = 1}^{3} { \cdot m_{ij} } } }}} \hfill \\ {Y_{\text{COG}} = \frac{{m_{0} \cdot Y_{0} + \sum\nolimits_{i = 1}^{6} {\sum\nolimits_{j = 1}^{3} {Y_{{{\text{COG}}_{ij} }} \cdot m_{ij} } } }}{{m_{0} + \sum\nolimits_{i = 1}^{6} {\sum\nolimits_{j = 1}^{3} { \cdot m_{ij} } } }}} \hfill \\ {Z_{\text{COG}} = \frac{{m_{0} \cdot Z_{0} + \sum\nolimits_{i = 1}^{6} {\sum\nolimits_{j = 1}^{3} {Z_{{{\text{COG}}_{ij} }} \cdot m_{ij} } } }}{{m_{0} + \sum\nolimits_{i = 1}^{6} {\sum\nolimits_{j = 1}^{3} { \cdot m_{ij} } } }}} \hfill \\ \end{array} } \right.$$
(12)

where m 0 is the mass of robot body; m ij is the mass of jth limb of ith leg, and \( \left[ {\begin{array}{*{20}l} {X_{\it{0}} } \hfill & {Y_{0} } \hfill & {Z_{0} } \hfill \\ \end{array} } \right]^{T} \) is the COG position of robot body that is the original point of the global reference frame {G} (i.e., \( \left[ {\begin{array}{*{20}l} {X_{\it{0}} } \hfill & {Y_{0} } \hfill & {Z_{0} } \hfill \\ \end{array} } \right]^{T} = \left[ {\begin{array}{*{20}l} {\it{0}} \hfill & 0 \hfill & 0 \hfill \\ \end{array} } \right]^{T} \)). Therefore, the vertical projection of the robot COG is at position \( \left[ {\begin{array}{*{20}l} {X_{COG} } \hfill & {Y_{\text{COG}} } \hfill & 0 \hfill \\ \end{array} } \right]^{T} \) in the global reference frame {G}.

Remark 1

By considering the statically stable walking, the walking hexapod robot is statically stable if the vertical projection of COG is inside the support polygon, which is formed by the robot support points as shown in Fig. 7. Therefore, it is important to calculate the positions of support points and COG projection in the global reference frame. For the hexapod robot walking on the flat ground, the D–H convention can be directly applied to calculate the positions of support points and COG projection in the global reference frame. However, as mentioned before, applying only D–H convention is not enough when the robot is walking on an incline. In this study, the IMU sensor settled at the center of the chest of the hexapod robot is utilized to measure the rotation angles for the rotation matrix (7). By applying the rotation matrix with the D–H convention, the positions of support points and COG projection in the global reference frame can be calculated when the robot is walking on an incline.

3.3 Fuzzy Control Design

This subsection proposed the fuzzy control design for the hexapod robot walking on an incline. By applying the D–H convention described in the previous section, the vertical projection of COG and the COG of support polygon can be calculated. Since the statically stable walking is applied for the robot, the fuzzy control is designed to adjust the angles of motors of supporting legs for maintaining the vertical projection of COG close to the COG of support polygon (the ideal COG) as shown in Fig. 13. Hence, the stability margin, which is defined as the shortest distance from the horizontally projected COG to the edge of the support polygon as shown in Fig. 14, can be maximized by the proposed fuzzy control.

Fig. 13
figure 13

Ideal COG, the vertical projection of robot’s COG and support polygon

Fig. 14
figure 14

Stability margin S m ≡ min (T 1T 2T 3)

Assume that the position of ideal COG is (x i y i ) and the vertical projection of robot’s COG is (x ry r), and define the errors along the directions of the coordinates X G, Y G to be e x  ≡ x i  − x r and e y  ≡ y i  − y r in the global reference frame as shown in Fig. 15. As mentioned in Sect. 3.1), when the legs of set A are the supporting legs, the robot’s COG is moved forward by the supporting legs of set A.

Fig. 15
figure 15

Position of ideal COG (x i y i ), the vertical projection of robot’s COG (x ry r), and the errors e x  ≡ x i  − x r and e y  ≡ y i  − y r in the global reference frame

In contrast, the designed fuzzy controller is to maintain the vertical projection of robot’s COG close to the ideal COG. Therefore, the fuzzy controller does not operate when the legs of set A are the supporting legs, or there will be a conflict such that the robot’s body oscillates.

Now, we temporarily assume that the rotation angle ϕ around Z-axis is zero. When the legs of set B are supporting legs in the tripod gait as shown in Fig. 16, the fuzzy PD controller is applied to adjust the angles, θ 3L1, θ 4L1, θ 3L3, θ 4L3, θ 3R2 and θ 4R2 of motors of supporting legs for maintaining the vertical projection of robot’s COG close to the ideal COG. The block diagram of the proposed fuzzy control system of the hexapod robot is shown in Fig. 17. The fuzzy proportional-derivative (PD) controller compensates the angle Δθ x to the angles of motors of the leg FR2 to adjust the robot’s COG along the direction of coordinate X G and compensates the angle Δθ y to the angles of motors of leg FL1 and FL3 to adjust the robot’s COG along the direction of coordinate Y G as shown in Fig. 16b.

Fig. 16
figure 16

Supporting legs of set B in the tripod gait. a Top view. b Side view

Fig. 17
figure 17

Fuzzy control system of the hexapod robot

Figure 17 shows that the inputs of fuzzy PD controller are \(e_{x} ,\;e_{y} ,\;\dot{e}_{x}\) and \(\dot{e}_{y}\). Moreover, the outputs of the fuzzy PD controller are the compensation angles Δθ x and Δθ y for the motors of robot’s supporting legs. Figure 18 shows the structure of the fuzzy PD controller. The outputs of the fuzzy PD controller are calculated as:

$$\Delta \theta_{x} = K_{{\left( {{\text{p}},x} \right)}} e_{x} + K_{{\left( {{\text{d}},x} \right)}} \dot{e}_{x}$$
(13)
$$\Delta \theta_{y} = K_{{\left( {{\text{p}},y} \right)}} e_{y} + K_{{\left( {{\text{d}},y} \right)}} \dot{e}_{y}$$
(14)

where K (p,x), K (d,x), K (p,y) and K (d,y) are the proportional and derivative gains of the PD controller that will be adjusted by the fuzzy control. Figure 19 shows the premise membership functions, consequent membership functions and fuzzy rule tables for the fuzzy control. In the design of fuzzy rule tables, the magnitudes of proportional gains K (p,x), K (p,y) and derivative gains K (d,x), K (d,y) are inversely proportional to the magnitudes of errors e x , e y and derivatives of errors \(\dot{e}_{x} ,\;\dot{e}_{y}\) (the reason will be given in Remark 2). For instance, Fig. 19c shows that K (p,x) and K (d,x) are positive big (PB) when e x and \(\dot{e}_{x}\) are zero (ZO); K (p,x) and K (d,x) are positive big (PB) when e x and \(\dot{e}_{x}\) are zero (ZO); K (p,x) and K (d,x) are positive median (PM) when e x and \(\dot{e}_{x}\) are positive small (PS); and K (p,x) and K (d,x) are positive small small (PSS, i.e., positive very small) when e x and \(\dot{e}_{x}\) are positive big (PB). It is noted that the fuzzy PD control operates from the end of step 3 to the end of step 2 of tripod gait during walking. Moreover, in step 2 of tripod gait, the legs of Set A lift after the robot’s COG is adjusted into a small region around the COG of support polygon formed by supporting legs of Set B by the fuzzy PD controller as shown in Fig. 20. This manner helps the hexapod robot stably walking on the incline. When the robot’s direction of motion is not the same as the direction of coordinate Y G that is ϕ ≠ 0, the fuzzy PD controller cannot work due to that the compensation angles Δθ x and Δθ y for the motors of supporting legs cannot compensate the errors e x and e y , respectively. Therefore, for practical operation, the global reference frame {G} is set to rotate with the robot’s reference frame {0} around Z-axis that is ϕ = 0 all the time. By this setting, the fuzzy PD controller woks well independent of the rotation angles ϕ measured by the IMU sensor.

Fig. 18
figure 18

Structure of fuzzy PD controller

Fig. 19
figure 19

Premise membership functions, consequent membership functions and fuzzy rule table for the fuzzy control. a Premise membership functions. b Consequent membership functions. c Fuzzy rule table for K (p,x), K (d,x). d Fuzzy rule table for K (p,y), K (d,y)

Fig. 20
figure 20

Robot’s COG adjusted closed to ideal COG by the fuzzy PD controller

Remark 2

The reason why we apply fuzzy PD controller instead of PD controller is given as follows. At the beginning, we tried to apply linear PD controller to compensate the motor angles for statically stable walking on an incline. However, if relative large magnitudes of proportional gains K (p,x), K (p,y) and derivative gains K (d,x), K (d,y) are chosen, the hexapod robot overturned when the magnitudes of errors (e x e y ) and derivatives of errors \((\dot{e}_{x} ,\;\dot{e}_{y} )\) are relative large. However, if relative small magnitudes of proportional and derivative gains are chosen, the linear PD controller could not compensate the angles of motors well when the magnitudes of errors and derivatives of errors are relatively small. Therefore, we design the fuzzy PD controller such that the magnitudes of proportional and derivative gains are inversely proportional to the magnitudes of errors and derivatives of errors. By this design, the fuzzy PD controller can prevent the robot to overturn when the magnitudes of errors and derivatives of errors are relatively large. Furthermore, the fuzzy PD controller can compensate the angles of motors well when the magnitudes of errors and derivatives of errors are relatively large. Figure 21 shows the comparison between outputs of linear PD controller and fuzzy PD controller. It can be seen that the output of fuzzy PD controller is a nonlinear surface. Therefore, the magnitudes of proportional and derivative gains can be adjusted according to the magnitudes of errors and derivatives of errors that cannot be done by the linear PD controller.

Fig. 21
figure 21

Comparison between outputs of the fuzzy PD controller and linear PD controller with K (p,y) = 0.5 and K (d,y) = 0.05. a Output of fuzzy PD controller. b Output of linear PD controller

Remark 3

The hexapod robot is a multi-degree-of-freedom system with multi-link mechanism such that the dynamics of the robot is very complicated and not easy to be obtained. Moreover, the closed-loop stability of the hexapod robot control system is difficult to be analyzed. In this study (just like [5, 15, 19, 23]), only the kinematics is considered. Moreover, a fuzzy PD controller, for the design of which the dynamics of the robot is not required, is applied to adjust the angles of motors for statically stable walking on an incline.

4 Experimental Results

In this section, some experimental results are given to show the validity of the proposed fuzzy control strategy for the hexapod robot walking on inclines of different slopes. The parameters of the hexapod robot are given in Table 3, where ɛ is the small distance shown in Fig. 20.

Table 3 Parameters for the designed hexapod robot

4.1 Comparison Between the Results Without Control and with the Fuzzy PD Controller

Figure 22 shows the stability margins for the hexapod robot walking on the flat ground and inclines of slopes 18° and 26° without control and with the fuzzy PD controller. In Fig. 22, it shows that the stability margin goes to its minimum value at point A where the robot is moving its COG forward in step 3 of the tripod gait. Figure 22a shows that the stability margin with the fuzzy PD controller is similar to the stability margin without control for the case of walking on the flat ground due to that the tripod gait is originally designed for the hexapod robot walking on the flat ground. Figure 22b shows that the stability margin with the fuzzy PD controller is better than the stability margin without control for the case of walking on the incline of slope 18°. Moreover, Fig. 22c shows that the robot with fuzzy PD controller can still statically stably (i.e., stability margin remains positive) walk on the incline of slope 26°. Figure 23 shows the hexapod robot with the fuzzy PD controller walking through the incline of slope 26° successfully. However, in the same case of walking on the incline of slope 26°, the robot without control overturns as shown in Fig. 24a such that the IMU sensor value of X-axis becomes 60° as shown in Fig. 24b.

Fig. 22
figure 22

Stability margins the hexapod robot walking on ground and inclines of slopes 18° and 26° with and without the fuzzy controller. a Walking on the flat ground. b Walking on the incline of slope 18°. c Walking on the incline of slope 26°

Fig. 23
figure 23

Hexapod robot with the fuzzy PD controller walking through the incline of slope 26° successfully

Fig. 24
figure 24

Robot without control walking on the on the incline of slope 26°. a The robot overturns. b The IMU sensor value of X-axis

4.2 Comparison Between the Results with the Fuzzy PD Controller and Linear PD Controllers

Figure 25 shows the stability margins for the hexapod robot walking on the incline of slope 22° with the fuzzy PD controller and linear PD controller of relative small gains (i.e., K (p,x) = 0.2, K (p,y) = 0.3, K (d,x) = 0.05 and K (d,y) = 0.05). As mentioned in Remark 2, Fig. 25 shows that the stability margin with the fuzzy PD controller is better than the liner PD controller with relative small gains. Furthermore, for the same case of walking on the incline of slope 22°, the robot with linear PD controller of relative large gains (i.e., K (p,x) = 0.2, K (p,y) = 0.5, K (d,x) = 0.05 and K (d,y) = 0.05) overturns such that the IMU sensor value of X-axis becomes 54° as shown in Fig. 26.

Fig. 25
figure 25

Stability margins for the hexapod robot walking on the incline of slope 22° with the fuzzy PD controller and linear PD controller of relative small gains (K (p,x) = 0.2, K (p,y) = 0.3, K (d,x) = 0.05 and K (d,y) = 0.05)

Fig. 26
figure 26

IMU sensor value of X-axis for the hexapod robot walking on the incline of slope 22° with linear PD controller of relative large gains (K (p,x) = 0.2, K (p,y) = 0.5, K (d,x) = 0.05 and K (d,y) = 0.05)

5 Concluding Remarks

The fuzzy control strategy for a hexapod robot walking on an incline has been proposed and implemented in this paper. Denavit–Hartenberg convention is applied to calculate the positions of motors and end points of legs such that the robot’s COG can be obtained. For maintaining the vertical projection of COG within the support polygon, the robot’s posture is adjusted by a fuzzy PD controller depending on the slope of incline that is measured by the IMU sensor settled at the center of the chest of a hexapod robot. By the proposed fuzzy control strategy, the stability margin of the hexapod robot is maximized such that the robot can walk on an incline stably. Finally, several experiments are implemented to demonstrate the effectiveness of the proposed fuzzy control strategy.