1. Introduction
Animal localization plays a vital role in monitoring and controlling animals in real-time using virtual fence applications [
1]. Global Positioning System (GPS) devices obtain coordinates from internal GPS modules which monitor signals from satellites in near-earth orbit. GPS technology is designed to determine geoposition and has in recent times been extensively used in many Internet of Things (IoT) devices such as smart collars [
2,
3]. However, the accuracy of the positioning of the single-frequency GPS module is not sufficient for safe IoT applications in agriculture, such as intelligent farming systems and virtual fencing systems, to avoid incorrect monitoring and convenient animal management. GPS receivers embedded in smart collars are commonly low-cost single-frequency modules, and their normal location error is around 10–15 m [
4,
5]. These characteristics are sufficient for coarse navigation, but they are not accurate enough from a security point of view. In addition, in overcast weather and inside cites with urban canyons, the positioning characteristics deteriorate significantly.
Many methods have been proposed to increase the GPS positioning accuracy. One commonly used method is relative positioning [
6]. Methods such as relative positioning, including static, fast static, kinematic, pseudo-kinematic, and kinematic in real-time, have proven the ability to improve GPS accuracy [
7,
8,
9]. Hurm in 1989 [
10] and 1993 [
11] carefully studied the principles of operation, the degree of internal error as well as the methods used to reduce errors associated with GPS. Since animals of medium and large size wear GPS collars, it seems to have little effect on their behavior [
12]. However, the GPS technology offered a magnificent opportunity for recording animal movements in arbitrary zones [
13,
14,
15], use of resources and their activities [
16,
17].
One of the problems of studying the behavior of animals using GPS based smart collars, inherent inflationary impact of system errors in the movement of animals [
18]. As a rule, GPS accuracy can be related to several aspects such as satellite geometry, atmospheric conditions, receiver or satellite errors, numerous road effects, satellite orbit errors [
11], and topography, depending on the air tires or adjacent structures [
19,
20]. The error of the GPS signals does not make exact distance [
21].
The technology of virtual fencing has allowed fast modern approaches and demonstrated technical capabilities for goats [
22]. Normally, virtual fencing systems for animals use a method which combines animal behavior with GPS to develop complete virtual fencing [
22,
23,
24,
25]. Similar to physical fences, a virtual fence system provides a border for animals, but, unlike normal ones, they do not create physical barriers [
26]. The perception and development of reducing GPS error in virtual fencing technology for goats are less advanced. Nevertheless, the potential of virtual fencing technology for goat grazing was demonstrated very well. A wide study is needed to correct GPS errors for improving performance of the virtual fence system for goats, determining the management of goats in their correct coordinates.
This study utilizes research results from our virtual fence project for controlling and monitoring the behavior of goats [
22]. While conducting our project study, we faced several problems related to goat GPS position error. For example, occasionally, we received wrong coordinate data from the GPS module and, as a result, test goats were given electronic or sound stimuli unnecessarily.
In this study, we have purposed two objectives. First, to achieve goats’ current behavior using Support Vector Machines (SVM) which contribute to the effectiveness of individual accelerometer units [
22]; and second, to demonstrate GPS error correction based on achieved real-time goat behavior. The rest of this article is organized as follows.
Section 2 summarizes information about the materials and methods of the proposed GPS error filter method. Moreover, it discusses the related algorithms, which are the main reference algorithms for obtaining the complete working method.
Section 3 extensively explains the experiment schedule, process, and its results; and
Section 4 concludes.
2. Materials and Methods
2.1. GPS Based Smart Collars
In a previous study, we introduced the use of a smart collar, which can be worn around the neck of a goat, and for the convenience of the user, we introduced a smart virtual fence application to monitor and control the movement of goats. Communication applications “smart collar” and “virtual fence” were implemented in the form of a centralized client-server architecture, where the server component is responsible for determining the virtual fence zones using a decision-making algorithm.
Figure 1a represents the components of the center shield of a smart collar. These are Arduino Nano (Arduino, Ivrea, Italy) as a central microcontroller, XBee module (Digi International Worldwide Headquarters, Hopkins, MN, USA) for communication with the server, GPS receiver, MPU-6050 accelerometer and gyro sensors (InvenSense, Technology Dr. San Jose, CA, USA), for the stimuli it is used MP3 player (developed by the DFRobot Electronics in Shanghai, China) and high voltage electric shocker.
Figure 1b illustrates a fully assembled smart collar around the neck of a goat.
We used the Adafruit GPS device to determine the current position of the goats. This device was connected to a serial port (TX1, RX0) and 3v power port. Adafruit GPS module is a high-quality GPS module capable of tracking up to 22 satellites through 66 channels. The device is able to receive up to 10 location updates per second for high speed, high sensitivity of recording or tracking [
27].
The MPU-6050 was used to obtain accelerometer and gyroscope data; get the current activity behavior of the animal. The MPU-6050 devices combined a triaxial gyroscope and a triaxial accelerometer on a single chip along with an integrated Digital Motion Processor, which processed complex six-axis algorithms MotionFusion. In addition, there was a built-in temperature sensor which had an I2C bus interface for communicating with microcontrollers, such as an Arduino Nano.
2.2. Software Infrastructure
In our previous study, we implemented a virtual fence application [
22] whose main task was to create virtual fences using a remote PC. This allowed us to view, monitor and track the behavior and location of goats through a wireless network in real-time and determine the deviated position of animals in the reception area. We were able to add the current GPS error correction method to the virtual fence application.
We did not limit our GPS error filter method to only specific types of animals, for example, goats; we were able to add a feature that makes our method available for all types of animals. Using our virtual fence applications, farmers can now easily choose their animal types and include a GPS error filter function for them.
2.3. Behavior Based Algorithm
To reduce GPS error in virtual fencing systems, we proposed a method which uses an animal’s real-time behavior and speed.
First, the method calculates animal position in two dimensions with signals received from the smart collar worn around the animal’s neck (as shown in
Figure 2). Simultaneously, the method retains position calculation time and helps to calculate the animal’s travel speed between two consistently received GPS position data (points). Secondly, it checks animal’s behavior for two received GPS position time periods. If the animal’s behavior was “running” or “walking,” the method calculates maximum probable travel distance for the time period. The device then compares the distances between two GPS receiver points and maximum probable traveled distance. If the distance between the two GPS points is more or less than the calculated maximum probable traveled distance, the method creates a new geolocation which lies somewhere on an imaginary line between the two points received from the GPS receiver. For the other conditions, the method does the same as well. For example, if the animal’s condition is “standing” or “laying,” the method reports the last position as current.
The main components that build up the complete system are the algorithm for measuring the distance between two points on a spherical surface, the classification of behavior using machine learning algorithms and calculated destination points using a given distance and bearing from the starting point. All algorithms used are discussed in the following sections.
2.3.1. Physical Activity Classification
The physical activity classification is one of the essential techniques of the current study. The previous research classification method is used for the current study.
Table 1 shows the five classified goat activity behaviors from our previous study. For an individual goat, 10-dimensional raw data acquired from the smart collar, including six-dimensional data of the accelerometer sensor: accelerometer data:
, gyro data:
a and the four-dimensional quaternion raw data [
28]:
(they are x, y, z-axis and w-rotation amount). The quaternion plays the most crucial role in distinguishing between the five considered goat behaviors. The four-dimensional quaternion calculation supported by the I2Cdevlib Arduino library [
29]; (as shown in Equation (1)).
The 10-time series were combined for classification:
where
is an array of the 10-time series at a particular time sample index
.
A machine learning algorithm called the SVM classifier was used to classify goat’s activity in real-time. SVM-classification was used because it copes well with small and unbalanced data. SVM is a classifier used for classification and regression analysis tasks. It belongs to the family of linear classifiers and can also be considered as a special case [
30,
31]. As a result, the liner classification algorithm can be written as shown in Equation (2):
where
is the number of the Support Vector,
is an object space of feature vector,
is a normal vector to the separating hyperplane,
is an auxiliary parameter. The linear classifier tends to show high performance if the feature vector is classified as linear.
However, our classification data is multidimensional. It can be better classified using nonlinear classification methods. In this case, the Kernel Trick technique was used to classify goat behavior using multidimensional data. So, in our previous study, we used the RBF kernel to classify the activities of goats [
22,
25]. Using the Radial Basis Function (RBF) kernel-based SVM classification, we could obtain sufficiently good results in the previous study. The total archived
F-score accuracy of classification was 91%, as shown in
Table 2. The accuracy of the classification was evaluated using the precision (
P), recall (
R), and
F-score metric [
32]:
The number of intervals from the class that was correctly classified is
truepos, the number of intervals from another class that was incorrectly classified as the class is
falsepos, and the number of intervals belonging to the class that was classified as another class is
falseneg. The precision (also called positive predictive value) is the fraction of relevant instances among the retrieved instances, while recall (also known as sensitivity) is the fraction of relevant instances that have been retrieved over the total amount of relevant instances. Both precision and recall are therefore based on an understanding and measure of relevance [
33]. The
F-score is the harmonic mean of accuracy and recall, where the
F-score reaches its best value at 1 (perfect accuracy and recall) and worst at 0 [
22,
34].
2.3.2. Distance Estimation Using GPS Data
To achieve our aim, it is required to have one more critical distance measuring technique between the two received GPS points and the distance between the maximum probable traveled distance from the last received GPS point. In general, the closest distance between the two points
and
calculates by the formula below:
However, this approach will not work for the simple reason that the Euclidean metric is designed to calculate the distance on the plane, and the surface of the Earth is still a figure very close to the sphere. To solve this problem, we need to turn to the frequently used algorithm called Haversine. To project the distances with higher precision, we used Google Maps API, which provides ready functions that can be used to calculate distances on the Earth surface using Haversine algorithm. The coordinates such as latitude and longitude are used as a coordinate system of Google Maps. The Haversine technique is applied to measure the length of two geolocations on the surface of the Earth, based on a 2-D geoposition. To solve many problems of navigation and mapping of small scale, the Earth is taken as a sphere (as a ball). The position of a point on the earth’s sphere is determined by spherical coordinates: spherical latitude and spherical longitude (the term “geographical coordinates” is used in cartography). To determine the distance between two points, the latitude and longitude of the first point and second points are needed. The calculations are complicated by the fact that the Earth is not an ideal sphere and its radius varies slightly. We use the average radius value, which, in accordance with WGS84, is approximately 6367.45 km, which allows is to get a result with an accuracy of 99.5%. [
32].
The principle work of the Haversine method is described in
Figure 3. The operation of the Haversine algorithm, demonstrates the direct distance between points as a given separate sphere. A “triangle” on the surface of the sphere is defined by great circles connecting the three points u, v, and w on the sphere, where a, b and c are the distances that must be calculated [
35,
36]. For any two points on the Haversine sphere of the central angle between them is calculated by the formula:
where
is haversine function,
is the central angle between two points lying on the large circle,
is the sphere radius,
are the latitude of the first and second points in radians,
are the longitude of the first and second points in radians [
32,
33].
The Haversine length-to-radius ratio sign as a
, on the left side of the Equation (4). To determine the distance
, it applies the archaversine (reverse haversine) or uses the arcsine function (inverse sine) [
35,
36]:
The smart collar of our virtual fence system was developed to transmit data at 1 Hz (a data per second). Using the above functions, we can calculate the distance which the goat can travel during 1 s. A goat’s maximum speed is 17 kph (17 kph = 4.72 mps), so the maximum possible traveling distance per second for a goat is 4.72 m. If the second point received from the GPS module is located further than 4.72 m, the system removes and creates a new point which is located 4.72 m away from the first point.
4. Conclusions
The new proposed method for GPS error correction is applied well for virtual fence technology for goats, in this study. The proposed technique helps to improve the position accuracy of virtual fencing technologies with GPS based smart collars. The proposed method is based on animal behavior in real-time. For our current experiments, we used a smart collar from our previous study [
20]. The current study method’s implementation was made technically possible with results from the previous study’s virtual fence application. Our smart collar transmits 3-D GPS coordinates and 10-D accelerometer sensor data at 1 Hz. The transmitted data is logged and received in the virtual fence application database.
In the current study, we conducted experiments over a seven-day period for the three different goat behavior activity such as running, walking, and resting (standing, grazing, laying). During the seven days of experiments, the device received several GPS signals with errors. The proposed method was capable of finding incorrect GPS coordinates and determining the accurate position information. As stated by the results of our experiment, GPS positioning accuracy has improved significantly compared with traditional methods.
With unfiltered geolocations, the average distance offset is measured by the true position of the smart collar, and the coordinates obtained from the settlers were 110–190 m. Our proposed method significantly affected the results of the mean corrected data bias and unfiltered data bias. The mean bias of the corrected data was 0–16.2 m. The bias of unfiltered and filtered data for each goat behavior are found in
Table 5. Besides, the second day experiment results were visualized in
Figure 5 and
Figure 6.
The proposed method, however, is mainly oriented for use in virtual fencing systems. The method aids in obtaining true animal positions and reduces incidents of incorrect stimuli administration (sound, electronic, etc.).