Abstract
Introduction
Locomotion control has been a durative hot research topic among the robotics community due to its fundamentality in mobile robot research. Conventional locomotion controllers need to model the dynamics of the robot, which, in most cases, is too complicated to be established. Moreover, deficiencies like limited flexibility, adaptability and stability make these model-based approaches incompetent at easily generating a smooth trajectory online and responding to the unknown environment rapidly. Therefore, more and more researchers have taken inspiration from animal locomotion, which has evolved to be efficient, rapid, adjustable and reliable under evolutionary pressures [1]. One class of the promising bio-inspired controllers is the CPG controller [2], which consists of coupled networks capable of producing coordinated oscillatory patterns of rhythmic activity while receiving simple adjustment signals from higher control centres [2–4]. It is desirable that the artificial CPG controllers possess the similar intrinsic properties of rhythm, coordination, variety and robustness to those naturally occurring CPGs in animals [2]. The artificial CPG controllers have been extensively studied and applied to various bio-inspired robots, such as bipedal-or quadrupedal-legged robots [5–7], robotic fish [8–10], a salamander robot [11] and a snake-like robot [12].
Noticeably, a wide variety of CPG controllers have been designed for and applied to bio-inspired swimming robots which have drawn more and more attention over the past few decades. Research on the CPG-based locomotion controllers of swimming robots can be divided into two categories: open-loop CPG controllers and closed-loop CPG controllers. Open-loop CPG controllers, which have primarily been focused on in the existing literature, are always employed to generate multiple swimming behaviours and to realize smooth transitions between those related behaviours. Examples include Ijspeert et al.'s salamander robot [11] and fish-like robot [8], Yu et al.'s robotic fish [13], Kamimura et al.'s snake-like robot [12] and our group's robotic fish [10, 14, 15]. In contrast, closed-loop CPG controllers always integrate sensory feedback into the CPG network to regulate the CPG behaviours automatically, which is more like the real mechanism of animal CPG activities. According to the specific surroundings and tasks, closed-loop CPG controllers are able to realize automatic swimming gait transition [9], pattern synchronization [16], gait stability [17] and gait optimization [18].
Although open-loop and closed-loop CPG controllers have been extensively investigated on the swimming robots, most of CPG controllers need massive control parameters working simultaneously to generate a specific swimming pattern. Moreover, most of the CPG controllers only produce planar motions or partially typical swimming behaviours. It is unusual for CPG-based locomotion controllers to be designed to involve all typical swimming patterns for a certain swimming robot just as it is with its natural counterpart. More remarkably, exact attitude control of swimming robots within the CPG-based control framework was rarely been tackled in the literature. One example can be found in Seo et al. [16], where a closed-loop CPG method is proposed to control the attitude of the foil fins and altitude of the underwater vehicle by synchronizing the 8-DOF foil fins.
Motivated by the above discussion and based on our previous work on robotic fish design and locomotion control [10], this paper aims at designing a CPG-based locomotion controller, which endows the robot with abilities in flexible switching among multiple 3D swimming patterns and exact attitude control of yaw and roll of the robot. First, by importing a transition layer, we primarily improve the open-loop CPG network proposed in [8] to generate all typical 3D swimming patterns with only four control parameters. Moreover, the stability of the built CPG model is proved strictly to ensure the intrinsic stability of swimming patterns. By employing sensory feedback from the IMU, we propose a closed-loop CPG controller to realize automatic attitude control in the robot's yaw and roll angles while swimming. Using the suggested CPG-based locomotion controllers, typical swimming pattern transitions and attitude control are further validated on a robotic fish.
The rest of this paper is organized as follows: Section II gives an overview of the robotic fish. The open-loop and closed-loop CPG networks are formulated in Section III. Experiments are provided in Section IV to validate the proposed CPG-based networks. Section V concludes this paper with an outline of future work.
Prototype of the Boxfish-like Robot
With the purpose of designing manoeuvrable and fully autonomous 3D motions, we attempt to fuse the mechanical structure, functional characteristics and multiple sensors of the physical robot. That is, the conceived robot has as many equivalent functions as possible compared with its biological counterpart while remaining a compact mechanical structure. Therefore, the dorsal and anal fins of the natural boxfish are excluded in the robot design since they play less of a role compared with the paired pectoral fins and the caudal fin. Figure 1a shows the mechanical configurations of the boxfish robot consisting of a roughly rectangular main body, a pair of pectoral fins and a caudal fin. The rigid and waterproof main body housing rechargeable battery, sensors and actuators, is composed of two parts: the upper case body and the lower case body. The upper is made of transparent Fibre Reinforce Plastic (FRP) while the lower is made of lightened polyurethare. Both static and moving seals are adopted to ensure the robot is waterproof. Specifically, tailor-made O-rings and silicone adhesives are used between the two external casings, while seals and grease are used between the driving shaft and the body shell. Note that the maximum operating depth of the robot is only about one metre due to the technical limitations of the waterproofing in our laboratory condition. All three replaceable fins are made of Polyethylene with a non-uniform thickness to approximate the hardness and flexibility of real fins. The robot density has been calibrated close to that of water so that it can float in water. Mass distribution is well balanced by placing a clump weight in the tested position to achieve smooth rolling motions.

Mechatronics of the boxfish robot. (a) Mechanical configuration of the robot. (b) Electronics and sensors in the robot.
The robot is operated by an embedded Linux system and can work in two control modes: the manual mode and autonomous control mode. In the manual mode, the robot is dominated by a remote control server via a wireless communication network (WiFi). In the autonomous control mode, the robot is able to swim autonomously and interacts with its near environment by using its onboard sensors: the Inertial Measurement Unit (IMU) and camera [10], as shown in Figure 1b. Specifically, the IMU consisting of a triaxial accelerometer, a triaxial gyroscope and a triaxial electronic compass, is fixed parallel to the body principal axis to monitor the robot's pitch, yaw and roll angles. It can also measure the robot's accelerations for future developments. The sampling rate is set at 50 Hz for real time application. The vision sensor is placed centrally in the front of the main body to capture images of surroundings for obstacle avoidance and localization. Table 1 lists the basic technical specifications of the robot.
Technical specifications of the boxfish robot prototype
To mimic the excellent locomotion capacity of natural fish, two kinds of CPG networks are designed in this section. First, we give a simplified dynamic analysis of ostraciiform robotic fish. Based on the locomotion analysis, we then propose a two-layer CPG controller with explicit expressions to produce multiple swimming patterns and flexible switching among these patterns. Next, we prove the stability of the built open-loop CPG model to ensure the intrinsic stability of the robot locomotion. More strikingly, by employing the sensory feedback from the IMU, we propose a closed-loop CPG controller to realize automatic attitude control of the robot while swimming. Automatic attitude control is one of the key abilities when the robot executes specific tasks in an unknown environment, such as passing through narrow spaces, trajectory tracking and multi-robot formation control.
Simplified Dynamic Analysis
A simplified dynamic analysis of robotic fish is provided to explain why the robot has various swimming behaviours in the water. As an ostraciiform robotic fish, the robot swims in the water by actively oscillating its bio-inspired fins while the rigid main body keeps to small passive oscillations. Therefore, the propulsive force is mainly provided by the robot's oscillating fins (the paired pectoral fins and caudal fin) which push the nearby water. According to the conservation of momentum, the water stream will give each oscillating fin a reaction force, which acts on the centre of pressure of the fin and pushes the fin with a direction parallel to the midplane of the oscillating fin. Since the rotating shafts of the fins are fixed on the robot, the reaction force will equivalently act on the robot. For the robotic fish, because the paired pectoral fins are able to rotate 360 degrees and the caudal fin is able to rotate about 120 degrees, a variety of reaction forces can be generated and then act on the robot by oscillating different combinations of these three fins. Therefore, the robot is able to generate multiple swimming patterns.
Figure 2 shows the force analysis on eight typical swimming patterns while other patterns can be analysed in a similar way. Note that the reference position for the pectoral fins is when the fins are turned backwards in a horizontal position while the reference position for the caudal fin is when that fin is in the sagittal plane, as illustrated in Figure 2a. Note also that the indicated forces

Simplified force analysis of the robot in typical locomotor patterns. (a) Swimming forwards [paired-fin (PF) mode], (b) swimming forwards [body-caudal fin (BCF)+PF mode], (c) swimming backwards, (d) turning, (e) turning on the spot, (f) pitching. (g) rolling, (h) braking.
With the purpose of simplifying the stability proof as well as maintaining the intrinsic properties of the CPG network, we linearize the nonlinear phase oscillator proposed in [8] through the first-order Taylor expansion. Thus, the coupled linear oscillators take the forms
where
In order to reduce the complicatedness of swimming pattern switching, a two-layer CPG network is proposed, as illustrated in Figure 3. The input drive received from the upper controller can be divided into four command inputs, namely

The proposed open-loop CPG model
Inspired by the swimming characteristics of the boxfish where the swimming speed is roughly linear with the frequency and amplitude [21–23], we use a combination of
where
Next, the combination of offset
where sgn(·) is a Signum function and is defined as follows:
To explicitly express the relationship between the control parameter set

Illustration of the robot performing multiple swimming patterns. (a) Input drive
Mapping table between parameter set and swimming patterns
CPG parameter values applied to the boxfish robot
By using theory of multi-agent systems (MAS), we prove the stability of the employed open-loop CPG model. To facilitate the analysis, three reasonable assumptions are made. 1) Dynamic parameters α
First, Equations (1a) and (1b) explain the dynamics of amplitude and offset of oscillator
It is obvious that
Letting
Next, using algebraic graph theory, we rewrite Equation (8) as the matrix form
where
Because μ is real, then
where
Further, letting
Since every oscillator is affected by the other
where
Thus, ϕ
Using sensing systems, animals always need to stabilize their motion states (such as attitude and position) in their daily activities (for instance, in prey and migration). To duplicate the ability of attitude stabilization in animals, we introduce sensory feedback into the CPG to form a closed-loop CPG network, which endows the robot with an automatic stabilizing ability while swimming. Because of the mechanical configurations of robotic fish, pitching angle is almost zero while the robot is swimming downwards or upwards in the 3D space. Therefore, only the attitude of yaw and roll angles are stabilized in this paper. As shown in Figure 5, the closed-loop CPG network contains four parts: the coupled oscillators, feedback signal generator, PID controller and onboard IMU. Correspondingly, the set of input drive for the closed-loop CPG controller becomes

The proposed closed-loop CPG network
Specifically, the working process of the closed-loop CPG controller is described as follows. To stabilize the robot attitude with an expected yaw angle
First, the coupled oscillators containing the feedback signals are designed as follows:
where
Then, based on the force analysis described in Section 3.1, the feedback signal generator are mathematically defined as follows:
where
Here we explain how the paired pectoral fins operate to stabilize the roll angle of the robot. First, to make the best of the force produced by the pectoral fins, the fin plane should be perpendicular to the transversal surface of the body, as shown in Figure 2g. Moreover, to maintain the roll angle at a specific value, the directions and the magnitude of the produced forces on two sides should be the same. Thus, the offsets of the paired fins are equal, as defined in Equation (21) and (22). Furthermore, the built dynamic model [25] and experimental validation [26] have shown that the thrust (speed) increases roughly and linearly with the amplitude. As a result, we use
Moreover, the PID controller is used to generate the appropriate λ
When the feedback is introduced into the CPG network, the obtained closed-loop dynamic system becomes a complicated nonlinear dynamic system. However, the stability analysis for the general nonlinear system is still unsolved, and we now also have not solved the stability proof of our closed-loop CPG network. Therefore, the mathematical proof of the closed-loop CPG network will be left as an open problem. Instead, extensive attitude control experiments will be performed on the robotic fish to experimentally validate the stability of the full model with feedback. The structure parameters of α and β, and the PID controller should be selected carefully. If the output rate of the PID controller is set to be high, α and β should also take large values to rapidly converge to the steady state. However, α and β values that are too large may result in an unsmooth swimming curve of the robot.
In this section, a series of relevant experiments with the robotic fish are conducted systematically to evaluate the proposed open-loop and closed-loop CPG controllers.
Multiple Swimming Patterns
To evaluate the ability of the proposed open-loop CPG controller, multiple swimming patterns, such as forward/backward swimming, turning, pitching and rolling motion, were first tested in a swimming tank (300 cm × 200 cm × 30 cm). Some scenarios of swimming patterns are illustrated in Figure 6. The 2D state estimation of the robot (position and speed) is analysed online using vision tracking software. While 3D state estimation is conducted offline by analysing the experimental videos. Due to the space limitation, only the pitching and rolling motions are specified below.

Snapshots of typical swimming patterns. (a) Turning, (b) turning on a spot, (c) swimming backwards, (d) swimming downwards.
By modulating the attack angle
Figure 7 compares time-averaged horizontal (

Relationship between the pitch speeds (horizontal speed and vertical speed) and the varied attack angle
This section validates the capability of the open-loop CPG in the rolling motion in the 3D space. Aquatic animals exhibit rolling manoeuvres in the wild [27]. They can be used to escape or to remove attachments from the animal's body surface. However, compared with yawing and pitching motions, the rolling motions of robotic fish have rarely been investigated in the literature, except regarding two kinds of robotic fish in Ijspeert's group [8] and Yu's group [9]. Thanks to the proposed CPG controller, we can just use input drive

Snapshots of the robot rolling with the control drives
In this section, attitude control experiments were conducted to validate the effectiveness and stability of the closed-loop CPG controller. In the experiments, the real attitude measurements of the robot are recorded online by the onboard IMU. Specifically, three kinds of experiments are performed: yaw angle control, roll angle control and the united attitude control of yaw and pitch.
Yaw Angle Control
When the robot operates in an unknown environment, the ability of yaw angle control (i.e., orientation control) makes great sense. Therefore, under the control of the closed-loop CPG controller, the stabilizing performance of the yaw angle control of the robot is first evaluated. Figure 9 illustrates the tracking results when the reference yaw angles are constant. We can see that the estimated angles can rapidly converge around the corresponding reference angles. Because the offset of the beating tail is used to regulate the yaw angle of the robot, the experimental results exhibit as an oscillatory form. We did 20 similar experiments to evaluate the stability of the closed-loop controller. All of them are successful to track the reference yaw angles and the average tracking error is about 5° for arbitrary reference yaw angles. Note that the experimental errors are remarkably smaller than that of the yawing control results in [28], where a dynamic model is built and implemented on a robotic fish.

Data collected during three yaw stabilization experiments, respectively at
In addition, to evaluate the response speed of the closed-loop CPG controller, the following reference yaw angle is adopted
whose frequency ω was set to 0.05 Hz. As shown in Figure 10, the controller is able to track the sine-based

The robot is tracking a sine-based
Possibly due to the contradiction between the complicated motion and the limited control parameters as well as the simple mechanical configuration of the robot, roll control of robotic fish has rarely been tackled in the literature. An example can be found in Barbera et al. [29], where a simplified Newton-Euler linearly dynamic model was built to track a designed roll angle. In this work, however, we use the model-free CPG-based controller to stabilize the roll angle of the robot. We did 15 experiments to evaluate the stability of the rolling control and all of them are successful at tracking the reference roll angles with the average tracking error being about 3° for the reference roll angle range −45° ≤

The measured roll angles in three different roll control experiments where
By coordinating the motions of the pectoral and caudal fins, the robot can stabilize its yaw angle and roll angle at the same time. This section validates the effectiveness of the united control of yaw and roll angles of the robotic fish by using the proposed closed-loop CPG network. To the best of our knowledge, the united yaw and roll angle control of the robotic fish within the CPG control framework is realized here for the first time. For instance, the expected roll angle and yaw angle are defined as follows:
whose frequency ω was set to 0.22 Hz. As illustrated in Fig. 12, we can see that both the roll and yaw angles of the robotic fish are tracked under the control of the closed-loop CPG model. Specifically, the real roll angle exhibits a time lag as compared with the reference roll angle

The united control of yaw and roll angle of the robot by using the closed-loop CPG controller. The other input parameters are
In this paper, two kinds of CPG-based controllers, that is, the open-loop controller and closed-loop controller, are proposed successively for the boxfish-like robot. Based on the CPG-based controller, the robot is able to flexibly switch between multiple 3D swimming patterns and control its attitude of yaw and roll exactly while swimming.
Specifically, a two-layer open-loop CPG model with only four control parameters is first proposed in an explicit expression to generate all the typical swimming patterns of the robotic fish, such as swimming forwards/backwards, turning left/right, swimming upwards/downwards and rolling clockwise/counter-clockwise. To ensure the intrinsic stability of swimming patterns, the stability of this open-loop CPG controller is proved strictly. Nevertheless, a more important contribution of this paper, besides improving the open-loop CPG network in theory and experiments, is that we introduce a novel closed-loop CPG-based control method, which can automatically stabilize the attitude of the robot without interference from the upper control centre. The CPG-based attitude control of the yaw and roll of the robotic fish is designed and realized for the first time in the literature. Systematical experiments have been conducted to validate the effectiveness and stability of the proposed open-loop and closed-loop CPG controllers.
It is anticipated that the proposed CPG-based locomotion controllers will be a useful tool to optimize the swimming patterns of robots and assist them in accomplishing practical underwater tasks. For this purpose, interesting topics like control parameter optimization, adaptive learning and path planning are worthy of further investigation.
