A positioning method based on sliding window anomaly detection and Kalman filtering
By combining sliding window anomaly detection and Kalman filtering, the problems of signal strength fluctuation and noise impact in indoor positioning are solved, and fast and accurate dynamic target positioning is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUXI ZHENYUAN TECH CO LTD
- Filing Date
- 2025-05-08
- Publication Date
- 2026-05-15
AI Technical Summary
Existing indoor positioning technologies struggle to quickly and accurately locate dynamic targets in complex environments, especially due to fluctuations in wireless signal strength and noise, resulting in inaccurate positioning results.
The method employs sliding window anomaly detection and Kalman filtering. By detecting the signal strength between the Bluetooth positioning beacon and the moving target, outliers are replaced with the mean of the sliding window, and Kalman filtering is used to correct the initial position estimate, thereby optimizing signal strength measurement and position estimation.
It improves the accuracy and reliability of indoor dynamic target positioning, can quickly respond to environmental noise interference, achieve smooth positioning trajectory, and reduce the impact of environmental noise on positioning accuracy.
Smart Images

Figure CN120186557B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of indoor positioning technology, specifically to a positioning method based on sliding window anomaly detection and Kalman filtering. Background Technology
[0002] With the rapid development of IoT technology, indoor positioning technology is gaining popularity in fields such as smart homes, warehousing and logistics, medical monitoring, and shopping mall navigation. Compared to traditional outdoor positioning technologies (such as GPS), indoor positioning needs to address more complex environmental constraints and meet higher accuracy requirements.
[0003] Therefore, many related technologies employ trilateration algorithms based on RSSI (Radio Signal Strength Indicator) to locate indoor targets. However, in practical applications, complex indoor environments (such as metal obstacles, human movement, and electromagnetic interference) cause significant fluctuations in RSSI signals. Furthermore, because trilateration algorithms are highly sensitive to outliers and noise in RSSI data, the positioning results are not accurate enough. In dynamic positioning scenarios, RSSI signal fluctuations are even more severe, requiring even longer to achieve accurate positioning, making this method unsuitable for quickly and accurately locating dynamic indoor targets. Summary of the Invention
[0004] This application provides a positioning method based on sliding window anomaly detection and Kalman filtering, which can quickly and accurately locate dynamic targets indoors.
[0005] In a first aspect, this application provides a localization method based on sliding window anomaly detection and Kalman filtering, the method comprising:
[0006] When a moving target is detected in the target area, a first signal strength value between a preset Bluetooth positioning beacon in the target area and the moving target is calculated;
[0007] An outlier value in the first signal strength value is detected using a sliding window, and the outlier value is replaced with the average signal strength value of the sliding window to obtain the second signal strength value.
[0008] The preliminary estimated position of the moving target is calculated based on the second signal strength value;
[0009] The initial estimated position is corrected using Kalman filtering to obtain the final estimated position of the moving target.
[0010] By employing the above technical solution, a first signal strength value between the Bluetooth positioning beacon and the moving target is calculated, establishing the initial positioning basis for the moving target. The sliding window detection mechanism can promptly detect outliers in the first signal strength value. The second signal strength value is obtained by replacing the outliers with the average signal strength value of the sliding window, effectively eliminating sudden interference and abnormal fluctuations in signal strength measurement. The preliminary estimated position of the moving target is calculated based on the processed second signal strength value, significantly improving the reliability of the initial positioning. Finally, Kalman filtering is used to correct the preliminary estimated position to obtain the final estimated position. By combining state prediction and measurement updates, the positioning trajectory can be effectively smoothed, reducing the impact of environmental noise on positioning accuracy. Compared with related technologies, the solution provided in this application optimizes both signal strength measurement and position estimation through the synergistic effect of sliding window outlier processing and Kalman filtering, enabling rapid and accurate positioning of dynamic indoor targets.
[0011] Optionally, when a moving target is detected in the target area, calculating a first signal strength value between a preset Bluetooth positioning beacon in the target area and the moving target includes:
[0012] When a moving target is detected in the target area, the movement trajectory of the moving target is established;
[0013] Based on the data points containing time-series information in the movement trajectory, calculate the estimated distance between the preset Bluetooth positioning beacon and the moving target within the target area;
[0014] The three Bluetooth beacons closest to the estimated distance are identified as target Bluetooth beacons, and a first signal strength value between the target Bluetooth beacons and the moving target is calculated.
[0015] By adopting the above technical solution, at least three Bluetooth positioning beacons with the closest estimated distance are selected as target Bluetooth positioning beacons, and the first signal strength value between these target Bluetooth positioning beacons and the moving target is calculated. This not only reduces the computational complexity, but also improves the accuracy of the signal strength value because the selected beacons are close together, the signal transmission path is short, and the impact of signal attenuation and multipath effect is small.
[0016] Optionally, the step of using a sliding window to detect outliers in the first signal strength value and replacing the outliers with the average signal strength of the sliding window to obtain a second signal strength value includes:
[0017] When a new current data node generated by the moving target is received, the mean and standard deviation of the signal strength of each data node within the sliding window are calculated.
[0018] Calculate the standard score of the current data node based on the mean signal strength, the standard deviation, and the first signal strength value corresponding to the current data node;
[0019] If the standard score exceeds the preset score threshold, the current data node is determined as an abnormal node, and the first signal strength value corresponding to the current data node is determined as an abnormal value.
[0020] The outlier value is replaced with the average signal strength of the sliding window to obtain the second signal strength value.
[0021] By adopting the above technical solution, when a new current data node is received from a moving target, a statistical characteristic benchmark for signal strength values is established by calculating the mean and standard deviation of the signal strength of each data node within a sliding window. A standard score for the current data node is calculated using the mean signal strength, standard deviation, and the first signal strength value corresponding to the current data node, which can quantitatively assess the degree of anomaly of the current data node. When the standard score exceeds a preset score threshold, the current data node is identified as an anomalous node, and its corresponding first signal strength value is identified as an anomaly. A second signal strength value is obtained by replacing the anomaly value with the mean signal strength value from the sliding window. This maintains the continuity of signal strength data while effectively filtering out anomalous data caused by environmental interference, signal obstruction, and other factors, making the signal strength values more stable and reliable.
[0022] Optionally, the method further includes:
[0023] If the standard score does not exceed a preset score threshold, the current data node is added to the sliding window, and the earliest data node in the time series in the sliding window is removed.
[0024] By adopting the above technical solution, the sliding window is dynamically updated based on whether the standard score exceeds the preset score threshold. When the standard score does not exceed the preset score threshold, the current data node is added to the sliding window and the earliest data node in the time series is removed. This ensures that the sliding window always maintains the latest valid data, which not only ensures the timeliness of the data, but also avoids the interference of historical data on the current positioning by removing the earlier data nodes. As a result, the signal strength data in the sliding window can better reflect the real-time status of the moving target and improve the accuracy of subsequent positioning.
[0025] Optionally, calculating the preliminary estimated location of the moving target based on the second signal strength value includes:
[0026] Based on the second signal strength value, the distance between the Bluetooth positioning beacon and the moving target, as well as the weight index of the Bluetooth positioning beacon, are calculated.
[0027] Substitute the distance and the weight index into the trilateration matrix, and use the weighted least squares method to calculate the preliminary estimated position of the moving target.
[0028] By adopting the above technical solution, the weight index is introduced to consider the degree of influence of different beacons on the positioning results, so that beacons with high reliability have a greater influence in the positioning calculation. At the same time, the application of the trilateration matrix ensures the accurate expression of spatial geometric relationships, and the weighted least squares method can effectively suppress the influence of measurement errors, thereby improving the accuracy of the preliminary position estimation.
[0029] Optionally, calculating the distance between the Bluetooth positioning beacon and the moving target, and the weight index of the Bluetooth positioning beacon, based on the second signal strength value, includes:
[0030] Substituting the second signal strength value into the distance estimation formula, the distance between the Bluetooth positioning beacon and the moving target is obtained;
[0031] The distance estimation formula is as follows: ;
[0032] in, This represents the distance between the i-th Bluetooth positioning beacon and the moving target. This represents the reference signal strength value at 1 meter. This represents the second signal strength value of the i-th Bluetooth positioning beacon at the location of the moving target;
[0033] Substituting the second signal strength value into the weight calculation formula, we obtain the exponential weight corresponding to the Bluetooth positioning beacon.
[0034] The weight calculation formula is as follows: ;
[0035] in, This represents the exponential weight of the i-th Bluetooth positioning beacon. This represents the second signal strength value of the i-th Bluetooth positioning beacon at the location of the moving target. The value represents the maximum value of the second signal strength that can be received at the moving target, and k represents the attenuation coefficient.
[0036] By adopting the above technical solution, the second signal strength value is compared with the maximum receivable signal strength value by calculating the exponential weight of each beacon, and then exponentialized by combining the attenuation coefficient. This results in beacons with stronger signals receiving higher weights. This dynamic weight allocation mechanism based on signal strength not only considers the relative strength of the signals, but also amplifies the differences between beacons through the exponential function, thereby more reasonably balancing the contribution of each beacon in subsequent positioning calculations.
[0037] Optionally, substituting the distance and the weight index into the trilateration matrix and using weighted least squares to calculate the preliminary estimated position of the moving target includes:
[0038] Substituting the distance and the weight index into the trilateration matrix, we obtain the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, the distance squared difference matrix between the Bluetooth positioning beacon and the moving target, and the weight matrix.
[0039] The trilateration matrix is as follows: ;
[0040] ;
[0041] ;
[0042] Where A represents the geometric relationship matrix between the Bluetooth positioning beacon and the mobile target, and B represents the distance squared difference matrix between the Bluetooth positioning beacon and the mobile target; This represents the x-axis coordinate of the nth Bluetooth positioning beacon. This represents the y-axis coordinate of the nth Bluetooth positioning beacon. The exponential weight of the (n-1)th Bluetooth positioning beacon is represented by W, which represents the weight matrix.
[0043] Substituting the geometric relationship matrix, the distance squared difference matrix, and the weight matrix into the weighted least squares calculation formula, the preliminary estimated position of the moving target is obtained;
[0044] The weighted least squares calculation formula is as follows: ;
[0045] in, This indicates the preliminary estimated location of the moving target. This represents the transpose of the geometric relation matrix.
[0046] By employing the above technical solution, a geometric relationship matrix, a distance squared difference matrix, and a weight matrix were constructed between the Bluetooth positioning beacon and the moving target. These three matrices reflect the spatial positional relationship, distance relationship, and beacon reliability between the beacon and the moving target, respectively. Substituting these matrices into the weighted least squares calculation formula, and through the transpose and matrix inversion operations of the geometric relationship matrix, spatial geometric features and beacon weights are comprehensively considered to obtain a preliminary estimated position of the moving target. This approach fully utilizes the positional and weight information of multiple beacons, effectively eliminating the influence of measurement errors and resulting in higher accuracy and reliability of the preliminary position estimate.
[0047] Optionally, obtain the state transition matrix, observation matrix, process noise covariance matrix, observation noise covariance matrix, and initialize the covariance matrix;
[0048] Based on the historical state and historical covariance matrix of the moving target at the previous time step, the predicted state and predicted covariance matrix of the moving target at the current time are calculated using the state prediction formula.
[0049] The state prediction formula is as follows:
[0050] ;
[0051] ;
[0052] in, This represents the predicted state at the current time k. Let F represent the historical state corresponding to time k-1 in the previous cycle, and let F represent the state transition matrix. This represents the prediction covariance matrix corresponding to the current time k. This represents the historical covariance matrix corresponding to time k-1 in the previous period. Let Q be the transpose of the state transition matrix, and let Q be the process noise covariance matrix.
[0053] Substituting the predicted state, prediction covariance matrix, observation matrix, observation noise covariance matrix, and preliminary estimated position into the position correction formula, the final estimated position of the moving target is obtained.
[0054] The position correction formula is:
[0055] ;
[0056] ;
[0057] Where K represents the Kalman gain, Let H be the transpose of the observation matrix, H be the observation matrix, and R be the observation noise covariance matrix. This indicates the preliminary estimated location. This represents the prediction covariance matrix corresponding to the current time k. This represents the predicted state at the current time k. This indicates the final estimated location.
[0058] By adopting the above technical solution, the state estimation and position correction method based on Kalman filtering, through iterative calculation in two stages of prediction and update, not only considers the temporal continuity of the system state, but also incorporates the latest observation data, which can effectively suppress the influence of random noise and make the final estimated position have better smoothness and accuracy.
[0059] Secondly, this application provides a positioning system based on sliding window anomaly detection and Kalman filtering, the system comprising:
[0060] The detection module is used to calculate a first signal strength value between a preset Bluetooth positioning beacon in the target area and the moving target when a moving target is detected in the target area.
[0061] The processing module is configured to use a sliding window to detect outliers in the first signal strength value, and replace the outliers with the average signal strength of the sliding window to obtain a second signal strength value.
[0062] The calculation module is used to calculate the preliminary estimated position of the moving target based on the second signal strength value;
[0063] The correction module is used to correct the preliminary estimated position using Kalman filtering to obtain the final estimated position of the moving target.
[0064] Thirdly, this application provides a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing any of the methods described above.
[0065] Fourthly, this application provides an electronic device including a processor, a memory, and a transceiver, wherein the memory is used to store instructions, the transceiver is used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform any of the methods described above.
[0066] In summary, the beneficial effects of the technical solution of this application include:
[0067] By employing the above technical solution, a first signal strength value between the Bluetooth positioning beacon and the moving target is calculated, establishing the initial positioning basis for the moving target. The sliding window detection mechanism can promptly detect outliers in the first signal strength value. The second signal strength value is obtained by replacing the outliers with the average signal strength value of the sliding window, effectively eliminating sudden interference and abnormal fluctuations in signal strength measurement. The preliminary estimated position of the moving target is calculated based on the processed second signal strength value, significantly improving the reliability of the initial positioning. Finally, Kalman filtering is used to correct the preliminary estimated position to obtain the final estimated position. By combining state prediction and measurement updates, the positioning trajectory can be effectively smoothed, reducing the impact of environmental noise on positioning accuracy. Compared with related technologies, the solution provided in this application optimizes both signal strength measurement and position estimation through the synergistic effect of sliding window outlier processing and Kalman filtering, enabling rapid and accurate positioning of dynamic indoor targets. Attached Figure Description
[0068] Figure 1 This is a flowchart illustrating a localization method based on sliding window anomaly detection and Kalman filtering according to an embodiment of this application.
[0069] Figure 2 This is a schematic diagram of a positioning system based on sliding window anomaly detection and Kalman filtering according to an embodiment of this application;
[0070] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0071] Explanation of reference numerals in the attached drawings: 300, electronic device; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. Detailed Implementation
[0072] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0073] In the description of the embodiments of this application, words such as "illustrative," "for example," or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "illustrative," "for example," or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of words such as "illustrative," "for example," or "for example" is intended to present the relevant concepts in a specific manner.
[0074] In the description of the embodiments of this application, the term "multiple" means two or more. For example, multiple systems means two or more systems, and multiple screen terminals means two or more screen terminals. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0075] Please see Figure 1 This is a flowchart illustrating a localization method based on sliding window anomaly detection and Kalman filtering, provided in an embodiment of this application. This method can be implemented using a computer program, a microcontroller, or run on a localization system based on the von Neumann architecture and sliding window anomaly detection and Kalman filtering. The computer program can be integrated into an application or run as a standalone utility application. The specific steps of the localization method based on sliding window anomaly detection and Kalman filtering are described in detail below.
[0076] S101: When a moving target is detected in the target area, calculate the first signal strength value between the preset Bluetooth positioning beacon in the target area and the moving target;
[0077] The moving target refers to a dynamic object that is in continuous motion within the target area and needs to be tracked and located in real time. Its motion state, trajectory and speed may change. In this embodiment, it can be understood as a mobile device or portable terminal equipped with a Bluetooth signal receiving device. The device can continuously receive signals sent by Bluetooth positioning beacons during the movement and measure the signal strength value in real time to collect the dynamically changing first signal strength value.
[0078] In this context, a Bluetooth positioning beacon refers to a Bluetooth signal transmitting and receiving device with fixed coordinates, pre-deployed within a target area. In this embodiment, it can be understood as a hardware device with a Bluetooth communication module. This device includes a signal transceiver unit, a signal strength measurement unit, and a data processing unit, used to establish a Bluetooth communication connection with the moving target and measure the received signal strength, thereby providing basic data for calculating the moving target's location. These Bluetooth positioning beacons are typically deployed at known locations within the target area, and their spatial coordinate information is pre-recorded in the positioning system. Each beacon has a unique identifier that can be recognized and distinguished by the system.
[0079] The first signal strength value refers to the raw received signal strength indication (RSSI) measured when the Bluetooth signal sent by the Bluetooth positioning beacon is received by the mobile target. In this embodiment, it can be understood as a value in decibels and milliwatts (dBm). This value reflects the degree of signal attenuation when the Bluetooth positioning beacon is the signal source and the mobile target is the receiver, and is used to characterize the distance relationship between the mobile target and each Bluetooth positioning beacon.
[0080] Specifically, the system pre-deploys multiple Bluetooth positioning beacons at key locations within the target area. The locations of these beacons are fixed and known. When a moving target enters the target area, the Bluetooth device on the moving target establishes a communication connection with the surrounding Bluetooth positioning beacons. Each Bluetooth positioning beacon receives the Bluetooth signal emitted by the moving target and measures the Received Signal Strength Indication (RSSI), i.e., the first signal strength value. This RSSI value characterizes the degree of attenuation of the Bluetooth signal during propagation, and its magnitude is closely related to the distance between the moving target and the beacons.
[0081] Based on the above embodiments, as an optional implementation method, step S101 further includes S201-S203.
[0082] S201: When a moving target is detected in the target area, establish the movement trajectory of the moving target;
[0083] To accurately track a moving target's dynamic position when it enters the target area, a movement trajectory needs to be established. This trajectory is constructed by continuously recording the target's position information at different time points. The system records the first signal strength value received by the target at each sampling moment and its corresponding timestamp as data points. These time-series data points constitute the movement trajectory. The main purpose of establishing the movement trajectory is to capture the target's motion patterns, as the target may experience changes in speed, direction, and other complex situations during its movement. Relying solely on the position information at a single moment is insufficient to accurately reflect its actual motion state. In practice, the system first acquires the initial position information of the target upon entering the target area. Then, according to a preset sampling frequency, it periodically collects the first signal strength value received by the target and adds a corresponding timestamp to each sampling point, thus forming a sequence dataset containing both time and signal strength information.
[0084] S202: Calculate the estimated distance between the preset Bluetooth positioning beacon and the moving target within the target area based on the data points containing time-series information in the movement trajectory;
[0085] The estimated distance refers to the approximate spatial distance between the moving target and each Bluetooth positioning beacon, calculated based on data points containing time-series information in the moving target's trajectory. In this embodiment, it can be understood as the approximate distance between the moving target and the Bluetooth positioning beacon, quickly calculated based on the moving target's historical location information. This is used to initially determine which Bluetooth positioning beacons are closer to the moving target, thereby selecting suitable target Bluetooth positioning beacons.
[0086] Specifically, the system rapidly estimates the spatial distance between the moving target and various preset Bluetooth beacons within the target area based on historical location information recorded in the movement trajectory. Since the data points in the movement trajectory contain timestamp information, the system can calculate the approximate distance between the moving target and each Bluetooth beacon based on the most recent location data. While this rough distance estimation is not highly accurate, it is fast and sufficient to determine which Bluetooth beacons are relatively close to the moving target. By calculating the estimated distance, the system can quickly filter out relatively close Bluetooth beacons, avoiding including excessively distant beacons in the positioning calculation, thereby improving the efficiency of subsequent positioning processes.
[0087] S203: Identify at least three Bluetooth beacons that are closest in estimated distance as target Bluetooth beacons, and calculate the first signal strength value between the target Bluetooth beacons and the moving target.
[0088] Among them, the target Bluetooth positioning beacon refers to at least three Bluetooth positioning beacons that are closest to the moving target, selected from a plurality of preset Bluetooth positioning beacons in the target area based on the estimated distance. In this embodiment, it can be understood as the combination of Bluetooth positioning beacons that are closest and most suitable for participating in the positioning calculation at the current moment, determined based on the moving trajectory data of the moving target, and used to provide the moving target with high-quality signal strength data.
[0089] In practice, since planar positioning requires at least three reference points to achieve trilateration positioning, the system selects at least three Bluetooth positioning beacons with the closest estimated distances and designates them as target Bluetooth positioning beacons. The closest Bluetooth positioning beacons are chosen because signal attenuation occurs during propagation, with attenuation becoming more severe over greater distances; therefore, selecting nearby beacons yields better quality signal data. After determining the target Bluetooth positioning beacons, the moving target receives the Bluetooth signals transmitted by these beacons and measures the initial signal strength value.
[0090] S102: Use a sliding window to detect outliers in the first signal strength value, and replace the outliers with the average signal strength of the sliding window to obtain the second signal strength value;
[0091] The second signal strength value refers to the signal strength value obtained after the sliding window anomaly detection process. In this embodiment, it can be understood as the smoothed signal strength value after replacing the outlier value with the average signal strength of the sliding window.
[0092] Because the moving target is in continuous motion, the initial signal strength value between it and the Bluetooth positioning beacon is easily affected by factors such as obstruction and multipath effects, resulting in abnormal fluctuations. These outliers reduce positioning accuracy. To eliminate the influence of these outliers, the system uses a sliding window to detect and process the initial signal strength value. Specifically, the system sets up a sliding window to store the initial signal strength values at multiple consecutive moments, calculates the mean and standard deviation of all signal strength values within the window, and identifies outliers in the signal based on these statistical characteristics. When an outlier is detected, the system replaces it with the mean signal strength value within the sliding window, thus obtaining a smoother initial signal strength value.
[0093] Based on the above embodiments, as an optional implementation method, the method of detecting and removing outliers using a sliding window further includes steps S301-S304.
[0094] S301: When a new current data node generated by a moving target is received, calculate the mean and standard deviation of the signal strength of each data node within the sliding window;
[0095] Here, a data node refers to a data sampling point recorded when a mobile target receives a signal sent by a Bluetooth positioning beacon at a certain moment. In this embodiment, it can be understood as a data record containing timestamp information and a corresponding first signal strength value, used to record the signal transmission status between the mobile target and the Bluetooth positioning beacon during the movement, and constitutes the basic data unit for anomaly detection in the sliding window.
[0096] As the moving target continues to move, the system continuously receives new current data nodes. To determine whether these data nodes contain outliers, statistical analysis based on historical data within the sliding window is required. Specifically, when a new current data node is received, the system first calculates the arithmetic mean of the first signal strength values corresponding to all data nodes within the sliding window, as the signal strength mean; simultaneously, it calculates the dispersion of these first signal strength values from the mean, obtaining the standard deviation.
[0097] Optionally, the mean and standard deviation of the signal strength of each data node within the sliding window can be calculated using the following formula.
[0098] ; ;
[0099] in, This represents the average signal strength of each data node within the sliding window. The standard deviation of each data node within the sliding window is represented by N, and the size of the sliding window is represented by N. This represents the first signal strength value of the i-th data node.
[0100] S302: Calculate the standard score of the current data node based on the mean signal strength, standard deviation, and the first signal strength value corresponding to the current data node;
[0101] The formula for calculating standard scores is: Where Z represents the standard score of the current data node, and X represents the first signal strength value of the current data node.
[0102] Specifically, the system calculates the difference between the first signal strength value of the current data node and the mean signal strength within the sliding window, and divides this difference by the standard deviation to obtain a standard score reflecting the degree of deviation of the current data node. This standard score-based calculation method standardizes the fluctuation of the first signal strength value, allowing signal strength fluctuations at different times and within different numerical ranges to be compared under a unified metric.
[0103] S303: If the standard score exceeds the preset score threshold, the current data node is identified as an abnormal node, and the first signal strength value corresponding to the current data node is identified as an abnormal value.
[0104] When the calculated standard score exceeds a preset score threshold, it indicates that the first signal strength value corresponding to the current data node has deviated significantly from other data within the sliding window, possibly due to sudden interference or occlusion during the movement of the target. In this case, the system marks the current data node as an abnormal node and determines its corresponding first signal strength value as an anomaly. This threshold-based anomaly detection method can quickly and accurately identify abrupt changes in signal transmission.
[0105] S304: Replace outliers with the average signal strength of the sliding window to obtain a second signal strength value.
[0106] After identifying outliers, the system needs to process them to ensure the reliability of the signal data. To this end, the system replaces the first signal strength value corresponding to the outlier node with the average signal strength within a sliding window. Specifically, the system replaces the first signal strength value marked as an outlier in the current data node with the average signal strength of all non-outlier data nodes within the current sliding window, thus obtaining a smoother second signal strength value. This window-means-based replacement method utilizes signal strength data from recent times, eliminating abnormal fluctuations while maintaining the overall trend of signal changes.
[0107] Based on the above embodiments, as an optional implementation method, the sliding window can be updated and improved in the following way. The specific steps are as follows: if the standard score does not exceed a preset score threshold, the current data node is added to the sliding window, and the earliest data node in the time series is removed from the sliding window.
[0108] Specifically, the system adds the current, normal data node to the sliding window, while removing the oldest data node in the time series to maintain the window size. This time-series-based window update method ensures that the sliding window always contains the latest consecutive normal data nodes, thus reflecting the latest signal transmission status between the moving target and the Bluetooth positioning beacon in a timely manner.
[0109] S103: Calculate the preliminary estimated position of the moving target based on the second signal strength value;
[0110] The preliminary estimated position refers to the approximate position coordinates of the moving target within the target area, calculated based on the second signal strength values between the moving target and each target Bluetooth positioning beacon. In this embodiment, it can be understood as the position estimation result of the moving target obtained based on the processed signal strength data using a trilateration matrix and weighted least squares method.
[0111] Specifically, step S103 further includes steps S401-S402.
[0112] S401: Calculate the distance between the Bluetooth positioning beacon and the moving target, as well as the weight index of the Bluetooth positioning beacon, based on the second signal strength value;
[0113] The weight index refers to a numerical parameter that reflects the importance of each target Bluetooth positioning beacon in the positioning calculation. In this embodiment, it can be understood as an exponential weight calculated based on the second signal strength value. This weight increases with the increase of signal strength and is used to weight the information provided by different target Bluetooth positioning beacons in the location estimation process, so that positioning beacons with better signal quality have greater confidence in positioning.
[0114] After obtaining the second signal strength value, the signal strength data needs to be converted into distance and weight information required for positioning calculation. Specifically, the system first substitutes the second signal strength value into the distance estimation formula and calculates the distance between each target Bluetooth positioning beacon and the moving target based on the signal attenuation law during spatial propagation. Simultaneously, the system substitutes the second signal strength value into the weight calculation formula and calculates the exponential weight of each target Bluetooth positioning beacon based on the relative magnitude of the signal strength. The distance estimation formula considers the attenuation characteristics during signal propagation, while the weight calculation formula ensures that target Bluetooth positioning beacons with greater signal strength receive larger weight values.
[0115] The specific calculation steps are as follows:
[0116] Substituting the second signal strength value into the distance estimation formula, the distance between the Bluetooth positioning beacon and the moving target is obtained;
[0117] The distance estimation formula is: ;
[0118] in, This represents the distance between the i-th Bluetooth beacon and the moving target. This represents the reference signal strength value at 1 meter. This represents the second signal strength value of the i-th Bluetooth beacon at the location of the moving target;
[0119] Regarding distance calculation, the distance estimation formula reflects the logarithmic relationship between signal strength and distance, as Bluetooth signals attenuate during propagation in space. Specifically, the reference signal strength value at one meter is the baseline signal strength measured under standard test conditions when the distance between the moving target and the Bluetooth beacon is fixed at one meter. The second signal strength values of each Bluetooth beacon at the moving target are the actual signal strength values obtained after outlier handling via a sliding window. The difference between the reference signal strength value at one meter and the second signal strength value in the formula reflects the degree of signal attenuation from transmission to reception. Dividing this difference by ten times the path loss exponent, and then taking the exponent with base 10, yields the actual distance between the Bluetooth beacon and the moving target. This calculation process converts the signal strength attenuation into spatial distance, where the path loss exponent characterizes the signal attenuation characteristics in the actual environment.
[0120] Substituting the second signal strength value into the weight calculation formula, we obtain the exponential weight corresponding to the Bluetooth positioning beacon.
[0121] The formula for calculating the weight is: ;
[0122] in, This represents the exponential weight of the i-th Bluetooth beacon. This represents the second signal strength value of the i-th Bluetooth positioning beacon at the location of the moving target. This represents the maximum value of the second signal strength that can be received at the moving target, and k represents the attenuation coefficient.
[0123] Regarding the calculation of the weighting index, the system first needs to determine the maximum value among all the second signal strength values that can be received at the moving target. This maximum value is typically derived from the Bluetooth beacon closest to the moving target. Then, for each Bluetooth beacon, its corresponding second signal strength value is compared to this maximum value, and the difference between them is calculated. This difference reflects the degree of attenuation of the current Bluetooth beacon's signal strength relative to the optimal signal. Dividing this difference by an attenuation coefficient adjusts the attenuation rate of the weight; the larger the attenuation coefficient, the smaller the weight difference corresponding to different signal strengths. Finally, the adjusted difference is exponentially calculated to obtain the exponential weight of the Bluetooth beacon. Due to the use of an exponential function, when the second signal strength value is close to the maximum value, the calculated weight is close to 1; while when the second signal strength value is much smaller than the maximum value, the calculated weight rapidly approaches 0.
[0124] This weighting method ensures that Bluetooth beacons with signal strength closer to their maximum value receive a larger weight, while those with weaker signals receive a smaller weight. Through this exponential processing based on signal strength differences, the system obtains a weight index reflecting the reliability of each Bluetooth beacon.
[0125] S402: Substitute the distance and weight indices into the trilateration matrix and use the weighted least squares method to calculate the preliminary estimated position of the moving target.
[0126] After obtaining the distances and corresponding weights between the Bluetooth beacons and the moving target, the system needs to calculate the preliminary estimated position of the moving target. Specifically, the system first substitutes these distances and weights into a trilateration matrix to construct a geometric relationship matrix, a distance squared difference matrix, and a weight matrix between the Bluetooth beacons and the moving target. The geometric relationship matrix describes the coordinate relationships of each Bluetooth beacon, the distance squared difference matrix contains distance information, and the weight matrix reflects the importance of each Bluetooth beacon in the calculation. Then, the system substitutes these three matrices into the weighted least squares calculation formula to obtain the preliminary estimated position of the moving target.
[0127] The specific calculation steps are as follows: Substitute the distance and weight index into the trilateration matrix to obtain the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, the distance squared difference matrix between the Bluetooth positioning beacon and the moving target, and the weight matrix;
[0128] The trilateral measurement matrix is:
[0129] ;
[0130] ;
[0131] ;
[0132] Where A represents the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, and B represents the distance squared difference matrix between the Bluetooth positioning beacon and the moving target; This represents the x-axis coordinate of the nth Bluetooth beacon. This represents the y-coordinate of the nth Bluetooth beacon. Let W represent the exponential weight of the (n-1)th Bluetooth beacon, and let W represent the weight matrix.
[0133] The trilateration matrix contains three key matrix structures. The first is the geometric relationship matrix, which describes the relative positional relationships between all beacons except the last Bluetooth beacon and the last beacon. Specifically, by calculating the coordinate differences between each Bluetooth beacon and the last beacon on the horizontal and vertical axes and doubling these differences, a matrix structure reflecting spatial geometric relationships is formed.
[0134] The second is the squared difference distance matrix, which integrates the location and ranging information of the Bluetooth beacons. For each Bluetooth beacon, the squares of its horizontal and vertical axes are added together, and then the squares of the horizontal and vertical axes of the last beacon are subtracted. The squared difference distance between these two beacons and the moving target is also considered, thus constructing a matrix structure that contains complete distance relationships.
[0135] The third is the weight matrix, a diagonal matrix in which the exponential weights of all Bluetooth beacons except the last one are arranged sequentially along the diagonal, with all other positions containing zero. This diagonal matrix structure ensures that the weight of each Bluetooth beacon can independently affect its corresponding location and distance information in subsequent calculations.
[0136] This matrix construction method standardizes the expression of spatial relationships, distance information, and weight information, enabling the information from each Bluetooth beacon to participate in subsequent location calculations in a unified mathematical form. Through the construction of these three matrices, the system obtains a mathematical expression describing the complete spatial relationship between the moving target and each Bluetooth beacon.
[0137] Substituting the geometric relationship matrix, the distance squared difference matrix, and the weight matrix into the weighted least squares calculation formula, we obtain the preliminary estimated position of the moving target.
[0138] The weighted least squares calculation formula is as follows: ;
[0139] in, This indicates the preliminary estimated location of the moving target. This represents the transpose of the geometric relation matrix.
[0140] The geometric relation matrix needs to be transposed, which interchanges the rows and columns of the original matrix. This ensures smooth matrix multiplication in subsequent operations. The system then multiplies the transposed geometric relation matrix with the weight matrix, weighting the contribution of each Bluetooth beacon. Next, the weighted result is multiplied again with the original geometric relation matrix, resulting in a new matrix reflecting the weighted spatial geometry. Inverting this new matrix yields the first part of the calculation formula. The second part of the formula multiplies the transposed geometric relation matrix with the weight matrix, and then with the squared difference of distance matrix.
[0141] Multiplying the results of the first and second parts of the formula yields a preliminary estimated position of the moving target. This calculation essentially seeks an optimal solution among all observation data, minimizing the weighted sum of squared position errors. This weighted least squares-based calculation method comprehensively considers the influence of spatial geometry, distance constraints, and signal quality. By using matrix operations to weight and fuse various influencing factors, it achieves a relatively accurate position estimation. Due to the introduction of the weight matrix, the calculation automatically strengthens the contribution of Bluetooth beacons with good signal quality and weakens the influence of beacons with poor signal quality, thereby improving the accuracy of the preliminary position estimate.
[0142] S104: Use Kalman filtering to correct the initial estimated position and obtain the final estimated position of the moving target.
[0143] The final estimated position refers to the position coordinates of the moving target obtained after correction by the Kalman filter algorithm. In this embodiment, it can be understood as a more accurate position information obtained after noise suppression and smoothing of the preliminary estimated position, which is used to provide the indoor positioning system with a more accurate and stable real-time position of the moving target.
[0144] Specifically, after obtaining the initial estimated position of the moving target, the system uses a Kalman filter algorithm to refine this position to obtain a more accurate final estimated position. The core of the Kalman filter is to achieve position correction through two steps: prediction and update. In the prediction step, the system predicts the possible position at the current moment based on the moving target's historical position information. In the update step, the system compares the predicted position with the initial estimated position calculated using weighted least squares, and determines the weight allocation between the predicted and initial estimated positions by calculating the optimal Kalman gain, thereby obtaining a more accurate final estimated position.
[0145] Based on the above embodiments, as an optional implementation method, the specific modification steps in step S104 are as follows:
[0146] Obtain the state transition matrix, observation matrix, process noise covariance matrix, observation noise covariance matrix, and initialize the covariance matrix;
[0147] Based on the historical state and historical covariance matrix of the moving target at the previous time step, the predicted state and predicted covariance matrix of the moving target at the current time step are calculated using the state prediction formula.
[0148] The state prediction formula is:
[0149] ;
[0150] ;
[0151] in, This represents the predicted state at the current time k. Let F represent the historical state corresponding to time k-1 in the previous cycle, and let F represent the state transition matrix. This represents the prediction covariance matrix corresponding to the current time k. This represents the historical covariance matrix corresponding to time k-1 in the previous period. Let represent the transpose of the state transition matrix, and Q represent the process noise covariance matrix;
[0152] Substituting the predicted state, prediction covariance matrix, observation matrix, observation noise covariance matrix, and preliminary estimated position into the position correction formula, the final estimated position of the moving target is obtained.
[0153] The position correction formula is:
[0154] ;
[0155] ;
[0156] Where K represents the Kalman gain, H represents the transpose of the observation matrix, H represents the observation matrix, and R represents the observation noise covariance matrix. This indicates a preliminary estimated location. This represents the prediction covariance matrix corresponding to the current time k. This represents the predicted state at the current time k. This indicates the final estimated location.
[0157] In this context, the state transition matrix, observation matrix, process noise covariance matrix, observation noise covariance matrix, and initialization covariance matrix refer to the key parameter matrices used in the Kalman filter algorithm to describe the system state evolution, observation process, and various error characteristics. In this embodiment, they can be understood as follows: the state transition matrix describes the relationship between the position changes of the moving target between adjacent time points; the observation matrix describes the correspondence between the preliminary estimated position and the actual position; the process noise covariance matrix characterizes the degree of random disturbance during the moving target's motion; the observation noise covariance matrix characterizes the error characteristics during the position measurement process; and the initialization covariance matrix characterizes the degree of uncertainty in the initial state estimation of the system. These matrix parameters are used to accurately describe the motion and measurement characteristics of the moving target during the Kalman filter process, thereby achieving effective correction of the preliminary estimated position.
[0158] In the prediction phase of Kalman filtering, the system needs to calculate the predicted state and prediction covariance matrix for the current moment based on the historical state and historical covariance matrix of the moving target in the previous cycle. Specifically, the system first multiplies the state transition matrix by the historical state from the previous cycle to obtain the predicted state for the current moment, which reflects the state change of the moving target from the previous cycle to the current moment. Simultaneously, the system also needs to update the covariance matrix. This is done by multiplying the state transition matrix by the historical covariance matrix from the previous cycle, then by multiplying it by the transpose of the state transition matrix, and finally adding the process noise covariance matrix to obtain the prediction covariance matrix for the current moment. This prediction method not only considers the state evolution of the moving target but also reflects the increase in uncertainty during the prediction process through the update of the covariance matrix, enabling the system to accurately grasp the possible state distribution of the moving target at the current moment.
[0159] After obtaining the predicted state and the predicted covariance matrix, the system needs to fuse these predictions with the preliminary estimated position using a position correction formula to obtain a more accurate final estimated position. Specifically, the system first calculates the Kalman gain, which determines the system's level of confidence in the predicted and observed values. During the calculation, the system multiplies the predicted covariance matrix by the transpose of the observation matrix, and then multiplies the result by the product of the observation matrix and the predicted covariance matrix, as well as the inverse of the sum of the observation noise covariance matrices, to obtain the Kalman gain. A larger gain value indicates that the system is more inclined to trust the observed values, and vice versa.
[0160] The system then uses the observation matrix to transform the predicted state into the observation space and calculates the difference between the predicted and observed positions. This difference reflects the deviation between the predicted and observed values. Multiplying this deviation by the Kalman gain yields the amount needed to correct the predicted state. Finally, adding this correction to the predicted state gives the final estimated position of the moving target.
[0161] The following are system embodiments of this application, which can be used to execute the method embodiments of this application. For details not disclosed in the system embodiments of this application, please refer to the method embodiments of the application.
[0162] Please see Figure 2 This illustration shows a schematic diagram of a localization system based on sliding window anomaly detection and Kalman filtering, provided in an exemplary embodiment of this application. The system can be implemented in software, hardware, or a combination of both, forming all or part of a larger system. The localization system based on sliding window anomaly detection and Kalman filtering includes:
[0163] The detection module is used to calculate the first signal strength value between the preset Bluetooth positioning beacon and the moving target when a moving target is detected in the target area;
[0164] The processing module is used to detect outliers in the first signal strength value using a sliding window, and replace the outliers with the average signal strength of the sliding window to obtain the second signal strength value;
[0165] The calculation module is used to calculate the preliminary estimated position of the moving target based on the second signal strength value;
[0166] The correction module is used to correct the initial estimated position using Kalman filtering to obtain the final estimated position of the moving target.
[0167] Based on the above embodiments, as an optional embodiment, the detection module is further configured to establish the movement trajectory of the moving target when a moving target is detected in the target area; calculate the estimated distance between the preset Bluetooth positioning beacon and the moving target based on the data points containing time series information in the movement trajectory; determine at least three Bluetooth positioning beacons with the closest estimated distance as target Bluetooth positioning beacons, and calculate the first signal strength value between the target Bluetooth positioning beacon and the moving target.
[0168] Based on the above embodiments, as an optional embodiment, the processing module is further configured to, when receiving a new current data node generated by a moving target, calculate the mean and standard deviation of the signal strength of each data node within the sliding window; calculate the standard score of the current data node based on the mean signal strength, standard deviation, and the first signal strength value corresponding to the current data node; if the standard score exceeds a preset score threshold, determine the current data node as an abnormal node and determine the first signal strength value corresponding to the current data node as an abnormal value; replace the abnormal value with the mean signal strength of the sliding window to obtain a second signal strength value.
[0169] Based on the above embodiments, as an optional embodiment, the processing module is further configured to add the current data node to the sliding window and remove the earliest data node in the time series from the sliding window if the standard score does not exceed a preset score threshold.
[0170] Based on the above embodiments, as an optional embodiment, the calculation module is further configured to calculate the distance between the Bluetooth positioning beacon and the moving target, as well as the weight index of the Bluetooth positioning beacon, according to the second signal strength value; substitute the distance and weight index into the trilateration matrix, and use the weighted least squares method to calculate the preliminary estimated position of the moving target.
[0171] Based on the above embodiments, as an optional embodiment, the calculation module is further used to substitute the second signal strength value into the distance estimation formula to obtain the distance between the Bluetooth positioning beacon and the moving target;
[0172] The distance estimation formula is: ;
[0173] in, This represents the distance between the i-th Bluetooth beacon and the moving target. This represents the reference signal strength value at 1 meter. This represents the second signal strength value of the i-th Bluetooth beacon at the location of the moving target;
[0174] Substituting the second signal strength value into the weight calculation formula, we obtain the exponential weight corresponding to the Bluetooth positioning beacon.
[0175] The calculation formula is: ;
[0176] in, This represents the exponential weight of the i-th Bluetooth beacon. This represents the second signal strength value of the i-th Bluetooth positioning beacon at the location of the moving target. This represents the maximum value of the second signal strength that can be received at the moving target, and k represents the attenuation coefficient.
[0177] Based on the above embodiments, as an optional embodiment, the calculation module is also used to substitute the distance and weight index into the trilateration matrix to obtain the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, the distance squared difference matrix between the Bluetooth positioning beacon and the moving target, and the weight matrix.
[0178] The trilateral measurement matrix is: ;
[0179] ;
[0180] ;
[0181] Where A represents the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, and B represents the distance squared difference matrix between the Bluetooth positioning beacon and the moving target; This represents the x-axis coordinate of the nth Bluetooth beacon. This represents the y-coordinate of the nth Bluetooth beacon. Let W represent the exponential weight of the (n-1)th Bluetooth beacon, and let W represent the weight matrix.
[0182] Substituting the geometric relationship matrix, the distance squared difference matrix, and the weight matrix into the weighted least squares calculation formula, we obtain the preliminary estimated position of the moving target.
[0183] The formula for weighted least squares is: ;
[0184] in, Indicates the preliminary estimated location of the moving target. This represents the transpose of the geometric relation matrix.
[0185] Based on the above embodiments, as an optional embodiment, the correction module is also used to obtain the state transition matrix, observation matrix, process noise covariance matrix, observation noise covariance matrix, and initialize the covariance matrix;
[0186] Based on the historical state and historical covariance matrix of the moving target at the previous time step, the predicted state and predicted covariance matrix of the moving target at the current time step are calculated using the state prediction formula.
[0187] The state prediction formula is:
[0188] ;
[0189] ;
[0190] in, This represents the predicted state at the current time k. Let F represent the historical state corresponding to time k-1 in the previous cycle, and let F represent the state transition matrix. This represents the prediction covariance matrix corresponding to the current time k. This represents the historical covariance matrix corresponding to time k-1 in the previous period. Let represent the transpose of the state transition matrix, and Q represent the process noise covariance matrix;
[0191] Substituting the predicted state, prediction covariance matrix, observation matrix, observation noise covariance matrix, and preliminary estimated position into the position correction formula, the final estimated position of the moving target is obtained.
[0192] The position correction formula is:
[0193] ;
[0194] ;
[0195] Where K represents the Kalman gain, H represents the transpose of the observation matrix, H represents the observation matrix, and R represents the observation noise covariance matrix. This indicates a preliminary estimated location. This represents the prediction covariance matrix corresponding to the current time k. This represents the predicted state at the current time k. This indicates the final estimated location.
[0196] This application also provides a computer storage medium that can store multiple instructions. The instructions are adapted to be loaded by a processor and executed as described in the above embodiments for the localization method based on sliding window anomaly detection and Kalman filtering. For the specific execution process, please refer to the detailed description of the embodiments, which will not be repeated here.
[0197] Please see Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 300 may include: at least one processor 301, at least one network interface 304, user interface 303, memory 305, and at least one communication bus 302.
[0198] The communication bus 302 is used to enable communication between these components.
[0199] The user interface 303 may include a standard wired interface and a wireless interface.
[0200] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0201] The processor 301 may include one or more processing cores. The processor 301 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 305, and by calling data stored in memory 305. Optionally, the processor 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 301 and may be implemented as a separate chip.
[0202] The memory 305 may include random access memory (RAM) or read-only memory. Optionally, the memory 305 may include a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 305 may also be at least one storage device located remotely from the aforementioned processor 301. Figure 3 As shown, the memory 305, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program based on a sliding window anomaly detection and Kalman filtering localization method.
[0203] exist Figure 3In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and to obtain the user input data; while the processor 301 can be used to call an application program stored in the memory 305 that is a localization method based on sliding window anomaly detection and Kalman filtering. When executed by one or more processors, the electronic device executes one or more methods as described in the above embodiments.
[0204] An electronic device readable storage medium stores instructions that, when executed by one or more processors, cause the electronic device to perform one or more methods as described in the above embodiments.
[0205] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0206] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0207] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the shown or discussed mutual couplings or direct couplings or communication connections may be through some service interfaces; indirect couplings or communication connections between apparatuses or units may be electrical or other forms.
[0208] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0209] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0210] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0211] The above are merely exemplary embodiments of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of other embodiments of this disclosure upon considering the specification and the disclosure of practical truths. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure.
Claims
1. A localization method based on sliding window anomaly detection and Kalman filtering, characterized in that, The method includes: When a moving target is detected in the target area, a first signal strength value between a preset Bluetooth positioning beacon in the target area and the moving target is calculated; An outlier value in the first signal strength value is detected using a sliding window, and the outlier value is replaced with the average signal strength value of the sliding window to obtain the second signal strength value. The preliminary estimated position of the moving target is calculated based on the second signal strength value; The step of calculating the preliminary estimated position of the moving target based on the second signal strength value includes: Based on the second signal strength value, the distance between the Bluetooth positioning beacon and the moving target, as well as the weight index of the Bluetooth positioning beacon, are calculated; the distance and the weight index are substituted into the trilateration matrix, and the weighted least squares method is used to calculate the preliminary estimated position of the moving target; The step of calculating the distance between the Bluetooth positioning beacon and the moving target, and the weight index of the Bluetooth positioning beacon, based on the second signal strength value, includes: Substituting the second signal strength value into the distance estimation formula, the distance between the Bluetooth positioning beacon and the moving target is obtained; the distance estimation formula is: ;in, This represents the distance between the i-th Bluetooth positioning beacon and the moving target. This represents the reference signal strength value at 1 meter. The second signal strength value of the i-th Bluetooth positioning beacon at the mobile target location is represented by n, where n represents the path loss exponent. Substituting the second signal strength value into the weight calculation formula yields the exponent weight corresponding to the Bluetooth positioning beacon. The weight calculation formula is: ;in, This represents the exponential weight of the i-th Bluetooth positioning beacon. This represents the second signal strength value of the i-th Bluetooth positioning beacon at the location of the moving target. The value of the second signal strength that can be received at the moving target is indicated by k, where k represents the attenuation coefficient. The step of substituting the distance and the weight index into the trilateration matrix and using weighted least squares to calculate the preliminary estimated position of the moving target includes: Substituting the distance and the weight index into the trilateration matrix yields the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, the squared difference matrix of the distance between the Bluetooth positioning beacon and the moving target, and the weight matrix; the trilateration matrix is: ; ; Where A represents the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, and B represents the distance squared difference matrix between the Bluetooth positioning beacon and the moving target; This represents the x-axis coordinate of the nth Bluetooth positioning beacon. This represents the y-axis coordinate of the nth Bluetooth positioning beacon. The exponential weight of the (n-1)th Bluetooth positioning beacon is represented by W, which represents the weight matrix. Substituting the geometric relationship matrix, the distance squared difference matrix, and the weight matrix into the weighted least squares calculation formula, a preliminary estimated position of the moving target is obtained; the weighted least squares calculation formula is as follows: ;in, This indicates the preliminary estimated location of the moving target. Represents the transpose of the geometric relation matrix; The initial estimated position is corrected using Kalman filtering to obtain the final estimated position of the moving target.
2. The method according to claim 1, characterized in that, When a moving target is detected in the target area, the calculation of a first signal strength value between a preset Bluetooth positioning beacon in the target area and the moving target includes: When a moving target is detected in the target area, the movement trajectory of the moving target is established; Based on the data points containing time-series information in the movement trajectory, calculate the estimated distance between the preset Bluetooth positioning beacon and the moving target within the target area; The three Bluetooth beacons closest to the estimated distance are identified as target Bluetooth beacons, and a first signal strength value between the target Bluetooth beacons and the moving target is calculated.
3. The method according to claim 1, characterized in that, The step of using a sliding window to detect outliers in the first signal strength value and replacing the outliers with the average signal strength of the sliding window to obtain a second signal strength value includes: When a new current data node generated by the moving target is received, the mean and standard deviation of the signal strength of each data node within the sliding window are calculated. Calculate the standard score of the current data node based on the mean signal strength, the standard deviation, and the first signal strength value corresponding to the current data node; If the standard score exceeds the preset score threshold, the current data node is determined as an abnormal node, and the first signal strength value corresponding to the current data node is determined as an abnormal value. The outlier value is replaced with the average signal strength of the sliding window to obtain the second signal strength value.
4. The method according to claim 3, characterized in that, The method further includes: If the standard score does not exceed a preset score threshold, the current data node is added to the sliding window, and the earliest data node in the time series in the sliding window is removed.
5. The method according to claim 1, characterized in that, The step of correcting the preliminary estimated position using Kalman filtering to obtain the final estimated position of the moving target includes: Obtain the state transition matrix, observation matrix, process noise covariance matrix, observation noise covariance matrix, and initialize the covariance matrix; Based on the historical state and historical covariance matrix of the moving target at the previous time step, the predicted state and predicted covariance matrix of the moving target at the current time are calculated using the state prediction formula. The state prediction formula is as follows: ; ; in, This represents the predicted state at the current time k. Let F represent the historical state corresponding to time k-1 in the previous cycle, and let F represent the state transition matrix. This represents the prediction covariance matrix corresponding to the current time k. This represents the historical covariance matrix corresponding to time k-1 in the previous period. Let Q be the transpose of the state transition matrix, and let Q be the process noise covariance matrix. Substituting the predicted state, prediction covariance matrix, observation matrix, observation noise covariance matrix, and preliminary estimated position into the position correction formula, the final estimated position of the moving target is obtained. The position correction formula is: ; ; Where K represents the Kalman gain, Let H be the transpose of the observation matrix, H be the observation matrix, and R be the observation noise covariance matrix. This indicates the preliminary estimated location. This represents the prediction covariance matrix corresponding to the current time k. This represents the predicted state at the current time k. This indicates the final estimated location.
6. A positioning system based on sliding window anomaly detection and Kalman filtering, characterized in that, The system includes: The detection module is used to calculate a first signal strength value between a preset Bluetooth positioning beacon in the target area and the moving target when a moving target is detected in the target area. The processing module is configured to use a sliding window to detect outliers in the first signal strength value, and replace the outliers with the average signal strength of the sliding window to obtain a second signal strength value. A calculation module is used to calculate a preliminary estimated position of the moving target based on the second signal strength value. The calculation of the preliminary estimated position of the moving target based on the second signal strength value includes: calculating the distance between the Bluetooth positioning beacon and the moving target, and a weight index of the Bluetooth positioning beacon, based on the second signal strength value; substituting the distance and the weight index into a trilateration matrix, and using weighted least squares to calculate the preliminary estimated position of the moving target; the calculation of the distance between the Bluetooth positioning beacon and the moving target, and a weight index of the Bluetooth positioning beacon, based on the second signal strength value includes: substituting the second signal strength value into a distance estimation formula to obtain the distance between the Bluetooth positioning beacon and the moving target; the distance estimation formula is: ;in, This represents the distance between the i-th Bluetooth positioning beacon and the moving target. This represents the reference signal strength value at 1 meter. The second signal strength value of the i-th Bluetooth positioning beacon at the mobile target location is represented by n, where n represents the path loss exponent. Substituting the second signal strength value into the weight calculation formula yields the exponent weight corresponding to the Bluetooth positioning beacon. The weight calculation formula is: ;in, This represents the exponential weight of the i-th Bluetooth positioning beacon. This represents the second signal strength value of the i-th Bluetooth positioning beacon at the location of the moving target. The maximum value of the second signal strength that can be received at the moving target is represented by k, where k represents the attenuation coefficient. The step of substituting the distance and the weight index into the trilateration matrix and calculating the preliminary estimated position of the moving target using weighted least squares includes: substituting the distance and the weight index into the trilateration matrix to obtain the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, the distance squared difference matrix between the Bluetooth positioning beacon and the moving target, and the weight matrix; the trilateration matrix is: ; ; Where A represents the geometric relationship matrix between the Bluetooth positioning beacon and the moving target, and B represents the distance squared difference matrix between the Bluetooth positioning beacon and the moving target; This represents the x-axis coordinate of the nth Bluetooth positioning beacon. This represents the y-axis coordinate of the nth Bluetooth positioning beacon. Let W represent the exponential weight of the (n-1)th Bluetooth positioning beacon, and let W represent the weight matrix. Substituting the geometric relationship matrix, the distance squared difference matrix, and the weight matrix into the weighted least squares calculation formula, a preliminary estimated position of the moving target is obtained. The weighted least squares calculation formula is as follows: ;in, This indicates the preliminary estimated location of the moving target. Represents the transpose of the geometric relation matrix; The correction module is used to correct the preliminary estimated position using Kalman filtering to obtain the final estimated position of the moving target.
7. An electronic device, characterized in that, The device includes a processor, a memory, and a transceiver, wherein the memory is used to store instructions, the transceiver is used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1 to 5.