1 Introduction

Today, smartphones are important parts of people’s life and developing the Global Positioning System (GPS) made easy navigation for human activities, such as industry, science, research, trade, transport, and trip. In addition, automatic devices need navigation for controlling stable movement. Using smartphone sensors for motion analyzing is an easy solution for this problem. Some of these phones have inertial motion unit (IMU), which contains three-dimensional accelerometer, magnetometer and gyroscope. These smartphones are suitable for motion analyzing and GPS-independent navigation [1,2,3]. Some studies investigated postural and gait control [4, 5] or joint goniometry [6, 7], used expensive, such as the black box of airplanes, and immobile equipment for laboratory studies [8], or used smartphones for static and dynamic measuring in the motion analysis of moving objects. Fast position receiving [9] and data recording are important for intelligent transport, checking the traffic [10] or detecting the transport quality [11] using a network of sensors, and also analyzing driver behavior [12] or detecting car accidents [13] using smartphone features. Some reasons for studying novel motion analyzing methods are:

  • Controlling smart cars

  • Designing autopilot systems for aircrafts or unmanned aerial vehicles

  • Examining the performance of moving vehicles

  • Controlling multirotors

  • Designing self-balancing systems for bicycles or motorcycles

  • Medicine analyzing using the person’s gait

  • GPS-independent navigation.

Controlling these smart objects needs accurate information about the location of the object and also its performance during a certain motion. Motion analysis helps us to estimate the location of a motive object at each step of its motion and also the motion performance of this object during this motion. GPS-independent navigation lets to smart control some objects that have no access to the GPS data, such as submarines. A combination of various sensors can measure valuable data for this purpose. However, the smartphone is an accessible and cheap device for this aim. Therefore, examining its abilities for data recording, motion analyzing and GPS-independent navigation is necessary. This study defines a novel method for motion analyzing and GPS-independent navigation of moving objects, such as car, bus, bicycle, motorbike, helicopter, ship, boat, multirotor or aircraft. An Android application was installed on a smartphone to record measured values by its sensors. A homemade program code in JavaScript developed this application. Then, a developed MATLAB code analyzed the road trip of the car using the recorded data and calibrated the measured values by these sensors for GPS-independent navigation.

2 Methodology

2.1 Experiment

A Samsung (Galaxy S3) smartphone with the presented features in Table 1 has been used for recording the measured values by its sensors in a car (a Peugeot 405 GLX) road trip from Estahban to Neyriz, in Iran. A homemade code developed an Android application using the JavaScript for recording these measured values in an external memory:

Table 1 Some features of used smartphone
  • Time (in milliseconds since the UNIX epoch: January 1, 1970 00:00:00 UTC)

  • Rate of data recording (number of recorded data in each second)

  • Latitude (using the GPS, in degrees, which ranges from 0° at the Equator to 90° at the North or South pole)

  • Longitude (using the GPS, in degrees, which is defined as an angle pointing west or east from the Greenwich Meridian)

  • Altitude (using the GPS, in meters, above the WGS 84 reference ellipsoid)

  • Acceleration in the xs direction (using the gravity sensor, in meter per square second)

  • Acceleration in the ys direction (using the gravity sensor, in meter per square second)

  • Acceleration in the zs direction (using the gravity sensor, in meter per square second)

  • Roll (using the orientation sensor, in degree)

  • Pitch (using the orientation sensor, in degree)

  • Yaw (using the orientation sensor, in degree).

This smartphone, which was fixed at the estimated gravity center of the car, recorded these values with 200 samples per second frequency, in its normal activity mode. Figure 1 shows the defined xs, ys and zs directions (smartphone coordinate system) and roll, pitch and yaw orientations.

Fig. 1
figure 1

The defined xs, ys and zs directions, roll, pitch and yaw orientations for smartphone and also a schematic view of the coordinates transformations

2.2 Coordinate transformation

Figure 1 also shows a schematic view of the used coordinate transformations in this study. The GPS data is in the geographic coordinate system, which specifies each point by three numbers (see Fig. 1) as, \(\mathop {P_{g} }\limits^{ \to } = \left( {\begin{array}{*{20}c} \lambda \\ \varphi \\ h \\ \end{array} } \right)\) [14]. λ is the angular distance of a point from the Prime (Greenwich) Meridian, φ is the angular distance of a point from the Equator, and h is the vertical distance of a point from the geoid. The earth centered-earth fixed (ECEF) coordinate system represents this point as below [15]:

$$\mathop {P_{e} }\limits^{ \to } = \left( {\begin{array}{*{20}c} {x_{e} } \\ {y_{e} } \\ {z_{e} } \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} {(N_{e} + h)\text{Cos} \varphi \text{Cos} \lambda } \\ {(N_{e} + h)\text{Cos} \varphi \text{Sin} \lambda } \\ {[N_{e} (1 - e^{2} ) + h]\text{Sin} \varphi } \\ \end{array} } \right)$$
(1)

The coordinate system represents the position by xe, ye and ze. Its origin is located at the earth’s center of mass. The xe, ye, and ze axes extend through the intersection of the Prime Meridian and the Equator, through the intersection of the Equator and 90° longitude, and through the true north pole, respectively (see Fig. 1). Since, the earth is not a sphere and has a biaxial ellipsoid shape, Ne and e were presented for correction. Where \(N_{e} = {{r_{e} } \mathord{\left/ {\vphantom {{r_{e} } {\sqrt {(1 - e^{2} )\text{Sin}^{2} \phi } }}} \right. \kern-0pt} {\sqrt {(1 - e^{2} )\text{Sin}^{2} \varphi } }}\), e = 0.081819190842622 and re is the mean radius of the earth, which is equal to 6,378,137 m. The north east down (NED) coordinate system represents this point as below [15]:

$$\mathop {P_{n} }\limits^{ \to } = \left( {\begin{array}{*{20}c} {x_{n} } \\ {y_{n} } \\ {z_{n} } \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} { - \text{Sin} \varphi^{ref} \text{Cos} \lambda^{ref} } & { - \text{Sin} \varphi^{ref} \text{Sin} \lambda^{ref} } & {\text{Cos} \varphi^{ref} } \\ { - \text{Sin} \lambda^{ref} } & {\text{Cos} \lambda^{ref} } & 0 \\ { - \text{Cos} \varphi^{ref} \text{Cos} \lambda^{ref} } & { - \text{Cos} \varphi^{ref} \text{Sin} \lambda^{ref} } & { - \text{Sin} \varphi^{ref} } \\ \end{array} } \right) \cdot \left( {\begin{array}{*{20}c} {x_{e} - x_{e}^{ref} } \\ {y_{e} - y_{e}^{ref} } \\ {z_{e} - z_{e}^{ref} } \\ \end{array} } \right)$$
(2)

The origin of the vehicle-carried NED coordinate system is located at the center of gravity of the car (or smart phone). The xn, yn and zn represent the position along the geodetic north, east and normal axes, respectively (see Fig. 1). Reference position (\(x_{e}^{ref}\), \(y_{e}^{ref}\), \(z_{e}^{ref}\), \(\varphi^{ref}\) and \(\lambda^{ref}\)) is the position of origin of the local NED frame (i.e., the start point of the car in the road trip).

Now, we have a 3D displacement vector from the start point to each point of the road trip. The gradient of the displacement–time graph is the car speed (Vn). Until this section, all steps of coordinate transformation only used the GPS data. Vn is in the NED coordinate system. It can be transformed to the smart phone coordinate system (Vs) using the measured values of orientations. The following equation defines this transformation [16]:

$$\mathop {V_{s} }\limits^{ \to } = \left( {\begin{array}{*{20}c} {V_{sx} } \\ {V_{sy} } \\ {V_{sz} } \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} {\text{Cos} \theta \text{Cos} \psi } & {\text{Cos} \theta \text{Sin} \psi } & { - \text{Sin} \theta } \\ {\text{Sin} \phi \text{Sin} \theta \text{Cos} \psi - \text{Cos} \phi \text{Sin} \psi } & {\text{Sin} \phi \text{Sin} \theta \text{Sin} \psi + \text{Cos} \phi \text{Cos} \psi } & {\text{Sin} \phi \text{Cos} \theta } \\ {\text{Cos} \phi \text{Sin} \theta \text{Cos} \psi + \text{Sin} \phi \text{Sin} \psi } & {\text{Cos} \phi \text{Sin} \theta \text{Sin} \psi - \text{Sin} \phi \text{Cos} \psi } & {\text{Cos} \phi \text{Cos} \theta } \\ \end{array} } \right) \cdot \left( {\begin{array}{*{20}c} {V_{nx} } \\ {V_{ny} } \\ {V_{nz} } \\ \end{array} } \right)$$
(3)

where ϕ, θ and ψ are roll, pitch and yaw angles and Vsx, Vsy and Vsz are components of the car velocity (speed) vector in the xs, ys and zs directions, respectively (see Fig. 1). The gradient of the Vst graph is the car acceleration (aGPS) in the smart phone coordinate system. aGPS and aaccelerometer (the measured acceleration using the accelerometer sensor) are in a same coordinate system. Therefore, these values are comparable.

There are two ways for measuring the acceleration of a moving object using a smart phone, the GPS and accelerometer sensor. Calculating the acceleration using the GPS data needs a double differentiation (the slope of the displacement–time graph gives the speed, and the slope of the speed-time graph gives the acceleration). On the other hand, the accelerometer sensor measures this parameter directly. It can validate the calculated acceleration using the GPS data and clears its instantaneous errors.

The accelerometer sensor gives the components of acceleration vector (i.e. asx, asy and asz) in the smart phone coordinate system (see Fig. 1). The local earth gravitational acceleration (g) affects these values. The following equation calculates g at different altitudes [17]:

$$g = g^{ref} \left( {\frac{{r_{e} + h^{ref} }}{{r_{e} + h}}} \right)^{2}$$
(4)

where \(g^{ref}\) is the gravitational acceleration at the start point of the road trip. For removing the effects of g on asx, asy and asz, these values have been transformed from the smart phone coordinate system to the NED coordinate system (see Fig. 1). The values of role (ϕ), pitch (θ) and yaw (ψ) angles are necessary for this purpose. The orientation sensor of the smart phone measured these values. The following equation calculates the instantaneous acceleration of the car in the NED coordinate system [18]:

$$\mathop {a_{n} }\limits^{ \to } = \left( {\begin{array}{*{20}c} {a_{nx} } \\ {a_{ny} } \\ {a_{nz} } \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} {\text{Cos} \psi \text{Cos} \theta } & {\text{Cos} \psi \text{Sin} \theta \text{Sin} \phi - \text{Sin} \psi \text{Cos} \phi } & {\text{Cos} \psi \text{Sin} \theta \text{Cos} \phi + \text{Sin} \psi \text{Sin} \phi } \\ {\text{Sin} \psi \text{Cos} \theta } & {\text{Sin} \psi \text{Sin} \theta \text{Sin} \phi + \text{Cos} \psi \text{Cos} \phi } & {\text{Sin} \psi \text{Sin} \theta \text{Cos} \phi - \text{Cos} \psi \text{Sin} \phi } \\ {\text{Sin} \theta } & {\text{Cos} \theta \text{Sin} \phi } & {\text{Cos} \theta \text{Cos} \phi } \\ \end{array} } \right) \cdot \left( {\begin{array}{*{20}c} {a_{sx} } \\ {a_{sy} } \\ {a_{sz} } \\ \end{array} } \right)$$
(5)

Since anz and g vectors are parallel at each point, removing the effects of g from anz \(\left( {a_{nz}^{cor} = a_{zn} - g} \right)\) is possible. The following equation transfers the corrected acceleration from the NED coordinate system to the smart phone coordinate system (see Fig. 1):

$$\mathop {a_{s}^{cor} }\limits^{ \to } = \left( {\begin{array}{*{20}c} {a_{sx}^{cor} } \\ {a_{sy}^{cor} } \\ {a_{sz}^{cor} } \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} {\text{Cos} \theta \text{Cos} \psi } & {\text{Cos} \theta \text{Sin} \psi } & { - \text{Sin} \theta } \\ {\text{Sin} \phi \text{Sin} \theta \text{Cos} \psi - \text{Cos} \phi \text{Sin} \psi } & {\text{Sin} \phi \text{Sin} \theta \text{Sin} \psi + \text{Cos} \phi \text{Cos} \psi } & {\text{Sin} \phi \text{Cos} \theta } \\ {\text{Cos} \phi \text{Sin} \theta \text{Cos} \psi + \text{Sin} \phi \text{Sin} \psi } & {\text{Cos} \phi \text{Sin} \theta \text{Sin} \psi - \text{Sin} \phi \text{Cos} \psi } & {\text{Cos} \phi \text{Cos} \theta } \\ \end{array} } \right) \cdot \left( {\begin{array}{*{20}c} {a_{nx}^{cor} } \\ {a_{ny} } \\ {a_{nz} } \\ \end{array} } \right)$$
(6)

Since anx and any are perpendicular to the g direction, these parameters are free from the g effects.

2.3 Navigation using the smartphone sensors

Attending to suitable accordance of the smartphone sensors, it is possible to calculate the location of the vehicle using the obtained independence value of acceleration from the g effects. For this purpose, a set of polynomial equations were defined, as below, for removing the effects of sensors noises. These noises can have huge effects, as integral effects, on the calculated values for the velocity and location using the measured acceleration by the smartphone sensors.

$$a_{sx}^{modified} = c_{1} + c_{2} a_{sx}^{cor} + c_{3} (a_{sx}^{cor} )^{2} + c_{4} (a_{sx}^{cor} )^{3} + c_{5} (a_{sx}^{cor} )^{4}$$
(7)
$$a_{sy}^{modified} = c_{6} + c_{7} a_{sy}^{cor} + c_{8} (a_{sy}^{cor} )^{2} + c_{9} (a_{sy}^{cor} )^{3} + c_{10} (a_{sy}^{cor} )^{4}$$
(8)
$$a_{sz}^{modified} = c_{11} + c_{12} a_{sz}^{cor} + c_{13} (a_{sz}^{cor} )^{2} + c_{14} (a_{sz}^{cor} )^{3} + c_{15} (a_{sz}^{cor} )^{4}$$
(9)
$$\phi^{modified} = c_{16} + c_{17} \phi + c_{18} \phi^{2} + c_{19} \phi^{3} + c_{20} \phi^{4}$$
(10)
$$\theta^{modified} = c_{21} + c_{22} \theta + c_{23} \theta^{2} + c_{24} \theta^{3} + c_{25} \theta^{4}$$
(11)
$$\psi^{modified} = c_{26} + c_{27} \psi + c_{28} \psi^{2} + c_{29} \psi^{3} + c_{30} \psi^{4}$$
(12)

The defined constants in these equations (i.e. c1 to c30) were obtained by fitting the calculated location using these modified accelerations and orientations with the obtained location using the GPS. An optimization algorithm (i.e. fminsearch) was used for minimizing the existed difference between these locations. Table 2 presents the obtained values for these constants.

Table 2 The obtained values of c1 to c29

3 Results and discussion

Figure 2 shows the recorded data in the external memory for this road trip test. These data are: Fig. 2a) altitude, latitude and longitude, Fig. 2b) three components of acceleration vector, Fig. 2c) role, pitch, yaw angles. The recorded values of asx and asy depend on the values of pitch and roll, respectively. Because, the gravitational acceleration affects these values. Figure 3 shows the obtained xy plot, using the recorded GPS data, for this trip on a satellite image. The obtained xy plot in the NED coordinate system has a perfect accordance with the road in the map. It approves the accuracy of this method. This method is different from the other navigate applications. Other applications display your trip on a map using a comparison between the GPS data of your locations and prerecorded values for each point of its map. The distance between two points (i.e., origin and destination) in geodetic measurements has two different definitions:

Fig. 2
figure 2

The recorded data in the external memory

Fig. 3
figure 3

The obtained x–y plot for the trip on a satellite image from the Google Maps (using GPS)

  • The length of a straight line that connects these two points \(\left( {d = \sqrt {x_{n}^{2} + y_{n}^{2} + z_{n}^{2} } } \right)\), which indicates the linear distance between these points

  • The length of the existed road between these two cities \(\left( {d_{t} = \sum d } \right)\), which indicates the path length between these points

Figure 4 compares these lengths for this road trip. Clearly, mazes of the road increases the covered distance (compare dt with d). The slopes of these curves show the mean speed of the car in each section of the trip. This value was about 90 km/h throughout the trip. Figure 5 shows the instantaneous values of the car speed vector and its triple components in the smartphone coordinate system. These values have been calculated using the GPS data. Considering forward motion of the car (except in some conditions such as climbing or turning around), matching of Vsy and Vs was expected.

Fig. 4
figure 4

The covered distance in the road trip (using GPS)

Fig. 5
figure 5

The instantaneous values of the vehicle velocity vector and also its triple components in the smartphone coordinate system (using GPS)

The effects of g should be removed from the sensed acceleration for a suitable GPS-independent navigation using the measured values by the smartphone sensors. Figure 6 compares the measured and corrected values of acceleration. The corrected asz is smaller than the corrected values of asx and asy. Figure 7 compares the obtained acceleration using the GPS (\(\left( {a_{GPS} = \tfrac{{d^{2} (d_{t} )}}{{dt^{2} }}} \right)\) and accelerometer sensor \(\left( {a_{Accelerometer} = \sqrt {a_{sx}^{{cor^{2} }} + a_{sy}^{{cor^{2} }} + a_{sz}^{{cor^{2} }} } } \right)\). These values are near together, occasionally. However, the noisy GPS data have low accuracy for calculating the acceleration. As a result, it is more accurate to obtain the location and acceleration using the GPS and accelerometer sensor, respectively. Nevertheless, calibrating the measured noisy values by the smartphone sensors can improves the accuracy of the estimated location without the GPS data. Figure 8 compares the estimations of x, y and z using the calibrated values of the sensed accelerations and orientations with the obtained location by the GPS data in this road trip. It is observed that these calibrated values have acceptable estimations.

Fig. 6
figure 6

The measured and corrected values of components of acceleration vector (using accelerometer sensor)

Fig. 7
figure 7

The obtained acceleration of the vehicle by GPS and accelerometer sensor

Fig. 8
figure 8

Comparison of the estimated x, y and z using the measured values with the smartphone sensors, with the obtained values for these parameters using GPS

4 Conclusion

This study defined a novel method for motion analyzing of moving objects and GPS-independent navigation. A developed Android application was installed on a smartphone for recording measured values by its sensors. A developed MATLAB code analyzed a road trip of a car using these data and calibrated the measured data by the acceleration and orientation sensors. Several coordinate transformations were used to give valuable information from these recorded data. The measured acceleration was corrected for removing the effects of earth gravitational acceleration and also the existed noises in their measurements. The obtained x–y plot in the NED coordinate system had a perfect accordance with the road. The obtained instantaneous and mean speeds of the car presented acceptable and sensible information about this road trip. Integration or differentiation improves the noises of the accelerometer sensor and GPS unit of the smartphones. It is more accurate to obtain the location and acceleration using the GPS and accelerometer sensor, respectively. However, the presented calibration method in this study can improves the navigation accuracy of this smartphone without using the GPS data.