Design and Implementation of Container Positioning System Based on Wireless Sensor Network

— This paper aims to create an efficient container yard management system. For this purpose, a gantry crane management subsystem was designed and implemented for container information management based on the wireless sensor network (WSN). The system consists of a set of desktop management software and three different types sensor nodes, and locates the container via the two-way symmetrical time-of-arrival (TS-TOA) positioning approach. In this way, the subsystem enhances the accuracy of container positioning without elevating hardware cost. Through the implementation of the hardware and software systems, it is proved that the user can successfully locate the container, read and update cargo information, and complete similar operations through human-computer interaction in the desktop management software. Overall, this research greatly improves the efficiency of container management at the port, and helps to reduce the operational cost and port congestion.


Introduction
Recent years has seen a continued increase in international trade volume amidst economic globalization [1]. Against this backdrop, container shipping becomes the dominant transport means of international trade, thanks to its large capacity and low freight rate [2][3]. Nowadays, over 70% of the international trade volume relies on this safe and convenient transport means. To reduce operating cost and port congestion, it is urgently needed to realize manage containers [4] at the port in an accurate and efficient manner.
There are numerous interconnected processes between the arrival and departure of a container at the port [5], such as cargo reporting, cargo unloading, and cargo placement. These processes require the processing and exchange of a massive amount of data, which disqualifies manual identification, the error-prone, cost-intensive, and manpower-driven traditional method of data transfer and processing. To make port management more efficient, some new technologies have been adopted for container positioning, namely, laser orientation and video image recognition [6][7][8][9]. Neverthe-less, largescale promotion of these technologies is unlikely due to their high cost and poor recognition rate [10].
With the proliferation of sensors, microelectronics, microelectromechanical systems (MEMS) and global positioning system (GPS), it is now possible to enhance the management efficiency of container yard with the emerging technique of wireless sensor network (WSN) [11]. The WSN refers to a wireless multi-hop network of numerous self-organized stationary or mobile sensors for sensing, collecting, processing and transferring the information on the objects within its coverage [12][13]. The network greatly extends the user's ability of information acquisition, and lays the basis for accurate positioning. The low-cost, self-organizing and distributed nature of the WSN make it a desirable tool for container yard management [15].
In light of the above, this paper introduces the structure of the WSN, discusses the application of WSN in the information management of containers [16], and designs and implements a subsystem based on gantry crane container positioning.

Structure of the WSN
As shown in Figure 1, the WSN consists of sensor nodes, data nodes, management centre and the Internet. During the network operation, the information is collected, sent and transmitted by the multiple sensor nodes, and reaches the sink node via multi-hop routing. The network nodes are embedded with the abilities to simultaneously process the data from multiple sensors, communicate with neighbouring nodes wirelessly, and obtain object location through the positioning system.

Positioning technology
The positioning technologies of the WSN are either based on distance or independent of distance. The distance-based positioning algorithms include received signals strength indication (RSSI), angle of arrival (AOA), time of arrival (TOA) and time difference of arrival (TDOA). Specifically, the RSSI, as an empirical field positioning method, is prone to disturbance in actual practice, leading to low accuracy and other problems. The AOA determines the orientation of a signal source based on the signal transmission direction. With a high cost and strict node arrangement, this algorithm only applies to small sensor networks with a few nodes. The TOA identifies the distance by measuring the transmission time of the radio signal. The TDOA calculates the distance based on time difference between transmitted and received signals. Thus, each node has to be installed with an ultrasonic transceiver. Considering the distance limit of ultrasonic transmission, this algorithm is not necessarily suitable to lowpower wireless sensor applications.
Contrary to the distance-based positioning algorithms, the distance-independent methods, a.k.a. wireless ranging methods, achieve low-cost and power-saving effects at the expense of positioning accuracy. The common wireless ranging methods are the centroid method, Dv-Hop, approximate point in triangulation (APIT) and so on. This type of methods is generally adopted for projects with low accuracy requirements. Here, the merits of the distance-based methods, especially the TOA, and wireless ranging methods were integrated into a two-way symmetrical TOA positioning approach (TS-TOA).
In the TOA, the distance is determined based on the signal transmission time. The distance between two nodes can be obtained from: where v is the transmission speed of the wireless signal; t is the transmission time between the source node and the target node.
The TS-TOA solves some inherent defects of the TOA, such as the error caused by the node running speed. In this new algorithm, all nodes are depicted as machines of five possible states: waiting state, start state, mid-state 1, mid-state 2, and end state. Since the radio signal travels near the speed of light, the signal transmission time between the nodes is extremely short.
In the TS-TOA, the distance is measured in two symmetrical steps to offset the clock drift error. The first measurement is from the source node to the target node, while the second measurement is from the target node to the source node. The flow chart of the TS-TOA is presented in Figure 2 below.  Figure 2, the source node sends a data packet with its ID to the target node at time point T1; then, the target node will receive the data packet at time point T2, process the data packet, and send a message back to the source node at time point T3; the source node will receive the message at time point T4. After a period of time delay, the target node will send a data packet to the source node, in a similar procedure as that of T1~T4. The time points in the second procedure are denoted as T5, T6, T7 and T8.
In light of the above procedures, the transmission delay of the transmission of the data packets and messages can be expressed as: where T is the transmission delay. Thus, the distance between the source and target nodes can be obtained.
Compared to other ranging methods, the TS-TOA strikes a balance between performance and cost, and fits in with the GPS of container positioning.

3
Container Positioning Management System 3.1

Container management system
The container management can be roughly divided into two parts: container distribution and scheduling, and state information management. For the first part, there are already many mature management systems available. For the second part, however, it is necessary to realize real-time information update and onsite equipment supports and cooperation. Our goal is to develop a desirable information management system for the second part. In general, the containers are handled in the yard. The yard is further split into the front yard and the rear yard. The former is for temporary stacking of containers, while the latter is a fixed site for exchanging empty and full containers. Figure 3 is an image of a normal container yard. The containers are stacked orderly in the yard. To move from one place to another, the container must be firstly hoisted by a crane and loaded onto a truck. Considering the wide range of the yard, wireless communication/positioning is a good choice to mange the onsite information. Here, the TS-TOA and GPS are combined to realize precision container positioning.
The structure of container yard management system is illustrated in Figure 4 below. In our research, the focus is given to the positionings of the nodes installed onto the gantry crane management subsystem.

Container positioning subsystem
To facilitate the management of the entire yard, a real-time database was designed for the gantry crane management subsystem, containing all the information of the container being hoisted. The container was built in with a WSN consisting of a single chip microcomputer (SCM) and a wireless transceiver chip. The chip contains the position and other information of the container. The framework of the subsystem is shown in Figure 5.
As shown in Figure 5, the subsystem encompasses the software part and the hardware part. The software part contains the desktop management software, while the hardware part includes three types of sensor nodes and the SCM programs running on them. The functions of different types of sensor nodes are as follows: The first type of node (tag node) stores the basic information of the container, including the destination and type of goods. Each container has one tag node. The second type of node (anchor node), often installed on the boom of the gantry crane, forwards the container information and helps to locate the first type of node. The third type of node (BaseStation node), located on the system interface, transmits the commands from the upper layer to the lower layer, and collects and transfers the information from the lower layer to the upper layer.
To locate a container, the subsystem needs to acquire the real-time location information of the container via wireless ranging. Since the information only depends on the relative position between the container and the gantry crane, it is necessary to employ the GPS of the upper system, acquire the container's location information in the yard, and learn about the operation area of the container, before determining the exact location of the container in the yard. Hence, the container positioning is a threestep process. First, the location information of the gantry crane is obtained by the GPS; then, the relative location information of the target container is acquired in the gantry crane management subsystem; finally, the two sets of information are combined to obtain the exact position of the target container Considering the varied computer proficiencies among the staff, a set of desktop management software was designed to provide a user-friendly interface. The gantry crane management subsystem is depicted in Figure 6.  The pyramid structure in Figure 6 reflects both the level and number of each type of nodes. The user can access and update the information by inputting commands via the desktop management software. The commands will be transformed into tags, sent to BaseStation node for recognition, and then sent to the tag node. Once the tag node completes processing the tags, it will send feedbacks in the bottom-up sequence. Finally, the user will receive the feedbacks.

4
System Design and Implementation

Hardware system
This section describes the sensor nodes of the hardware part and the SCM programs running on them. In general, the SCM programs are similar to those in Figure  5, except for a few details arising from location difference.
The small-size NanoLOC AVR Module was adopted for the hardware system. As shown in Figure 7, the module consists of controller, transceiver chip, band-pass filter, unbalanced transformer, etc. As mentioned before, there are three types of nodes in the hardware system. Despite some slight differences, the SCM programs running on these types of nodes share similar main processes, including watchdog reset, interrupt service processing, chip state update, and application processing and calling.
Two of the four main processes are relatively important: the chip state update and the application processing and calling. The former determines the waiting time of new signals, while the latter selects the program for subsequent processing of the current state. Depending on the actual needs of the system, four basic commands were designed, namely, test, read, write and measure.
The test command checks if the BaseStation has a normal connection with the computer, aiming to ensure smooth communication and acquire the communication address. The read command extracts the information recorded in a specific tag node. The write command inputs or updates the basic information of a container to a specific tag. The measure command detects the distance of a specific tag node using a specific anchor node. The flows of the latter three commands are illustrated in Figures 9~10, respectively.   During the operation, each node goes through a series of different states. For instance, the BaseStation node changes its state when the command is returned to the anchor terminal or sent from the serial port; the anchor node changes its state when the command is received from the BaseStation node or returned from the tag node; the tag node, located at the end of the network, only changes its state when receiving the command from the anchor node.

Software system
(1) Software structure The desktop management software is responsible for user-friendly human-machine interaction. Thus, the overall hierarchy must be the focus of software design. In our design, the software was divided into 3 layers (Figure 12). The top blue layer is the human-computer interaction layer, the middle yellow layer is the logical layer, and the bottom orange layer is the transmission protocol layer. In Figure 12, the MainFormHelper responds to top-level demands like search strategies; the UserInteraction refers to the state display via the interaction between the program and the user; the BaseStation sends the upper command and receives the lower feedbacks; the BaseStationEventArg records the BaseStation-related events and the associated parameters; the Constant gives a broad macro definition of constants; the TransferProtocol defines various operational functions (e.g. command decoding); the TransferEventArg records and transfers various parameters on the protocol layer.
(2) Software implementation For simplicity, the NetFramework platform was employed as the main development tool. For the user, the desktop management software is in charge of his/her interaction with the computer. Once all the sensor nodes have entered the normal working condition, the BaseStation node should be connected to the computer via USB port, kicking off the operation of the software. Then, the system will be scanned to find the BaseStation nodes available for connection. A notification will pop up if the connection is successful, and a reminder will appear if otherwise.
The system software will convert the user command into a format recognizable by the BaseStation node. Then, the BaseStation node will send the command to the lower nodes. The command will be processed and returned to the BaseStation node, and then sent back to the desktop management software. After that, the feedbacks will be transformed and displayed in the corresponding graphical interface. The main interface of the software is given below: Fig. 13. The main interface of the software As shown in Figure 13, the main interface of the software covers two parts: the operation control area and the display area. In the former area, the buttons have the following functions: Display Info: display or hide the container information in the relevant tag nodes. Once the user clicks on this button, the software will send a command to the BaseSta-tion node, asking it to perform the read operation on the corresponding tag node, and also send the number of the nearest anchor node to the BaseStation node. Then, the anchor node will execute the corresponding command. After a period of operation, the information will be displayed in the dialogue box.
Search Tag: locate the information of all tag nodes. Once the user clicks on this button, the software will automatically scan all nodes according to the following procedure. Suppose there are four anchor nodes in the system, denoted as anchors 1~4. First, the software measures the distance between anchors 1~4 and tag node 1; then, the measured results are compared to find the node with the shortest distance, that is, the superior anchor node of the tag; finally, the information is saved in the system.  Save Info: write the revised container information to the chip of the target tag node through the anchor node. If the user only clicks on the OK button, the information will only be saved in the cache.
Exit: Close the software.

Conclusions
To improve the information management of container yard, this paper designs and implements a WSN-based gantry crane management subsystem. Specifically, the container positioning subsystem on the gantry crane was created with 3 types of sensor nodes and a set of software. Relying on the TS-TOA algorithm, the subsystem enhances the accuracy of container positioning without elevating hardware cost. Besides, the GPS was adopted to help the upper system determine the exact location of the container. Through the implementation of the hardware and software systems, it is proved that the user can successfully locate the container, read and update cargo information, and complete similar operations through human-computer interaction in the desktop management software. Suffice it to say that this research greatly improves the efficiency of container management at the port.

8 Authors
Xuexin Bao, is a lecturer title and marine technology professional graduation, the main research direction for shipping management and logistics transportation, and has sustained attention in this field, has published a number of academic papers.
Dan Zhang, is a lecturer title and major in maritime technology, with a research orientation of the safety of shipping and ports, a continuing interest in this field and a number of published academic papers.