Smartphone indoor positioning based on enhanced BLE beacon multi-lateration
209 final report V1
1. PIR Sensor Based Indoor Locating and Tracking System
EE209AS Course Project Report
Yicheng Wang SID: 804237453
Tairan Jin SID: 204589288
Longjia Niu SID: 304590762
Abstract—This paper presents an optimized indoor
locating and tracking system based on PIR sensor module.
The PIR sensors in one module are modeled as concentric
rings and combinations of outputs are used for detection.
In order to build the tracking system, methods of location
and expansion are proposed. Then the system is proved in
MatLab and Kalman filtering is used to eliminate the
possible detection error in practice. Finally, the hardware
prototype is tested to demonstrate the basic idea of the
system.
1. Instruction
With the rapid improvement of technology and the growth
of people comfort level, smart home and indoor locating and
tracking gradually become the hottest researching and
application area. People are looking for a cost-effective,
energy-saving indoor locating and tracking system with good
performance serving to household appliances (lighting, HVAC,
etc.). In our project, we proposed an indoor locating and
tracking method with implementation of PIR sensors. And we
optimized the tracking model considering the real situation of
measurement. What’s more, we made comparisons among
different implementation options and found a relatively
cost-effective one with high accuracy and low cost. Finally,
we made a prototype to achieve the basic one-object tracking.
In the second chapter, we mainly talk about the background
knowledge of indoor location system requirements and motion
sensors.
In the third chapter we talk about the project work,
including locating modeling, tracking modeling with Kalman
filtering, MATLAB simulation and hardware implementation.
In the final part we make a conclusion of the job we have
done.
2. Background
2.1 Indoor location system requirement
First of all, in order to implement an indoor location system,
several requirements need to be reached. Because many
sensors will be installed in rooms of different sizes, the
implementation has to be at a relatively low cost. And the
installation must be flexible due to the different shapes of each
room and the obstacles such as household appliances and
furniture. Also importantly, the sensors used should be robust
enough to environment noise. What’s more, the accuracy of
location system should be high enough and adjustable
according to room types.
2.2 Motion sensor
An indoor location system needs to employ multiple motion
sensors, and other indoor locating and communication
technology such as WIFI, ZigBee, etc. Motion sensors can be
sorted into active and passive motion sensor. Active motion
sensors (such as microwave and ultrasonic sensors) emit
energy to the detection field and receive reflected signals for
analysis, however, passive motion sensors (such as PIR
sensors and pressure sensors) only receive energy from the
detection field.
2.3 PIR sensor
The structure of PIR sensors is shown in Figure 1. The PIR
sensor can let a certain wavelength infrared radiation in and
block other wavelengths. So the sensor let in the strongest
radiation that human and animals can emit. And PIR sensor
has two sensing elements inside and they are put opposite.
When there is nobody or no movement in the detection field,
the output from these two sensing elements is low voltage
(0V); when PIR sees the movement of humans or animals, the
output from these two sensing elements becomes high and the
high voltage signal will be amplified and AD converted before
final output.
Figure.1 PIR structure
PIR sensors have many advantages when utilizing in the
indoor location system. First, it is robust to temperature,
humidity, and electromagnetic noise. Second, it will not be
affected by the structure of a room or any obstacles and easy
to install on the ceiling. And no wearable or handheld devices
are needed for PIR sensor based indoor location system.
Finally, PIR sensors are cheaper than many other sensors and
PIR sensors are energy saving because they do not emit any
energy. Therefore, considering the good performance, low
cost and energy efficiency of the PIR sensor, we eventually
choose it as the motion sensor implemented in our location
system.
3. Implementation
3.1 PIR Sensor Locating Model
Usually PIR sensors are installed on the ceiling because
there is no obstacle between the sensors and target person.
Also it can save space in the room. The sensing area of a PIR
is a circle as shown in Fig. 2. This is the original model.
However, this model does not provide satisfying accuracy.
Fig.2 Model as A Circle
2. For example, it cannot detect a person’s location within the
circle. In order to increase the accuracy, we combine several
PIR sensors into one module to optimize this original model.
3.1.1 Basic Model
Fig.3 shows our basic model to demonstrate the idea. In the
basic model, the circle is divided into three concentric rings
with equal distance one after another. White rings are
un-shaded area which the relevant PIR can detect.
Fig.3 FOV of PIRs in Basic Model
Gray rings are shaded area which the relevant PIR cannot
detect. Therefore, three PIRs in one module have different
FOVs and there is no overlap between different FOVs. In this
way, we can use the different combination of outputs from
three PIRs to detect the target person. For example, if the
target person is in the middle ring, PIR No.1 and PIR No.3
will output low voltage and PIR No.2 will output high voltage.
The output of the module will be (0, 1, 0). If we regard
different outputs of the module as different codes, there are
three codes in the basic model (1, 0, 0) (0, 1, 0) (0, 0, 1).
3.1.2 Location Detection
In the model, the location of the target can be represented as
the middle point of concentric rings. As Fig.4 has shown, if
the target is in B, the distance between the target and center is
d which equals to rA+0.5rB.
Fig.4 Location Detection (1)
If the radius is divided into N equal parts by N concentric
rings, the location of target can be estimated as
1 ∗ /2 (1)
in which d means distance between target and center, n means
the number of the sensing area starting from 1 from center to
the boarder, m means max radius. For example, in Fig.5, N is
Fig.5 Location Detection (2)
3, with (1) we have
1 ∗ /2 (2)
if target is in area No.2, which means n=2, we will get
(3)
3.1.3 Location and Expansion
With one PIR module, the ring where the target person is in
can be detected, but the exact location cannot be provided.
Trilateration is a simple but effective way for locating. (2)
can provide d within one module and three PIR modules need
to be used to estimate the exact location. As Fig.6 has shown,
if we assume
1 1, 1 , 2 2, 2 , 3 3, 3
and the target person’s location is
,
Fig.6 Trilateration Location
then we have
1 1 1 (4)
2 2 2 (5)
3 3 3 (6)
With (4) (5) (6) we have
(7)
In which
2
2 1 2 1
3 2 3 2
3 1 3 1
(8)
(9)
1 2 2 1 2 1
2 3 3 2 3 2
1 3 3 1 3 1
(10)
With (7)(8)(9)(10)we can calculate the location
(11)
Three PIR modules can detect the exact location in grey
area. If the room has bigger area, it can expand into locating
network as Fig.7 has shown. Every regular triangle is a small
function block and they detect different regions.
3. Fig.7 Location Network
A second way to provide the exact location is to calculate
all the intersection points of different concentric rings first and
then calculate the target person’s location with the intersection
points closest to the person.
Fig.8 Location with Intersection Points
As Fig.8 has shown, if the target person is in the unit
detection regionⅠ, the closest intersection points are A B C
D.
If we assume
1, 1 , 2, 2 , 3, 3 , 4, 4
and the target person’s location is
,
then we can estimate the location by
x (11)
y (12)
3.1.4 Multi-FOV for One PIR
In the basic model, one PIR sensor has one FOV. As Fig.9
has shown, PIR No.1’s FOV is A, PIR No.2’s FOV is B and
PIR No.3’s FOV is C.
Fig.9 FOV of PIR in Basic Model
In this case, the output signals are A(1,0,0) B(0,1,0) C(0,0,1)
in which 1 means the PIR sensor in the module outputs high
voltage. However, one PIR sensor may have more than one
FOV and we can use the overlap between FOVs. In this case,
the number of PIR sensors may be reduced to 2. For example,
PIR No.1’s FOVs are A and C. PIR No.2’s FOVs are B and C.
A B C can also be detected and output signals are A(1,0)
B(0,1) and C(1,1). In this way, the cost will be lower because
of reduced number of PIR sensors in a module.
The FOVs of PIR sensors need to be designed carefully in
order to avoid error signal. If we assume that the number of
PIR sensor in a module is N, the total number of output
combinations of all PIR sensors, or the number of codes we
can use is 2N
-1. For example, if there are 2 PIR sensors in a
module, the 3 codes are (1,0) (0,1) and (1,1). If we use M to
represent the number of areas which need to be detected, then
we have
2 1 (13)
log 1 (14)
Also the number of PIR sensors shall not exceed the
number of areas which need to be detected.
(15)
Therefore, we have
log 1 (16)
This means that the number of PIR sensors can be
determined by the number of areas which need to be detected.
In our model, the areas are concentric rings. For example, if
there are 5 rings A B C D E, according to (16), we need 3 PIR
sensors in one node. There are 7 codes for use ( 1, 0, 0 ) ( 0, 1,
0 ) ( 0, 0, 1 ) ( 1, 1, 0 ) ( 1, 0, 1 ) ( 0, 1, 1 ) ( 1, 1, 1 ). We can
choose five from them to determine the FOVs of PIR in a
node. If we choose ( 1, 0, 0 ) ( 0, 1, 0 ) ( 0, 0, 1 ) ( 1, 1, 0 ) ( 1,
0, 1 ) for 5 different rings, A ( 1, 0, 0 ) B ( 0, 1, 0 ) C ( 0, 0, 1 )
D ( 1, 1, 0 ) E ( 1, 0, 1 ), PIR No.1’s FOVs are A D E, PIR
No.2’s FOVs are B D and PIR No.3’s FOVs are C E.
This is the way to determine the FOVs of PIR sensors in a
module. If we do not use the code to determine FOVs of PIR
sensors, error signals may be easily generated. In the above
case, if PIR No.2’s FOVs are A B D instead of B D, there
output signals for detected A and D are the same (1, 1, 0),
which means detection fails.
3.1.5 Whole Process of Model Building
Fig.10 Accuracy determines ring number
The whole process for building the model is following. As
Fig.10 has shown, if the max radius of PIR sensing area is 3m
and design accuracy of location system is 0.5m, the circle
need to be divided in to at least 6 rings.
6 (17)
With (16) and (17), the number of PIR sensors in a node
will be determined.
2.81 6 (18)
For minimum cost, N is the minimum
3 (19)
Then we will get the code we can use ( 1, 0, 0 ) ( 0, 1, 0 )
( 0, 0, 1 ) ( 1, 1, 0 ) ( 1, 0, 1 ) ( 0, 1, 1 ) ( 1, 1, 1 ). If we
represent 6 rings as A B C D E F, from inside to outside, we
4. can choose six code for them A ( 1, 0, 0 ) B ( 0, 1, 0 ) C ( 0, 0,
1 ) D ( 1, 1, 0 ) E ( 1, 0, 1 ) F ( 0, 1, 1 ). Finally FOVs of PIR
sensors will be determined. PIR No.1’s FOVs are A D E, PIR
No.2’s FOVs are B D F and PIR No.3’s FOVs are C E F.
Influence From Height
In practice the target person may not be represented as a
point and person’s height may influence the system. As Fig.11
has shown, B C D will all detect the target person.
Fig.11 Influence From Height
We call this multi-output. For multi-output, we can locate
the target person in the active sensing area which is closest to
the center. In this case, output is B C D and B is closest to the
center. Thus the location systems output that the target person
is in B, which is the correct detection.
3.2 Kalman Filter Tracking Model
3.2.1 Why Need Kalman Filter
The PIR locating system may produce some measurement
errors resulting in inaccurate locating in some specific
scenario. See the examples in figure 12 and figure 13.
Figure.12 Uncertain Measurement Border
Because of the unavoidable manufacture errors, the width
of the shaded circles on the Fresnel lens is more or less than
1mm (the theoretical blind area caused by the shaded circle is
the yellow ring however the real blind area is yellow plus red
one (shown in Figure 12), so the detection areas of two
adjacent shaded circles may have overlap, which makes the
locating result incorrect. Meanwhile, because objects are seen
as radiation sources with specific cross sectional area, when
an object is crossing the border of two adjacent detection
areas, wrong locating result may also be output. See figure 13.
When the object (blue circle) has almost entered the detection
area 2, but PIR modules can find the object in both detection
area 1 and 2. And because detection area 1 is more closed to
the center point of the left PIR module, the final detection
result is the object is in detection area 1 based on our locating
algorithm, which is not accurate.
Figure.13 Crossing Between Two Adjacent Detection Areas
These measurement errors can be maximally eliminated by
utilizing Kalman filter theory. Kalman filter regards these
measurement errors as unavoidable system noise, white and
Gaussian. And the filter can produce more accurate results by
combining and reconfiguring the measurement values and
predicted values. And the predicting ability of Kalman filter
plays an important role in object tracking. So we choose
Kalman filter as our tracking model.
3.2.2 Kalman Filter Tracking Model
Kalman filter estimates process states by feedback control
method. The working procedure of Kalman filter is as follow.
Firstly the filter estimates the process state at moment k, i.e.
the predicted values at moment k, based on the process state
information at moment k-1. For our tracking problem, the
process state includes the position coordinates and moving
velocity of the object. Secondly the filter will combine the
predicted values with the measurement values at moment K to
produce a new estimate state as the process state at moment k.
The model is shown below.
State equation:
, , 20
, , (21)
Where , and , are the current state in x direction
and y direction separately. And , and , are the
estimate next state in x-coordinate and y-coordinate
separately.
,
,
, ,
,
A=[
1
0 1
], B= ∗
Where and , are the coordinate and velocity of the
object in x direction; and , are the coordinate and
velocity of the object in y direction. T is the sampling period.
is an error deviation, white and Gaussian, with zero and
covariance matrix , caused by the random acceleration of
the object.
~ 0,
Measurement equation:
, , 22
, , 23
, and , are the measurement state in x direction and y
direction separately.
H=[1 0]
is a measurement error of PIR locating system, also white
and Gaussian, with zero and covariance matrix .
5. ~ 0,
Kalman filter can be divided into two main parts: time
update and measurement update. We do a priori estimate and
can get the values of next state and error covariance Matrix
in time update part:
, , , 24
, , , 25
|
And we do a posteriori estimate by combining the values
from the priori estimate with measurement value and Kalman
gain matrix in measurement update part:
, , , 26
, , , 27
|
And iteration procedure of the Kalman filter tracking model
is shown in Table 1.
State model:
, ,
, ,
, ,
, ,
Where and are independent white Gaussian
noise with covariance matrix and separately.
Initialization: For k=0, we assume the initial
velocity of the object is 1m/s in both x and y
direction (1.4m/s in total), and set
,
0
1
, ,
0
1
|
0 0
0 1
Calculation: For k = 1,2,…, calculate:
Kalman gain matrix:
State estimate update:
, , , ,
, ,
Error covariance update:
Error covariance propagation:
Q
Table 1 Iteration Procedure of Kalman Filter Tracking Model
3.3 MATLAB Simulation Setup
3.3.1 Sensors Placement Setup
In our model, the simulated test area is a 20*20 square area,
4 sensors covering and 8 sensors covering cases are
considered, as shown in Fig.14. PIR Sensors aggregations are
represented by black nodes. Each of them forms an equilateral
triangle with other two. Each node is the center of 3 or 5
concentric rings, indicating the number of sensors in an
aggregation. For example, if there are 5 concentric rings
surrounding a node, then there are 5 PIR sensors locating at
that node which has the detection area corresponding to
concentric rings.
Fig.14. 4 Sensors Covering Model (Left) and 8 Sensors
Covering Model (Right)
3.3.2 Test Routes Setup
We also setup up three types of test routes to simulate the
actual human being's walking path. They include square
routes, reverse Z route and Z route, as shown in Fig.15. Each
of them will be tested carefully and thoroughly to gain a better
understanding of multi-sensor tracking.
Fig.15. Square Type of Route (Left), Reverse Z Type of Route
(Middle) and Z Type of Route(Right)
3.3.3 Impact of White Gaussian Noise (WGN)
In telecommunications and computer networking,
communication channels can be affected by Gaussian noise
which is statistical noise having a probability density function
equal to that of the normal distribution, which is also known
as the Gaussian distribution. White Gaussian Noise (WGN) is
a special case in which the values at any pair of times are
identically distributed and statistically independent.
We add WGN into our model and compare the prediction
precisions without and with WGN, as shown in Fig. 16.
Intuitively, PIR sensors without WGN have better resolution
than those with WGN, as estimated locations (Red Nodes)
diverge from actual locations (Black Nodes) less in the case
without noise than with noise. This is also confirmed by
statistics in Table 2, where we can see that, given the same
number of concentric rings and the number of circles covering
the area, we get at most 21% average error reduction for PIR
sensors without noise. As a result, Kalman Filter is integrated
in our model to relieve the effects of WGN and get better
prediction result.
Fig.16 Locations Estimated by PIR Sensors (Red Nodes)
Without Noise (Left) and With White Gaussian Noise (Right)
6. Table.2 Average Estimation Error Without and With WGN In
Given Conditions
3.3.4 Impact of Concentric Rings
The number of concentric rings for a node center indicates
the number of PIR sensors aggregated at that center. We
compare the estimation result between 3 and 5 concentric
rings model, as shown in Fig.17. Intuitively, 5 concentric rings
model has better resolution than 3 concentric rings model, as
estimated locations (Red Nodes) diverge from actual locations
(Black Nodes) less in the former case. This is also confirmed
by statistics in Table 3, where we can see that, given the same
condition of noise impact and the same number of circles
covering the area, we get at most 37% average error reduction
for PIR sensors without noise. As a result, Kalman Filter is
integrated in our model to relieve the effects of WGN and get
better prediction result.
Fig.17 Locations Estimated by PIR Sensors (Red Nodes) in 3
Concentric Rings Model (Left) and 5 Concentric Rings Model
(Right)
Table.3 Average Estimation Error for 5 or 3 Concentric Rings
Model In Given Conditions
3.4 MATLAB Simulation Results
3.4.1 Type One Route Simulation
With MATLAB simulation setup completed, we integrated
white Gaussian Noise and 5 concentric rings into our model,
and get all three types of test routes thoroughly tested. An
example of type one route estimation is shown in Fig.18.
Black nodes are actual paths, red nodes are estimation
locations before Kalman Filters, and green nodes are
estimation locations after Kalman Filters. From the simulated
graph, green nodes diverge from black nodes less than red
nodes, which shows us the effectiveness of Kalman Filters
intuitively.
We also get some statistical results, as shown in Table 4.
From the table we can see that given the same conditions,
locations predicted after Kalman Filters can have over 50%
reduction on average error than before Kalman Filters, which
indicates that Kalman Filters have successfully relieved the
average error of estimation locations.
Fig.18 Locations Predicted by PIR Sensors Before Kalman
Filters (Red Nodes) and After Kalman Filters (Green Nodes)
Table.4 Average Error for 5 Concentric Rings, 8 or 4 Circles
Covering Model Before and After Kalman Filters for Type
One Route
3.4.2 Other Routes Simulation
The results of reverse Z routes and Z routes are shown in
Fig.19 Table.5 and Fig.20 Table.6.
Fig.19 Locations Predicted by PIR Sensors Before Kalman
Filters (Red Nodes) and After Kalman Filters (Green Nodes)
for Type Two Route
Table.5 Average Error for 5 Concentric Rings, 8 or 4 Circles
Covering Model Before and After Kalman Filters for Type
Two Route
7. Fig.20 Locations Predicted by PIR Sensors Before Kalman
Filters (Red Nodes) and After Kalman Filters (Green Nodes)
for Type Three Route
Table.6 Average Error for 5 Concentric Rings, 8 or 4 Circles
Covering Model Before and After Kalman Filters for Type
Three Route
3.4 Cost-effective Implementation
In industrial field we care much about how to achieve a
highly accurate locating system with lower price. From last
chapter we have discussed 4 implement options (8 PIR
modules with 3 PIR in one each; 8 PIR modules with 2 PIR in
one each; 4 PIR modules with 3 PIR in one each; 4 PIR
modules with 2 PIR in one each). We try to find the optimal
one from the dimension of the number of PIR sensors in a
module and the dimension of the m=number of modules. And
the result is drawn in fig.21.
Fig.21 Cost-effective Analysis
From fig.21 we can see the relatively optimal one is the
option in red (4 PIR modules with 3 PIR in one each).
3.5 Hardware Prototype Implementation
In our project we implement a hardware prototype to test
the working parameters of single PIR sensor and combined
working of multiple PIR sensors.
3.5.1 PIR Sensor Benchmarking
After did the benchmarking of PIR sensors in the market.
We found there are mainly 3 kinds of PIR sensors.
The first kind is shown in Fig.22. This PIR module is built
with a PIR sensor and a PIR motion detector IC. This module
can achieve PIR detection function easily with the help of the
IC but the output of this module has minimum 5s delay, which
means when it sees a person in detection field, it outputs a
high voltage signal with 5s delay no matter the person is still
inside the field or not in this 5s. This feature brings a lot
inconvenience for our real time detection.
Fig.22 PIR Sensor with Micro Power PIR Motion Detector IC
Second kind PIR sensor is shown in Fig.23. The output
signal of this kind of PIR sensor is an analog at very low
voltage. And the signal can only be used after amplifying and
AD converting. This PIR sensor with a circuit board can
achieve real time detection and with no delay, however, we
should layout a circuit board by ourselves.
Fig.23 PIR Sensor with a circuit board (Based on Datasheet
from Murata)
The third kind PIR sensor is shown in Fig.24. This PIR
sensor is designed by Panasonic. It integrates the amplifier
and converter circuit inside PIR sensor. So the PIR sensor can
achieve real-time detection in a small size. Finally we choose
this kind of PIR sensor for our hardware implementation. And
the model number of the Panasonic PIR sensor is
EKMC160111.
Fig.24 Panasonic PIR Sensor (Based on Panasonic PIR sensor
Datasheet)
3.5.2 Hardware Prototype Implementation
We did the test of the detection range of Panasonic
EKMC160111 PIR. The hardware implementation is shown in
fig.25, including an Intel Edison board, a PIR sensor and an
indicator light.
8. Fig.25 Working Parameters Testing
And the testing result of max detection distance and angle
are shown in Table.7. From the table we can see that the
theoretical values and test values are almost the same. The
design and simulation in our project are based on the test
values of these parameter.
Theoretical Value Test Value
Max Distance 5m 5.3m
Max Angle 94° 90°
Table.7 Detection Range Test
Then we combined 3 PIR sensors in a module to achieve a
basic tracking test. The hardware prototype is shown in fig.26.
We use 2 clapboards between every two adjacent PIR sensors
to divide the detection areas of the 3 PIR sensors into 3
different regions (similar function as the shaded rings on the
Fresnel lens). And we use a servo to show the location of the
object. The tracking video can be found on YouTube. URL:
https://youtu.be/0cNfHSquj08
Fig.26 (1) Front of The Hardware Prototype
Fig.26 (2) Back of The Hardware Prototype
4. Conclusions
In our project, firstly we have done an investigation of the
normally used sensors in the locating and tracking fields.
Compared with other sensors, we finally choose PIR sensors
for its good performance, low cost and energy efficiency.
Then we combine multiple PIR sensors together in a module
and cover their Fresnel lens by distributed shaded concentric
rings. We implement the modules on the ceiling and build a
locating model to detect the location of objects with the
accuracy of 0.5m. Considering the unavoidable measurement
errors, we employ Kalman filter to maximally eliminate the
measurement noise. Next we utilize MATLAB to simulate the
locating and tracking model we build and the results show that
our models can achieve locating and tracking in high accuracy.
And the tracking results are improved by using Kalman filter.
What’s more, we find a relatively cost-effective (high
accuracy with low cost) implementation after comparing 4
implementation options of locating system we have simulated.
Finally we achieve a prototype to test the locating and
tracking based on PIR sensors.
References
[1] Plett G L. Kalman-filter SOC estimation for LiPB HEV
cells[C]//Proceedings of the 19th International Battery, Hybrid
and Fuel Cell Electric Vehicle Symposium & Exhibition
(EVS19). Busan, Korea. 2002: 527-538.
[2] Luo R C, Chen O, Lin C W. Indoor human monitoring
system using wireless and pyroelectric sensory fusion
system[C]//Intelligent Robots and Systems (IROS), 2010
IEEE/RSJ International Conference on. IEEE, 2010:
1507-1512.
[3] Rahimi A, Dunagan B, Darrell T. Simultaneous calibration
and tracking with a network of non-overlapping
sensors[C]//Computer Vision and Pattern Recognition, 2004.
CVPR 2004. Proceedings of the 2004 IEEE Computer Society
Conference on. IEEE, 2004, 1: I-187-I-194 Vol. 1.