Position Control of Heave Compensation for Offshore Cranes Based on a Particle Swarm Optimized Model Predictive Trajectory Path Controller

: The wave compensation system can be very useful in several naval applications. It can greatly reduce the relative irregular motion between the two ships when replenishment operations are performed, or between the ship and the offshore platform, which is caused by the waves. It is widely used in offshore operations, offshore cargo transfer, oil and gas exploitation, deep-sea min-ing, the hoisting and recovery of submersibles, etc. However, when a crane is used in a ship or moving platform, due to the influence of the hull, the crane load movement is similar to a space ball pendulum, which causes the heave displacement to show significant nonlinear motion characteristics. Moreover, the time delay of the detection mechanism and control error could result in untimely compensation, which deteriorates the performance. Consequently, this paper proposes one advanced prediction compensation method, namely Particle Swarm Optimized Model Predictive Trajectory Path controller (PSO−MPTP), which can improve the heave compensation performance. This method, which is based on Model Predictive Control (MPC), is firstly applied to the position servo system and takes into account the heave prediction and control effects simultaneously. The heave displacement of the crane load could be predicted in multiple steps in advance and used as the input of the position loop of the compensation machine. The achieved simulations show that the proposed controller has better prediction ability, higher control accuracy, and stronger robustness.


Introduction
Human maritime industrial activities have become more and more significant in recent years. Consequently, crane operation, an essential part of the offshore industry and offshore facility supply chain, becomes more and more important. However, the interference of waves will make the ship move with 6-Degrees of Freedom (DOF) (sway, surge, heave, roll, pitch, and yaw) and seriously affect offshore lifting and cargo shifting operations on ships due to the complicated ocean environment [1]. In particular, the heave motion and yaw motion have the most significant impact on the crane load during the operation process [2]. Due to other relatively small motions compared to the heave motion, heave compensation is the more crucial motion for the offshore work of cranes.
Normally, the basic principle of heave compensation is to use sensors to detect and record the relative distance of ship and crane load and produce a compensation signal to the crane to make the load swing at the opposite speed. In this way, a collision between the cargo and ship deck caused by waves can be avoided, and the safety of cargo operators during lifting work can be improved. If the heave motion of cranes could be predicted in advance and the servo system can effectively compensate over time, the unnecessary heave movement of the load can be significantly reduced [3]. The wave compensation system is generally divided into the Passive Heave Compensation system (PHC), Active Heave Compensation system (AHC), and Semi-Active Heave Compensation system (SAHC) [4]. In principle, the PHC device is located between the offshore crane and the crane load and can be represented by a parallel spring damping system. It does not require energy and is generally used with heavy loads and low accuracy requirements. PHC cannot compensate for the relative motion between the effective load and the ship in real-time, which has a specific time delay. To summarize, PHC has limitations in compensating for relative motion. The compensation efficiency of PHC in decoupling ship heave motion and load motion does not exceed 80% [5], while for AHC, the performance largely depends on the reliability of the control system. The relative compensated speed is much faster and the compensation accuracy is much higher. It can adjust the overcompensation more actively and significantly suppress the coupling of the heave motion of the payload [6]. However, this system consumes energy and is more suitable for small and medium-sized systems. SAHC combines the advantages of PHC and AHC, which can achieve satisfactory compensation accuracy with lower energy consumption [7]. Nevertheless, due to the combination of the two systems, SAHC is more complicated and expensive.
Huang et al. designed an AHC that satisfies the good control characteristics of the wave compensation system and obtains higher compensation accuracy [8]. The Motion Reference Unit (MRU) measures the actual ship motion. The AHC controller then calculates the motion of the actuator to counteract the ups and downs. The efficiency of the system can reach more than 90% [9,10]. The primary actuation of most AHCs is delivered by either hydraulic or electric drive systems. The electric drive system-based AHC has more advantages than the hydraulic system-based AHC in terms of compensation accuracy and speed. The efficiency of the electric heave compensation systems is between 70% and 80%. Compared with hydraulic systems, the characteristics of no oil reservoir and low motor noise have attracted more and more consumers. Moreover, for hydraulic systems in general, the biggest disadvantage is low efficiency with likely as low as 10% to 35% average efficiency of some open-loop systems [11].
As shown in Figures 1-3, AHCs are mainly divided into the draw-works retractable type, the hydraulic cylinder telescopic type, and the boom luffing type [12]. This paper will mainly focus on the draw-works retractable type, which is shown in Figure 1.   A number of papers have investigated AHC with the aim of reducing compensation errors. The most commonly used method is predicting the movement of the crane load and compensating for the prediction result. Lin et al. compensated for the heave motion of a crane based on motion prediction and fuzzy PID control [13]. Due to the hysteresis of the hydraulic system, it is difficult to respond quickly and accurately to the control signal. The compensation action and wave motion are out of step, which affects the compensation effect. The method proposed in Ref. [13] can not only solve the hysteresis, which has always existed in hydraulic actuators, but also uses motion prediction and fuzzy PID to avoid overshoot and instability. Chu et al. proposed a neural network-based ship motion prediction method to apply to offshore crane operations and implemented the proposed AHC algorithm [14]. They trained a multi-layer perceptron model to predict the ship's motion and used the ship's future motion information as the controller's input to compensate for the shaking of the crane load. This method used predictive data for control and helped to overcome the signal delay of measuring sensor data. Longer forecasts can also provide on-board support and early warnings to prevent system failures. Neupert et al. used the prediction of heave motion as part of the AHC crane control method [15]. A crane dynamics-based linear model and a pole-assignment control method to set the load position were adopted. Shi et al. proposed a Kalman filter-based using Kalman Filter Particle Swarm Optimization to improve the prediction performance of a Support Vector Regression (KPSO-SVR) advanced statistical machine learning algorithm to analyze and research deep-sea fishing vessels [16]. Unlike the previous neural network algorithm, it can avoid the neural network over-fitting phenomenon that may occur due to the minimization of the Structural Risk Minimization (SRM ) structure risk to accurately predict the heave motion of the ship crane to compensate for the crane load. The proposed prediction model can overcome the increasing lag of the Autoregressive Moving Average Model (ARMA) prediction model over time. Küchler et al. proposed a prediction algorithm for the heave movement of crane load [17]. The Fast Fourier Transform (FFT) analyzes the motion caused by waves in the frequency domain. A peak detection algorithm extracts the amplitude, frequency, and other signals from the frequency domain signal, which is then processed by a Kalman filter. After the identification, the heave movement of the crane load is estimated. Using the controller and prediction method, which can significantly reduce the heave movement of the crane load, compensates for the dead time in the system.
High-precision compensation for the heave of the crane load is carried out using the control algorithm in the compensation mechanism. Cai, Zheng, and Liu proposed an adaptive robust dual-loop control scheme and proposed a multi-degree-of-freedom velocity feedforward compensator to decouple motion disturbances from the basic platform [18]. The original dynamic model was transformed into a linear parameterized form, and the adaptive law was used to estimate the basic parameters. A command-filter-based adaptive robust controller was developed to solve the problem that the uncertainty from the load and hydraulic system may reduce the system performance. Woodacre, Bauer, and Irani designed a Model Predictive Control (MPC) controller to drive a hydraulic test system for unloading and compared the experimental results of the PID controller [19]. It was found that the MPC controller can track various test cases and references and is better than the PID controller in all experiments. The decoupling of the transmitted movement by the MPC-PI controller can reduce the percentage by 99.6%. Johansen et al. combined the traditional AHC with the feedforward control strategy [20]. It reduced the impact force and effectively improved the stability of the crane load. Messineo and Serrani proposed an adaptive controller for heavy cranes [21]. It used an adaptive observer and two adaptive external interference models to make the closed-loop system adaptive in terms of equipment parameters and harmonic disturbance frequencies. Yang et al. designed a neural network-based adaptive control method to control the driving and non-driving state variables without any linearization operation [22]. In particular, the proposed rule could effectively compensate for the uncertainty of parameters and crane system structure. The manipulator and rope can reach the preset position within a limited time, and the payload swing can be suppressed entirely. Arnold et al. proposed a nonlinear control strategy combined with a model-based optimal trajectory generation method [23]. The trajectory tracking and anti-interference of crane load transportation were studied. The optimal control problem solved online considers the linearized system including state feedback, input, and state constraints. The generated optimal trajectory and straightness pitch motion control were applied to the measurement of the mobile port crane. The movement of the load was greatly compensated. Richter et al. proposed a real-time model predictive trajectory planner [24]. By predicting the vertical position and speed of the crane apex, the optimal control problem with the state constraints for each time step was solved online. A repetitive polynomial-based trajectory planner was used as a fallback strategy if the best control solution could not be found within the available time. If the optimization algorithm fails to find an efficient solution within the available time, continuity of control can be guaranteed.
According to the literature, indeed, these references propose different methods, which could improve the compensation performance, using either feed-forward control to predict the heave motion or feedback control to compensate for the displacement of the crane load. However, these methods mainly focus on only one part and hardly discuss the hybrid control, which takes into account the prediction and control effects simultaneously to improve the performance. This paper proposes a Particle Swarm Optimized Model Predictive Trajectory Path (PSO−MPTP) controller, which combines the feed-forward and feedback controls. It uses the heave displacement trajectory signal of the crane load as an input to the compensation mechanism. Furthermore, according to this method, it can use future set-points to respond to changes in trajectory tracking in advance. This should be a good method to solve the above problems. For simplification, only the heave direction displacement of the crane load is considered. The trajectory of the crane load is tracked in the Northeast Down (NED) frame. The required reference trajectory is calculated, the actuator and measuring unit of the heave compensation system must be independent units of the modular platform. This paper adopts the Permanent Magnet Synchronous Motor (PMSM) servo system as the actuator in Figure 1, which is an important part of the offshore crane system. The PSO−MPTP is introduced into the wave compensation system for the first time, which replaces the conventional PI of the position loop in the three-phase closed-loop control of the traditional PMSM for real-time position compensation.
Consequently, this paper is structured as follows. In Section 2, the mathematical model of wave disturbance force and crane system is established. The overall system uses coordinate movement to obtain the displacement and velocity of the crane load in the heave direction. In Section 3, a mathematical model of PMSM is developed. In Section 4, the state equation is established for the motion equation of the crane system. Subsequently, PSO−MPTP for the position loop is designed and constrains the control quantity and control increment. Finally, the three-phase closed-loop control of the PMSM is presented and implemented in Matlab/Simulink. The analysis of the simulation results proves the feasibility of PSO−MPTP in the heave displacement compensation of the crane load.

System Model and Dynamic Equation
When the ship is traveling in the sea, it is affected by the wind and waves, which will cause the hull to shake and produce 6-DOF movement. The wave disturbance force is transmitted to the crane load through the hull, making the crane load heave and move. The overall process of the displacement compensation system of the crane load is shown in Figure 4. The work in this article is based on some reasonable assumptions, which are as follows: 1. Assuming that the shape of the crane ship is a square barge, the hull is regarded as a rigid body during operation and will not be deformed by the impact of waves. Moreover, during the lifting process, it is assumed that the sling is not deformed too much. 2. The sling quality occupies a small proportion of the entire compensation system with negligible impact. 3. Only the heave displacement of the crane load in the Z-axis direction is considered for compensation.
Firstly, the wave disturbance force is modeled. Waves on the sea surface are generated by the sea wind. The wind speed determines the height and period of each wave. The waves impact the hull, and the force is transmitted from the hull to the crane load subsequently.
According to the linear regression formula based on the data in the paper of Price and Bishop, the wave mathematical model is obtained in Formula (1) [25].
where a is the wave height (m); UT is the wind speed (m/s); Tw is the wave period (s); k is the wave number; ωk is the reciprocal of Tw.
Thus, the wave impact force and the corresponding torque can be calculated with Formulas (2) and (3) where Fx, Fy, and Fz are the wave force in x, y, and z directions of the hull (N); Mx, My, and Mz are the torque corresponding to the wave force in x, y, and z directions of the hull (N·m); ρ is the density of seawater (kg/m 3 ); g is the gravitational acceleration (m 2 /s); d is the draft (m); B is the width of the ship (m); Lship is the length of the ship's waterline (m); φ is the wave encounter angle (rad); and ωn is the encounter frequency (Hz). t is time and the above formula changes with time. Figure 5 presents the ship crane system model. From this figure, A is the hoisting point, L0 is the initial rope length of the hoisting rope, L is the rope length after the lifting and sinking displacement of the hoisting object, and α and β are the inner and outer angles of the plane. O-XbYbZb is the BODY (Body-axis coordinate system) frame, and O-XNYNZN is the NED (Northeast Down) frame. Fx, Fy, and Fz are wave forces. ΔZ is the heave displacement of the crane load. The movement formula of the crane load in the system can be obtained in Formula (4).
Taking the first derivative of Formula (4), the speed of the crane load in three directions can be obtained in the following Formula (5).
According to Figure 5, when the crane load swings from the point G to point G1, the potential energy of the YNOZN surface is set to 0 at this time, and the total kinetic energy and potential energy of the crane system can be deduced in Formula (6).
Then, the Lagrangian function La of the crane load can be developed in Formula (7).
where mG is the weight of the crane load (kg).
Using Formulas (2) and (3), combined with Newton's second law, the acceleration of the wave force on the hull in the x, y, and z directions can be obtained. Then, according to the Lagrangian Equation (8), the second-order multivariate dynamic differential equation of the crane system can be obtained in Formula (9). The inner angle α and the outer angle β can be obtained by Formula (9).
Finally, the heave displacement ΔZ of the crane load in the heave direction can be obtained in Formula (10) in accordance with the inner and outer angles and Figure 5.
ΔZ is the reference trajectory given by the heave motion of the crane load. The input is ΔZ to PSO−MPTP. Through PMSM three-phase closed-loop control, using the idea of trajectory tracking, with the help of the servo mechanism, PMSM can reverse track the heave displacement of ΔZ to maintain the position of the crane load.

Mathematical Model of PMSM
Due to the high torque-to-current ratio, high power-to-weight ratio, high efficiency, high power factor, and robustness, PMSM is adopted as the actuator of the servo mechanism in this paper, and the accuracy of motor control directly affects the efficiency of system compensation.
The voltage and flux expressions of PMSM in the dq axis are given in Formulas (11) and (12).
where ud and uq are the d and q-axis voltages (V); and id and iq are the d and q -axis currents (A); Ld and Lq are the d and q-axis inductances (mH); ψd and ψq are the flux linkage components (Wb); Rs is the stator equivalent resistance (Ω), ωe is the electrical angular velocity of the motor (rad/s); ψf is the permanent magnet flux of the rotor (Wb).
The torque equation is shown in Formula (13).
The mechanical equation of the motor is given in Formula (14) L e m T T t where Te is the electromagnetic torque (N·m); pn is the number of pole pairs; J is the moment of inertia (kg·m 2 ); ωm is the mechanical angular velocity (rad/s); and TL is the load torque (N·m).

Application of PSO−MPTP in Motor Position Control
The PID controller plays a leading role in industrial process control. However, because of the complicated working condition on the sea, the conventional PID controller has poor robustness and control performance to the parameters' variation in the PMSM position servo system [27]. Moreover, the PID controller has other problems such as error selection, side effects of integral feedback, extraction of differential terms, and so on [28]. In order to overcome these disadvantages, Active Disturbance Rejection Control (ADRC) is proposed. They are all error-based controllers to eliminate error and do not need an accurate mathematical model. Although the performance of ADRC is better than PID [29], the traditional ADRC also has some problems in the PMSM position servo system, such as a slow positioning response, poor positioning accuracy, and difficult parameter setting [30]. For the sake of solving the defects of the above controllers, MPTP, which is developed from MPC, is proposed. The only difference is the initial state. For MPC, the initial state of the optimal control problem is the current feedback value of the control system. Based on the research background of this paper, the initial state of the optimal control problem for MPTP is the value calculated in advance. Thus, this section uses the PSO algorithm to increase the accuracy and speed of MPTP quadratic programming.
The PSO−MPTP is adopted in the position loop of three-phase closed-loop control of PMSM. In principle, the crane load position signal is used as the input of the position loop of the three-phase closed-loop of PMSM. After comparing it with the feedback position, the predicted desired speed can be obtained through PSO−MPTP and tracked by classical speed and current loops. According to this basic process, the compensated motor could rotate to drag the hoisting rope and compensate for the crane load in the heave direction, which can significantly reduce the wave disturbance and keep the crane load and the ship relatively static. In order to achieve this result, several steps should be followed.

Forecast Model Heading
To establish the relationship between heave displacement and the motor, the heave displacement ΔZ caused by the shaking of the crane load should be transformed into the rotation angle of the compensated motor in Formula (15). It means that the heave displacement can be controlled by the rotation of the compensated motor.
where r is the radius of the roll (m). The kinematic equation of the crane load at point G in the NED frame is presented in Formula (16).
The expected displacement of the crane load is θr, the subscript r represents the reference quantity, and the actual displacement of the crane load is θm. The expected displacement error of the crane system can be summarized in Formula (17).
The desired displacement error should be as small as possible. Therefore, the limitation of e(t) is zero in Formula (18).
It can be seen from Formula (16) that the entire crane system can be regarded as a control system with a state quantity of θ = [θm] and a control quantity of W = [ωm]. Its general form can be represented by Formula (19).
At each moment, the jitter caused by the wave disturbance force on the crane load satisfies the above kinematic equation. It can be summarized in Formula (20).
After the Taylor series expansion of Formula (19), it can be rewritten in Formula (21) if the higher-order terms are ignored.
The state quantity deviation and control quantity deviation of the crane system are assumed to be represented by Formula (22).
Formula (23), based on the kinematics model, needs to be discretized to obtain the discrete state space Formula (24).
Formula (24) can be written in the form of Formula (25). With: In the value function, it is necessary to constrain the control increment to calculate the system's output for a period of time in the future. Formula (25) is transformed into Formula (26).
where m is the dimension of the state quantity; n is the dimension of the control quantity.

Rolling Optimization
From the calculation of (22)- (28), it can be seen that the prediction output expression of the system is Formula (29).
where Np is the prediction time domain; Nc is the control time domain. Therefore, if the current state quantity and the control increment in the control time domain Nc are known, the system output in the future forecast time domain Np can be predicted.

Rolling Optimization
For the value function to ensure that the suspension rope of the compensation motor can quickly and smoothly track the expected displacement of the crane load, it is necessary to optimize the deviation of the system state quantity and the control increment. This paper uses a value function of the form Formula (30) [31]: where Q and R are symmetric positive definite weight matrices.
In Formula (30), the control quantity is used as the state quantity in the value function. The structure is simple and easy to realize, but it also has some shortcomings. It cannot accurately constrain the control increment, and the phenomenon of sudden changes in the control quantity of the controlled system is unavoidable. It seriously affects the continuity of the control amount. In this case, the control increment is selected as the state quantity of the value function, and Formula (31) is selected as the value function.
The first item of the value function represents the error between the output value and the reference value, reflecting the system's ability to track the displacement of the reference crane load stably. The last item reflects the stability of the system's control of the crane load. The whole function minimization will lead the system to track the expected displacement of the crane load quickly and stably. This will be performed acting in the compensation motor. The value optimization function problem shown in Formula (31) can be transformed into a quadratic programming problem through some processing.
At the same time, in the actual crane system, the speed and speed increment of the lifting and lowering of the crane load can only be limited within a specific range, and it cannot be increased infinitely. It is not only necessary to select the optimal value function but also to meet some constraints related to the state quantity and control quantity of the crane system, such as Formulas (32) and (33).
Control constraint: Control increment constraint:

MPTP Optimal Solution Problem Based on PSO
In the value function, the control increment is a variable requiring solution, and the control increment constraint must be added to it. Therefore, the control constraint must be converted into the control increment constraint. The control quantity and control increment are given in the recursive Formula (34).
The above formula can be rewritten as Formula (35). With: In the actual situation, the constraint amount should be defined clearly and given in Formula (37). In this paper, the set amount is selected only to verify the feasibility of the algorithm to constrain the control amount and control variable, it can be adjusted according to the actual situation.
Combining the Formulas (29) and (31), the complete value function can be achieved in Formula (38). where ; Hk and Gk are positive definite matrices.
Finally, the MPTP optimal solution problem could be solved by PSO as in Formula (39). In fact, there may be other meta-heuristic optimization algorithms that are effective or better for MPTP, such as Firefly Algorithm (FA ), the Genetic Algorithm (GA), and Ant Colony Optimization (ACO), etc. [32][33][34].
This basic optimization process is shown in Figure 6. Formula (39), as the value function of PSO, calculates the solution of the MPTP value function corresponding to each particle, and takes the particle with the smallest value function to obtain the global optimal solution. According to Figure 6, after solving each control cycle, a series of control input increments can be obtained. The first element of the control sequence is the input in the inner loop of the motor control as the actual increment. Finally, the predicted angular velocity output value of the compensation motor at time k can be expressed as Formula (40).
At each moment, the predicted angular velocity is cyclically input into the PI controller of the motor speed loop, and then input into the current loop. Finally, the actual output value of the compensation motor angle can be obtained, which will be fed back to the position loop PSO−MPTP. The system will continue to start the prediction work at the next moment. The three-phase closed-loop control of the motor is shown in Figure 7.

Simulation Result Heading
In order to compare and analyze the results objectively, the evaluation coefficient should be defined. According to the literature and applicable situation, the evaluation coefficient Compensation Efficiency (CE), used for evaluating the compensation effect, is finally selected and defined in Formula (41) [35][36][37].
where d is the error after compensation, h is the displacement in the heave direction of the ship, and std is the standard deviation. The prediction time domain Np = 20 and the control time domain Nc = 1 are chosen for multi-step prediction of the crane load's position. All the simulation results are compared with that of conventional PI and ADRC, which are achieved according to [38,39]. In this paper, the compensation displacement is inverted in Simulink to facilitate comparison with ΔZ.
The background of this article is that regular waves are in a level 4 sea state: UT = 8 m/s, and φ = 45°. Wave force simulation results are shown in Figure 8.

Simulation under Ideal Conditions
Case 1: L = 25 m and V = 0 m/s In this case, the crane load hovers. It can be seen from Figure 9 that the inner and outer angles are not large, and the maximum displacement of the crane load in the heave direction is approximately 2.5 m. The CE of PI is 95.7%, the CE of ADRC is 98.1%, the CE of MPTP is 99.3%, and the CE of PSO−MPTP is 99.7%. Consequently, the displacement of the crane load in the heave direction is significantly reduced, and PSO−MPTP has a better performance.  Figure 10, the inner and outer angles are larger and larger, and the shaking is more serious. The swing amplitude of the inner and the outer angles are bigger than that in case 1, and the heave displacement of the crane load is significantly increased in this working condition. It can be seen from Figure 10 that the maximum displacement of the crane load in the heave direction is approximately 10.5 m. The CE of PI is 94.3%, the CE of ADRC is 95.3%, the CE of MPTP is 99%, and the CE of PSO−MPTP is 99.8%.  Figure  11, the inner and outer angles are smaller than that in the other two cases and the maximum displacement in the heave direction is bigger, up to approximately 1.8 m. The CE of PI is 95.4%, the CE of ADRC is 98.1%, the CE of MPTP is 99.2%, and the CE of PSO−MPTP is 99.9%; the heave displacement is significantly reduced. In order to test ΔW and W of PSO−MPTP and ADRC, the most severe working conditions, Case 2, are selected for testing. The simulation results are shown in Figure 12. According to this figure, ΔW and W of ADRC exceed the constraint, while ΔW and W of PSO−MPTP are within the constraint, ensuring the smooth operation of machinery and equipment and personal safety. In this section, three different working conditions are introduced when the crane is working. Under the same impact of sea waves, CE of PSO−MPTP is better than that of ADRC, and the control effect is relatively smooth and stable in all three cases. Whether lifting or lowering the crane load, the compensation system can compensate well in poor sea conditions.

White Noise
In actual work, unexpected disturbance is inevitable. The compensation system and ship would be interfered with by the harsh environment. In order to analyze the antiinterference ability of PSO−MPTP, white noise is used as the actual noise interference, and white noise and ΔZ superposition are used as the input signal of the position loop. In this section, three cases, as in the previous part, are simulated for the analysis ( From Figures 13-15, even the noise is added to the system, PSO−MPTP always presents better performances than that of ADRC. For these three cases, CEs of PSO−MPTP are 94.1%, 94.8%, and 94.2%, respectively; CEs of MPTP are 93.3%, 92.9%, and 93%, respectively; CEs of ADRC are 91.3%, 91.9%, and 91%; CEs of PI are 85.3%, 85.9%, and 87%, respectively. Although these values are relatively smaller than that in the ideal conditions, the compensation effect is still excellent and can be accepted.

Parameter Variation
In actual work, system parameters may change due to the working conditions. For example, the wave encounter angle may change when the hull encounters a wave, and the parameters of PMSM may also be verified due to the high humidity and salt fog. For Case 7, the wave encounter angle φ changes from π/4 to π/3 and impacts the hull at t = 30 s. As shown in Figure 16, when the angle φ changes, the heave displacement greatly increases and ca reach approximately 12.5 m. After the compensation under this condition, the CE of PSO−MPTP is still as high as 99.7% with only a 0.1% reduction compared with Case 2. The CE of MPTP is 98.3%, while for ADRC and PI, CEs are reduced by nearly 1-5% and equal to 94.1% and 89%. For Case 8, to verify the robustness of the PSO−MPTP, the PMSM parameters also change at t = 30 s, Rs changes from 4 Ω to 5 Ω, and Ld and Lq change from 0.07 mH to 0.08 mH. As shown in Figure 17, the track performance of PI becomes worse after t = 30 s, while the track performance of PSO−MPTP is still excellent. Although the compensation errors of PSO−MPTP and MPTP are slightly worse than that in Case 2, the CEs of PSO−MPTP and MPTP are still as high as 99.7% and 98.8%, respectively, while for ADRC and PI, CEs are only 94.3% and 90.1%, respectively.

Conclusions
This paper firstly introduced the principle of heave compensation and modeled the wave disturbance force and the ship crane system. Second, the displacement of the crane load in the heave direction was obtained through the Lagrangian equation and the differential equation of the system. Then, the PSO−MPTP was established through the motion state equation of the crane load and firstly added to the position loop. PSO was used to solve the quadratic programming in MPTP, which further improves CE and the operation speed of MPTP. PSO−MPTP provides a solid foundation for future hardware experiments. The system uses the multi-step predicted position signal of the crane load, which finishes the three-phase closed-loop of the PMSM. Finally, the compensation problem of crane load heave and displacement under the action of waves under three different working conditions was analyzed. The results show that displacement compensation can be performed well under different working conditions with a CE of more than 99%. Robustness analysis was also carried out in this paper. In the simulation, whether the system is disturbed by white noise or motor parameter variations, the CE of PSO−MPTP far exceeds the CEs of PI and ADRC and can reach more than 94%.
It can be seen that PSO−MPTP has strong robustness to disturbances for nonlinear systems and relatively smooth control effects compared to PI and ADRC. Whether lifting or lowering the crane load, the compensation system can compensate well in poor sea conditions, which guarantees the safety of the crane load and personnel to a great extent. However, as this paper only considers the heave displacement of the crane load and ignores the wind disturbance to the sling, it simplifies the system model and makes the PSO−MPTP compensation efficient. Subsequent research needs to decouple and compensate for the sway of the crane load in other directions and the wind disturbance.

Data Availability Statement:
The data that support the findings of this study are available within the article.