eXogenous Kalman filter ( XKF ) for Visualization and Motion Prediction of Ships using Live Automatic Identification System ( AIS ) Data

This paper addresses the problem of ship motion estimation using live data from Automatic Identification Systems (AIS). A globally exponentially stable observer for visualization and motion prediction of ships has been designed. Instead of using the extended Kalman filter (EKF) to deal with the kinematic nonlinearities the eXogenous Kalman Filter (XKF) is applied and by this global stability properties are proven. The proposed observer was validated using live AIS data from the Trondheim harbor in Norway and it was demonstrated that the observer tracks ships in real time. It was also demonstrated that the observer can predict the future motion of ships. The motion prediction capabilities are very useful for decision-support systems since this can be used to improve situational awareness e.g. for manned and unmanned autonomous ships that operate in common waters.


Introduction
AIS is a global system, which allows ships to view marine traffic in their area and to be seen by other ships (Automatic Identification System, 2018).Vessels are equipped with a dedicated VHF AIS transceiver, which allows local traffic to be viewed on a chartplotter or computer monitor while transmitting information about the ship itself to other AIS receivers, see Fig. 1.
Ships can be tracked by AIS base stations located along coast lines or satellites when far away from the base stations.The International Maritime Organization (IMO) requires AIS to be fitted aboard international voyaging ships with 300 or more gross tonnage.

AIS data
There are 27 AIS messages with different priority that are transmitted using class A and B transceivers (US Coast Guard, 2018).Class B transceivers are smaller, simpler and lower cost than Class A transceivers.For ship tracking and motion prediction the position reports of messages 1, 2, 3 and 18 are particularly useful.These messages contain longitude, latitude, speed over ground (SOG), course over ground (COG), yaw rate, true heading etc.
The AIS data are transmitted at asynchronous time samples using TCP/IP of the Internet protocol suits, which implies that a state estimator must take into account that the measurement update times are different from the sampling time.Several multi-rate fil-Figure 1: AIS receiver and software components for motion prediction.
ter approaches such as Andrisani and Gau (1987) and Cristi and Tummala (2000) can be used to overcome this problem.In this article, a novel approach for handling asynchronous data is applied.The system model of a discrete-time Kalman filter (KF) can be propagated at 30-60 Hz to predict the ship's motions.Since the asynchronous AIS measurements are received and decoded at a much lower frequency than the sampling frequency, the update time of the corrector can be chosen in multiples of the sampling frequency (Gelb, 1974).

Motion prediction
Live AIS data can be used to predict the motion of ships using a linear discrete-time KF as shown by Jaskolski (2017).Our approach is a nonlinear observer with proven global exponential stability (GES) properties using a generic ship model, which does not require information about the ship model parameters.The discrete-time EKF implementation for the same model is found in Fossen and Fossen (2018).However, the EKF only guarantees local stability.
Statistical methods have been applied to AIS data for maritime traffic probabilistic forecasting (Xiao et al., 2017), analysis of motion patterns (Ristic et al., 2008), and position prediction using historical AIS data (Mazzarella et al., 2015).
Game technology is used more and more in engineering applications for simulation, 3-D visualization and virtual reality (VR).The human eye requires 30-60 frames per second (FPS) to make pictures appear as a smooth film.This also applies to a pilot who operates an unmanned surface vehicle (USV) using a 3-D visualization system.Hence, the position and course of the AIS ships must be estimated at 30-60 Hz to satisfy human constraints.
An observer will also improve the accuracy of the AIS data by removing measurement noise.Even more important is that the dynamic model of the state estimator makes it possible to predict future ship motion at least for a limited time horizon.This is very useful in a simulation and visualization environment for decision support where the operator would like to observe actual and future movements of ships in his operational space.A typical scenario is manned ships and USV operating close to each other.In such cases, the remote control centre would like know present and future movements of all ships operating close to the USV in order to decide if human intervention is necessary to avoid a collision.In addition, autonomous ship operations will benefit from having accurate ship motion predictors in order to improve situational awareness.

Global exponential stability and robustness
The main contribution of the article is the design of a GES observer for live AIS data as illustrated in Fig. 1 using the XKF (Johansen and Fossen, 2017).GES is an important property since it guarantees exponential convergence to zero of the estimation errors.In addition, GES implies that the observer is robust to large uniformly bounded disturbances (Khalil, 2014).On the contrary, the EKF only guarantees local stability.The design objectives of the XKF are: • Ship motion prediction: Decision-support and systems and USV pilots would like to receive the current and predicted positions of all AIS ships operating in the vicinity of their vehicle.
• AIS estimates at 30-60 FPS for visualization: A fixed frame rate of 30-60 FPS is necessary for smooth 3-D visualization of ship operations.Hence, the estimator must be designed for asynchronous measurements and smoothing of data between successive measurements.
The XKF is implemented and tested using live AIS data obtained from a VHF AIS receiver.The AIS data is decoded in real time using a parser, which feeds the decoded ship motion measurements to the XKF, see Fig. 1.The performance of the XKF is demonstrated in a ship motion prediction scenario.The motion predictor clearly demonstrates that live AIS data can be used to accurately predict future ship positions.

Ship model
Let the North-East positions and course angle be denoted (x, y) and χ, respectively.Consequently, a ship moving at forward speed U and course χ is given by Fossen (2011): The linear acceleration a and course rate r are ship dependent and unknown.For slow AIS measurements (i.e.update frequencies less than 0.5 Hz) it is recommended to choose the inputs as a = r = 0.
AIS measurements faster than 0.5 Hz can be used to compute estimates r c and a c of a and r, respectively.The estimates must be filtered in order to avoid rapid changes.Moreover, where T a and T r are user defined time constants.The saturation function sat(x) ensures that |x| ≤ x max , which adds robustness to AIS wildpoints.Let the last three AIS speed and course measure- Unfortunately, the data is not evenly spaced, that is h 1 = h 2 .To deal with this problem, a backward difference approximation of the first derivative for nonevenly data is derived (see Appendix A for details): where

AIS measurements
The following AIS measurements are used by the XKF: • SOG and COG (states U and χ).
• Longitude l and latitude µ.
As shown in Farrell (2008), longitude and latitude can be mapped to Cartesian coordinates using the World Geodetic System (WGS-84), which is the standard coordinate system for the Earth.
For local navigation and visualization it is convenient to use a flat Earth approximation based on WGS-84.The procedure is outlined below.

North-East positions from longitude and latitude (WGS-84)
Assume that the flat Earth coordinate origin is located at longitude and latitude (l 0 , µ 0 ) and define: The Earth radius of curvature in the prime vertical R N and the radius of curvature in the meridian R M are Farrell (2008): where a = 6 378 137 m is the semi-minor axis (equatorial radius) and e = 0.0818 is the Earth eccentricity.Small changes in the North and East positions (x, y) are computed as: where atan2(y,x) is the 4-quadrant inverse tangent confining the result to [−π, π].

The eXogenous Kalman filter
It is well known that the linear KF is GES and optimal in the sense of minimum variance under some conditions.However, its nonlinear extension, known as the EKF, linearizes the system about the estimated state trajectories.Unfortunately, this can lead to stability problems.Johansen and Fossen (2017) propose to use a cascade of two observers where the first observer generates a globally convergent state estimate, which can be used to design a linearized KF.This approach is referred to as the eXogenous Kalman filter (XKF) and it is illustrated in Fig. 2. The first stage is to construct a deterministic observer with global stability properties.This is done without optimality consideration and the presence of unknown measurement errors and process disturbances.The estimate, x, from the kinematic observer is an exogenous signal used in a linearized KF.
As shown by Johansen and Fossen (2017), the cascade of the kinematic observer and KF will inherit the global stability property of the kinematic observer and also benefit from the local optimality properties of the linearized KF.

Stage 1: Kinematic observer
The first step is to design a fixed-gain kinematic observer for the XKF in Fig. 2 based on the ship model in Section 2.1.The purpose of the kinematic observer is to generate a smooth globally convergent signal x for the linearized KF.This can be done by using four fixed-gain observers copying the dynamics (1)-( 4): where K i > 0 (i = 1, 2, 3, 4).It is straightforward to verify that the equilibrium point of the error dynamics

Stage 2: Linearized Kalman filter
The next step is to express the nonlinear system model ( 1)-( 6) as: where w and e are Gaussian process and measurement noise, and the only nonlinearity is the vector field f (x).
The XKF design process involves constructing a linearized KF about x = x using a Taylor-series expansion: The Kalman gain is computed as: Theorem 1 (XKF) The fixed-gain kinematic observer ( 16)-( 19) in cascade with the linearized KF ( 22)-( 23) as shown in Fig. 3 renders the equilibrium point of the two-stage observer error dynamics GES 1 .

Sketch of proof:
A detailed version of the proof is found in Johansen and Fossen (2017, Theorem 2.1), which makes use of three Assumptions A1-A3.The kinematic observer and linearized KF is a cascaded system.The equilibrium point of the error dynamics of the kinematic observer in Section 3.2 is GES.Hence, Assumption A3 clearly holds.This also implies boundedness of F(x) due to the smoothness of the vector field f (x).Hence, Assumption A1 holds since the LTV system (F(x), B, H) is uniformly completely observable and controllable.Finally, Assumption A2 is satisfied by choosing the KF tuning matrices P(0), Q and R symmetric and positive definite.Since Assumptions A1-A3 are satisfied, Johansen and Fossen (2017, Theorem 2.1) guarantees that the equilibrium point of the cascaded system inherits the GES property of the kinematic observer.

Ship motion prediction
The ship motion predictor is designed by using a discrete-time version of the system model ( 1)-( 6).
Consequently, an N -step predictor with k = 1, ..., N using Euler's integration method with sampling time h 1 As shown by Bhat and Bernstein (2000), mechanical systems with rotational degrees of motion cannot be globally stabilized by continuous feedback due to the topological obstruction imposed by SO(3).Hence, the GES property is based on the assumption that χ ∈ R and not [−π, π].However, if χ is mapped to [−π, π] when implementing the XKF, Theorem 1 still guarantees local exponential stability. is:

Implementation aspects for asynchronous AIS data
The AIS data is transmitted using the TCP/IP protocols.Hence, the XKF must handle delayed measurements, asynchronous communication as well as loss of packets.The XKF ( 16)-( 19) and ( 22)-( 23) will run at a fixed time step, typically 30-60 Hz for 3-D visualization applications.Since, the AIS data are transmitted at asynchronous time samples the XKF is implemented in discrete time using the predictor-corrector representation (Gelb, 1974).Moreover, • The discrete-time system model of the XKF is propagated at 30-60 Hz to predict positions, velocity and course angle.
• The state vector is updated and corrected at each time an AIS measurement is received.This happens at much lower frequency (typically 1-2 Hz).Hence, the update times of the corrector must be chosen in multiples of the sampling frequency.
Let + and − denote the states after and before the measurements are applied.Hence, the predictorcorrector representation for ( 22)-( 23) and ( 27) become: Corrector (AIS measurements at 1-2 Hz): is the Kalman gain matrix.
Predictor (30-60 Hz for visualization): where h is the sampling time.Notice that xk is computed using the kinematic observer.

Experimental validation
This section shows how live AIS data can be decoded and used for ship motion prediction and visualization.

Live AIS data
The observer and its prediction capabilities are validated using live AIS data from the Trondheim harbor in Norway.Live AIS data were obtained using a

High-speed passenger ferry MS LADEJARL
The high-speed passenger ferry MS LADEJARL was chosen in the case study, see Fig. 5.The ship has MMSI number 257 082 200.Detailed information about the ship can be obtained by using the Marine Vessel Traffic webpage: http://www.marinevesseltraffic. com/2013/06/mmsi-number-search.htmlwhere the MMSI number uniquely identifies the ship: The top speed of the ship is 37 knots (19.0 m/s).Data was logged for approximately two hours such that the ship had time to move out the fjord via Lensvik towards the North Atlantic and return to Trondheim harbor, see Fig. 6.

Motion prediction
The linearized KF was implemented in discrete time at 50 Hz using the predictor-corrector representation (Gelb, 1974) and Euler's integration method.
The AIS course angle measurement is in many cases unreliable and it is not reported for all ships.Consequently, the XKF was implemented by computing the COG using the traveled path.The standard way to implement this is to use two data points at times t m and t m−1 to compute: Sensitivity to wildpoints and corrupted measurements is handled by using a relative large value for the yaw rate time constant T r in the estimator.This explains why the yaw rate time constant T r = 50 s is chosen 5 times larger than the surge acceleration time constant T a = 10 s.Two cases as shown in Fig. 6 were considered: • Case 1: 30 seconds motion prediction just before the ship arrives Lensvik harbor.
• Case 2: 60 seconds motion prediction on the route to Trondheim harbor.
As seen from Figs. 8-9 the ship positions are predicted quite well both for the 30 s and 60 s cases.The first ship indicates were motion prediction is started and the second ship shows the pose of the ship after 30 and 60 s, respectively.The position accuracy will of course be best for ships on a straight course.However, the motion predictor should be restarted each time a new measurement is received such that it automatically adjusts to turning maneuvers.
Figs. 8-9 also show the difference of the kinematic observer (red) and the XKF (cyan).The red curve is used for linearization of the Kalman filter.As expected the accuracy of the kinematic observer is not so good as the XKF since this is a simplified decoupled fixed-gain observer.However, the red trajectory is accurate enough to provide the XKF with a trajectory for linearization.
An obvious advantage of the XKF to the fixed-gain kinematic observer is that the covariance of the esti-mation errors are computed.Hence, it is possible to include outlier detection based on growth in the covariance estimates.Fig. 8 also indicates that the performance of the XKF is better than the fixed-gain kinematic observer.Similar observations were made in the case studies presented by Johansen and Fossen (2017).The computational requirements typically increase with 25 % when using the XKF instead of the fixedgain kinematic observers.This is not a problem when using state-of-the-art computers.
Fig. 10 shows the measured signals (circles) and the estimates in red and cyan.As before, red denotes the kinematic observer and cyan is the XKF.The smoothing effect and increased accuracy of the XKF is more visible in Fig. 8 where a clear performance improvement is observed.

Conclusions
The problem of estimating the motion of ships from live automatic identification system (AIS) data has been addressed.To the authors knowledge, this problem has not been addressed previously using nonlinear observer theory.For this purpose a nonlinear globally exponentially stable (GES) observer for visualization and motion prediction of ships has been constructed.
Instead of using the well-celebrated extended Kalman filter (EKF) algorithm, the eXogenous Kalman Filter (XKF) has been applied in order to guarantee global stability properties.
AIS data are transmitted from ships globally and a VHF AIS receiver was used to pick up the coded signals, which are in ASCII character format as specified by the National Marine Electronics Association (NMEA).The AIS sentences were successfully decoded using a parser to obtain real-time ship position, course and speed measurements.
Finally, the proposed observer was validated using asynchronous AIS data from the Trondheim harbor in Norway and it was demonstrated that the observer estimates ship position, velocity and course in real time with good accuracy at 50 Hz, which is a good frame rate for 3-D visualization.It was also demonstrated that the observer could predict future ship positions and thus be used in decision-support systems.Typical applications of AIS data are motion prediction and intelligent situation awareness of autonomous ship operations as well as operation of manned and unmanned ships together in restricted areas.

A. Backward difference operator for non-evenly spaced data
The backward difference approximation of the first derivative for non-evenly spaced data at times t k , t k−1 and t k−2 is derived by using the Taylor-series expansions: where h 1 = t k −t k−1 and h 2 = t k−1 −t k−2 .Multiplying (35) with and subtracting (36) from (35) makes F (k) vanish.Hence, the error will be of order O((h 1 + h 2 ) 3 ).This gives Solving for F (k), finally gives

Figure 2 :
Figure 2: The XKF as a two-stage estimator.The kinematic observer produces an estimate x used in a linearized KF, which returns the improved estimate x.

Figure 3 :
Figure 3: Signal flow of the eXogenous Kalman filter.

Figure 4
Figure 4: 3-D visualization of two AIS detected ships moving down the Nidelven river in Trondheim using the Unity game engine (Unity, 2018).
VHF antenna.Approximately 30 ships were close to the harbor when logging the data.The North-East coordinate origin was chosen at Munkholmen island, approximately 2 km west of Trondheim harbor.The longitude and latitude measurements were transformed to xy−positions using the WGS-84 reference systems as outlined in Section 2.3.Figure4show the live positions of two ships moving down the Nidelven river in Trondheim.

Figure 7
Figure 7: 3-D visualization of a catamaran passenger boat in the Trondheim fjord using the Unity game engine (Unity, 2018), and the Hydroform Ocean System and Terraland plugins from the Unity Asset Store (http://assetstore.unity.com).The green arrow shows the predicted path of the vessel.
Fig. 7 is a 3-D visualization of catamaran vessel in the Trondheim fjord.The green arrow shows the predicted path of the vessel.

Figure 9 :
Figure 9: The 60 seconds predicted motion of MS LADEJARL when on route to Trondheim harbor.The red and cyan lines are the kinematic observer and XKF, respectively 243

Figure 10 :
Figure 10: Course angle χ [deg], speed U [m/s], x-position [km], y-position [km], acceleration a [m/s 2 ] and yaw rate r [deg/s] versus time s.The circle denotes the live AIS measurements, while the red and cyan lines are the kinematic observer and XKF estimates, respectively.The period of inactivity corresponds to the stop in Lensvik harbor.

xy-plot: Kinematic observer (red) and XKF (cyan)
39)Figure8: The 30 seconds predicted motion of MS LADEJARL just before the ship arrives Lensvik harbor.The red and cyan lines are the kinematic observer and XKF, respectively