You are on page 1of 7

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/337985439

Geofencing on the Real-Time GPS Tracking System and Improving GPS


Accuracy with Moving Average, Kalman Filter and Logistic Regression
Analysis

Conference Paper · October 2019


DOI: 10.1109/ISMSIT.2019.8932766

CITATION READS

1 536

2 authors:

Zeynep Özdemir Bulent Tugrul


Ankara University Ankara University Faculty of Sport Sciences
4 PUBLICATIONS   7 CITATIONS    12 PUBLICATIONS   41 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Desing of Geofence mechanims on real time tracking system with GPS+GSM+GPRS technology View project

All content following this page was uploaded by Zeynep Özdemir on 31 January 2020.

The user has requested enhancement of the downloaded file.


Geofencing on the Real-Time GPS Tracking
System and Improving GPS Accuracy with
Moving Average, Kalman Filter and Logistic
Regression Analysis
Zeynep ÖZDEMİR Bülent TUĞRUL
Ankara University Ankara University
Computer Engineering Computer Engineering
Ankara,Turkey Ankara,Turkey
zynpozdemir@ankara.edu.tr btugrul@eng.ankara.edu.tr

Abstract—People throughout history have wondered their depend solely on the number of satellites. There are four
position on the world. This led to the development of Global factors that affect the performance.
Navigation Satellite Systems (GNSS). The most widely used is
the GPS (Global Positioning System) technology. Signals 1. Accuracy: Distance, speed, time difference between the
emitted from GPS satellites. Calculates your own location by measured position and actual position.
detecting GPS receivers on earth. The GPS data obtained in this 2. Integrity: Providing accurate alarm and information in
study was sent to a remote server via GSM and GPRS and unexpected and unwanted conditions
turned into a real-time tracking system. The location of the GPS 3. Continuity: System continues to operate without
device can be monitored instantly by observing the application interruption
map screen from devices such as computer and phone. This
4. Availability: The period in which the transmitted signal
monitored location has a certain delay considering the factors
such as the arrival time of the GPS data to the device and the provides three other factors and the system is running.
time the device connects to the internet. The system operates If these conditions are not sufficiently fulfilled, GNSS
with a delay of 4 - 5 seconds. In addition, the Geofence field is services will improve with support from satellite-based local
used to alert the device when it moves away from a specified
development systems. GPS is now widely used for both
location. As the Geofence area, a predetermined polygon on the
map can be used or the polygon area drawn during the military and civilian purposes. Navigation of land, air and sea
application can be used as Geofence. On the application screen, vehicles, missile guidance, finding targets, determination of
an audible warning is given when leaving the Geofence area. the position of the aircraft in limited or not, such as military
GPS does not always show the exact correct position; it has a use; animal, vehicle, infant tracking systems, cadastral
certain margin of error. Many factors affect this margin of surveys, surveys for geodetic and geodynamic purposes,
error. This causes the application to give false alarms and development of geographic information system databases.
operate with the wrong location. In order to reduce this error,
the error rate was tried to be reduced by using Kalman filter, There are 24 satellites of the United States Department of
logistic regression analysis and moving average filter. Normally Defense. Three of them are reserved. These satellites emit a
the error margin of up to 15 meters is considerably reduced by kind of radio signal. This signal contains the position and
these filters. time of the satellite. The GPS device calculates its position
with the position and time information sent by the satellites.
Keywords—GPS, GSM, GPRS, Geofence, Kalman Filter, Moving The GPS device calculates the latitude and longitude values
Average, Logistic Regression Analysis
when it sees three satellites. As the number of satellites
I. INTRODUCTION increases, the accuracy of the position information increases.
In the open air, a GPS receiver can see at least 4 and at most
Today, most people think of GPS when it comes to location
12 satellites. The satellites are placed in orbit accordingly.
service. Although GPS is known as a popular location service GPS devices produce data in NMEA standard as a result of
around the world, these two services, together with the
their calculations. This is important for the proper use of GPS
Russian alternative GLONASSS (Global Orbiting coordinates [11].
Navigation Satellite System), are part of a system called
GNSS (Global Navigation Satellite System). There are Global System for Mobile Communications is abbreviated as
different location services developed by India, China and GSM. It is the most common mobile phone network in the
European countries. Since it is the first service, it is generally world. The user can access and make calls to all countries of
known as GPS. GNSS is briefly defined as a set of satellites the world on the same line. GSM uses the cellular network as
that send signals from satellites in space and are used for standard.
global positioning. GNSS receivers, such as mobile phones,
GPRS stands for "General Packet Radio Service". GPRS is a
can detect their own position by decoding signals that are sent
mobile data technology that enables data transfer over mobile
by orbiting satellites that contain data such as positioning and
phone receivers. Uses packet-switched data transfer. Allows
timing. The higher the number of satellites that a GNSS
you to connect to the Internet. Packet-switched data
receiver receives, the higher the accuracy of the calculated
communication means that the data is separated into packet-
position, but the performance of GNSS services does not
named pieces and then reassembled according to the

978-1-7281-3789-6/19/$31.00 IEEE
sequence number. The Internet network generally works with points are located, measurement was performed with the
this technology. device. On the data obtained, error reduction process was
performed with moving average and Kalman filter.
This study was planned as a real-time tracking system. This
vehicle monitoring can be used in the follow-up of children Kalman filter is a method that can estimate the values of
or in case of loss of Alzheimer's patients. In short, the location systems in many different fields. In mathematical terms, the
is followed wherever the device is located. The methods used Kalman filter predicts the states of a linear system. Generally
in tracking systems are very different, sometimes used in GPS systems. It was also used in this study and tested
communicating via text message, sometimes only data is how much it reduces the error.
stored in the memory card.
II. RELATED WORKS
In this application, GPS data can be sent to a remote server
As the study is comprehensive, various fields and scientific
and tracked on the map. After the data sent using GPRS
studies have been utilized. Arduino and Sim908 related part
technology is saved to the database, it can be actively used in
of the embedded software, GSM and GPRS related part of the
different applications. However, it takes a certain time for the
data communication, NodeJS used part of the web software
signals received from the satellite to be received and sent to
and leaflet and map software were completed by the technical
the remote server. This delay varies between 3 - 8 seconds in
part of the project. Studies to improve the accuracy of GPS
the device we use.
data have also been handled separately.
As it is understood from the study, it consists of two parts.
In one study [1], a GPS and GSM based tracking system was
The first is to receive GPS position data using the Sim908
studied. They designed a vehicle tracking system as a
device and send the data to a server using GSM and GPRS
different and practical model. Compass sensor YAS529 and
technologies. The second is the display of GPS data via web
Accelerator sensor KXSC72050 were used. The direction of
or Android application. It is very difficult to follow a location
the vehicle is estimated and followed by SMS and GPRS. In
on the application screen. For example, it is not an effective
another vehicle tracking system study [2], GPS, GSM and
solution to monitor and monitor a child for 24 hours. The
GPRS were used. The geofence area is already defined in the
child can play for hours without leaving the park boundary.
system and is circular. When this field is exited, it is provided
In order to find solutions to such situations, the ability to
to be alerted by SMS. The entrance and exit of the Geofence
make geofence on the map screen has been added. Geofence
area gives warning in case of stopping and moving of the car.
can be briefly defined as a geographical restriction. It is a
Google Maps API is used as a base map.
system that warns when going out from a certain area. A child
can be given an example of the target to be followed and the In one study [3], a car was designed as an anti-theft system.
parking area where he plays is an example of a Geofence area. GSM and GPS module is used and the vehicle is stolen with
Parents of the child can use the devices we use on the child a vibration sensor. The system is in constant contact with the
in the form of electronic bracelets to follow up and be aware owner of the car. Likewise, the purpose of the vehicle
of the situation. As soon as the child steps out of the Geofence tracking and security system study using GPS GSM modules
area, his / her parents can be warned by SMS, voice alert or [4] is to perform real-time tracking of bus transportation
mail. Geofence is designed in two kinds. The first one is static between the cities. When the car crashes and theft reports.
geofence, the polygon area defined herein are used as Written in the article of tracking system [5], GPS and GSM
geofence. The second one is followed by the dynamic are used in the same way.
geofence and the map is used as a geofence area without
There is an improved study to follow animals in wild-life [6].
recording the polygon. The advantage of this is to make new
It is a study that can be used in endangered and prohibited
drawings at any time and actively use the work.
animals. In a project [7], a follow-up project was developed
There are many causes of errors in the GPS data. A few of to avoid getting lost while travelling. There is another study
these are weather conditions, reflections in the atmosphere, in the form of a system that prevents intruders from entering
and the reflection of the signals hitting buildings. This error [8].
rate may vary depending on the device used, the weather
There are also studies developed on Arduino. [9] In the study
conditions at the location and the density of the building.
where Telit-gl865 device and GPS click device were used,
Although the error in the data is caused by many reasons, the
the only tracking system was developed. In another study
error rate can be reduced by making corrections on the data.
developed with Sim900 device, [10] geofencing features
There are various approaches to reduce the error rate. In this were added.
study, the error was tried to be reduced by moving average
and Kalman filter. The average filter is based on the III. MATERIALS AND METHOD
mathematical average of the data received. The moving Devices, libraries, systems and algorithms used in this section
average filter, on the other hand, is used for data that travels will be introduced in general.
in a time-dependent series. For example, averaging 10 data,
including new incoming data, is estimated at the next point. A. Arduino
This results in a high reduction of the error in the data that Arduino is an electronics development board. It has its own
makes a sudden jump. Makes distribution softer. The amount processor inside. Codes are loaded and executed from the
of error reduction can be understood when the actual value of development interface via computer. The Arduino cards are
the data is known. In order to create this test medium, 3 points equipped with AVR microcontrollers from Atmel. Arduino
with known actual location were determined. Where these consists of an IDE (Integrated Development Environment),
Arduino bootloader, libraries, microcontroller called allows you to easily add modules written by other developers
AVRDude and software compiler. In this study, Arduino Uno to the project and develop faster applications. [13]
was used.
Using a library called Express.js, server creation, setup, and
B. Sim908 execution are performed. Thanks to this library, various
Sim908 has GSM and GPS modules together. Designed to settings are made automatically instead of making them one
work with Arduino and Raspberry Pi. The AT commands are by one. [14] Gulp is a Javascript task manager. It performs
given in the instruction manual are communicated. each given task in the file “Gulpfile.js ile respectively. This
automates and accelerates all the processes we need to do
before compiling. For example, one of the given tasks is to
reduce the used Javascript libraries to file_name.min.js. All
we need to do is show the path to the javascript libraries and
define the task. It reduces the operating time by automating
operations [15].
D. Leaflet.js
The leaflet is an open-source JavaScript library written to
create maps. Although Openlayers has alternatives like
Google Maps API, it is preferred because it is very flexible,
easily developed and customizable. A large number of plug-
in libraries are available from Github and can be customized
to suit your usage needs. Leaflet supports its own GeoJSON
format and other map data formats. The GeoJSON format
allows the JSON data format to be used in mapping
applications. In other words, the values that we can use on the
map such as point, polygon and line are in a certain format.
GeoJSON has added flexibility and speed to the Leaflet
library. Data can be added and processed in a single layer.
Leaflet Realtime is a library that can simultaneously display
data from a web service without refreshing the map screen.
The most important feature of the study is actually in this
library. It allows the data sent from the device to be displayed
Fig. 1. Arduino and sim908 module [12] instantly on the map.

The connections are as shown in fig-1. The SIM (Subscriber E. Kalman Filter
Identity Module) card and GPS and GPRS receivers are Kalman Filter was first discovered by Rudoff Kalman. It is a
installed. It is then integrated into the Arduino. Pin filter that is dynamic and can predict the location of the next
adjustments should be made as shown in the Fig 1. system in a system with known state space using previous
data. If there is scholastic or random noise in the system, the
The Arduino board is connected to the computer with a cable. Kalman filter works very well [16]. The real purpose of the
The Arduino IDE is loaded with the necessary code and is Kalman filter is to reduce errors in the covariance matrix. The
enabled to run. First, GPS data is received. A data set in basic Kalman filter accepts measurement results as a linear
NMEA format is obtained. This data is processed instantly system, but not many systems in the real world. For this
and sent to a remote server via GPRS. HTTP Get methods are reason, the Kalman filter has been developed and diversified.
used. Although much data was obtained, latitude, longitude, In this study, a linear Kalman filter was used.
altitude and time data were sent. Data can be sent at intervals
of 3 to 5 seconds. F. Moving Average Filter
C. NodeJS The average algorithm is to obtain a certain number of data
and divide it by the number of data. Moving average filter is
NodeJS is a runtime JavaScript platform that can be used for averaging according to filter size with the FIFO structure by
both background and foreground applications. The structure taking a certain number of data. It is a simple but effective
is asynchronous. Therefore, instead of making requests one filter.
by one, it does it in parallel. After each request, a function is
called to indicate that the request is finished and this structure G. Logistic Regression Analysis
enables real-time applications, games and instant messaging Linear regression is a statistical method for summarizing the
applications. NodeJS has been preferred because speed and relationships between binary and continuous data. Defines
performance are the most important factors in the real-time the relationship between dependent and independent
tracking system application. The GPS data from the variables. This is also used for time-varying data. Logistic
background is continuously checked and shown on the map regression is used to analyze data with one or more
in real-time. NPM (Node Packaged Modules) is a package independent variables that determine the outcome. In short, it
manager that we can easily download and install libraries. It can be thought of as a classification problem, which depends
on many variables, and the result is yes or no. As a result, find
the most suitable model. It is used in many different
problems. Provides efficient classification when working
with nonlinear data. Or find the right truth for them.
IV. RESULTS
A. System Architecture
The general operation of the system is shown in the Fig. 2.
The received GPS data was processed and sent to a remote
server. Then, it was turned into a real-time tracking system
with the location information shown on the map application. Fig. 3. Application screen using all libraries

Web application developed with NodeJS and Leaflet.js is


used on the map screen. Leaflet-pip and Leaflet-realtime
libraries were used for Geofence. Leaflet pip works based on
a point in polygon algorithm.

Fig. 2. System Architecture

To summarize briefly, Arduino Uno and Sim908 were used


together in this study and the data were taken and recorded to
a remote server. After writing our codes on Arduino IDE, we
Fig. 4. Geofence application
connect our device to the computer with a USB. The
appropriate port setting is made on the computer. The baud It is tested whether the GPS coordinate we have is in a
rate for the Sim908 device is 11500. AT instruction sets are specified polygon. While a polygon registered in the
used for communication with the Sim908 device. It is background can be used as a geofence area, the online drawn
necessary to put waiting times between these commands. polygon area can be used as a geofence area without saving
More or less this time affects performance. 2000 ms. After it to the database. The ability to do so has given the project
the code installation, our program will try to communicate flexibility and ease of use. Since there are 2 different uses,
with Sim908. In order to activate at this stage, we need to the nomenclature has been named as static geofence and
press the ON-OFF button on Sim908. After waiting for a dynamic geofence. A static geofence is the use of the polygon
certain time, whether the connection is established or not is registered in the database as the geofence field, while
determined by the led light. Firstly, the GPS module dynamic geofence is used as the non-registered polygon as
communicated with the location data. Adjustments are made the geofence field.
to position each second. The received NMEA data is prepared
to be segmented and sent. Latitude, longitude and time data
were used. Since the size of the data to be sent via GPRS B. Increasing GPS Accuracy
affects the transmission speed, the minimum amount of data
we need is selected. HTTP Get methods were used to send Two different problems were encountered while working
the data. with GPS. The first is that GPS data has a margin of error.
There are many reasons for these errors. Weather conditions,
Our data was transmitted approximately every 4 -5 seconds. atmospheric breaks, a reflection of signals from tall
On the server-side, a service is written and recorded to the buildings, time difference between satellites and GPS device
database of received data. The data recorded in the database are some of these reasons. As a solution, some algorithms and
is obtained through SQL queries and displayed on our web techniques have been used to reduce the margin of error to
application screen. Important data is the most recently added the data we have recorded in the database. Moving average
current data. This data is queried and displayed on the map filter, logistic regression analysis and Kalman filter were
screen. The 10 most recently added data are also shown for evaluated as solutions for this problem. The second problem
visualizing the route. is that the data are not taken at some time values for various
reasons. This can be ignored in data received per second, but
it is a problem that GPS data of a migrant animal is sampled
once an hour. The next position can be estimated without
error reduction.
Algorithms can be used to measure with GPS device, but data
with an error rate of 0 is needed to compare the accuracy of
the algorithms. For this reason, 3 points were determined and
the measurement of the sim908 device was compared with
the measurement made by the device with an error rate of 0.2 V. CONCLUSION
cm. Three locations were determined and 100 measurements In this study, real-time tracking and geofence were
were taken and the results of the algorithms used were performed. As described in the literature review, previous
compared. The data were based on time series analysis studies only perform real-time follow-up. In addition, some
because of the continuous error. have a simple geofence. This geofence was performed by
measuring the distance between the coordinates on the
hardware side. In this study, the geofence process is
performed on the map application screen after the data is
transferred to the server-side. Not only the circle but also the
polygons connected to the user's drawing can be used as
geofence. In real-life applications, the smooth circle-shaped
geofence area is useless. This problem was solved by defining
geofence in the form of polygon.
The application can be used for tracking children. If the child
is playing in the yard of the house and the geofence area is
determined to cover the perimeter of the house, it will give a
warning when the child moves away from the house.
Fig. 5. Position 1 GPS error reduction
According to this scenario, the geofence area is customized
in two ways as static and dynamic. Static predefined polygon.
The home where the child lives is always defined as static
because the school he/she goes to is always immutable. The
fact that the polygon drawn in real-time in a newly travelled
area can be used as a geofence without saving is defined as
dynamic geofence and has provided a very flexible use to the
study.
NodeJS is preferred as a web system. Both server-side and
user-side are written in the JavaScript language. It is more
secure than other systems because it only sends HTML output
to the user part. The Leaflet library is also an open-source
Fig. 6. Position 2 GPS error reduction mapping software library. A user-friendly web application
was written using it with different libraries.
GPS data has errors for various reasons. It is aimed to reduce
the error rate in the data in order to make the system run faster
and to be stable. As stated in the literature summary section,
this issue is very much focused and various algorithms have
been developed. The most preferred of these was the Kalman
filter. The comparative results of the three methods are given.
Moving average, logistic regression and Kalman filter were
applied for error reduction. In the moving average, the
parameter value which decreases the error the most is
determined as 10 and used in this way. In this algorithm, it is
a negative situation that no estimation value is obtained for
Fig. 7. Position 3 GPS error reduction the first 10 data. The input parameters of the Kalman filter
are also important for use with GPS data. The parameter
The figures show a comparison of the results of the value used in logistic regression analysis is 9. In order to
algorithms. Mean square error method was used to compare determine whether our algorithm results are working
the error rates of the data. According to the results obtained, correctly, we need accurate and accurate values of the tested
the algorithm that reduces the error the most is the Kalman GPS data. For this reason, 3 points were determined and
filter. measurements were made at these points. The actual value of
the received position is based on a more advanced GPS
TABLE I. MSE ERROR RATE COMPARISON
device with a margin of error of 1-2 cm. Kalman filter reduces
Location
Moving Logistic
Kalman Filter
the most errors for all positions in the comparison with this
Average Regression value. The experiment was conducted outdoors and in a low-
Point1 Lat 0.339551 0.232372 0.030419 density building. Therefore, the average error value for our
Point1 Lon 0.400679 0.297516 0.003212 data is around 2 meters.
Point2 Lat 0.020859 0.013332 0.001970
Point2 Lon 0.082780 0.051854 0.000382 REFERENCES
Point3 Lat 0.159223 0.139857 0.047036 [1] Le-Tien, T. and Phung-The, V. 2010. Routing and tracking
Point3 Lon 0.020673 0.013697 0.000515 system for mobile vehicles in a large area. Içinde Proceedings - 5th IEEE
International Symposium on Electronic Design, Test and Applications,
DELTA 2010 297–300.
[2] Almomani, I. M., Alkhalil, N. Y., Ahmad, E. M. and Jodeh, R.
M. 2011. Ubiquitous GPS Vehicle Tracking and Management System.
[3] Hu, J. M., Li, J. and Li, G. H. 2012. Automobile anti-theft system
based on GSM and GPS module. Proceedings - 5th International Conference
on Intelligent Networks and Intelligent Systems, ICINIS 2012, 199–201.
[4] Fleischer, P.B., Nelson, A.Y., Sowah, R.A. and Bremang, A.
2012. Design and development of GPS/GSM based vehicle tracking and alert
system for commercial inter-city buses. Proceedings of the 2012 IEEE 4th
International Conference on Adaptive Science and Technology, ICAST
2012, 1–6.
[5] Verma, P. and Bhatia, J.S. 2013. Design and development of
GPS-GSM based tracking system with google map based, 3(3), 33–40.
[6] Thomas, B., Holland, J.D. and Minot, E.O. 2011. Wildlife
tracking technology options and cost considerations. Wildlife Research,
38(8), 653–663.
[7] Beeco, J. A., Hallo, J. C., and Brownlee, M. T. J. 2014. GPS
Visitor Tracking and Recreation Suitability Mapping: Tools for
understanding and managing visitor use. Landscape and Urban Planning,
127, 136–145.
[8] Monti, G., Tarricone, L., Corchia, L. and De Benedetto, E. 2016.
Wearable logoantenna for GPS–GSM-based tracking systems. IET
Microwaves, Antennas & Propagation, 10(12), 1332–1338
[9] Koyuncu.B., Z. Ozdemir (2016). Real time position detection by
using GPS+GSM+GPRS and Arduino Mega based Telit GL865,
International Journal of Electronics Communication and Computer
Engineering, Vol 7 ,issue 1, IJECCE, pp 44-48
[10] Koyuncu, B., Özdemir, Z. 2016. Real Time Localization and
Leaflet Map Geofencing by using Sim900 based GPS / GSM / GPRS, IFRSA
IFRSA International Journal Of Electronics Circuits And Systems, 5(2), 47–
52.
[11] Kaplan, E.D. and Hegarty, C. 2005. Understanding GPS:
Principles and Applications, Second Edition. Artech House.
[12] https://www.cooking-
hacks.com/documentation/tutorials/geolocation-tracker-gprs-gps-
geoposition-sim908-arduino-raspberry-pi/
[13] https://www.npmjs.com
[14] https://expressjs.com/
[15] https://gulpjs.com/
[16] Kalman, Rudolph Emil. "A new approach to linear filtering and
prediction problems." Journal of basic Engineering 82.1 (1960): 35-45.

View publication stats

You might also like