Reference: http://network.chinabyte.com/376/12363876.shtml
1. Introduction
Location Information plays an important role in people's daily life. In the suburbs, exhibition halls, parks and other unfamiliar environments, positioning and navigation information can provide more convenient services for the audience to visit. During the warehousing and logistics process, real-time Positioning and tracking of items will greatly improve work efficiency. In the prison environment, timely and accurate information on the location of relevant personnel can help improve the level of security management and simplify prison management.
Currently, the Global Positioning System (GPS) is the most common method for obtaining location information about outdoor environments. In recent years, with the rapid development of wireless mobile communication technology, GPS and cellular network combined A-GPS (GPS) Positioning System in the emergency rescue and a variety of location-based services (lbs, location-Based Services. However, because satellite signals are easily blocked by various obstacles, GPS, apgs, and other satellite positioning technologies are not suitable for indoor or high-rise buildings. Currently, the wireless indoor positioning technology is developing rapidly, it has become a powerful supplement to GPS.
Generally, the process of obtaining the target location information using the wireless signal strength is the process of establishing a stable ing relationship between the wireless signal strength and the location information. Existing indoor wireless positioning systems mainly use infrared, ultrasonic, Bluetooth, WiFi (Wireless fidelity), RFID (Radio frequencyidentification) and other short-range wireless technologies. Wi-Fi network-based wireless positioning technology has received much attention due to its wide deployment and low cost. Among them, the radar system developed by Microsoft is the earliest WiFi-based positioning system. It uses the RF fingerprint matching method to find the nearest K neighbors from the fingerprint database and take the mean of their coordinates as the coordinate estimation. The indoor positioning system described in [5] is located by calculating the posterior probability distribution of the target location using Bayesian formula based on the statistical characteristics of the received signals of the target location.
This article also designs and implements a wireless Indoor Location System Based on the Wi-Fi network. However, unlike the above Positioning method, this article uses a location algorithm based on weight selection, RSS is reduced to some extent. location Error Caused by random signal changes. The experimental results show that the system can achieve a good positioning accuracy (4 meters ).
2. System Design
This system provides positioning services for mobile terminal customers in exhibition halls, shopping malls, campus and other application scenarios. Given that mobile terminals are limited by computing power, storage capacity, battery power, and so on, only simple signal acquisition is completed. Positioning computing is done by the positioning server.
The architecture system 1 of the positioning system is shown in. The server is mainly responsible for locating computing and responding to terminal locating requests. Based on the server Load balancer, the web server responding to the request is separated from the positioning server running the positioning computing. The data exchange mode adopts the same data exchange mode as the client and the web server. The client depends on a specific object and is mainly responsible for collecting the wireless signal strength of the peripheral AP, and submitting signal features to the server. The server uses the signal features collected by the client for locating and computing, obtain the location estimation of the mobile terminal.
The communication between the client and the server adopts the standard HTTP protocol, which is easy to program and highly scalable. The client program functions can be expanded as needed.
Figure 1 System Network Structure
Figure 2 shows the information interaction flowchart of the positioning system. The mobile terminal submits a GET request to the Web server. The GET request contains the signal strength feature vector. After receiving the request, the Web Server delivers it to the location server in the same way and locates the server to query the database, and perform related positioning operations to obtain the location estimation of the mobile terminal.
Figure 2 information interaction between mobile terminals and servers 3. System implementation
3.1. Client Design
The system client uses the Android mobile phone.
Android is a Linux-based open-source mobile phone operating system released by Google in 2007. In recent years, the market share of mobile phones based on this platform has continuously increased. With its good openness and rich API interfaces, various applications can be easily developed.
3.1.1. Introduction to the Android system architecture
The Android system architecture is shown in Figure 3. It is built on the Linux kernel and contains various device drivers and management modules, including a very complete library and framework, including lightweight database SQLite and browser WebKit. The entire system is built on the Dalvik virtual machine, and applications are written in Java. The Android system provides a wide range of frameworks (activity management and location management) to manage the system's software and hardware resources, and integrates common applications (contacts, phone books, etc ), it also opens a wide range of APIS for users to use, and the entire platform has good openness and scalability.
Figure 3 architecture of the android System
3.1.2. Activity Lifecycle
Applications running on the Android system generally contain one or more activities, which are managed by the activity manager. activity is the basic unit for allocating and managing resources in the Android system. Each activity has its own lifecycle (figure 4 ).
Figure 4 activity Lifecycle
The oncreate () method is called at the beginning of the activity, and the onstart () method and the onresume () method are called in sequence. The activity is in the running state. If a new activity is started, the onpause () method is called (), the activity is transferred to the background. If the memory is insufficient, the active process is disabled. To exit the program, onstop () and ondestroy () are called in sequence ().
The activity Manager manages the activity by calling the preceding methods in different lifecycles. You can reload these methods as needed. Generally, the main program class inherits the activity class, and the user's function code is implemented in reloading these methods.
3.1.3. Obtain peripheral AP signal strength
This article uses the RFID fingerprint-based locating method, and mobile terminals need to obtain the image-based fingerprint feature of the surrounding AP. The Android system provides an interface to conveniently implement this function.
See Figure 5 sample code snippet. First, create a receiver (reciever) that contains the response scan result and reload the onreceive () method. This method is the callback function for receiving WiFi signals. The user-defined function is implemented here; then, use the registerreceiver () method to register the scanner with the Android system. The getsystemservice () method is used to obtain the handle for operating the WiFi device. Finally, use the startscan () method to start scanning, after the scan result is obtained, the system triggers the registered callback function to complete the user code function.
Figure 5 scan sample code
The experimental results show that it takes about 400-500 ms to receive the scan results. Considering the algorithm operation and network communication overhead of the backend server, the positioning process takes more than 500 ms.
3.1.4. Procedure
Based on the functions of the program, the client needs to complete three functions: regularly scan and obtain the signal strength fingerprint features of the surrounding AP, submit the fingerprint feature information to the server, and obtain the positioning results. Then, the interface is updated. The procedure 6 is shown in.
First, the program initializes and establishes an update callback function, obtains the WiFi Service handle, registers the callback function, and finally starts the scanning process periodic scan until the system ends the program.
The callback function first obtains the scan result, formats it as a string, and submits it to the server through the GET request. After obtaining the positioning result, it updates the display interface.
Figure 6 program flowchart
3.1.5. Obtain peripheral AP signal strength
This article uses the RFID fingerprint-based locating method, and mobile terminals need to obtain the image-based fingerprint feature of the surrounding AP. The Android system provides an interface to conveniently implement this function.
See Figure 5 sample code snippet. First, create a receiver (reciever) that contains the response scan result and reload the onreceive () method. This method is the callback function for receiving WiFi signals. The user-defined function is implemented here; then, use the registerreceiver () method to register the scanner with the Android system. The getsystemservice () method is used to obtain the handle for operating the WiFi device. Finally, use the startscan () method to start scanning, after the scan result is obtained, the system triggers the registered callback function to complete the user code function.
Figure 5 scan sample code
The experimental results show that it takes about 400-500 ms to receive the scan results. Considering the algorithm operation and network communication overhead of the backend server, the positioning process takes more than 500 ms.
3.1.6. Procedure
Based on the functions of the program, the client needs to complete three functions: regularly scan and obtain the signal strength fingerprint features of the surrounding AP, submit the fingerprint feature information to the server, and obtain the positioning results. Then, the interface is updated. The procedure 6 is shown in.
First, the program initializes and establishes an update callback function, obtains the WiFi Service handle, registers the callback function, and finally starts the scanning process periodic scan until the system ends the program.
The callback function first obtains the scan result, formats it as a string, and submits it to the server through the GET request. After obtaining the positioning result, it updates the display interface.
Figure 6 program flowchart
3.2. Server Software Design
3.2.1. Web Server
The Web server is used for external communication, receiving external requests, and returning corresponding location information.
The Web server runs Apache Tomcat 6.0.20, in response to the Network Positioning request, the corresponding software settings parameters: in the % tomcat_home % \ webapps directory to establish a directory: \ exservlet \ WEB-INF, Web. XML description file and classes folder, Web. XML files are description files, and classes stores class files processed by the background.
The Web. xml defines the name of the Service externally referenced and the corresponding class file. The content fragment is shown in figure 7.
Figure 7 Web Server Web. XML code snippet
3.2.2. Locate the server
The locating server is used to run algorithms. The hardware configuration parameter is: CPU: Intel core2 duo e7500 2.93 GHz, memory: 2 GB, Nic: Marvell Yukon 88e8057 PCI-egigabit Ethernet controller. the software configuration parameters are Windows XP Professional SP3 and Apache Tomcat 6.0.20. the corresponding software configuration parameters are similar to those of the Web server. see Figure 8.
Figure 8 Locating Server Web. XML code snippets
3.3. 3 communications between the client and the server
Both the client and the server are connected to the Internet. standard HTTP Communication simplifies the design and leaves space for future Web applications.
The server servlet is used to respond to client requests. The client only needs to submit the fingerprint information in the GET request to obtain the positioning result. Figure 9 shows the Java sample code used by the client to obtain location information from the locating server. The URL contains the IP address of the server and the fingerprint information of the request. The getconnection () method sends a GET request to the server, and the server returns the location information. After obtaining the input stream, the server reads the location information, the interface is updated to complete the communication process. The HTTP protocol is easy to implement and is suitable for multiple programming languages.
Figure 9 Communication sample code of the client for obtaining Location Information
4. Positioning Algorithm
Due to the complex indoor environment, Wi-Fi wireless signals have strong time-varying characteristics. Figure 10. the radio signal propagation and attenuation model is difficult to characterize the ing between distance and signal strength. This paper uses a method based on RF fingerprint matching to provide better positioning robustness.
Figure 10 time-varying characteristics of signal strength
The fingerprint matching method locating algorithm is based on the experimental data. It mainly includes two stages: offline training and online positioning, in the offline training phase, the task is to establish a one-to-one correspondence between the RF signal intensity vector and the client location to form a fingerprint Library (Radio map ), in the positioning phase, the acquired signal strength vectors are used to match the fingerprint library constructed during the training phase to obtain the target location estimation.
The existing method based on RF fingerprint matching mainly includes deterministic and probabilistic positioning. Among them, the deterministic Positioning Algorithm generally selects the centroid of the few points with the minimum distance from the real-time collected RF fingerprint in the fingerprint Library as the target location estimation. The computation efficiency of the deterministic positioning algorithm is high, but the accuracy is low. Probabilistic positioning algorithms generally use Bayesian Estimation Theory and use different likelihood functions, such as kernel-based likelihood functions, to calculate the posterior probability of the target location, and take the location point with the highest posterior probability as the final location estimation of the target. The probabilistic positioning algorithm has high positioning accuracy and robustness, but the calculation amount is relatively large.
In this paper, a fast selection algorithm is used. In the training phase, the fingerprint features adopt the mean value of HTTP and the method of matching the accumulated average value with the fingerprint database. This greatly reduces the complexity of the operation.
4.1. Algorithm Description
The fingerprint features use the mean value of each AP, that is:
That is, in the training phase, the data of each AP collected at the same position is averaged multiple times, and in the positioning phase, the difference is that the training phase collects as much data as possible to obtain as much information as possible, the positioning phase only collects less data and reduces positioning latency, which improves real-time performance to a certain extent.
Fingerprint matching uses quick selection. The pseudo code is as follows:
Set a selection interval for the received AP's image strength (SNR-Σ, SNR + Σ) and the empirical value of Σ for multiple experiments, find the location points that meet the range in the fingerprint database. If n location points fall into the range, the weights of these location points are 1/N, respectively, for other location points, the weights are 0. After the above processing is performed on all APs, the largest Location Point of the weights is the estimated location. If the weights of multiple locations are the same, the signal strength distance is compared to the minimum.
4.2. Algorithm Analysis
The algorithm in this paper is based on the relatively stable Statistical Characteristics of HTTP. From Figure 11, we can see that the histogram distribution of the bps value is similar to the normal distribution curve, therefore, the mean value is a certain value that represents the characteristics of the HTTP. This also avoids the deviation of the positioning result caused by the instability of a certain AP in the signal strength of a single scan.
Figure 11 Statistical Features
Time Complexity Analysis: A scan has m APs and N locations in the early training phase. m is required, and N locations are traversed each time, the time complexity is O (M * n). When the weights are the same, you must make a secondary selection. In the worst case, compare n times. The time complexity is O (n ), therefore, the total time complexity is O (M * n ).
5. Experiment
5.1. Experiment Process
The experiment was conducted on the 6-layer computing Institute, as shown in Figure 12. A total of 24 locations were collected in the corridor on both sides of the North and South, about 4 meters away, plus data at a total of 25 locations in room 645. The scan cycle is 1 S, and the number of scans is 120. It takes about one hour to collect data.
Figure 12 experiment environment
This experiment mainly verifies the positioning accuracy. Therefore, the mean value of multiple scans is used as the signal feature during positioning. A total of six locations are selected as the location points of the experiment. The number of tests is about 50, and the scan cycle is 2 S. See figure 13.
Figure 13 mobile terminal display
5.2. Experiment results
The results of each experiment position are shown in figure 14. the positioning accuracy of each random test position is high.
Figure 14 location of each experiment
6. Summary
Based on the Android smartphone platform, this paper designs and implements a mobile terminal Location System Based on Wi-Fi signals, and proposes a location algorithm based on weight selection, to some extent, the positioning error caused by random disturbance of the received signal is overcome. after testing in the actual environment, the accuracy of multiple positioning experiments is about 4 meters, and the positioning accuracy can be further improved by adjusting the AP layout. This system can be conveniently deployed in pavilions, campuses, and other practical scenarios.