1. Introduction
With the trends towards autonomous shipping, advanced ship motion control techniques are being developed to ensure that ships can independently control their actions, especially in complicated situations. When a ship is navigated in a confined waterway with limited width, it needs to maintain a sufficient distance from the banks to ensure safety. This brings in the problem of path-following, in which the control design is to calculate the control inputs to drive the ship to a reference path. Most cargo ships are underactuated with propellers and rudders for surge and yaw motions and without other actuators for the sway motion, which are coupled with the nonlinear ship hydrodynamic characteristics. Various control methods have been proposed for solving the path-following problem of ships, such as sliding-mode control (Zhang et al., Reference Zhang, Zhang and Bu2022), adaptive control (Culverhouse et al., Reference Culverhouse, Yang, Annamalai, Sutton and Sharma2015), observer-based control (Liu et al., Reference Liu, Lu and Gao2019), model predictive control (Liang et al., Reference Liang, Li and Xu2021), etc. These methods require an ideal and accurate mathematical model of the ship. Inland ships face speed loss and decline of manoeuvrability when sailing in a confined waterway, according to experienced seafarers, which increases the risk of collision with the bank (Du et al., Reference Du, Ouahsine, Sergent and Hu2020). To investigate the ship–waterway interactions, a numerical model has been developed by Du et al. (Reference Du, Ouahsine, Toan and Sergent2017) to predict ship manoeuvring in a confined waterway using a nonlinear model with optimisation techniques to accurately identify the hydrodynamic coefficients involved. Finding a prior ship model for such effects is challenging as the ship would be affected by uncertainties and disturbances induced by the environment.
Over the last decade, several data-driven control methods have been proposed, which may alleviate the efforts spent in identifying and modelling all disturbances that a model-based controller may need to take into account. Weng and Wang (Reference Weng and Wang2020) developed a data-driven robust back-stepping control approach for tracking of unmanned ships with uncertainties and unknown parametric dynamics, in which the requirement of model information, including system order and inertia matrix, could be completely removed. A data-driven performance-prescribed reinforcement learning control scheme was investigated by Wang et al. (Reference Wang, Gao and Zhang2021) to deal with the trajectory tracking problem considering control optimality and prescribed tracking accuracy simultaneously. Gao et al. (Reference Gao, Liu, Wang and Wang2022) proposed a data-driven model-free resilient speed control method using available input and output data only with pulse-width-modulation inputs. Wang et al. (Reference Wang, Li, Liu and Wu2022) proposed an antenna mutation beetle swarm predictive reinforcement learning algorithm to address the path-following problem of underactuated ships using the input and output data retrieved from experiments.
A growing number of data-driven methods have been proposed and integrated with Model Predictive Control (MPC), which uses system identification techniques and stored data to build the prediction model, and the data collected during operation can be dynamically incorporated in MPC controller design and be used to fix the system prediction model (Hewing et al., Reference Hewing, Wabersich, Menner and Zeilinger2020). MPC enables optimal control inputs while guaranteeing constraints satisfaction, and data-driven modelling enhances performances and adapts to system changes. MPC requires a system model that can capture the characteristics of its dynamics while not being too complicated to be incorporated in an online optimisation framework (Kabzan et al., Reference Kabzan, Hewing, Liniger and Zeilinger2019). For a system that involves complex high-order nonlinear terms, applying MPC directly on a nonlinear system model may be computationally expensive, whereas an over-simplified system may result in reduced performance and control accuracy. In this paper, a system identification method is proposed to build a linear, data-driven ship model based on the data gathered over time, which enables accurate approximations of the true ship dynamics.
Iterative Learning Control (ILC) is an effective strategy in handling repeated control processes, due to its structural simplicity and effective learning ability (Jin, Reference Jin2016). By taking advantage of the repetitive nature in the learning process, ILC algorithms can improve the control performance gradually with the increase of iterations. By combining the iterative learning control scheme and MPC, in each iteration, the controller could learn from stored data in previous iterations and improve its closed-loop tracking performance and modelling accuracy.
This paper proposes a data-driven approach for predictions and control of underactuated ships with unknown dynamics in confined waterways via integrating MPC with an ILC scheme. The stored datasets form the basis of the learning procedure, which consist of ship states and control sequences that could successfully steer the ship to complete path-following tasks while satisfying all required constraints, upon which regression techniques are used to approximate the unknown ship dynamics as a linear state-space model. This alleviates the need for accurate ship dynamics and parameter-specific observers, while maintaining the advantages of MPC including predictive behaviour and constraints satisfaction. Based on the identified linear prediction model, a learning-based MPC controller is designed.
The main contribution of this paper is threefold.
• A learning-based MPC strategy is proposed, which makes use of the stored data from previous iterations and the collected data during operation to improve the performance of the controller with an ILC scheme.
• A system identification strategy is proposed to build a linear state-space prediction model that approximates unknown ship dynamics, which uses kernel-based linear regressors to minimise the error between the predicted evolution of states and true states.
• A confined waterway is divided into a series of straight-line and curved lines, a line-of-sight guidance law is used as the guidance principle for straight-line segments, and a curvilinear reference frame is introduced, as the guidance principles for curved segments.
The rest of the paper is organised as follows. Section 2 gives the nonlinear ship dynamics. Section 3 introduces the guidance principles. Section 4 describes the proposed learning scheme and controller design steps. Simulation results are presented in Section 5. Conclusions and future work are given in Section 6.
2. Nonlinear ship dynamics
A 3-DOF (degree of freedom) model is used to represent the ship dynamics on the surge, sway and yaw axes with the MMG (Manoeuvring Modelling Group) form, in which the hydrodynamic forces and moments on the ship are divided into hull, rudder and propeller, expressed in the following form (SNAME, 1950):
where subscripts $H,P,R$ represent the hull, the propeller and the rudder; $m,\,m_x$ and $m_y$ are ship mass, added mass in $x$-direction and added mass in $y$-direction; $I_z$ and $J_z$ are moments of inertia and added moment of inertia around the $z$-axis.
Figure 1 shows the ship coordinate system used in this paper: the earth-fixed coordinate system $O_0$—$x_0 y_0 z_0$ and the ship-fixed coordinate system $o$—$xyz$, where $o$ locates on the midship of the ship, with $x,\,y$ and $z$ axes that point towards the bow, towards the starboard and vertically downwards, respectively. Variables $u$ and $v$ are ship longitudinal and lateral speeds. Course angle $\psi$ is defined as the angle between the $x_0$ and $x$ axes, $\delta$ represents the rudder angle and $r$ represents the yaw rate. The evolution of ship states is usually expressed in the following way (Fossen, Reference Fossen2011):
Parameters $d_{wu}$, $d_{wv}$ and $d_{wr}$ represent the disturbances on the $x,\,y$ and $z$ axes. The main control forces are the surge force $T_u(\cdot )$ and the yaw moment $F_r(\cdot )$, which are generated with different propeller revolution rate $n$ and rudder angle $\delta$, respectively. It is also noted that there is no direct control force on its lateral movement on the $y$ axis, which makes the ship an underactuated system. In practice, a ship rarely changes its propeller revolution rate when it is sailing. Therefore, this paper assumes that control input $n$ and force $T_u(\cdot )$ are constants and considers the rudder angle $\delta$ as the main control input, as it is the case in actual ship manoeuvring operations. The yaw moment $F_r$ is a nonlinear term, and together with the high-order fluid dynamics items $f_{u}(\boldsymbol {v})$, $f_{v}(\boldsymbol {v})$ and $f_{r}(\boldsymbol {v})$, add up to the nonlinear characteristics of ship manoeuvring.
In Equation (2.2), parameters $m_u, m_v$ and $m_r$ are calculated as follows:
Variables $f_{u}(\boldsymbol {v})$, $f_{v}(\boldsymbol {v})$ and $f_{r}(\boldsymbol {v})$ represent the high-order fluid dynamics items, which are defined as
in which
The surge force $T_u(\cdot )$ is determined by propeller revolution rate $n$, propeller diameter $D_P$ and the propeller thrust coefficient $K_T$:
where $K_T$ is commonly expressed by second-order polynomials of the propeller advance ratio $J_P$ as
in which $J_P$ can be obtained as
In Equation (2.8), $w_P$ is the wake factor at the propeller position in manoeuvring. It is commonly estimated based on the wake factor at the propeller position in straight moving $w_{P_0}$ and the geometrical inflow angle to the propeller in manoeuvring $\beta _P$, defined as
where $\beta = \arctan (-{v}/{u})$, $x_P' = x_P/L_{pp} = -0{\cdot }48$ and $x_P$ is the longitudinal portion of the propeller.
Parameter $w_P$, introduced as
where $w_{P_0}$ is the wake factor at the propeller position in straight moving, and $C_1$ and $C_2$ are experimental constants. Furthermore, $C_1$ and $C_2$ are different in motions for port and starboard owing to an asymmetric wake factor with respect to the propeller rotational effect.
The yaw moment $F_r(\cdot )$ is defined as
where $a_H = a_H' = L_{PP}$ and $x_H = x_H' = L_{PP}$.
Considering the effect of the propeller on the increment of the rudder inflow velocity, the longitudinal velocity of the inflow to the rudder $u_R$ is expressed as
where $\varepsilon = (1 - w_R)/(1 - w_P)$, $w_R$ is the wake factor at the rudder position in manoeuvring, $\kappa$ is an experimental constant for expressing $u_R$ and $\eta$ is the ratio of the propeller diameter to the rudder span. The lateral inflow velocity to the rudder $v_R$ is written as
where $\gamma _R$ is the flow straightening factor and, different for port and starboard motions, $\ell _R' = \ell _R/L_{pp}$ is the effective longitudinal coordinate of the rudder position. We refer the readers to Yasukawa and Yoshimura (Reference Yasukawa and Yoshimura2014) for more details on the nonlinear ship manoeuvrability model.
As can be seen, the evolution of states $u,\,v$ and $r$ in the nonlinear ship model in Equation (2.2) are dependent on the hydrodynamic coefficients and ship parameters. These coefficients and parameters are usually identified via computational fluid dynamics analysis and tank tests, which takes time and much effort. Meanwhile, the manoeuvrability of a ship changes when it is sailing with different speed and rudder angle alterations, which makes the identification procedure a complicated task. Therefore, this paper proposes to learn the ship dynamics from data in a linear state-space form, which will be further explained in Section 4.
3. The guidance principles for straight-line and curved waterways
A confined waterway usually consists of straight-line and curved segments. This paper divides a waterway into a set of segments $S$. When the ship is sailing within a straight-line segment, a line-of-sight guidance principle is used generate reference course angle. For curved segments, a curvilinear reference frame is introduced.
3.1 Line-of-sight guidance law
Line-of-sight (LOS) is a conventional guidance principle, and its main idea is that if a ship is able to keep its course angle aligned with the so-called LOS angle, then the convergence to the desired position is also achieved. The LOS scheme was first applied to surface ships by Fossen et al. (Reference Fossen, Breivik and Skjetne2003). Researchers found it is useful when considering the control of underactuated ships, since it renders possible an approach of reducing the desired reference from $x_d,\,y_d,\,\psi _d$ to only one reference $\psi _d$. In this way, the path-following task $\psi \rightarrow \psi _d$ is achieved using only the one control input $\delta$.
The desired reference path is composed of a set of way-points. As shown in Figure 2, if the ship's current position is $p = [x,y]$, the LOS position $p_{{\rm los}}$ is located between the previous $p_{k-1}$ and current $p_k$ way-points. Let the ship's current horizontal position $p$ be the centre of a circle with the radius of $n$ times the ship length $L_{{\rm length}}$. This circle then intersects the current straight-line segment at two points where $p_{{\rm los}}$ is selected as the point closest to the next way-point.
To calculate $p_{{\rm los}} = [x_{{\rm los}}, y_{{\rm los}}]$, the following two equations need to be solved:
Selecting way-points in the way-point table relies on a switching algorithm. A criteria for selecting the next way-point, located at $p_{k+1} = [x_{k+1},y_{k+1}]^\top$, is for the ship to be within the range of acceptance of the current $p_k$, as shown in Figure 2. If at time $t$, the ship's current position satisfies
then the next way-point will be selected from the way-point set.
With the LOS position $p_{{\rm los}}$, the LOS angle can be computed:
in which the four quadrant inverse tangent function $\arctan 2(y,x)$ is used to ensure that $\psi _{{\rm los}} \in [- \pi, + \pi ]$.
The ship state vector $\boldsymbol {x} = [u,v,r,x,y,\psi ]^\top \in \mathcal {R}^6$. Then ship kinematics can be discretised as follows:
where $\Delta t$ refers to the discretisation time. We can rewrite it with a linear state-space form:
3.2 Curvilinear reference frame
Curvature $C(s)$ is introduced to describe the curved features of the waterway segment $s \in S$, which is a known parameter that can be drawn from the map information of a waterway. As shown in Figure 2, the control task is to ensure $e_y \rightarrow 0, e_\psi \rightarrow 0$ so that the ship can follow the reference path. The evolution of ship states $e_\psi,s,e_y$ are expressed as follows:
Therefore, the ship state vector $\boldsymbol {x} = [u,v,r,e_\psi,e_y,s]^\top \in \mathcal {R}^6$. Then, the ship kinematic model in Equation (3.7) is discretised as follows:
Similar to Equation (3.6), it can be reformulate as follows:
In this paper, the control input is chosen as $\boldsymbol {u} = [n,\delta ]^\top \in \mathcal {R}^2$, in which $n$ refers to the propeller revolution rate and $\delta$ refers to the rudder angle.
According to Section 2, the dynamic equations of ship motion variables $u,\,v$ and $r$ in Equation (2.2) include many nonlinear high-order terms. To deal with the nonlinearity, this paper proposes to learn a linear model around states $(u,v,r)$, in which regression vectors $\boldsymbol {\Gamma }^l \in \mathcal {R}^5$ ($l = \{u,v,r\}$) are introduced. Based on the values of the regression vectors, the prediction model can be reformulated as follows:
where $\boldsymbol {\Gamma }^l_i(\boldsymbol {x})$ denotes the $i$th element of vector $\boldsymbol {\Gamma }^l(\boldsymbol {x})$. Linear regression methods are used to identify $\boldsymbol {\Gamma }$, which will be introduced in Section 4.
Combining Equation (3.6) or (3.9) with Equation (3.10), the 6-states ship prediction model can be restructured in the form of $\boldsymbol {x}_{k+1} = A\boldsymbol {x}_k+B\boldsymbol {u}_k+C$. As can be seen, the evolution of states $(\psi,x,y)$ or $(e_\psi,s,e_y)$ are derived from ship kinematic characteristics and independent of ship parameters. The values of $\boldsymbol {\Gamma }$ are determined via regression methods based on the data collected from the ship. In other words, the formulation in Equation (3.10) does not require pre-knowledge on ship parameters and hydrodynamic coefficients. This makes it possible to construct a prediction model for unknown ship dynamics.
4. Iterative learning scheme and controller design
Figure 3 illustrates the iterative learning scheme and controller design steps of the proposed method. First, a model-free control law is applied to the ship and steer the ship from the start to finish point of a confined waterway for several loops while the ship states and the control inputs are stored. Each loop is referred to as one iteration. In this paper, we choose a proportional-integral-derivative (PID) controller as the nominal controller. In other words, each iteration finishes a successful ship track around the waterway. Based on the stored dataset $X_{\mathrm {PID}}$, a linear time-varying (LTV) prediction model is constructed using a system identification strategy. Then a rolling horizon optimisation problem is formulated with the LTV model, and an MPC controller is designed. Similarly, another dataset is collected after applying the MPC controller to the ship for several loops (iterations), referred as $X_{\mathrm {MPC}}$. Datasets $X_{\mathrm {PID}}$ and $X_{\mathrm {MPC}}$ are then employed to build the initial prediction model of the proposed Learning-based MPC (LMPC) controller. Together with the data obtained from LMPC running during iterations, the prediction model is improved with an iterative learning scheme. In each iteration, the data collected from previous iterations are used to construct a sampled safe set, terminal constraint set, and cost function, which are exploited in the LMPC controller design. In LMPC, the control problem of path-following is formulated as a repetitive task, and the controller uses the data from previous iterations to enhance the controller performance.
4.1 Kernel-based linear regression of prediction model
To facilitate a data-driven modelling of unknown ship dynamics, this paper estimates the evolution of $u,\,v$ and $r$ via linear regression instead of identifying the ship parameters first and then linearising them. It learns a linear affine time-varying ship model around each point so as to construct the prediction model in the MPC controller.
For the unknown ship dynamics, a PID controller is designed and applied to the ship, and steering the ship from the start point $\boldsymbol {x}_S$ to the finish point of the waterway for $M_1$ loops:
where $\delta$ represents the rudder angle and $\boldsymbol {e}=\{e_y,e_\psi \}$. After running $M_1$ loops (iterations), the ship states and control inputs are stored in dataset $X_{\mathrm {PID}}$ with vectors $\boldsymbol {x}^i = [\boldsymbol {x}^i_0,\ldots,\boldsymbol {x}^i_{T^i}]$ and $\boldsymbol {u}^i = [\boldsymbol {u}^i_0,\ldots,\boldsymbol {u}^i_{T^i}]$, in which $T^i$ denotes the time when the ship reaches the finish point, and $\boldsymbol {x}_{T^i} \in \mathcal {X}_F$. Here, $\mathcal {X}_F$ is a set of points beyond the finish point, and $\mathcal {X}_F = \{\boldsymbol {x}\in \mathcal {R}^6:[0 \, 0 \, 0 \, 0 \,1 \, 0]\cdot \boldsymbol {x} = s \ge L\}$, in which $L$ is the length of the waterway. Here, $s\ge L$ means that the ship has passed the finish point of the waterway.
Based on dataset $X_{\mathrm {PID}}$, a set time of indices $I_{i}(\boldsymbol {x})$ of $P$ nearest neighbours of point $\boldsymbol {x}$ at iteration $i$ are identified and defined as
in which $k_m\in \{0,\ldots,T^i\},\,m \in \{1,\ldots,P\}$, and $T^i$ refers to the ship sailing time spent in iteration $i$. Additionally, $Q$ is a scaling matrix of different variables. In other words, the set $I_i$ include the associated indices of the neighbours of each state point $\boldsymbol {x}$. Based on these data with index $I$, three kernel functions are introduced as the linear regressors, including Epanechnikov, Tri-cube and Gaussian density kernel functions:
where $z = {\lVert \boldsymbol {x} -\boldsymbol {x}^i_{k_m}\rVert ^2_Q }/{h}$, and $h$ is a hyperparameter that represents the bandwidth.
To find $\boldsymbol {\Gamma }^u(\boldsymbol {x}),\boldsymbol {\Gamma }^v(\boldsymbol {x}),\boldsymbol {\Gamma }^r(\boldsymbol {x}) \in \mathcal {R}^5$ in Equation (3.10) for $u,\,v$ and $r$, the following three optimisation functions are formulated:
in which
Problems $J_u,\,J_v$ and $J_r$ form quadratic programming problems, which can be easily solved via an optimisation solver. Here, $\boldsymbol {x}^i_k$ represents the stored ship states data in iteration $i$ at time $k$. Solutions to problems $J_u,\,J_v$ and $J_r$ are $\boldsymbol {\Gamma }^u(\boldsymbol {x}) = \arg _{\boldsymbol {\Gamma }} \min J_u,\boldsymbol {\Gamma }^v(\boldsymbol {x})=\arg _{\boldsymbol {\Gamma }}\min J_v$ and $\boldsymbol {\Gamma }^r(\boldsymbol {x})=\arg _{\boldsymbol {\Gamma }}\min J_r$, respectively.
Based on the identified model in Equation (3.10), a linear time-varying prediction model can be constructed at time $t$ of iteration $i$ as follows:
in which it is noted that $\boldsymbol {x}^i_{k|t} = [u^i_{k|t},v^i_{k|t},r^i_{k|t},\psi ^i_{k|t},y^i_{k|t},x^i_{k|t}]$ if it is a straight-line waterway segment and that $\boldsymbol {x}^i_{k|t} = [u^i_{k|t},v^i_{k|t},r^i_{k|t},e^i_{\psi _{k|t}},e^i_{y_{k|t}},s^i_{k|t}]$ if it is a curved waterway segment. The matrices $A^i_{k|t},\,B^i_{k|t}$ and $C^i_{k|t}$ are calculated as follows:
where
Here, $\bar {\boldsymbol {x}}^i_{k|t} \in \bar {\boldsymbol {x}}^i_t=\{\bar {x}^i_{k|t},\ldots,\bar {x}^i_{k+N|t}\}$ refers to a set of candidate solutions that are defined using the optimal solution from the previous time step $t-1$, and $z^i_t$ represents one of the candidate terminal state of the planned ship trajectory at time $t$.
Then an MPC controller can be designed using Equation (4.8) as the prediction model. The control objective is to steer the ship from initial state $\boldsymbol {x}_S$ to the terminal set $\mathcal {X}_F$. In each sampling interval $k$, the MPC controller solves an infinite time horizon optimal control problem:
where Equation (4.12) represents the linearised ship prediction model, Equation (4.13) defines the initial ship states, Equations (4.14) and (4.15) represent input and state constraints. In Equation (4.11), it is assumed that $h(\cdot,\cdot ) = \| \boldsymbol {x_F} - \boldsymbol {x}_k\|_Q + \|\boldsymbol {u}_k\|_R$, which refers to the stage cost. It is continuous and satisfies the following conditions in all iterations:
After solving Equation (4.11), an optimal control sequence $\boldsymbol {U} = \{\boldsymbol {u}_0,\ldots,\boldsymbol {u}_{N-1}\}$ with prediction horizon $N$ at each sample time $k$, such that the resulting state sequence $\boldsymbol {X}=\{\boldsymbol {x}_0,\ldots,\boldsymbol {u}_N\}$ and the control sequence $\boldsymbol {U}$ are obtained without violating Constraints (4.12)–(4.15). This controller is then applied to the ship to run for $M_2$ loops to create another dataset $X_{\mathrm {MPC}}$. Datasets $X_{\mathrm {PID}}$ and $X_ {\mathrm {MPC}}$ form the basis for LMPC controller design.
4.2 Learning-based MPC controller design
In each iteration $i$, the controller selects $N_{\mathrm {ss}}$ points from the previous $i-N_{\mathrm {s}}$ iteration to construct a sampled safe set. Here, $N_{\mathrm {ss}}$ and $N_{\mathrm {s}}$ are the control parameters to be determined. A sampled safe set $\mathcal {SS}^i$ at iteration $i$ consists of all successful trajectories performed in the previous $i-1$ number of iterations, which is defined as
Figure 4 gives the illustration of safe set $\mathcal {SS}^i$ in iteration $i$, which is the collection of all ship states at iteration $j$ for $j \in M^i$, where $M^i$ refers to the set of indexes $k$ associated with successful iteration $k$ for $k \le i$. It is also noted that $M^j \subseteq M^i$ and $\mathcal {SS}^j \subseteq \mathcal {SS}^i,\ \forall j \le i$. For every point in $\mathcal {SS}^i$, there exists a feasible control strategy which satisfies the state constraints and steers the state towards terminal state $\boldsymbol {x}_F$.
In addition, terminal cost and constraints are updated in each time step based on the planned ship trajectory in the previous time steps, so as to reduce computational burden. The LMPC solves a finite time constrained optimal control problem at time $k$ of iteration $i$:
where Equation (4.19) represents the linearised ship dynamics and Equation (4.20) defines the initial condition. The state and input constraints are defined via Equation (4.21). Equation (4.22) ensures that the terminal state reaches one of the points in the sampled safe set $\mathcal {SS}^{i-1}$ of the previous iteration $i-1$. Stage cost $h(\cdot,\cdot )$ is used to quantify the controller performance, which is the same as the stage cost in MPC formulation.
Function $Q^i(\cdot )$ is defined over $\mathcal {SS}^i$, which represents the learned minimum cost from previous iterations:
where
For every point $\boldsymbol {x} \in \mathcal {SS}^i$, the value of $Q^i$ is determined over index pairs $(j^*,t^*)$ in the $N_{\mathrm {ss}}$ points, which is the minimum cost along the ship trajectories in $\mathcal {SS}^i$, in which
After Equation (4.18) at time $k$ of iteration $i$ is solved, solutions are obtained, including $\boldsymbol {x}^{i*}_{k:k+N|k}$ and $\boldsymbol {u}^{i*}_{k:k+N|k}$:
Then the first element of $\boldsymbol {u}^{i*}_{k:k+N|k}$ is applied to the ship. The finite-time optimal control problem in Equation (4.18) is solved with an primal-dual interior point method based on the Nesterov–Todd scaling at time $k+1$, based on updated state $\boldsymbol {x}_{k+1|k+1} = \boldsymbol {x}^i_{k+1}$. For more details regarding the solution algorithm, we refer readers to Andersen et al. (Reference Andersen, Roos and Terlaky2003) and Sturm (Reference Sturm2002). Algorithm 1 concludes the algorithmic steps.
4.3 Asymptotic stability
To guarantee the asymptotic stability of the proposed LMPC, it is desirable to use infinite prediction and control horizons. While it is not feasible to get solutions for an infinite horizon nonlinear optimisation problem, stability of LMPC can still be guaranteed by choosing suitable safe sets and setting initial conditions. This has been studied by Rosolia and Borrelli (Reference Rosolia and Borrelli2018), and the required stability conditions are summarised as follows.
1. There exists a controller that keeps the ship in the waterway when the ship has passed the finish point of the waterway. Assume that $\mathcal {X}_F$ is a control invariant, $\forall \boldsymbol {x}_k \in \mathcal {X}_F$, $\exists \boldsymbol {u}_k \in \mathcal {U}: \boldsymbol {x}_{k+1} = \boldsymbol {Ax}_k + \boldsymbol {Bu}_k \in \mathcal {X}_F$.
2. Let $\mathcal {SS}^i$ be the sampled safe set at iteration $i$, $\mathcal {SS}^ 0$ is non-empty, and $\boldsymbol {x}_0 \in \mathcal {SS}^i$ is feasible and convergent to control invariant set $\mathcal {X}_F$.
3. At $t=0$, $J^\mathrm {LMPC,i}_{0\rightarrow N}(\boldsymbol {x}^i_0) \le J^\mathrm {LMPC,i}_{0\rightarrow N}(\boldsymbol {x}^{i-1}_0)$ holds, $\forall i \ge 1$.
If Conditions (1)–(3) hold, then the system in a closed-loop with the controller obtained by Algorithm 1 converges to a steady-state trajectory when the number of iterations goes to infinity.
5. Simulation results
To evaluate the effectiveness of the proposed method, a KVLCC2 tanker model with a length of 7 m, and a width of 1${\cdot }$16 m is taken as the target ship, its parameters are given in Appendix A1. The hydrodynamic parameters can be found in Yasukawa and Yoshimura (Reference Yasukawa and Yoshimura2015). We use a modular type ship manoeuvring model which was proposed in our earlier work in Liu et al. (Reference Liu, Quadvlieg and Hekkenberg2016) as the simulation model. This model was validated by comparing simulated and tested results (Lee et al., Reference Lee, Toxopeus and Quadvlieg2007; Yasukawa and Yoshimura, Reference Yasukawa and Yoshimura2015) to reflect the actual characteristics of ship motion.
Experiments are performed on an Intel Core i9-10900K CPU with 16 GB RAM running Windows 10 with Python 3.7.6. CVXOPT 1${\cdot }$2 is used as an optimisation solver, in which a quadratic cone program solver is used. The initial ship state is set as $x_0 = 0$, $y_0 = 0$, $\psi _0 = 0$, $u_0 = 1$ m/s, $v_0 = 0$ m/s and $r_0 = 0$ rad/s. A small input rate cost is added to take into account the changing rate of the rudder angle alterations of a ship. As a ship engine usually runs at a fixed speed in practice, the value of the control input $n$, which represents the propeller revolution rate, is set as $n = 10{\cdot }34$. The rudder angle input ranges from $-35^\circ$ to $+ 35^\circ$.
In addition, unknown disturbances are also considered, in which the following stochastic dynamics are employed:
To generate dataset $X_{\mathrm {PID}}$, a PID controller is used to manoeuvre the ship to a reference path for $M_1 = 2$ loops, in which $K_p = [2, 0{\cdot }6]$, $K_i =[\mathrm {random}(0{\cdot }1,0{\cdot }2),\mathrm {random}(0,0{\cdot }1)]$, $K_d = [0{\cdot }6,0{\cdot }9]$. It is noted that a random perturbation has been introduced in the control action deployed on the ship, so as to cover a larger region of the state space. Based on $X_{\mathrm {PID}}$, a linear state space prediction model is formulated and used to construct an MPC controller. The parameters of the MPC controller are $Q= \mathrm {diag}(1,0,0,100,0,10), R = \mathrm {diag}(0,10)$. Then, dataset $X_{\mathrm {MPC}}$ is generated via applying the MPC controller to the ship to perform another $M_2=2$ loops along the reference path.
The safe sets and the $Q$-functions in the proposed LMPC controller are retrieved from datasets $X_{\mathrm {PID}}$ and $X_{\mathrm {MPC}}$. The LMPC controller is then applied to the ship for $M_3=30$ loops. In each loop, the previous $N_{\mathrm {s}} = 3$ trajectories are chosen, in which $N_{\mathrm {ss}} = 60$ points are chosen from each trajectory. In the LMPC controller, $Q= \mathrm {diag}(1,0,0,100,0,10)$, $R = \mathrm {diag}(0,10)$, $Q_{\text {input rate}} = [0,15{\cdot }8^\circ ]$, $Q_{\mathrm {terminal\ cost}} = \mathrm {diag}(100,1,1,1,10,1)$. In both MPC and LMPC controllers, the prediction horizon $N = 15$. In each iteration loop, the LMPC problem in Equation (4.18) is solved in each sampling interval with a length of $t = 1s$, and the ship data are stored to update the controller for the next iteration.
5.1 Open-loop prediction performance
To evaluate the prediction performance, the changes of ship states over time are predicted with the identified linear state-space model in Equation (4.19) with a time horizon of 20 s, starting from each point on its simulated trajectory with 1-second interval. Figure 5 shows the Root Mean Square Error (RMSE) between the predicted states and true states of the ship over prediction horizon in all iterations, with the prediction models constructed with different kernel functions labelled as LMPC-$K^{\mathrm {Epanechinikov}}$, LMPC-$K^{\text {Tri-cube}}$ and LMPC-$K^{\mathrm {Gaussian}}$, respectively. Table 1 presents the maximum, minimum and average RMSEs of different prediction models. As can be seen, the RMSEs of motion variables $u,\,v$ and $r$ are much smaller than the ship's nominal speed 1${\cdot }$4 m/s and rated speed 10$^\circ /{\rm s}$. The average RMSEs of the position variable $e_\psi$ range from 9${\cdot }$396$^\circ$ to 9${\cdot }$486$^\circ$, those for variable $s$ range from 0${\cdot }$648 to 0${\cdot }$658 m and those for variable $e_y$ range from 0${\cdot }$244 to 0${\cdot }$253 m. Among these prediction models, LMPC-$K^{\mathrm {Gaussian}}$ performs best as it leads to smaller deviations from true states.
5.2 Closed-loop path-following control performance of MPC
To evaluate the optimisation cost and controller performance improvements over iterations, $M_3=30$ loops (iterations) have been carried out with different kernel functions. Figure 6 gives the simulated ship trajectories. In the first iteration, the simulated ship trajectories of LMPC-$K^{\mathrm {Epanechinikov}}$ and LMPC-$K^{\mathrm {Gaussian}}$ deviate from the reference path in the beginning but then keep up afterwards, while the ship trajectories of LMPC-$K^{\text {Tri-cube}}$ show larger deviations over the whole path. Figure 7 gives the simulated ship trajectories in the last iteration. It can be seen that with the increase of iterations, the simulated ship trajectories converge to better path-following performance. Among these LMPC controllers, LMPC-$K^{\mathrm {Gaussian}}$ shows relatively smaller path-following errors over iterations.
Figure 8 illustrates the simulated control inputs over iterations. It can be seen that the control inputs of different LMPC controllers varies in the beginning iterations and then converges to similar values in the last iteration.
5.3 Computation costs
Figure 9 presents the changes of optimisation costs of ship trajectories over iterations, which is the sum of values of the objective function in Equation (4.18) over all sampling intervals on each trajectory. It can be seen that LMPC-$K^{\mathrm {Epanechinikov}}$ converges at an earlier iteration, while LMPC-$K^{\text {Tri-cube}}$ and LMPC-$K^{\mathrm {Gaussian}}$ show larger fluctuations. Figure 10 gives the changes of path-following errors over iterations, in which the course angle error $e_\psi$ converges and stabilises at approximately 4${\cdot }$15$^\circ$, and the error on the $y$-axis $e_y$ stabilises at approximately 0${\cdot }$18 m.
Figure 11 gives the average computation times for solving the optimisation problem in each sampling instant. As can be seen, the computation time ranges from 0${\cdot }$16 to 0${\cdot }$26 s, with an average of 0${\cdot }$20 s. This implies that the proposed LMPC requires far less computation time than the 1-s sampling interval, which could facilitate its implementation in practice.
6. Conclusions and future work
In this paper, a data-driven MPC strategy is proposed for path-following of unknown underactuated ship dynamics in confined waterways. It uses off-line historical data and data collected during operation to create safe sets and terminal costs. A kernel-based linear regression is used for system identification, so as to build a linear time-varying prediction model of ship states evolution. With an ILC scheme, the control approach learns from previous iterations to guarantee the stability of the system and improve controller performance. Simulation results demonstrate that it improves the path-following performance in terms of root mean square tracking error over iterations.
For future work, this research will be extended in several directions. First, experiments in actual waterways will be carried out to further validate its effectiveness. Second, the theoretical properties of the LMPC strategy only applies for deterministic cases. For this, a Gaussian process can be introduced to model the uncertainties as a function of relevant variables such as the system state and input. Moreover, it is noted that this paper uses PID to generate initial data due to its simplicity and practicality; however, the PID controller could also be replaced with other advance control techniques to generate even better initial data. It would be interesting to investigate how the quality of the off-line data would affect the performance of the LMPC controller.
Acknowledgment
This work was supported by National Natural Science Foundation of China (62003250), Southern Marine Science and Engineering Guangdong Laboratory (Zhuhai) (SML2021SP101).
Appendix