Using Fuzzy Logic to Improve BLE Indoor Positioning System

. Accuracy and precision are key parameters in the definition of indoor positioning systems. We want to provide a mobile robot with the capacity to autonomously determining its location inside buildings, to allow it to autonomously navigate. The solution developed is based on spreading emitter beacons of Bluetooth Low Energy in the building and use location finding techniques to determine the robot’s location. The main challenge is the capacity to obtain accurate readings of signal strength and the low repeatability of readings even under unchanged conditions. To improve the signal strength measurements it is necessary to deal with this imprecision. Our approach is based on the use of Fuzzy Logic to deal with the accuracy problem. Once better signal strength readings are achieved, using this method, approximate distances are calculated based on signal strength and the trilateration method is implemented to provide the location of the mobile robot.


Introduction
Indoor location is an emerging market that can be used for commercial purposes, public safety, and military.Commercially it can be applied to track children, people with special needs, help navigate blind people, locate equipment, mobile robots, etc.For military and public safety it will be useful to track prisoners, help policeman, soldiers and firemen navigate inside buildings [1].
Location and outdoors navigation was solved long ago with GPS.The problem occurs when you need accuracy or indoors location.GPS nowadays have an error of about 10 meters, radio signals coming from distant satellites don't work well with obstructed paths and the high-frequency waves bounce around when they hit metal and walls.This technology is therefore not usable on indoor location issues [2].
Actually there are some companies searching and testing solutions using different technologies to find a solution for indoors location.In general, the most important components of the system are location sensor devices that produce metrics of the relative position of a mobile terminal (MT) and a known reference point (RP).Most conventional positioning methods are Angle of arrival (AOA) to estimate direction; received signal strength indicator (RSSI), Time difference of arrival (TDOA) and Time of arrival (TOA) are used to estimate distance [1].
Our goal is to provide a mobile robot (ServRobot 1 ) with a tool to know is location using Bluetooth Low Energy beacons signals.

Cyber Physical Systems
The cyber-physical systems (CPS) consider computational components and physical units to cooperate with humans using different technologies.CPS are intelligent, realtime, distributed, networked (wired/wireless) control systems and likely linked in a loop.They can be useful in several fields.CPS design consists of a network of cooperating elements with physical inputs and outputs.It connects computational and physical rudiments to obtain better effectiveness, functionality, security and flexibility [3].
This work is related to cyber-physical systems, by combining physical entities: Bluetooth Low Energy (BLE) beacons, with computational elements that through a BLE signal receptor connected to a computer, allows to process the input values and implement algorithms to build the desired system.The final goal is to locate an autonomous mobile robot in a wireless network in real time that could be adapted in the future to locate other objects like phones or even people.It consists on build a system in real-time with feedback loops where physical processes, in this case the received signal strength indicator from the BLE beacon affect computations and have influence on the robot next moves and upgrade others functionalities by knowing the robot location, it can improve the efficiency, safety, reliability and functionality of the mobile robot.
This project could help the research on efficient and functional indoor location systems contributing for the cyber physical systems development too.

Conventional Positioning Methods
In the next sections, several conventional positioning methods are presented.RSSI -It is a process used to estimate the distance between the receiver and a beacon.It matches the probability distribution with the strength of the received signals, and estimates the distance using a statistical method.To start a sample of the signal strength is read in different locations, but the environment changes modify the path loss models that enables to repeat the same strength of the received signal.It is necessary an environment precise path loss model to use the location estimate system [4].
AOA-This method is used to measure the direction in a system and it can do it reading the direction of the received signal using two or more antennas on different positions [4].
TOA -It is a time-based positioning technique that measures the signal travel time between nodes [5].
TDOA -This method estimates the time difference of arrival between two signals moving between two reference nodes and the given node [5].
Table 1 compares the accuracy degradation of an indoor location system due to multipath fading and increase of the distance between devices for each positioning method.

Indoor Location Systems
There are different location determination systems and processes for indoor environments: ultrasound, infrared, electromagnetic, visual location, physical contact and radio frequency systems.We will focus on radio frequency systems.
Bluetooth based systems -Radio hardware (beacons) with Bluetooth low energy protocol.Beacons are spread over surface and the signals that they send can enable devices to determine their location.Some systems use beacons signal to incorporate on fingerprints database, others determine absolute or relative location by measuring distances, trilateration.Furniture and walls hinder signal propagation.Using three beacons is enough but a fourth one will decrease localization errors [6].Indoor location is challenging because of the reflections and absorptions.Besides Bluetooth Low Energy there are Wi-Fi, RFID, ZigBee and Ultra-Wideband based systems.More details in [7,8,9].Some developers combine multiple technologies like fusing data based on Wi-Fi and Bluetooth.Fusing helps to obtain more accurate results.

Location Techniques in Indoor RF-based Systems
There are two types of techniques to calculate the location using RF-based systems, geometric (traditional) and pattern recognition.
Geometric techniques -calculate positions based on distances between mobile transmitter-receiver and fixed receiver-transmitter. Trilateration -Provides an estimate of the device's location by using the received signal strength from different transmitters (non-linear).The distance estimation from the transmitters to the receiver is calculated using the relation between distance and signal strength: (1) Pt is the transmitters power (in dBm), Pr is the power at the receiver, λ is the wavelength, n is the path loss exponent (n=2 is free space), d is the distance transmitter/receiver.The distance estimation generates a circle centered on each transmitter, the device will be located where circles coincide.The technique is called trilateration [11].Triangulation -Uses geometric properties of triangles to estimate the target's location.More details in [11].
Pattern Recognition techniques -It consists in buildin a signal strength model.To estimate the mobile device's location is necessary to calculate the match with the signal strength model.It requires two phases: the offline phase, where a map is built after collecting the RF signals from defined location points.And the online phase, where an algorithm is used to find the match between the read signals and the previously collected signals to estimate the device location [5].Traditional methods are K-Nearest Neighbors, Neural Networks and Probabilistic.More details in [12].

Fuzzy Logic
Fuzzy Logic is bets fit on under uncertainty, it deals automatically with tolerance for imprecise values.The variables are represented by membership functions, instead of the absolute true or false values.It reproduces the human mind capacity to employ approximate reasoning.In classic logic the decision is binary, true or false, whereas in Fuzzy Logic variables have a range between 0 and 1, of degree of membership towards a fuzzy set [13].Imprecise inputs can be considered and used as "linguistic variables" denoting values such as big and small, low/medium/high are used in the model.Common membership functions used in Fuzzy sets are triangular, Gaussian, trapezoidal, etc, although triangular (see fig. 2) is more widely used.Figure 3 shows the block diagram of fuzzy logic mechanism.Fuzzification is a procedure that classifies numerical values into fuzzy sets, the rule base contains the IF-THEN rules that represent the linguistic variables.The evaluation relates the IF-THEN rules to the fuzzy sets to get a fuzzy output.The Fuzzification changes crisp data into linguistic values using linguistic variables, membership functions map every element of the input variables onto a membership rate from 0 to 1.The evaluation makes approximate reasoning [13].
The defuzzification procedure alters the fuzzy output back to the classical output with the control goal.There are three defuzzification techniques normally used, the most widely used is the Center of Gravity method (COG) is identical to the physical calculation of center of gravity in objects, the weighted average of the membership function of the center of the gravity of the area limited by the membership function curve is computed to be the crispest value of the fuzzy values.Besides COG there are Mean of Maximum and Height Methods [13].

Development
Our system development starts with the interaction between a BLE transmitter (beacon) and the BLE receptor (sniffer).

Bluetooth low energy sniffer and beacon
To receive the received signal strength indicator (RSSI) from the beacons a Bluetooth low energy sniffer (Adafruit bluefruit LE Sniffer nRF51822) is used.This device is a USB-to-BLE board that allows the computer to communicate with a BLE enabled device.The Gimbal U-Series 5 proximity beacon is a small, USB powered device that transmits a Bluetooth Low Energy signal that can be detected by other devices, in this case by the Bluetooth Low Energy sniffer.This signal enables the identification of the beacon by the MAC Address.The sniffer captures the RSSI value and with it it's possible to calculate the distance estimation between the devices.

Obtaining distance from RSSI values
The code used by the device Adafruit bluefruit LE Sniffer nRF51822 is written in python and allows to retrieve the RSSI and MAC address of nearby BLE beacons, this project uses that code as start point.To obtain the distance in meters from the received signal strength indicator (RSSI) it was necessary to measure a bunch of RSSI measurements at known distances, then we did a best fit curve to match the data points, this algorithm was developed by David Young in Java.In this work the code was adapted to python language [14]. (2) The variable txPower is the RSSI value at 1 meter of distance, it was calibrated and the obtained value was -87 db.The values 0.89976, 7.7095 and 0.111 are the three constants calculated when solving for a best fit curve to the measured data points.Each 0.95 seconds a distance reading is received, the main challenge is the capacity to obtain accurate readings of signal strength (and consequent approximate distance in meters) given the low repeatability of readings even under unchanged conditions.The direct signal strength measured by the Bluetooth signal receiver vary in each reading because of physical disturbing factors such as wall reflections and other devices transmitting the same frequency.To improve the measures, two normalizing techniques: "median and average filters" and "Fuzzy Logic" were implemented.

Median and Average Filters
After some tests comparing the real distance measured with a scale and the distance obtained at the program by the sniffer it was detected that the accuracy is bad and has low repeatability of readings.To try to improve the accuracy and the repeatability, a way to discard the absurd values on was developed.First a vector accumulates ten measurements and after that the values are sorted, the extremes are excluded and the four middle values are used to calculate the average.However, as the results were still far from good, since they were imprecise we decided to use another approach.Using Fuzzy Logic to deal with imprecision.

Fuzzy Logic implementation
To deal with imprecise values we decided to use Fuzzy Logic.This could be a good way to improve the results.The tool used was an open source java library called jFuzzyLogic.This library imports a Fuzzy control language file with the input and output variables and the linguistic terms configured, then checks the rules to return an output variable based on inputs.We take the results of the median process and in the end it will return only one output variable with the final value.For each of the four inputs there are twelve linguistic terms possibilities to do the fuzzification ranging from "less 0.5m" to "more 5m".Then the system will check the rules block with 23 rules and makes the decision (Fuzzy inference).To finish the defuzzification is done and a real value is obtained as output.Considering ten direct distance measures read by the sniffer at 1 meter away from the beacon (real distance), the four middle values are selected as inputs for the FCL file and each of them is fuzzified.Then the system checks the rules block, makes the decision and does the deffuzification to obtain a real value as output.In our test the final distance output is 1.02 m, close to the real distance 1 m.The defuzzification technique, Center of Gravity method was used.

Distance readings results
Three different ways to obtain the distance between the BLE beacon and BLE sniffer were tested in an office room without objects between the devices.The first method uses direct distance readings each 0.95 seconds, the second method applying median and average filters after ten direct readings and third method implements a fuzzy logic inference system after ten direct readings.The BLE beacon was fixed on a power supply and the BLE sniffer connected to a computer was positioned at different distances measured by a scale at 0.5m, 1m, 1.5m, 2m, 2.5m and 3m.The test values were obtained ten seconds after fixating the BLE sniffer position to guarantee receiving a stabilized signal.The following graphics compare the measurements obtained by the three methods:

Conclusions and Future Work
After doing these tests with the three methods some behaviors of the receiving signal were detected.The signal takes some time to stabilize after changing the distance between the beacon and the sniffer.It is necessary to wait some seconds until the values get closer to the real distance.Once the signal stabilizes the repeatability increases.In general as the distance between the beacon and the sniffer increases, the average error of distance estimations increases.That is an expected behavior because the disturbing factors like signal reflecting rise their negative influence as long as the direct signal wave power (the desired one) gets lower.
Comparing the direct readings average error and the estimations after applying median and average filter average error, the results of applying the filter are not as good as expected.That can be explained because even maintaining the sniffer at same fixed position when the distance estimation gets high or low it tends to still get higher or lower with time.The normalizing factor by applying median and average filter excludes the estimations that usually are far from real distance, but due to the trend to the estimation to get high or low with time, it doesn't improve the average error.In practice the average error obtained by direct readings method is similar to the average error applying median and average filter.Comparing the direct readings average error with the Fuzzy Logic inference system estimations average error, the implementation of Fuzzy Logic reduces the error between real distance and estimation, improving the accuracy and the repeatability.This normalizing method proved to be more satisfying that Median and Average method.It proved to be useful improving the estimation values and Fuzzy Logic inference system was adopted in this project.The next step will consist in implementing the trilateration algorithm after obtaining the estimated distance between three fixed BLE beacons in known positions at x, y coordinates and the BLE sniffer which is in an unknown position and can move.

Table 3 .
Average error for each method at different distances