Abstract
In ocean voyages, cabin indoor localization plays a considerably important role in ship safety management. Due to the special structure of ships and the influence of internal and external environment, the mainstream indoor positioning technology nowadays is not ideal for positioning inside the cabin. In order to improve the positioning accuracy, this article proposes an adaptive
Introduction
Although the level of automation in modern ship management is increasing, regular inspections by the engine crew are still inevitable for the current ship safety management in China. The crew has a vital role in the safety management of the ship’s engine; however, due to the special working environment on the ship, it is difficult for the chief engineer to effectively supervise the duty crew. Once the crew are not in place and they cannot find dangerous problems and handled in time, it may lead to extremely serious consequences. Using indoor localization technology to manage the duty personnel in the wheel cabin can effectively reduce the accidents caused by human factors. 1
Currently, common indoor localization technologies include Ultra-Wideband (UWB) technology, 2 Radio Frequency Identification (RFID), Bluetooth, 3 Wireless Local Area Networks (WIANs), Light Detection and Ranging (LiDAR), and so on. Some of these localization technologies have been commercially available. 4 Various localization techniques have different advantages and limitations, and the selection of different localization techniques can achieve more accurate positioning according to the complexity and diversity of indoor scenes. In this article, we found that the internal environment of the ship’s cabin is different from the usual indoor environment on land, 5 and the cabin environment is more complex, with more interference factors, and the positioning equipment is easily eroded. Among the above localization technologies, Bluetooth positioning has become the first choice for indoor localization in ship environment because of its low cost, small volume, easy deployment, low-power consumption, and other advantages. 6
Indoor localization based on low-power Bluetooth (BLE) usually uses Received Signal Strength Indication (RSSI) data for real-time ranging between the local BLE node and the mobile terminal,
7
or fingerprint-based methods to obtain the location information of the mobile terminal in real-time.
8
Therefore, indoors it is usually affected by multi-path propagation and Non-Line-of-Sight (NLOS), which may affect the final positioning results. Compared with range-based positioning algorithms, RSSI-based fingerprint positioning algorithms have better localization accuracy.
9
However, traditional fingerprint algorithms mainly use
In order to improve the indoor positioning accuracy in the special environment of ships, this article proposes an indoor localization algorithm based on the adaptive
The rest parts of this article are as follows. Section “Related work” introduces the relevant work of Bluetooth localization. Section “KNN fingerprint localization algorithm based on adaptive
Related work
In recent years, with the rapid emergence of various large and complex buildings, there is an increasing demand for indoor positioning. For this reason, scholars at home and abroad have done a lot of research in the field of indoor positioning, and have also proposed a series of positioning techniques,11,12 such as Wi-Fi, UWB, BLE, and ultrasonic. Each localization technology has its own advantages and drawbacks, and this section focuses on BLE-based indoor localization technology.
Unlike typical indoor environments, indoor localization in cabin environments mainly faces the following challenges:
Complex spatial structure: there are many machines and equipment inside the cabin. Due to the particularity of the ship, the internal environment is not open, the multi-path effect caused by object shading is relatively obvious, so the ordinary fitted fingerprint data are not suitable for application to the ship’s cabin environment.
Equipment loss problem: as cargo ships sail on the sea surface for a long time, the natural environment is much harsh compared with land. Besides, the opening of the main engine will produce huge noise and vibration, which is very serious for the erosion of equipment.
Interference of magnetic field: the many electronic devices inside the engine room will affect the local magnetic field, thus reducing the positioning accuracy of the traditional method.
Therefore, considering the cost and environmental factors, Bluetooth is more suitable to serve as a signal source for indoor localization in the cabin environment rather than Wi-Fi, UWB, and so on. And many research works have been done by domestic and foreign scholars in Bluetooth indoor positioning.
Jin et al. 13 used coarse and fine granularity division to build a fingerprint library about the location mapping of RSSI sampling points, and proposed an adaptive Bluetooth fingerprint localization algorithm based on region preference. This algorithm can effectively remove points far from the localization point, but for the indoor environment with complex structure, the localization accuracy will be much reduced.
Peng et al. 14 establish a regional discrimination model for the RSSI signal, and build the RSSI vector group with the region. Then, they attain the weighted values of the RSSI signal by the Bayesian estimation. Finally, the discrimination model identifies the region of the received RSSI signal and conducted multi-point center of mass localization. The model adopts fitting data to test, and the actual localization effect is still unknown. In order to improve the detection performance of Bluetooth nodes, Mackey et al. 15 used three different Bayesian filters—Kalman filter (KF), particle filter (PF), and nonparametric information filter (NIF)—for optimization in order to improve the proximity detection performance of Bluetooth nodes. The experimental results show that the proximity detection performance is improved by 30% using Bayesian filters.
Yu et al. 16 proposed a three-dimensional (3D) indoor localization algorithm combining low-power Bluetooth with multi-sensor. It combines Inertial Navigation System (INS) with Pedestrian Dead Reckoning (PDR) to accuracy lead and estimate speed. The algorithm can achieve meter-level 2D positioning accuracy and sub-meter-level 3D height estimation accuracy in a typical indoor environment, and the combined positioning accuracy can reach 1.5 m in 75% of the cases. But they used more sensors, and some smartphones do not contain the required devices for localization, so it is difficult to achieve localization. Moreover, due to the hardware deviation, different equipment may receive the signal deviation, further calibration is required.
From the above-related work, it can be seen that the current Bluetooth-based indoor positioning mainly focuses on the construction of fingerprint library and the filtering processing of real-time signals. A number of sensing devices are often needed to carry out auxiliary localization. However, it is not possible to use multiple sensors for auxiliary positioning in the cabin environment because of the special structure of the ship. Because when installing the localization equipment, hulls may be punched holes, which damages to the hull structure and produce some safety risks.17,18 However, the positioning accuracy would be greatly reduced in the absence of multi-sensor-assisted localization. Therefore, for the special environment of ship cabin, this article proposes an adaptive
KNN fingerprint localization algorithm based on adaptive K -values
The KNN is the most commonly used indoor localization method in fingerprint localization. This method is improved on the basis of KNN. The KNN algorithm usually first selects the fingerprint data of the
where
The whole localization process is divided into two modules: the offline stage is the establishment of the fingerprint database, and the online localization module adopts the double KNN localization method with adaptive

Dual KNN localization flowchart of adaptive
The main steps of the offline phase include the following:
Step 1. Converting location areas to the Cartesian coordinate, select the coordinate origin, and construct the coordinate system.
Step 2. Collect the fingerprint data of the localization area by fingerprint acquisition equipment, and correspond the fingerprint data to the coordinates established in Step 1 to build the location fingerprint database of Bluetooth signals in the experimental environment. Each fingerprint point collects multiple sets of data, and the number can be selected according to the actual situation. In this article, 10 sets of data are collected for each fingerprint point to reduce the cost of fingerprint creation.
Step 3. Optimizes the data collected in Step 2, and only one set of fingerprint data is kept for each fingerprint point, in the optimized way as in formula (1).
The main steps of the online positioning module include the following:
Step 1. Collect the fingerprint data from different points to be measured, and the obtained data are saved in the csv file format.
Step 2. Clean and denoise the data, so that it can reduce the impact of the noise on the localization results. In this phase, multiple sets of data are collected for localization, and each set of data contains the RSSI and number of nine Bluetooth beacons. In this article, several test points are set up, and each test point collects 500–1000 sets of data, among which there are about 10% of abnormal data. These abnormal data have a large impact on the localization, so the data need to be cleaned before localization. Since the RSSI signal basically conforms to the Gaussian distribution, this article uses the great likelihood method to estimate the mean value of each RSSI signal at the point to be located, and basically eliminates some abnormal data that are large or small.
Step 3. Sets the threshold values
Assuming that there are
Step 4. Sets the threshold values
In summary, the improved algorithm proposed in this article provides an accurate and specific solution to the localization problem in the cabin environment.
First, the collected fingerprint data are cleaned and the specific parameters of its Gaussian model are estimated by maximum likelihood method. Second, the adaptive
Experiments and results
In this section, detailed experiments were conducted to evaluate the performance and localization accuracy of the adaptive
Deployment of the experimental environment
The experimental site adopted in this article is Shanghai Maritime University Marine Engine Room Integrated Lab. In the experimental environment of 23 m × 24 m × 15 m, located in the middle is the mainframe, which has three levels, and to the left of the mainframe is a three-level corridor, and to the right is a double-level corridor, arranged with various instruments and equipment necessary for ship navigation. As shown in Figure 2, the internal environment is very complicated. To ensure that the Bluetooth signal can cover the whole area, nine Bluetooth beacons are arranged according to the distribution of instruments and numbered by 1∼9 to facilitate the subsequent acquisition and identification of fingerprint data. The distribution of the numbered beacons is shown in Figure 3.

Experimental environment of the automation laboratory. (a) Experimental site of this article, (b) Bluetooth beacon, and (c) Layout of the Bluetooth beacon.

Spatial distribution of the Bluetooth beacons.
The collection and processing of the experimental data
In this experiment, the experimental environment of 23 m × 24 m × 15 m was divided into several 1 m × 1 m × 1 m areas. Each cubic meter represents one fingerprint point, and the data collected by each fingerprint includes coordinates, device number, and RSSI. The entire test area was divided into 8280 fingerprint points, but some of the fingerprint points were occupied by the machine or could not be collected, and a total of 2790 fingerprints were collected. Ten sets of data were collected for each fingerprint, totaling 27,900 sets of data, and some of the data are shown in Table 1.
Coordinates fingerprint data from (1,1,3).
After the establishment of the fingerprint library, the 10 sets of data for each point are processed by formula (1) to reduce the time of localization matching. The 1000 groups RSSI values to be measured are used as test data. We find that the Bluetooth RSSI values at the same position is similar to the Gaussian distribution, that is, the probability of the received RSSI values meets a Gaussian distribution model when the distance is constant. The data distribution for multiple tests is shown in Figure 4, and the probability density function is shown in formula (5)
Among them,

The RSSI probability distribution of multiple test points.
Comparison and analysis of the experimental results
Result analysis of the KNN algorithm
In order to verify the performance of the improved algorithm in the cabin environment, comparative experiments are done in this article between the KNN algorithm and the KNN algorithm with adaptive

Different metric distance localization changed with
In the KNN algorithm test experiment, several points to be localized were selected and 1000 sets of RSSI fingerprint data were collected at each point. One of the experimental results is shown in Figure 6. In this experiment,

KNN localization result. The red is the
Result analysis of KNN algorithm with adaptive K -values
In this article, the specific steps of the improved KNN algorithm are presented in section “KNN fingerprint localization algorithm based on adaptive

First positioning results for different values of R1.

Final positioning results for different values of R2.
In the improved KNN algorithm, the stability of localization is improved by adopting the adaptive

(a) First adaptive KNN result and (b) second adaptive KNN result. The red is the
In this article, the trajectory positioning was performed in the automated ship cabin laboratory to test the positioning performance of the improved KNN algorithm. The track is shown in Figure 10 (blue is the actual trajectory and green is the positioned trajectory). The experimental results show that the positioned trajectory is basically consistent with the actual trajectory. Unlike typical indoor environment, the environment of the wheel cabin is more complex and more disturbed, while the improved KNN algorithm has a better localization performance in the cabin environment. In most cases, the localization error is within 1.41 m. Compared with the single KNN localization method, the improved KNN positioning algorithm significantly improves the indoor positioning accuracy and stability in the cabin environment.

Positioning trajectory. Blue is the actual trajectory, and green is the positioned trajectory.
Overall analysis
In this article, the KNN algorithm is improved and the improved algorithm is verified in a shipboard environment. The results are shown in Table 2.
The positioning accuracy of the improved KNN algorithm.
KNN:
To eliminate the problem of poor stability of the single
Conclusion
In order to improve the indoor positioning accuracy in the ship cabin environment, this article proposes a cabin indoor localization algorithm based on the adaptive
This article provides a feasible solution for indoor localization in a cabin environment, and fills the research gap of indoor positioning in cabin to a certain extent. But there are still some problems and defects. For example, the pre-construction fingerprint database takes a lot of time, and with the increase locate the scene, fingerprint matching time will be longer and longer. These are all the focus of future research. The future work in this article is to further improve the indoor localization accuracy in the cabin environment. We are considering whether it can simulate the fingerprint information in the cabin environment to establish a fingerprint attenuation model and automatically generate a fingerprint database, so that the cost of fingerprint construction will be reduced. In addition, a region of interest will be selected to reduce fingerprint matching time and increases the location accuracy.
Footnotes
Handling editor: Peio Lopez Iturri
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported in part by the Innovation Program of Shanghai Municipal Education Commission (grant no. 2021-01-07-00-10-E00121) and in part by the Ministry of Transportation and Communications (grant no. Z20208141).
