Indoor positioning method and system based on WiFi signals
Technical Field
The invention belongs to the technical field of communication, and particularly relates to an indoor positioning method and system based on WiFi signals.
Background
With the development of smart phones and the internet, the use of mobile terminals to realize position location greatly facilitates the daily life of people. In contrast, GPS outdoor positioning technology based on satellites is very mature, and is difficult to be applied indoors due to the shielding of buildings from GPS signals and the complex indoor environment. The existing indoor wireless signals such as WiFi and Bluetooth are generally selected as the source, and the position estimation is carried out according to a geometric measurement method or a fingerprint positioning method.
The WiFi signal-based position fingerprint positioning algorithm is mainly divided into two stages, namely an offline sampling stage and an online positioning stage. In the off-line sampling stage, the construction of a fingerprint database is mainly completed, namely, the association between the physical position in the positioning area and the wireless signal characteristics is established. The method comprises the steps of using a smart phone pair, firstly selecting a series of reference points for area division grids, using the smart phone to collect WiFi Signal intensity of each Access Point (AP) which can be Received at the position of the reference Point, carrying out certain pretreatment on original data to obtain Signal intensity (RSS) corresponding to each reference Point, and storing the RSS into a database according to a certain format to be used as a fingerprint map. In the on-line positioning stage, the fingerprint data of the point is collected by the mobile phone at the position to be measured, and the current position coordinate is estimated by matching the data in the fingerprint map through a certain matching algorithm, wherein the schematic diagram of the algorithm principle is shown in fig. 1.
In the indoor environment, wireless signals are influenced by reflection, refraction, diffraction and the like, signal attenuation is irregular, the environment is complex and changeable, the fluctuation of the wireless signals can be caused by the movement of a human body and the shielding of obstacles, and the AP signals are unstable. Therefore, certain denoising and screening preprocessing needs to be performed on the signals in the off-line stage. In the prior art, the matching algorithm mainly comprises a deterministic algorithm such as a nearest neighbor algorithm, a probabilistic algorithm such as a Bayesian algorithm and the like, and in recent years, algorithms such as a neural network, a support vector machine and the like are applied to the indoor positioning fingerprint matching process. However, different APs of these existing indoor positioning methods based on WiFi fingerprints fluctuate at various reference points due to various factors, so that signals that are too unstable are not suitable for being recorded in a database as reference APs, and because different APs received at each position are different in distance and position, the strength and stability performance are different, and therefore, the contribution to the positioning algorithm is different.
In order to solve the problem that the deterministic data in the fingerprint database cannot reflect the real distribution condition of the WiFi signals under the influence of multipath effect and environment, a plurality of methods based on probability statistics are proposed, and a Nibbel system proposed by the university of California in the United states uses the signal-to-noise ratio as a signal characteristic parameter to construct a fingerprint database; still another scholars has proposed a Horus system that uses a probabilistic model to store RSS gaussian distribution fits in a fingerprint map. Although the method records the volatility of WiFi into the fingerprint database as the characteristic through the probability model, the real situation of signals in the environment is reflected more comprehensively, the storage cost of the database is increased, and the complexity of a subsequent online matching algorithm is increased.
Disclosure of Invention
Aiming at the defects of the prior art, the invention aims to provide an indoor positioning method and system based on WiFi signals, and aims to solve the problems of unstable AP signals and complex matching algorithm of the existing positioning method.
To achieve the above object, according to one aspect of the present invention, there is provided an indoor positioning method based on WiFi signals, comprising an offline sampling phase and an online positioning phase, wherein the offline sampling phase comprises:
dividing a region to be positioned into grids, taking grid points as reference points, and acquiring original data information of each AP received at each reference point;
preprocessing original data information to obtain screened data information;
taking the signal intensity and standard deviation of each AP received at each reference point in the screened data information as position characteristics;
establishing a position fingerprint database by using the position coordinates and the position characteristics of the reference points;
the on-line positioning stage comprises:
collecting WiFi signals of all APs received by a position to be detected to obtain a signal vector of the position to be detected;
calculating characteristic Euclidean distances between the signal vector of the position to be detected and the position characteristics of each reference point in the position fingerprint database;
selecting four reference points with the minimum characteristic Euclidean distance as candidate reference points;
and according to the position coordinates of the candidate reference points, combining the characteristic Euclidean distance and the actual physical position to weight and calculate the coordinates of the position to be measured.
Preferably, the raw data information includes coordinates of the reference point, name of each AP received, MAC address, signal strength.
Preferably, the preprocessing of the original data information includes filtering out the time when the RSS value jumps to 0, sorting the fixed APs installed in the screened environment according to the AP signal strength from high to low, filtering out the APs with the signal strength lower than a preset value, and filtering out the APs with the stability lower than the preset value.
Preferably, the stability is the standard deviation of the AP signal strength values.
Preferably, the step of establishing the position fingerprint database by using the position coordinates and the position features of the reference points comprises establishing a mapping relation between the position coordinates of the reference points and the position features of the positions, generating a record, and storing the record into the database.
Preferably, the location fingerprint database includes coordinates of the reference points, a name of each AP, a MAC address, a signal strength mean, and a standard deviation of each AP.
Preferably, assuming that the position to be measured receives signals of n APs, the signal strength at the jth AP is RSSj. For the ith sample point position, the signal strength at the jth AP is rssij. Because the performance capabilities of the APs received at each position are different, after different weights are given to each AP according to the signal strength and stability of the AP, the characteristic Euclidean distance is calculated, and the calculation formula is as follows:
wherein d isiIs the weighted characteristic Euclidean distance, w, of the ith sampling point in the position fingerprint database and the position to be measuredijCalculating the weight of the jth AP at the ith sampling point position according to the standard deviation of the signal intensity of the AP, and then calculating the weight according to the following formula:
after selecting candidate reference points, calculating the sum of the physical position coordinate distances of each point and other points in the 4 candidate reference points, and the ith candidate reference point is dliCalculated using the formula:
consideration of characteristic Euclidean distance diPhysical distance dl from reference pointiAs the ith candidate reference pointBy a weighting factor wi:
And finally, calculating the position coordinates of the point to be measured as follows:
based on the principle of a deterministic algorithm, the standard deviation of WiFi signal fluctuation is extracted as a characteristic value representing the stability of the WiFi signal fluctuation, the method is respectively improved in an offline sampling fingerprint database construction stage and an online positioning fingerprint matching stage, fuzzy and redundant unstable access points are filtered out through an AP selection algorithm, the expressive ability information of APs at all positions is fully utilized in the positioning stage, characteristic Euclidean distances are calculated in a weighted mode, and the accuracy of the positioning algorithm is improved under the condition that the database cost is saved as much as possible.
According to another aspect of the present invention, there is provided an indoor positioning system based on WiFi signals, including:
the off-line sampling module is used for obtaining a position fingerprint database containing reference point position coordinates and position characteristics;
and the online positioning module is used for acquiring the coordinates of the position to be detected by acquiring the position signal to be detected and inquiring the position fingerprint database.
Preferably, the offline sampling module includes:
the acquisition unit is used for acquiring original data information;
the screening unit is used for screening the original data information acquired by the acquisition unit;
and the construction unit is used for constructing a position fingerprint database by using the screened data information.
Preferably, the online positioning module comprises:
the calculating unit is used for calculating the characteristic Euclidean distance of the position to be measured;
and the positioning unit is used for positioning the coordinates of the position to be measured according to the coordinates of the position of the reference point.
Through the technical scheme, compared with the prior art, the invention can obtain the following advantages
Has the advantages that:
1. the invention improves the data preprocessing algorithm in the off-line fingerprint database construction stage, filters out AP abnormal points to obtain reliable WiFi signal strength which is used as a fingerprint to be stored in the database, and provides an AP selection algorithm, selects reliable access points which can effectively provide positioning reference, filters out fuzzy and unstable APs, improves the positioning precision and reduces the size of the position fingerprint database;
2. under the condition that the pressure of a database and the complexity of online matching calculation are not increased as much as possible, standard deviation is introduced to serve as a characteristic basis for measuring the fluctuation characteristic of the AP, the strength and the stability of the AP at the position are comprehensively considered by a later-stage online matching algorithm to serve as contribution values of the AP to positioning, and different weights are given to calculate characteristic distances according to different expressive forces;
3. when the reference point estimation coordinates are selected, the characteristic ambiguity is considered, the contribution of each reference position to the coordinates of the point to be measured is different, the large error is introduced by simply calculating the coordinate mean value, the actual physical distance and the characteristic distance of the reference point are comprehensively considered, and the weighting algorithm is provided for estimating the coordinates to be measured.
Drawings
Fig. 1 is a schematic diagram of a prior art WiFi signal based indoor positioning method;
fig. 2 is a schematic flowchart of an indoor positioning method based on WiFi signals provided by the present invention;
fig. 3 is a schematic diagram of distribution of area reference points in the indoor positioning method according to the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
The main scheme of the invention is that an AP which is not suitable for reference is filtered by an AP selection algorithm in an off-line sampling stage, the fluctuation standard deviation of the AP is used as the characteristic for measuring the stability of the AP, and the fluctuation standard deviation and the RSS intensity value after processing are stored in a corresponding position together to be used as a fingerprint; in the on-line positioning stage, the strength and stability of different APs at each position are comprehensively considered as their contribution factors, the weighted AP characteristic distance is calculated, a suitable number of reference points are selected for the position to be measured, and finally the contribution degree of the reference points is analyzed to realize the weighted coordinate estimation, as shown in fig. 2, the specific steps are as follows:
step S1: dividing a region to be positioned into grids, establishing a coordinate system, dividing space coordinates according to the grids, taking grid points as reference points, collecting signal intensity values from each AP received by the position for multiple times at each reference point position, wherein the collected information comprises reference point coordinates, names of the APs, MAC addresses and the signal intensity values.
1.1 selecting a reference point of a positioning area: selecting the area shown in fig. 3 as a positioning area to establish a two-dimensional coordinate system, performing grid division on the area according to a certain spacing distance, wherein the division density is determined according to the size of a scene and the capacity of a database, in the example, the spacing between reference points is selected to be 0.8m, a grid center is selected to allocate position coordinates according to the coordinate system, the grid point is used as a reference point sampling position, and the reference point position information is represented by (id, x, y), wherein id represents the serial number of the point in a fingerprint database, and x and y respectively represent the position coordinates of the point in the coordinate system.
1.2, reference point original data information acquisition: the personnel hand-hold the smart machine terminal, each reference point of selection in last section in proper order uses the collection software, and the signal of all AP that can accept is sampled many times in each position department a period, and the collection frequency is relevant with terminal equipment, and this example sets up sampling frequency 1Hz, and 10 minutes are sampled in succession at every sampling point department, and the information that signal acquisition obtained includes: the name of the AP, the MAC address, and the signal strength.
Step S2: the raw data information acquired in step S1 is preprocessed. Due to the fact that the WiFi signals are affected by multiple factors such as environment multipath effect, personnel walking, building shielding and the like, the strength of the acquired WiFi signals fluctuates along with time. The original data needs to be preprocessed to remove noise influence, and the position characteristics needing to be stored in the position fingerprint database are obtained through calculation.
The specific process is as follows:
2.1 at some time, the signal of a certain AP is unstable and jumps to 0, which indicates that the signal at the time is too weak and the device can not detect the signal, and the value at the time is rejected.
2.2 at a certain reference point, for the ith AP received, calculating the average value of the signal intensity in a period of time after filtering and recording as
2.3 calculating the Signal Standard deviation σ for each AP at each reference Point locationiAs a basis for measuring the stability, the standard deviation for the ith AP is calculated by the following formula:
wherein,represents the jth signal strength value, N, from the ith APiThe number of APs.
Step S3: an AP selection algorithm is used for filtering out access points which are not suitable for reference, such as personal hotspots with large fluctuation, weak signals and instability, and the like, and the specific operation steps are as follows:
3.1 filtering out some personal hotspots by SSID names, selecting a fixed access network in the environment as an AP to be screened, and then sequencing the AP from strong to weak according to the signal strength value.
3.2 setting initial AP number K value and initial RSS intensity threshold ThrssTaking the first K APs as available APs, and comparing the signal of the Kth AP with ThrssThe size is larger than the value, the value enters 3.3, and the value is smaller than the value enters 3.4.
3.3 continue comparing RSS and Th of the k +1 Th APrssIf the value is larger than the preset value, the comparison is continued until the value is smaller than 3.4.
3.4 setting fluctuation threshold ThsdCalculating the standard deviation of all the selected APs in the previous step, when it is less than ThsdThen it is the AP that is finally selected.
Step S4: constructing a position fingerprint database: and establishing a mapping relation between the position coordinates of the reference point of the positioning area and the position characteristics of the position, generating a record, and storing the record in a database. Wherein each record comprises: and (4) referring to the position coordinates x and y, the names and MAC addresses of the APs, the processed signal intensity mean value and standard deviation of each AP. The specific record format is shown in the figure, and for the ith record, the reference point position coordinate is (X)i,Yi) The received fingerprints corresponding to the n APs are:
for the same position fingerprint database, two points far away from the database can receive different APs, if the AP is collected in two areas respectively, the problem that the AP collection sequence is inconsistent can be caused, the problem is brought to the matching of the corresponding APs in the later real-time positioning stage, in order to simplify calculation, collection software only adds information behind an AP file to a newly appeared AP signal in an off-line experiment, and when data is preprocessed, a smaller value of-100 dBm is uniformly given as a default value to the undetected data.
Step S5: in the online matching stage, the WiFi signal intensity of the position to be detected is collected, the intelligent terminal equipment is held, signals of all received APs are detected in real time and compared with MAC address records of the APs stored in the position fingerprint database, the signal intensity of the corresponding AP is screened out, and the received signal intensity of the jth AP is assumed to be RSSj. For the signals of the APs already in the fingerprint library that are not detected, the signal strength value is defaulted to-100 dBm.
Step S6: and comparing the fingerprint of the position to be detected with the records in the position fingerprint database, and calculating the characteristic Euclidean distance between the fingerprint of the current position to be detected and each fingerprint in the position fingerprint database.
For the ith reference point, assuming the location fingerprint database ultimately selects n available APs, then for the jth AP received, the signal strength is rssij. Because the performance capabilities of the APs received at each position are different, after different weights are given to each AP according to the signal strength and stability of the AP, the characteristic distance is calculated, and the specific calculation method is as follows:
wherein d isiThe weighted characteristic distance, w, between the WiFi fingerprint of the position to be detected and the ith sampling point in the position fingerprint databaseijFor the weight of the jth AP at the i position, the signal intensity of the AP, i.e. the standard deviation, is calculatedAfter contribution, the weight is calculated by the following formula:
step S7: after the characteristic Euclidean distance between the position to be detected and each reference point in the position fingerprint database is calculated, the positions are sorted from small to large according to the distance, and the first 4 reference points are selected as candidate reference points.
Step S8: and estimating the position to be measured by a weighted coordinate calculation method according to the position coordinates of the selected candidate reference points. Firstly, calculating the coordinate distance sum of physical positions of each point and other points in the candidate reference points, and for the ith reference point, the sum is dliCalculated using the formula:
consideration of characteristic Euclidean distance diPhysical distance dl from reference pointiWeighting factor w as reference point ii:
And finally, calculating the position coordinates of the point to be measured as follows:
it will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and that any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the present invention.