Abstract
An intelligent walking strategy is vital for multi-legged robots possessing no a priori information of an environment when traversing across discontinuous terrain. Six-legged robots outperform other multi-legged robots in static and dynamic stability. However, hexapods require careful planning to traverse across discontinuous terrain. A hexapod walking strategy can be accomplished using a vision-based navigation system to identify the surrounding environment. This paper presents an image-based technique to achieve better walking strategies for a hexapod walking on a special terrain containing irregular, restricted regions. The properties of the restricted regions were acquired beforehand by using reliable surveillance means. Moreover, simplified forward gaits, better rotational gaits, and adaptive gait selection strategies for walking on discontinuous terrain were proposed. The hexapod can effectively switch the gait sequences and types according to the environment involved. The boundary of standing zones can be successfully labelled by applying the greyscale erosion comprising a structuring element similar in shape and size to the foot tip of the hexapod. The experimental results demonstrated that the proposed image-based technique significantly improved the walking strategies of hexapods traversing on discontinuous terrain.
1. Introduction
Multi-legged robots that mimic crawling insects perform satisfactorily, compared with wheeled robots [1, 2], and can overcome obstacles and walk on discontinuous terrain [3]. Among all multi-legged robot designs, the hexapod structure exhibits acceptable walking efficiency regarding the distribution of legs around the body, robot shape, and static stability [4, 5]. Numerous studies have been conducted on multi-legged robots [6–8]. McGhee et al. investigated a mechanism [9] for six-legged robots to achieve adaptive movement on an uneven surface [10]. Pratiar et al. [11] combined fuzzy control theory and a genetic algorithm to determine the adaptive hexapod robot gait travelling across a neighbouring region. Recently, a considerable amount of research done on robot vision [12] and has been primarily based on the rule of forbidden walking regions [9, 11, 13–15]. However, multi-legged robots present various limitations, such as travelling on discontinuous terrain and navigation systems, preventing them from broader applications. This study determined efficient walking strategies for hexapods by applying image-processing techniques and defined terrain parameters for examining the merits of the proposed method. This study employed greyscale morphology to locate hexapod standing terrain edges and derive the transition between standing and forbidden zones [16]. A satisfactory review of basic greyscale morphological operators can be found in [17]. The most basic greyscale morphological operations are based on dilation and erosion [18]. The effects of erosion on a greyscale image include (a) obtaining darker images and (b) maximizing dark portions.
The objective of this study was to derive efficient walking strategies for hexapods by using image-based techniques and examining the image of the surrounding terrain. In this study, a hexapod model (Figure 1) was designed to evaluate the efficiency of an adaptive walking strategy on discontinuous terrain. Furthermore, this study employed a simplified forward gait, maximal rotational gaits, and adaptive gait-selection strategies to demonstrate the feasibility of a hexapod traversing across discontinuous terrain. Moreover, the proposed method can adjust parameters for assessing and responding instantly to the terrain by using the image-processing results. Thus, a walking strategy can fine-tune the hexapod movement immediately and effectively by adjusting and repeating the experiments until a best output is achieved. Researching hexapod robots for commercial applications has been necessary. Thus, this research can assist robot designers in developing multi-legged robots for use in a broad range of applications.

Geometric model of the proposed hexapod robot
2. Method
2.1 Construction of Discontinuous Terrain
We applied MATLAB [19] command (rand) to construct the experimental terrain. As shown in Figure 2, the proposed method generated a 2000 by 2000 matrix. A total of 250 circles consisting of randomly chosen radii, namely, 15, 30, 45, 60, and 75, were subsequently added to construct discontinuous terrain, as shown in Figure 2. The circles corresponded to the hexapod's standing zone, denoted by 1 (white), and the areas outside the circle represented the forbidden zones, denoted by 0 (black). Finally, a uniformly distributed random terrain was created. A 2D terrain has proved to be a substantially efficient and complete algorithm (for an overview, see [20]). Terrain information of the environment was obtained using a surveillance camera. However, storing and computing a 3D grid are computationally expensive and demand additional memory storage [21]. Therefore, we labelled the terrain as either the standing zone or forbidden zone after using the terrain image to obtain terrain information. Bo et al. (2001) [22] proposed a hexapod adaptive gait system for uneven terrain by anticipating that the hexapod might slip or fall at the edges of the standing zone. As shown in Figure 3, the third gait of the hexapod had no foothold (outside the standing zone), and the sixth gait was marginally inside the standing zone (at the edges of the standing zone). Thus, this study proposes a method for determining the standing zone while avoiding the edges of standing regions by introducing transition zones. Greyscale morphology erosion was applied to locate edges of the standing zone [23]. The edges of the terrain discovered using greyscale erosion were marked in yellow. This study applied a structuring element size of seven by seven (Figure 4). The structuring element (SE) was chosen according to the shape and size of the hexapod foot tip. A darker image corresponding to an increased black portion was obtained after erosion. We labelled the portions as edges of the standing zone. The size and shape of the SE can be changed according to the gait size of the hexapod and the type of terrain. The proposed method involves applying greyscale erosion for determining a transition between the standing and forbidden zones in each step.

A uniformly distributed random terrain

Terrain edges (black lines)

Seven by seven structuring element [16]
The white zones were the standing areas on which the hexapod could stand, whereas the black zones were the forbidden areas. The edges were marked in yellow by using the greyscale erosion method, representing borders that the hexapod was required to avoid. As shown in Figure 5, the yellow boundaries correspond to the transition between the forbidden and standing zones.

Discontinuous terrain consisting of the standing zone (white), forbidden zone (black), and edges (yellow) [16]
3. The Proposed Hexapod
3.1 Dimensions
In the proposed hexapod (Figure 6), the ranges of motion were illustrated in a semicircular shape. The dimensions were the maximal ranges Rmax = 60 (pixels), minimal ranges Rmin = 20 (pixels), length between two sequential gaits B = 100 (pixels), width W = 50 (pixels), and the offset value D = 50 (pixels). This configuration enabled the robot to avoid obstacles and interference between each gait. In this study, a 320 by 320 (pixel) hexapod model was designed according to the aforementioned parameters for computer simulation (Figure 6). Figure 6 shows the 2-3-6 gait support pattern and stability margin of the hexapod. The stability margin (Sm) in each step is defined as the hexapod centre of gravity (CG) lying inside the support polygon. The stability margin is the shortest distance from the vertical projection of the CG to the boundaries of the support polygon in the horizontal plane [24]. The hexapod was statically stable when the distance between the vertical projection of the CG and the support polygon were greater than zero. The proposed method involved applying offset value D to ensure that the CG of the hexapod remained inside the support polygon in each step. As shown in Figure 7, offset value D ensured that Sm was greater than zero. We applied a stability margin greater than zero so that the hexapod could effectively traverse across discontinuous terrain. The stability margin of the hexapod improved after we applied the proposed offset model [25].

Hexapod parameters [16]

The 2-3-6 gait support pattern of the hexapod
3.2 Simplified Forward Gait
Each step of the simplified forward gait's ranges of movement (Km) was measured and stored in a matrix. As shown in Figure 8, each matrix was displayed as a greyscale image. The highest value (white) was denoted with a value of 255 and the lowest value (black) was denoted with a value of 0. Correspondingly, we assigned values from 0 to 255 according to the proportion of the grey pixel value. Bright zones represent high Km values (Figure 8), and vice versa. Therefore, white denotes wide ranges of movement and black represents short ranges of movement. This study applied this technique along with the stability margin to create an adaptive forward gait list by selecting from eight simplified forward gait angles, namely 0°, 15°, 30°, 45°, 60°, −15°, −30°, and −45°. The interval of angle was adaptively chosen for the effective performance of the hexapod and could be adjusted according to the terrain condition for an efficient forward gait. The parameters of the proposed hexapod's simplified forward gait (Figure 9) were forward angle α; stride length S; and SX, SY (S in X and Y directions, respectively). The parameters SX and SY were more significant than α and S. Table 1 shows the simplified forward gait parameters. The hexapod's movement range in the Y direction was wider than that of the X direction; this approach became a substantial basis for selecting a gait strategy. The Y direction range of movement was wide because of the semicircular hexapod gait.
The parameter values of hexapod's forward gait [16]

Greyscale image of a simplified forward gait

Various parameters of a simplified forward gait [16]
3.3 Rotational Gait (Around the Centre of Gravity)
The rotational gait measurement can be divided into two stages. First, the distance between every point of motion range and the CG was measured. This study then applied the aforementioned ranges of movement matrix for the hexapod's movement (Figure 10). The angle of rotation for each point was calculated in a counter clockwise direction. We employed the cosines law to measure the angle of rotation for each point. A grey value of 255 was defined for the maximal angle of rotation (white) and a grey value of zero was defined for the minimal angle of rotation (black).

The angle of rotation around the CG [16]
3.4 Maximal Angle of Rotation
As shown in Figure 10, we measured θ3 as 58.85°, θ2 as 30.03°, and θ6 as 30.39°. The CG of the rotation was gradually shifted to the right when the hexapod rotated clockwise with the 2-3-6 gait. Furthermore, θ3 decreased, and θ2 and θ6 increased gradually. The hexapod reached the maximal angle of rotation when θ2, θ3, and θ6 were equivalent. The position of the centre of rotation was OT (Figure 11). By applying this OT, the hexapod could not only rotate but also move forward. This enabled a robot exhibiting the most effective gait to traverse across discontinuous terrain. The experimental results indicated that the position of OT was 62 pixels right from the CG (Figure 12) for the 2-3-6 rotational gait sequence. We observed a rotation angle of 37.67° for the 2-3-6 gait sequence. Table 2 shows the comparison between the rotation angle around the CG and maximal angle of rotation. As shown in Table 2, no forward movement by using the rotation around the CG was observed. However, the maximal angle of the rotational gait also exhibited a forward movement of 40.16 pixels (including 13 pixels in the X direction and 38 pixels in the Y direction). This is applicable only to the rotational gait of the 2-3-6 gait sequence. By contrast, the 1-4-5 gait sequence was required to apply a rotational gait around the CG to obtain a full rotational angle.
The comparison of rotational gait [16]

Rotation around the point OT and after rotation

The maximum angle of rotation [16]
3.5 Rotation around Any Point
The strategy of rotation around any point involved assuming that the hexapod's destination target point was in front and the CG was on the right side of the rear position. Furthermore, the hexapod's rotational ranges depended on Gaits 1 and 3. In each step, the hexapod could rotate θ degrees. However, the rotation of the hexapod depended on the condition of the forbidden edges, zones, and target distance. After each movement, the hexapod's CG and stability margin were measured and updated. The stability margin could be defined as the shortest distance between the support polygon and CG of the hexapod (Figure 7). Table 3 shows the parameters and radii for 5° and 10° of rotation measured (Figures 13 and 14).
The parameters for rotation of 5° and 10° [16]

For 5° angle of rotation [16]

For 10° angle of rotation [16]
Table 3 shows the angles of the rotation results for θ = 5° and 10°. The X and Y directional movements were measured between the OT and CG. R is the radius in pixels, S is the stride length, and SX and SY are the stride length value in pixels for the X and Y directions. Sufficiently significant findings were determined by comparing the data listed in Tables 1 and 3. As shown in Table 3, the stride length for 5° of rotation was 101.9 pixels, and 93 pixels for 10° of rotation. Thus, for the 10° rotational gait, the hexapod's stride length was nine pixels less than that of the 5° rotational gait. However, for the 10° rotational gait, although the forward movement was less, the rotation was more. Thus, the strategy entailed the hexapod choosing 5° to rotate and move forward simultaneously. If a greater rotation was required, the robot could select a 10° rotational gait.
3.6 The Algorithm for Gait Selection
The key strategy used was for the robot to use a terrain image and premeasure the subsequent foothold point in real time. Figure 15 shows the experimental result, which was based on overlapping ranges (grey) between the terrain and gait ranges of movement. Thus, the grey regions that overlapped the standing zone and the terrain ranges of movement were the standing zones on which the hexapod leg could land. As shown in Figure 15, the third gait (labelled Number 3) was outside the ranges (not in the standing zone circle); thus, the hexapod switched to select the 1-4-5 gait sequence to determine an appropriate foothold. Moreover, the hexapod chose the foothold based on a high Km value so that the foothold was within the region of a standing zone. Consequently, the hexapod could continue to rotate and move simultaneously toward the destination.

The grey regions indicate the overlapping ranges of motion of the hexapod [16]
3.7 Adaptive Gait Strategy
The strategy involving the tripod gait is discussed in the previous sections. When the tripod gait failed to continue moving, the hexapod transformed to the symmetrical gait, and vice versa. Subsequently, the hexapod transformed back to the tripod gait. Figure 16 shows the simulation result of the proposed method. The proposed strategy involved assuming that the destination of the hexapod was in front; thus, the robot used a 0° straightforward gait. As shown in Figure 16, the robot moved from a lower portion to the top. The key strategy first applied the tripod gait to locate a foothold zone and continued moving. As shown in Figure 16, the green circles are 1-4-5 gaits, the blue boxes are 2-3-6 gaits' sequence, the purple triangles are symmetrical gaits, and the yellow star is the hexapod's destination. When obstacles or route complications were encountered, a transformation between 1-4-5 and 2-3-6 was immediately performed. As shown in Figure 17, no foothold option for Gait 2 was available. Figures 17 and 18 show the top boxes of each gait's current step's Km and the boxes below are Km produced from the earlier step. We observed that the highest Km values were 68 and 40 for the third and sixth gaits, respectively. Moreover, the first and fourth gaits produced adequate Km values in earlier steps (51 and 70). Thus, the robot switched from the tripod to the symmetrical gait. After the transformation, the hexapod applied a symmetrical gait (1-3-4-6) for foothold selection and moved 40 units. The symmetrical gaits labelled with purple triangles were the third and sixth gaits, as shown in Figure 16. The robot switched back to the tripod gait (2-3-6) depending on the terrain condition and foothold availability. The hexapod applied the symmetrical gait when the Km value was the lowest in the sixth gait, then converted back to the 2-3-6 tripod gait. Thus, the hexapod continued moving forward.

Changes in the gait sequence (the green circles are 1-4-5 gaits, blue boxes are 2-3-6 gaits, and purple triangles are symmetrical gaits) [16]

Transformation from the tripod to symmetrical gait [16]

Conversion back to the tripod gait [16]
4. Proposed Method of the Hexapod's Linear Movement
4.1 Gait Selection for Forward Walking
The proposed method involved applying eight angles of a simplified forward gait for linear walking. Thus, the hexapod possessed 64 combinations to measure and select the next foothold. However, the hexapod had to calculate the ideal gait in each step to continue moving forward, which could undesirably increase computational time and cost in real-time application. Thus, the key strategy was based on a 0° simplified forward gait to alleviate this limitation. The proposed method categorized 64 combinations of gait into three groups (Figure 19). The first priority was to combine a small angle gait group. In each step, the robot compared S (stride length), as shown in Table 1. The hexapod always preferred a 0° simplified forward gait when the stride length was at least 80% of the value shown in Table 1. When the stride length was less than 80% of the value listed in Table 1, the hexapod applied another group of best gait angles, such as Group 02. When the stride length of Group 02 was below 80% of the value shown in Table 1, the hexapod applied Group 03, as shown in Figure 19. The key strategy involved the hexapod always choosing a small angle gait to reach a destination.

The flow chart of the gait selection strategy for forward movement [16]
4.2 Adaptive Strategy for Walking
This study incorporated a database of eight types of hexapod movement, containing four rotational gaits, one tripod gait, and one symmetrical gait. If possible, the hexapod uses the 0° simplified forward gait to achieve the greatest stride length, whereas the ±15° gaits are its second priority. When the target angle is greater than 45°, a maximal angle rotational gait is used. Otherwise, the 5° or 10° rotational gaits are chosen. Subsequently, the hexapod reassumes the 0° simplified forward gait. The procedure of such a walking strategy is illustrated in Figure 20. MATLAB software was applied to construct the discontinuous terrain and simulate the hexapod traversing strategy. No a priori information on the terrain environment was assumed. The hexapod often operated in domains that were only partially known (such as from satellite photos). When a hexapod moves toward a destination, adaptive re-planning is often required as the knowledge of the terrain is updated. The proposed hexapod offset leg ensured that the stability margin and use of the aforementioned strategies solved the hexapod navigation problem on discontinuous terrain. Moreover, the ranges of movement, Km, value facilitated in effectively selecting the gait and switch between gait sequences when required by the scenario. Thus, the proposed hexapod can be used in a situation in which no previous knowledge of the environment is available. Photos taken by using a surveillance camera or drone to obtain whole terrain information beforehand can be further processed to derive relevant information to label areas on the terrain as either forbidden zones or standing zones.

Walking strategy for the proposed hexapod robot
Greyscale erosion is then used to label the transition between the standing and forbidden zone. We anticipated that the hexapod could fall on the boundary of the standing zone. The erosion method entailed employing SE according to the shape and size of the hexapod foot tip. Thus, the transition areas were also labelled as forbidden zones. Finally, the hexapod could traverse effectively across discontinuous terrain without prior knowledge of the environment.
5. Results
In the proposed method, the hexapod was designed considering offset gait to prevent interferences between the legs. Moreover, each gait's ranges of movement and the robot's stability margin were analysed in each step. The hexapod chose high Km values to continue walking efficiently. The proposed strategy dynamically selected a linear movement, a maximal rotational gait, and a transition between the tripod and symmetrical gait as the situation required. Figure 21 shows the simulation procedure of the proposed method. A total of 715 circles exhibiting radii of 10, 20, 30, 40, and 50 pixels on which the robot could stand were available. Regarding the proposed discontinuous terrain, the average radius of the circles was 29.71 pixels (41.2%). The ratio between the foothold zone and the entire terrain was 0.55. The experimental result of the hexapod is shown in Figure 21. Two red diamond boxes represent the starting point and destination of the hexapod. The blue boxes and green boxes indicate 2-3-6 gait and 14-5 gait sequences, respectively. The hexapod walked 27 steps in the experiment, as shown in Table 4. Table 4 shows the position of the current step, the selected gait for subsequent steps, rotational or linear movement, and other parameters in pixel values. Based on the result, applying large databases to a greyscale image-processing method significantly improved the walking strategy of hexapods with no a priori information on discontinuous terrain. The hexapod could apply the proposed method and database to reduce the computational complexity for real-time applications. The proposed strategy was based on Km to select the best gait. At each stage, the hexapod could calculate the subsequent step; when the step was not feasible, the hexapod returned to the previous step and recalculated.
Parameters for hexapod movement as shown in Figure 21

The proposed hexapod's trajectory generation
6. Conclusion
Thus far, multi-legged robot research has focused primarily on the forbidden zone concept. Determining better walking strategies for multi-legged robots is crucial. This study proposes using an image-processing method to design an intelligent gait selection strategy for hexapods walking on discontinuous terrain. The proposed method consists of parameters for establishing, adjusting, and investigating discontinuous terrain. This study determined the better linear and rotational movement by applying the image-based method. Moreover, the rotational gait included the rotation around the CG and rotation around any point. The findings suggest that the proposed method can be applied as a complete procedure for gait selection. Using image-processing techniques, coupled with a matrix database, significantly increases the efficiency of a robot's walking strategy. Therefore, the hexapod can simulate paths in advance and attain the adaptive gait control strategy. Moreover, we developed a physical model of the hexapod to demonstrate the effectiveness of the proposed method.
