SlideShare a Scribd company logo
1 of 43
Shrestha 1
Smartphone
Inertial
Navigation
-Pujan Shrestha
Shrestha 2
Acknowledgements
Randolph College Summer Research Program
Dr. Peter Sheldon
Kacey Meaker ‘08
Alex Tran ‘15
Timothy Slesinger ‘14
Mike Cheng, Virginia Episcopal School
Richard Lin, Virginia Episcopal School
Shrestha 3
Shrestha 4
Introduction
Inertial navigation system (INS) use accelerometers, gyroscopes to measure the position,
orientation and velocity of a moving body without the need of external devices like the Global
Positioning System (GPS) (Groves 2008, Kavanagh 2007, Nawrat, et al. 2012).The position,
velocity and orientation are measured by calculating the current position by using the data about
previously known position and conditions. This way, past data is used to predict the movement
of the object. This process is known as dead reckoning. Inertial navigation systems are currently
used ships, planes, cars, submarines, and even missile systems (Chaing 2013, Sadia 2011).
Devices such as accelerometers and gyroscopes are bulky and expensive and are not financially
feasible for classroom setting. However, just like phones and computers, conventional
accelerometers and gyroscopes have been increasingly replaced by microchips (Hwang, Yu
2012, Saeedi et al. 2014). Newer smartphones are equipped with such capabilities and can be
used as an INS. This has opened new horizons regarding the academic applications of inertial
navigation systems in classrooms to demonstrate kinematics.
The two components of INS work seamlessly with each other and collect data that is used
to predict the movement of the body. The accelerometer measures acceleration in three mutually
orthogonal axes- X, Y, and Z while the gyroscope measures the rotation about these axes
(Groves 2008, Kavanagh 2007, Pendrill 2011). The gyroscope also measures the rotational
acceleration of the body. Rotation along the different axes have different names and are shown in
the diagram below.
Figure 1: Rotation around the axes which are called Pitch, Roll, and Yaw respectively.
Shrestha 5
Dead reckoning is done by integrating the various kinematic equations and using the
previous conditions as the integration constants. We use double integration to find position and
orientation from acceleration. However, when integrating, we need initial conditions and
orientation of the body which we can use to have definite 1st and 2nd integrals (Groves 2008,
Nawrat et al. 2012, Savage 1998). It is crucial for data for initial conditions to be precise because
these errors cause significant discrepancy in the results. For this research, we start the body at
rest thus effectively making initial velocity equal to zero. Furthermore, the calculation methods
finds the change in position rather than the final position. This makes it easier to calculate total
displacement and direction of displacement. Thus, we are not interested in initial position. We
simplify our calculation of the body by starting from rest and fixing our axes at the position
where the body is at rest. This way both initial velocity and position is equal to zero.
While, using a smartphone instead of a traditional INS is the economical choice for
classrooms, it is not without its own drawbacks. Inertial navigation systems are plagued by issues
like, numerical drift, bias, noise and misalignment. The microchip itself is afflicted by
temperature interferences, magnetic interferences and vibrational interferences (Park 2013).
Using low quality components sacrifice accuracy and precision and skews the data. This is why,
filters are essential to obtain optimal data from the components. Each year, new and newer
smartphones are released with more advanced technology and thus such measurements taken
from new devices are increasingly more accurate. This provides the ability to teachers in
classrooms to use smartphones a teaching tool to demonstrate kinematics. The goal of this
research is to experiment the precision of smartphone INS in various twists and turns and also to
attempt to implement a form of Kalman filter to optimize the data. In doing so, the data obtained
and analyzed could be more accurate and might help facilitate in creation of a standalone app for
smartphones that uses the phone as an inertial navigation system for simple and complex 3d
motion.
Shrestha 6
Literature Review
As mentioned earlier, INS are used in different fields for navigation purposes. Its use is
most easily seen in pedestrian navigation and vehicular navigation systems. While each of the
two methods use of an accelerometer, the processes in which they use the various components
and data collected are different. Pedestrian navigation systems use accelerometer, gyroscope and
magnetometers to predict the movement of the object or person in an indoor setting. Vehicular
navigation systems, on the other hand, merge the data from the accelerometer and GPS to
provide real time and accurate location of the vehicle. The GPS integration helps to correct some
of the errors inherent in inertial navigation system such as drift, bias and scale factors. However,
additional errors such as ionospheric delay, tropospheric delay and the multipath effect are also
added into the system and have to be considered (Chiang 2013). Each of these applications of
INS demonstrate similar errors and provide multiple ways to combat them.
GPS and INS are used extensively in vehicular navigation. This is done in order to error
check the data obtained from both devices. GPS provide accurate data on position in open sky
conditions and if the object is in clear line of sight of 4 satellites. However, repeated signals and
blocked signals severely affect the quality of the data obtained. (Chaing 2013) Inertial navigation
system is used to supplement these data when the vehicle enters a GPS obstructed zone. The two
popular ways to link the GPS and INS is through tightly coupled (TC) scheme and loosely
coupled (LC) scheme with the help of an Extended Kalman Filter (EKF) (Ayeni, Junaidu 2013).
Figure 2: Loosely coupled scheme (left) and tightly coupled Scheme (Right)
Shrestha 7
Both the schemes are similar in implementation: the GPS calculates position and velocity
and sends these values to the EKF. The filter then compares this data to the data calculated by
the INS via dead reckoning and then optimizes the position and velocity. While loose coupling
is easier to implement, the scheme requires direct line of sight with at least four satellites in order
to obtain accurate GPS data. Tightly coupled scheme tackles this problem by obtaining carrier
phase, pseudo range and doppler measurement from the GPS and using the EKF to directly
calculate the position and velocity. This way, even with insufficient GPS data, the filter can
optimize the information. In one of the experiments, a van was equipped with an INS and GPS
on the roof and the movement of the van was tracked as it drove around the city. The literature
proposed a modified form of tightly coupled scheme which rejected abnormal GPS data in order
to maintain accuracy (Figure 3) and reported a 60% improvement in uncertainty compared to the
pure TC and the standard LC schemes. (Chiang 2013)
Figure 3: Modified Tightly coupled Scheme for GPS/INS integration.
However, one of the problems in using INS is the fact that conventional gyroscopes and
accelerometers are expensive and cannot be used in a classroom setting. However, in the last
decade, due to growing fad of miniaturization on computers, even the accelerometer and
gyroscopes have been minimized into microchips. This development let to a point where both the
Shrestha 8
accelerometer and the gyroscope can be fitted into on microchip. Nowadays, smartphones are
equipped with these microchips that can help the function. This development in smartphones has
allowed us to use these microchips as INS without having to exhaust funds. This brings us to the
next popular use of INS.
Figure 4: This microchip can be used as an
inertial navigation system because it contains a
gyroscope as well as an accelerometer and costs
less compared to the traditional components of
INS.
Pedestrian Navigation System (PNS) is used to find the position and velocity of a person.
Since most of the calculation about the movement of the person is done internally, the PNS is
independent of Wi-Fi or GPS connection (Park 2010, Saeedi et al. 2014). This makes it easier to
gather data even when the person is in a house or a cave. Similarly, either Wi-Fi can be used to
increase the accuracy of the data obtained from the inertial system. In one of the experiments, an
INS was attached to the top of the shoe. This application used the the rotation of the shoe in the y
and z axis.
When walking, we can notice that we move our foot up and down while simultaneously
rotating our foot forward. Using this idea of a walking motion, the pitch is then divided into 4
sections which represent separate part of the movement. These segment represent the 4 main
movements for the foot: resting on the floor, leaving the floor, moving above the floor, and
Shrestha 9
landing on the floor. The algorithm that identifies the movement state is called the Markov
Model (Park 2010).
Figure 4: The figure displays the 4 different sections of the walking motion
After the algorithm has been applied, state transition probabilities are used to correct the
data in order to avoid non-zero velocity when not moving. These state transitions represent the
probability that the movement will move from one state to the other. These probabilities are
different for both walking and running motion. The experiment proposes a form of Markov
model in order to analyze the state transitions for both running and walking motion while also
detecting and correcting non-zero velocities (Park 2010).
Figure 5: The figure demonstrates the probability of change of state during walking motion.
Shrestha 10
These experiments all reported similar sources of errors – non-zero velocities when at
rest, loss of signal, interference due to magnetic fields, interference in GPS/Wi-Fi signals, and
numerical drift (Barberis 2014,Chaing 2013, Park 2010, Sadia 2011). The Markov model above
was implemented in order to recalibrate for non-zero velocities when not moving. These value
are contradictory because when non-zero velocity data is obtained, then the system interprets it
as movement even when the body is at rest. This presents a huge problems in the data. In order to
avoid this error, we have used zero as our initial position and velocity. When using a GPS/INS
integrated system, due to various environmental factors such as building, clouds, and trees, the
device might not receive appropriate data from the GPS which leads to incorrect data (Chaing
2013). Furthermore, while GPS systems can accurately measure the movement in 2 dimensions,
it is inefficient in measuring the movement in z axis. For example, if the data of a rollercoaster
ride was collected on a particularly cloudy day then, the data for movement is x,y axes will be
more accurate than the data from z axis. This research is in the indoor phase of perfecting data
collection and analysis for simple motion in a lab and thus will only use accelerometers and
gyroscopes. This way, errors due to GPS signals attenuation are avoided. Other sources of errors
can be temperature, bias, misalignment, and vibrational and magnetic interference (Barberis
2014, Chaing 2013, Park 2010, Sadia 2011).
Each source of error is a significant problem for the data calculation. The process of dead
reckoning uses integration and past data to predict future motion. Any error in the device, data,
or the measurement of data will be amplified in the process. This leads to a numerical drift of the
predicted position and velocity from the actual position and velocity (Groves 2008, Park 2010,
Savage 1998). Therefore it is extremely important to deal with all sources of errors in order to
obtain optimum data.
Shrestha 11
Figure 6: This figure shows the quadratic drift in INS data compared to actual video analysis
Some of the literature suggests recalibration of the accelerometer in order to improve data
collection (Serra n.d). By using the gyroscope data and the movement of the normal vector
perpendicular to the smartphone screen, the accelerometer looks for small changes in the
orientation of the screen while the gyroscope uses this data to readjust the acceleration data. The
normal vector is calculated by analyzing the components of acceleration due to gravity in order
to find the plane on which the screen rests on. This way, accelerometer and gyroscope
complement each other in data collection to obtain accurate data form the movement of the
phone. This method of integrating the 2 components is called plane holography (Serra n.d).
Various literatures suggest also suggest in adding a magnetometer in order to counteract the
effects of magnetic interference on the smartphone.
Filtering data is shown to improve the optimization of data. Kalman filter (KF) is used to
a great extent in INS systems (Ayeni 2013, Chen et al 2015, Riaz 2011). Named after the
scientist who helped formulate the algorithm, the filter is a two-step process. In the first step, the
filter uses the current data to formulate an estimate for the future data and their uncertainty as
well. In the next step, after the data is collected, the filter compares the current data and
Shrestha 12
estimated data and updates the estimated data with a weighted average. The higher weight is
given to the data which has more certainty. This way, the filter actively predicts the next step
using current data and updates the predictions at it operates real-time (Chen et al 2015).
Figure 7: This simplified flowchart demonstrates the flow of logic in a Kalman Filter
However, some literature also suggest using extended Kalman filter instead of the normal
Kalman filter (Enkhtur 2013, Filieri n.d, Riaz 2011). The main difference between EKF and KF
is that KF is more suited to be used in a linear system. In this research, we are taking double
integration of acceleration to calculate the position and velocity. Thus, any error in acceleration
is seen as a quadratic drift in position. EKF is suggested because it is more suited with nonlinear
motion. (Enkhtur 2013, Filieri n.d, Riaz 2011) The study further proposes including quadratic
constraints on the integrals while using a TC scheme with a GPS to provide Doppler estimation.
In our previous research, due to the complexity of implementing a Kalman Filter real time data
analysis, moving average filter was used. However, due to the errors in such a filtering method,
low pass filter was also implemented.
Shrestha 13
Figure 8: The above figures demonstrates the how each of the filters help in improving the data.
Furthermore, increasing sampling rate also helps in increasing the accuracy of the data.
Just like, large pixels in a TV screen displays less information about contrast compared to a TV
with more pixels, increasing the data sampling rate paints a fuller picture of the motion of the
object. In addition, some studies have suggesting in adjusting of the sensors to avoid incorrect
data. While, it is a trivial error, due to the tendency of errors carrying forward to amplify, even
the source of slight error has to be mitigated. Finally, revising the integration methods by using
quadratic constraints, abandoning simple integrations for complex but accurate ones like Boole’s
rule had also been suggested.
The literature review was incredibly productive in learning about the various errors and error
mitigation methods that can be applied in this research. Currently our system consists of an
accelerometer and a gyroscope. The gyroscope has enabled exploration into different degrees of
freedom. Even though, the change of filtering methods from moving average to band had
resulted in more accurate data, there is still numerical drift inherent in the system. The reduction
Shrestha 14
of this drift is important for the proper onsite implementation of the smartphone as an INS. This
literature review was beneficial because it provides the next goal of the research:
experimentation of various different types of motion and implementation of best type of filter.
The filter is extremely important because due to the size of the microchip and its inherent sources
of errors, it is more inaccurate than a traditional INS. This prompts the search for more accurate
method of data collection and data analysis if smartphones were to be used as an INS. However,
implementing a real-time Kalman filter is complicated and arduous. In order to check the
accuracy of each type of filter, they are implemented on the data retroactively and compared to
actual video analysis of the motion. Unless the data collection and analysis methods are not fully
perfected, using the smartphone as an INS is not going to be effective. Furthermore, this research
is not interested in walking motion. Markov method and transition probabilities cannot be used
because continuous motion cannot be divided into various states. Finally, this research is not
going to use a GPS, however, it is an eventual goal to implement a tightly coupled GPS/INS
integration in order to use the smartphone in an outdoor setting. One of the long term goals of
this research is to use the smartphone as an INS to analyze the velocity and g-forces that one
experiences in a rollercoaster ride. And as literature suggests, GPS/INS or Wi-Fi /INS coupling
can greatly improve data for long term calculation.
Shrestha 15
Apparatus Used
 LoggerPro 3.0
 iPod touch 4th generation
 Unicycle and rotating table
 Frictionless track and cart
 Cart fan attachment
 Digital camera and tripod
 Mat lab (see appendix for programs used)
Methods
Our inertial navigation system is dependent on the integrated microchip in the
smartphone. The microchip uses an integrated gyroscope and accelerometer to measure the
acceleration and orientation of the phone. The position and velocity of the object is calculated by
using this data. In this research, the smartphone was allowed to experience different types motion
– 1D simple, 1D complex, 2D simple, 2D incline, and rotations around the x-y and the y-z axes.
Each experiment was designed to increase the difficulty of the data analysis process by adding
degrees of freedom to the motion of the smartphone.
In 1D motion, the phone was affixed to a cart and was allowed to move on a straight
track. The track forced the cart to move back and forth in one direction. In the simple case, a
small initial force was applied onto the cart in the direction of the track. Friction from the track
slowed down and eventually brought the cart to a halt. For the complex case, a battery powered
fan attached onto the cart. The fan was directed to oppose the direction of the initial force and
thus, the cart would slow down after the initial push and return back to the original position. For
Shrestha 16
the incline experiment, one edge of the track was put on ledge thus allowing for analysis into
horizontal as well as vertical axis.A rotating platform and a custom bicycle rig was used for the
rotational motion. The smartphone was affixed on a known radius on the device and allowed to
spin. Similar to 1D motion, an initial force was applied tangentially to the wheel. It was then
allowed to come to a halt due to friction.
Figure 9. These images show the set up for the rotational motion in the horizontal axis
and the vertical axis.
Finally, three straight tracks and three carts were used to build the set-up for 2D motion.
A straight track was affixed on top of two carts. Two of the carts were then placed onto two
parallel tracks and the cart containing the smartphone was placed on top of the uppermost track.
This way, the top track could move in one direction while the cart containing the smartphone
could move in a different direction thus allowing us to analyze motion in two dimensions.
Special care was given to construct the setup. A builders leveling tool app was used to check if
all the tracks were horizontal. Furthermore, it was necessary for the bottom tracks to be parallel
in order to avoid errors in the system.
Shrestha 17
Figure 10. This image shows the setup for the tracks that was used to analyze 2D motion.
In the start of each experiment, a video camera was positioned at the most optimal
location to fully capture the motion of the phone. The smartphone data measurement application
was initiated and the initial force was applied towards the desired direction. When the phone
came to a complete halt, the data collection was manually terminated. The camera recorded the
complete motion of the phone. Using these three forms of input, data analysis was done in order
to calculate position and velocity. The video of the motion helped determine the true velocity and
position of the phone. The data obtained from the phone’s sensor was then compared to the data
obtained from video analysis.
The video analysis was done in a program called LoggerPro. It has a feature that allows
the user to open video files, analyze them frame by frame, add and modify co-ordinate axes, and
even set a known distance as scale for the video. In fact, the purpose of the blue ruler in Figure
10 was to serve as a known distance for video analysis. All the videos from the experiments
experience the same treatment. First a known distance is set for scale and the origin of the co-
ordinate axis aligned at the initial position of the smartphone. The positive X axis is rotated
Shrestha 18
towards the direction of the initial movement. After this process, the user can click on the phone
and the program records the position of the phone with respect to the co-ordinate axes and moves
onto the next frame. The user can also manually change the frame skip rate of the clicks. The
new position of the phone is clicked on again and the program automatically moves to the next
frame. During this process, using the user specified scale, Logger Pro automatically analyses the
position change and timeframe to calculate the velocity of the body. This cycle is repeated until
the phone comes to a complete stop. The velocity and position obtained from this process is
treated as the true velocity and position.
Figure 11. This image is a screen shot of the Video analysis process. Position is measured in
both axes
The data from the phone sensor is analyzed through retroactively with the help of a developed
algorithm (see appendix) that calculates the velocity and the position of the object. It does so by
numerically integrating the acceleration to calculate the velocity. Further numerical integration is
Shrestha 19
done in order to obtain the position of the object. This process can be described by the following
equations:
𝑣 = 𝑣0 + ∫ 𝑎 𝑑𝑡
𝑡
0
𝑥 = 𝑥0 + ∫ 𝑣 𝑑𝑡
𝑡
0
In our experiments, the carts starts at rest and thus, both the initial position (x0) and initial
velocity (v0) are assumed to be zero. Therefore we use these values as our constants of
integration in the previous equation. Furthermore, Boole’s rule (given below) was used as the
method of numerical integration.
Where,
The Matlab program applies this logic process to the data obtained from the phone
sensors to calculate the position change and the velocity of the object. However, as noted in the
literature review, this part of the data analysis is highly prone to errors like bias and noise. The
developed program corrects the data for any bias in the system and then filters the data to reduce
the noise level. Currently, the program uses a low pass filter which ignores data under a certain
cut off level and attenuates the data above the cut off level. In addition to a low pass filter,
Kalman filter will also be implemented into simple motion types. Due to the complexity of
Kalman filter, applying it into motion with higher degrees of freedom is arduous. For this
research, we try to filter the acceleration data for 1D and 2D motion retroactively with a Kalman
filter as well as a low pass filter to compare their effectiveness.
Shrestha 20
However, raw acceleration measured by the accelerometer does not differentiate between
translational and rotational acceleration. Raw acceleration alone cannot be used to calculate the
position of the body. This is where the gyroscope plays a vital role in an inertial navigation
system. The gyroscope data describes the rotation and the orientation of the phone. When this
data is compared to the initial values of orientation, we can determine the rotational acceleration.
The data obtained from the gyroscope in the form of roll (α), pitch (β) and yaw (γ) can be
converted into a rotational matrix M. This matrix is used to transform the raw acceleration
vector into a new acceleration vector that consists of only translational acceleration. This way,
we use the gyroscope data to correct the accelerometer data. This full procedure is shown below.
If,
by, then, for any raw acceleration matrix,[
𝑋
𝑌
𝑍
] theAnd is denoted
translational acceleration [
𝑋′
𝑌′
𝑍′
] is given by,
For the rotational motion, a different method is used to calculate the position of the
object. In our experiments, the radius of the rotational motion is known. If we place the axes of
rotation in the center of the wheel, we can see that the phone would make sinusoidal motion.
Shrestha 21
Thus, we can calculate the position of the phone by using the formulae of angular motion which
are given by:
𝑥 = 𝑅 ∗ cos( 𝛾) , where γ = yaw
𝑦 = 𝑅 ∗ sin(𝛾)
Results/ Analysis
The procedures of analysis of all the motions in these research are similar. Let us use the
simplest of the motion in order to demonstrate the analysis process. A small initial force is
applied on the cart and the cart is allowed to come to a complete stop after some time. The data
was collected by the smartphone in the form of acceleration in the x ,y ,and z directions. The first
issue that we had to face is that, the raw acceleration data is riddled with errors such as bias and
non-zero acceleration.
Figure 12: This is the plot for the raw acceleration of the cart in 1D motion.
The first initial spike is the acceleration caused the applied force. We can see that there is
a definite non zero acceleration before the force was introduced. This is strange because the body
Shrestha 22
is not moving at all. A stationary body should have zero acceleration. In order to correct for that,
the data analysis program calculates the average value of the acceleration before the initial push.
This offset value, often referred to as bias constant, and is removed from the raw acceleration in
order to correct the data. Another source of error that can be seen from the figure above is the
noise after the initial push. This noise is created from the vibrations from the ground, friction,
electromagnetic waves. These errors are inherent in inertial navigation systems. The raw data is
put through a low pass filter in order to remove some of these spikes.
In this research, an attempt was done in order to replace the low pass filter with a more
efficient Kalman filter. Due to the complexity of the filter, the Kalman filter was restricted to 1D
and 2D motion. However, when programing the filter, a very important detail was realized. The
Kalman filter is a recursive system consisting of a measurement update step and prediction step.
The filter uses the equations of motion, known control inputs and measurements from the sensors
to predict and calculate the various variables associated to the system. This way, the filter
requires input from a source that is deemed to accurate. However, in our experiment, we
restricted the motion of the phone into strictly translational motion while preventing any
rotational motion. This induced the lack of gyroscope data as the control variable and made the
filter impossible to implement for the current setups. The pre-existing low pass filter was used
for this experiment instead. The low pass filter eliminated part of the noise in the acceleration
data
The filtered acceleration is numerically integrated to give the velocity of the body
throughout the motion. The values obtained are integrated again in order to obtain the position of
the body. These values are then compared to the true position of the body.
Shrestha 23
Figure 13. This is a plot for the filtered acceleration for Figure 12.
Figure 14. This is the plot for the velocity of the phone.
Figure 15. This is the plot for the calculated position of the phone compared to the true position
of the body that was obtained from the video analysis. The average error between the true
position and the calculated position was 0.25m.
Shrestha 24
The smartphone was able to collect the data with accuracy for the initial 10-15 seconds.
However, after that, the numerical drift from the accumulation of errors forces the divergence the
calculated position and the true position. Due to the process of calculation and numerical
integration, any error in acceleration due to biases, noise is integrated twice and thus results in
quadratic drift. While, an extended Kalman filter was recommended to combat these issues
effectively, the researcher was not able to implement it in these experiments. These trends were
noticed in other experiments as well.
Analysis of the different motions in the experiment
Figure 16. This is the plot for the 1d Complex motion and shows the body moving
forward and then returning back to the initial position. The average error calculated from these
experiments was 0.35m. The attached fan added errors in the form of extra vibration and
magnetic interference.
1D ComplexMotion
Shrestha 25
Figure 16: This is the plot for the motion of 2D simple motion. The cart was pushed in
the x direction first and then in the y direction. However, the two forces were not concurrent and
can be demonstrated by the calculated position graph in the y direction. Average error in X
direction = 1.0364m Average error in Y direction = 0.1985m
Figure 17. This is the plot for the motion of 2D Incline motion. At the end of the incline,
the cart hit a soft wall and came to an immediate stop thus increasing negative acceleration in
two directions. Average error in X direction = 0.43m. Average error in Y direction = 0.079m
2D Simple
2D incline
Shrestha 26
Figure 19. This is the plot for horizontal rotation. Average error in X = 0.0387m and
Average error in Y= 0.0411m
Figure 19. This is the plot for horizontal rotation. Average error in Z = 0.0772m and
Average error in Y= 0.0785m
Rotation along X-Y Axis
Rotation along Y-Z axis
Shrestha 27
Discussions and Conclusion
This project, although frustrating at times, provided me insight in dealing with natural
physical systems, large data manage and quantitative analysis of data. Recent developments in
the science has allowed the miniaturization of technology. Computers like the ENIAC, which
took up entire rooms have been miniaturized to small hand held phones. In fact, the computer
that put the man on the moon had lower processing capabilities than the smartphone used in this
experiment. Similarly, traditional devices of measurements like accelerometer and gyroscope
have been miniaturized into small microchips which are used in smartphones. The technology
was initially added onto a smartphone in order to rotate the screen when the user rotates the
screen from a vertical orientation to a horizontal orientation. Addition of such technology has
enabled people to look into more practical application of accelerometers and gyroscopes.
There were multiple sources of issues in the experiment. While some of the issues were
trivial and easily solved, some persisted throughout the experiment. One of the major problems
faced was the algorithm itself. Since the program was written in MATLAB by the previous
researcher, the input format for the video analysis and sensor data was unknown. Furthermore,
the program obtained from the project hard drive was not the actual final program provided in
the senior research paper. In addition to that, the program analyzed sensor data in meters while
analyzing the video data in centimeters. This information was not provided in the program itself.
In order to solve this issue, the program code was analyzed line by line, edited, and updated per
the requirements for this experiment.
The position of the video camera was also an issue. One idea was to remove the ceiling
tile in order to fully capture the motion from a vertical perspective while having the tracks on the
table underneath it. The problem faced that was that the table was not sturdy and trying to use the
camera before and after the experiment resulted the sensor mistaking vibrations as acceleration
Shrestha 28
data. This also resulted in the data shifting as there was no way to check if the camera was truly
vertically above the track. This issue was solved by the researcher’s ingenuity. The camera was
put on top of a tripod. One leg was extended longer than the other two legs so that the camera
could look vertically over the track without having its view obstructed. This setup is shown in
the figure below.
Figure 20. This picture shows the setup of the tripod so that the
user has full access to the back side of the camera as well as be
sure that the camera is vertically above the track. Furthermore,
Weights were added onto the longer leg in order to balance the
rotational moment of the body in order to keep the entire tripod
and the camera in equilibrium.
In this experiment, the gyroscope data was used to correct the raw acceleration data and
filtered to remove the noise and biases. The filtered acceleration data was integrated twice in
order to obtain the position of the phone. Thus any error in the data that was not filtered out was
integrated twice to result in quadratic drift. As mentioned earlier in the analysis, the nature of the
motions experimented upon restricted the use of a Kalman filter. This research is not without its
flaws however, this allows room for further improvement.
As seen in the data above, low pass filter is not the most effective way to filter out the
noise in the rotated acceleration. However, when investigating 1D and 2D motion with only
translational degrees of freedom, Kalman filter cannot be applied because of the lack of known
control values. An improvement would be to add more control values in the experiment itself.
One suggestion is to add a laser pointer and a sensor during the motion. This way, the laser
sensor data can be used as a known value. Another method is to attach the phone to a motor and
Shrestha 29
use the motor to pull on the phone with a constant voltage. This way, we can have a known
control value which can be used in the measurement update step of the Kalman filter. While, the
goal of the research is to have the device analyze the sensor data in real time, for future research,
it is advised to attempt the filter retroactively first.
The types of motions experimented on are simple. It’s imperative the data collection and
analysis be accurate for both short term and long term simple motion. After the program is
accurate for simple motion, it should be experimented onto more complex motions as well. In
this experiment, we explored the motion of using the gyroscope measurements in two different
rotational axes. However, this method of calculation cannot be used for a variable radius of
rotation. Thus, further research can be done into loops, twists and turns before our INS can be
applied onto real life motions.
Using different new smartphones might also improve the data. Newer smartphones are
equipped with the latest technology and thus have better INS microchip than the previous
versions. Using only one smartphone to analyze data is not enough and as such, it is important to
use smartphones from different vendors and write algorithms accordingly for them. As more
research is conducted, the method of filtering the data, the precision of the sensors and the
method of data collection will improve and be more sophisticated.
Shrestha 30
Appendix of Programs
RotateAcc4ipod
Data Condition
Shiftgryo4ipod
rotmatrix4ipod
CalcPosINStruct4ipod
Plotgryo4ipod
Shrestha 31
function INStruct = RotateAcc4ipod(AppOutput,vid,setshift)
%Appoutput is the output from the sensor
%vid is the exported loggerpro data analysis file
%setshift is a userdefined number that is set by the user and is used to
%shift the data.
% Unload time
Time_ms = AppOutput(:,1);
AppOutput = AppOutput(:,2:end);
UnfilteredAcc = AppOutput(:,1:3);
setshift;
% Delete first zeros in the beginning of data collection
CondAcc = DaaCondition(AppOutput);
% Shift gyroscope data so that initial value would be [0 0 0]
CondAcc = ShiftGyro4ipod(CondAcc,setshift);
len = length(CondAcc);
IniAcc=[];
for i = 1:len
Gyroindex = CondAcc(i,4:6);
CurrAcc = CondAcc(i,1:3);
M = rotmatrix4ipod(Gyroindex);
RotAcc = M*CurrAcc';
IniAcc(i,1:3) = RotAcc';
clear Gyroindex CurrAcc M RotAcc;
end
% Filter raw acceleration
for i=1:3
b=fir1(30,.08,'low');
IniAcc(:,i)=filter(b,1,IniAcc(:,i));
end
a1=IniAcc(:,1);
a2=IniAcc(:,2);
a3=IniAcc(:,3);
%remove the first (setshift/2) data points
a1(1:floor(setshift/2))=[];
a2(1:floor(setshift/2))=[];
a3(1:floor(setshift/2))=[];
Acc(:,1)=a1;
Acc(:,2)=a2;
Acc(:,3)=a3;
%check for and correct the bias
avg1=mean(Acc(1:floor(setshift/2),1));
avg2=mean(Acc(1:floor(setshift/2),2));
avg3=mean(Acc(1:floor(setshift/2),3));
Acc(:,1)=Acc(:,1)-avg1;
Acc(:,2)=Acc(:,2)-avg2;
Acc(:,3)=Acc(:,3)-avg3;
Shrestha 32
% Load data into INStruct
INStruct.Time_ms = Time_ms;
INStruct.InitialAcc = CondAcc(:,1:3);
INStruct.InitialGyro = CondAcc(:,4:6);
INStruct.RotatedAcc = Acc;
INStruct.UnfilteredAcc = UnfilteredAcc;
INStruct.Setshift = setshift;
INStruct.Vid = vid;
Shrestha 33
function CondAcc = DaaCondition(DataArray)
%used to remove the unnecessary vibrations caused by button pressing by
%removing the first 10 data points.
len=size(DataArray);
L=len(2);
for k=1:L
a=DataArray(:,k);
a(1:10)=[];
CondAcc(:,k)=a;
end
end
Shrestha 34
function CondAcc2 = ShiftGyro4ipod(CondAcc,setshift)
%clean up data
%for i=4:6
% b=fir1(30,.08,'low');
% CondAcc(:,i)=filter(b,1,CondAcc(:,i));
%end
%%% data is in rad
Gyroindex1 = CondAcc(:,4)*(180/pi());
Gyroindex2 = CondAcc(:,5)*(180/pi());
Gyroindex3 = CondAcc(:,6)*(180/pi());
CondAcc2 = CondAcc(:,1:3);
Gyroindex(:,1)=Gyroindex1;
Gyroindex(:,2)=Gyroindex2;
Gyroindex(:,3)=Gyroindex3;
avg1=mean(Gyroindex(1:setshift,1));
avg2=mean(Gyroindex(1:setshift,2));
avg3=mean(Gyroindex(1:setshift,3));
CondAcc2(:,4)=Gyroindex(:,1)-avg1;
CondAcc2(:,5)=Gyroindex(:,2)-avg2;
CondAcc2(:,6)=Gyroindex(:,3)-avg3;
% Offset yaw (pitch and roll)? 180 because the data goes from -180 to 180,
not 0
% to 360
CondAcc2(:,6) = CondAcc2(:,6)+180;
end
Shrestha 35
function M=rotmatrix4ipod(Gyroindex)
% angles must be in degrees
p=Gyroindex(:,1);%roll
k=Gyroindex(:,3);%yaw
w=Gyroindex(:,2);%pitch
M=[cosd(p)*cosd(k), cosd(w)*sind(k)+sind(w)*sind(p)*cosd(k), sind(w)*sind(k)-
cosd(w)*sind(p)*cosd(k),
-cosd(p)*sind(k), cosd(w)*cosd(k)-sind(w)*sind(p)*sind(k),
sind(w)*cosd(k)+cosd(w)*sind(p)*sind(k),
sind(p), -sind(w)*cosd(p), cosd(w)*cosd(p)];
end
Shrestha 36
function [avgXerror avgYerror] = CalcPosINStruct4ipod(INStruct)
%download the data from the structure
Acc = INStruct.UnfilteredAcc;
vid = INStruct.Vid;
setshift=INStruct.Setshift;
% Filter acceleration
for i=1:3
b=fir1(30,.08,'low');
Acc(:,i)=filter(b,1,Acc(:,i));
end
g=9.79941;
Acc=-Acc.*g;
% Code to make time vector for data and video analysis
h=1/100;
t=[];
t=0:h:length(Acc(:,1))*h-h;
vidx=vid(:,2);
vidy=-vid(:,3);
h=1/31;
vidt=[];
vidt=0:h:length(vid)*h-h;
h=1/100;
avg1=mean(Acc(1:floor(setshift/2),1));
avg2=mean(Acc(1:floor(setshift/2),2));
avg3=mean(Acc(1:floor(setshift/2),3));
Acc(:,1)=Acc(:,1)-avg1;
Acc(:,2)=Acc(:,2)-avg2;
Acc(:,3)=Acc(:,3)-avg3;
a1=Acc(:,1);
%x dir
%get velocity
v1=[];
v1(1)=0;
v1(2)=h*0.5*(a1(1)+a1(2));
v1(3)=h*(a1(1)+4*a1(2)+a1(3))/3;
v1(4)=h*(3*a1(1)+9*a1(2)+9*a1(3)+3*a1(4))/8;
for i= 5:length(a1)
v1(i)=v1(i-4)+h*(14*a1(i-4)+64*a1(i-3)+24*a1(i-2)+64*a1(i-
1)+14*a1(i))/45;
end
%get position
x1=[];
x1(1)=0;
x1(2)=h*0.5*(v1(1)+v1(2));
x1(3)=h*(v1(1)+4*v1(2)+v1(3))/3;
Shrestha 37
x1(4)=h*(3*v1(1)+9*v1(2)+9*v1(3)+3*v1(4))/8;
for i= 5:length(v1)
x1(i)=x1(i-4)+h*(14*v1(i-4)+64*v1(i-3)+24*v1(i-2)+64*v1(i-
1)+14*v1(i))/45;
end
%y dir
a2=Acc(:,2);
%get velocity
v2=[];
v2(1)=0;
v2(2)=h*0.5*(a2(1)+a2(2));
v2(3)=h*(a2(1)+4*a2(2)+a2(3))/3;
v2(4)=h*(3*a2(1)+9*a2(2)+9*a2(3)+3*a2(4))/8;
for i= 5:length(a2)
v2(i)=v2(i-4)+h*(14*a2(i-4)+64*a2(i-3)+24*a2(i-2)+64*a2(i-
1)+14*a2(i))/45;
end
%get position
x2=[];
x2(1)=0;
x2(2)=h*0.5*(v2(1)+v2(2));
x2(3)=h*(v2(1)+4*v2(2)+v2(3))/3;
x2(4)=h*(3*v2(1)+9*v2(2)+9*v2(3)+3*v2(4))/8;
for i= 5:length(v2)
x2(i)=x2(i-4)+h*(14*v2(i-4)+64*v2(i-3)+24*v2(i-2)+64*v2(i-
1)+14*v2(i))/45;
end
%z dir
a3=Acc(:,3);
%get velocity
v3=[];
v3(1)=0;
v3(2)=h*0.5*(a3(1)+a3(2));
v3(3)=h*(a3(1)+4*a3(2)+a3(3))/3;
v3(4)=h*(3*a3(1)+9*a3(2)+9*a3(3)+3*a3(4))/8;
for i= 5:length(a3)
v3(i)=v3(i-4)+h*(14*a3(i-4)+64*a3(i-3)+24*a3(i-2)+64*a3(i-
1)+14*a3(i))/45;
end
%get position
x3=[];
x3(1)=0;
x3(2)=h*0.5*(v3(1)+v3(2));
x3(3)=h*(v3(1)+4*v3(2)+v3(3))/3;
x3(4)=h*(3*v3(1)+9*v3(2)+9*v3(3)+3*v3(4))/8;
for i= 5:length(v3)
x3(i)=x3(i-4)+h*(14*v3(i-4)+64*v3(i-3)+24*v3(i-2)+64*v3(i-
1)+14*v3(i))/45;
end
figure(9);
clf;
Shrestha 38
subplot(3,1,1)
plot(t,v1);
xlabel('Time(s)');
ylabel('Velocity(m/s)')
title('X Vel')
subplot(3,1,2)
plot(t,v2);
xlabel('Time(s)');
ylabel('Velocity(m/s)')
title('Y Vel');
subplot(3,1,3)
plot(t,v3);
xlabel('Time(s)');
ylabel('Velocity(m/s)')
title('Z Vel');
Pos(:,1)=x1;
Pos(:,2)=x2;
Pos(:,3)=x3;
figure(10);
clf;
subplot(3,1,1);
plot(t,Pos(:,1),'b');
xlabel('Time(Sec)');
ylabel('Position(m)')
title('X displacement');
hold on;
plot(vidt,vidx,'r');
subplot(3,1,2);
plot(t,Pos(:,2),'b');
xlabel('Time(Sec)');
ylabel('Position(m)')
title('Y displacement');
hold on;
plot(vidt,vidy,'r');
legend('Calculated','Video Analysis');
subplot(3,1,3);
plot(t,Pos(:,3),'b');
xlabel('Time(Sec)');
ylabel('Position(m)')
title('Z displacement');
%difference between vidx and x
i=3;
e=0;
while (i<=length(vidx)) && (i*10/3 <= length(x1))
j = i* 10/3;
e=e+abs (vidx(i) - x1(j));
i=i+3;
end
avgXerror = e/(i/3);
%difference between vidy and y
Shrestha 39
i=3;
e=0;
while (i<=length(vidy)) && (i*10/3 <= length(x2))
j = i* 10/3;
e=e+abs (vidy(i) - x2(j));
i=i+3;
end
avgYerror = e/(i/3);
% subplot(3,1,1)
% plot(Pos(:,1));
% title('X-direction Pos')
%
% subplot(3,1,2)
% plot(Pos(:,2));
% title('Y-direction Pos');
%
% subplot(3,1,3)
% plot(Pos(:,3));
% title('Z-direction Pos');
end
Shrestha 40
function [avgXerror avgYerror]=Plotgyro4ipod(AppOutput,vid,r)
clf;
a=AppOutput;
%time
h=1/100;
t=[];
t=0:h:length(a(:,5))*h-h;
%plot raw gyro
figure(1);
subplot(3,1,1);
plot(t,sin(a(:,5)));
title('roll');
subplot(3,1,2);
plot(t,a(:,6));
title('pitch');
subplot(3,1,3);
plot(t,a(:,7));
title('yaw');
%calculate pos
yaw=a(:,7);
y=r*sin(yaw);
x=r*cos(yaw);
%prepare vid analysis
vidx=vid(:,2);
vidy=vid(:,3);
h=1/30;
vidt=[];
vidt=0:h:length(vid)*h-h;
%compair
figure(2);
subplot(2,1,1);
plot(t,x,'b');
title('X displacement');
hold on;
plot(vidt,vidx,'r');
hold off;
subplot(2,1,2);
plot(t,y,'b');
title('Y displacement');
hold on;
plot(vidt,vidy,'r');
hold off;
legend('Calculated','Video Analysis');
%difference between vidx and x
i=3;
e=0;
while (i<=length(vidx)) & (i*10/3<=length(x))
j=i*10/3;
e=e+abs(vidx(i)-x(j));
i=i+3;
end
avgXerror=e/(i/3);
Shrestha 41
%difference between vidy and y
i=3;
e=0;
while (i<=length(vidy)) & (i*10/3<=length(y))
j=i*10/3;
e=e+abs(vidy(i)-y(j));
i=i+3;
end
avgYerror=e/(i/3);
end
Shrestha 42
Works Cited
Alberto Serra , Tiziana Dessì, Davide Carboni, Vlad Popescu , Luigi Atzori.Inertial navigation systems
for user - centric indoor applications
Aleksander Nawrat, Karol Jędrasiak, Krzysztof Daniec, & Roman Koteras. (2012). Inertial navigation
systems and its practical applications. ()
AYENI, B. K., & SAHALU, J. B. (2013). Review of performance analysis methods for real-time
embedded systems design. Computer Science & Telecommunications, 39(3), 11.
Barberis, C., Andrea, B., Giovanni, M., & Paolo, M. (2014). Experiencing indoor navigation on mobile
devices. IT Professional, 16(1), 50-57. doi:10.1109/MITP.2013.54
Chen, Z., Zou, H., Jiang, H., Zhu, Q., Yeng, C. S., & Xie, L. (2015). Fusion of WiFi, smartphone
sensors and landmarks using the kalman filter for indoor localization. Sensors (14248220), 15(1),
715-732. doi:10.3390/s150100715
Enkhtur, M., Seong, Y. C., & Kyong-Ho Kim. (2013). Modified unscented kalman filter for a multirate
INS/GPS integrated navigation system. ETRI Journal, 35(5), 943-946.
doi:10.4218/etrij.13.0212.0540
Filieri, A., & Melchiotti, R. (n.d.). Position Recovery from Accelerometric Sensors Algorithms
analysis and implementation issues.
Gao, W., Zhang, Y., & JianguoWang. (2015). Research on initial alignment and self-calibration of
rotary strapdown inertial navigation systems. Sensors (14248220), 15(2), 3154-3171.
doi:10.3390/s150203154
Groves, P. D. (2008). Principles of GNSS, inertial, and multi-sensor integrated navigation systems.
Boston: Artech House.
Hwang, S., & Yu, D. (2012). GPS localization improvement of smartphones using built-in
sensors. International Journal of Smart Home, 6(3), 1-8.
Shrestha 43
Kai-Wei Chiang, Thanh, T. D., & Jhen-Kai Liao. (2013). The performance analysis of a real-time
integrated INS/GPS vehicle navigation system with abnormal GPS measurement
elimination. Sensors (14248220), 13(8), 10599-10622. doi:10.3390/s130810599
Kavanagh, R. M. (2007). Gyroscopes for orientation and inertial navigation systems. Cartography &
Geoinformation, 6, 254-270.
Park, K., Shin, H., & Cha, H. (2013). Smartphone-based pedestrian tracking in indoor corridor
environments. Personal & Ubiquitous Computing, 17(2), 359-370. doi:10.1007/s00779-011-
0499-5
Pendrill, A., & Rohl, J. (2011). Acceleration and rotation in a pendulum ride, measured using an
iPhone 4, 676.
Renaudin, V., Susi, M., & Lachapelle, G. (2012). Step length estimation using handheld inertial
sensors. Sensors (14248220), 12(7), 8507-8525. doi:10.3390/s120708507
Riaz, S. (2011). Mathematical modeling of INS/GPS based navigation system using discrete time
extended kalman filter schemes for flapping micro air vehicle. International Journal of Micro Air
Vehicles, 3(1), 25-33.
Saeedi, S., Moussa, A., & El-Sheimy, N. (2014). Context-aware personal navigation using embedded
sensor fusion in smartphones. Sensors (14248220), 14(4), 5742-5767. doi:10.3390/s140405742
Sang, K. P., & Young, S. S. (2010). A zero velocity detection algorithm using inertial sensors for
pedestrian navigation systems. Sensors (14248220), 10(10), 9163-9178.
doi:10.3390/s101009163
Savage, P. G. (1998). Strapdown inertial navigation integration algorithm design part 1: Attitude
algorithms. Journal of Guidance, Control, and Dynamics, 21(1), 19-28. doi:10.2514/2.4228

More Related Content

What's hot

Intern report final
Intern report finalIntern report final
Intern report final
Fazlul wahid
 
An adaptive treadmill-style locomotion interface and its application in 3-D i...
An adaptive treadmill-style locomotion interface and its application in 3-D i...An adaptive treadmill-style locomotion interface and its application in 3-D i...
An adaptive treadmill-style locomotion interface and its application in 3-D i...
toukaigi
 
Modeling Motion in Matlab 7.19.11_v4_Taylor_KKedits
Modeling Motion in Matlab 7.19.11_v4_Taylor_KKeditsModeling Motion in Matlab 7.19.11_v4_Taylor_KKedits
Modeling Motion in Matlab 7.19.11_v4_Taylor_KKedits
Anthony Taylor
 

What's hot (20)

1. mohammed aslam, b. mahalingam
1. mohammed aslam,  b. mahalingam1. mohammed aslam,  b. mahalingam
1. mohammed aslam, b. mahalingam
 
Intern report final
Intern report finalIntern report final
Intern report final
 
final poster
final posterfinal poster
final poster
 
IRJET- Get2School : An Android Application to Track School Location
IRJET-  	  Get2School : An Android Application to Track School LocationIRJET-  	  Get2School : An Android Application to Track School Location
IRJET- Get2School : An Android Application to Track School Location
 
Geographic information system(gis)
Geographic information system(gis)Geographic information system(gis)
Geographic information system(gis)
 
GIS in Health
GIS in HealthGIS in Health
GIS in Health
 
What is GIS?
What is GIS?What is GIS?
What is GIS?
 
Inertial Sensor Array Calibration Made Easy !
Inertial Sensor Array Calibration Made Easy !Inertial Sensor Array Calibration Made Easy !
Inertial Sensor Array Calibration Made Easy !
 
A decision tree based pedometer
A decision tree based pedometerA decision tree based pedometer
A decision tree based pedometer
 
FinalPoster2
FinalPoster2FinalPoster2
FinalPoster2
 
Introduction to remote sensing and gis
Introduction to remote sensing and gisIntroduction to remote sensing and gis
Introduction to remote sensing and gis
 
IJSRED-V2I3P82
IJSRED-V2I3P82IJSRED-V2I3P82
IJSRED-V2I3P82
 
Basic of gis concept and theories
Basic of gis concept and theoriesBasic of gis concept and theories
Basic of gis concept and theories
 
Planning techniques geo informatics
Planning techniques  geo informaticsPlanning techniques  geo informatics
Planning techniques geo informatics
 
Human Pose Estimation by Deep Learning
Human Pose Estimation by Deep LearningHuman Pose Estimation by Deep Learning
Human Pose Estimation by Deep Learning
 
Application of Vision based Techniques for Position Estimation
Application of Vision based Techniques for Position EstimationApplication of Vision based Techniques for Position Estimation
Application of Vision based Techniques for Position Estimation
 
An adaptive treadmill-style locomotion interface and its application in 3-D i...
An adaptive treadmill-style locomotion interface and its application in 3-D i...An adaptive treadmill-style locomotion interface and its application in 3-D i...
An adaptive treadmill-style locomotion interface and its application in 3-D i...
 
Udirect: accurate and reliable estimation of the facing direction of the mobi...
Udirect: accurate and reliable estimation of the facing direction of the mobi...Udirect: accurate and reliable estimation of the facing direction of the mobi...
Udirect: accurate and reliable estimation of the facing direction of the mobi...
 
REMOTE SENSING AND GEOGRAPHIC INFORMATION SYSTEMS
REMOTE SENSING AND GEOGRAPHIC INFORMATION SYSTEMS REMOTE SENSING AND GEOGRAPHIC INFORMATION SYSTEMS
REMOTE SENSING AND GEOGRAPHIC INFORMATION SYSTEMS
 
Modeling Motion in Matlab 7.19.11_v4_Taylor_KKedits
Modeling Motion in Matlab 7.19.11_v4_Taylor_KKeditsModeling Motion in Matlab 7.19.11_v4_Taylor_KKedits
Modeling Motion in Matlab 7.19.11_v4_Taylor_KKedits
 

Similar to Smartphone Inertial Navigation

Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...
Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...
Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...
toukaigi
 
Crowd Recognition System Based on Optical Flow Along with SVM classifier
Crowd Recognition System Based on Optical Flow Along with SVM classifierCrowd Recognition System Based on Optical Flow Along with SVM classifier
Crowd Recognition System Based on Optical Flow Along with SVM classifier
IJECEIAES
 
Paper id 2420143
Paper id 2420143Paper id 2420143
Paper id 2420143
IJRAT
 

Similar to Smartphone Inertial Navigation (20)

booysen_vehicle_paper automotive 2015.pdf
booysen_vehicle_paper automotive 2015.pdfbooysen_vehicle_paper automotive 2015.pdf
booysen_vehicle_paper automotive 2015.pdf
 
0326
03260326
0326
 
A real time filtering method of positioning data with moving window mechanism
A real time filtering method of positioning data with moving window mechanismA real time filtering method of positioning data with moving window mechanism
A real time filtering method of positioning data with moving window mechanism
 
Attitude Estimation And Compensation In Odometric Localization of Mobile Robo...
Attitude Estimation And Compensation In Odometric Localization of Mobile Robo...Attitude Estimation And Compensation In Odometric Localization of Mobile Robo...
Attitude Estimation And Compensation In Odometric Localization of Mobile Robo...
 
Novel Framework for Navigation using Enhanced Fuzzy Approach with Sliding Mod...
Novel Framework for Navigation using Enhanced Fuzzy Approach with Sliding Mod...Novel Framework for Navigation using Enhanced Fuzzy Approach with Sliding Mod...
Novel Framework for Navigation using Enhanced Fuzzy Approach with Sliding Mod...
 
Human activity recognition with self-attention
Human activity recognition with self-attentionHuman activity recognition with self-attention
Human activity recognition with self-attention
 
Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...
Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...
Real-time Estimation of Human’s Intended Walking Speed for Treadmill-style Lo...
 
Foot Mounted Pedestrian Navigation Systems
Foot Mounted Pedestrian Navigation SystemsFoot Mounted Pedestrian Navigation Systems
Foot Mounted Pedestrian Navigation Systems
 
Ijecet 06 10_003
Ijecet 06 10_003Ijecet 06 10_003
Ijecet 06 10_003
 
Crowd Recognition System Based on Optical Flow Along with SVM classifier
Crowd Recognition System Based on Optical Flow Along with SVM classifierCrowd Recognition System Based on Optical Flow Along with SVM classifier
Crowd Recognition System Based on Optical Flow Along with SVM classifier
 
Inertial_navigation_systems_for_mobile_robots.pdf
Inertial_navigation_systems_for_mobile_robots.pdfInertial_navigation_systems_for_mobile_robots.pdf
Inertial_navigation_systems_for_mobile_robots.pdf
 
Automation of Wheelchair Using Iris Movement
Automation of Wheelchair Using Iris MovementAutomation of Wheelchair Using Iris Movement
Automation of Wheelchair Using Iris Movement
 
APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...
APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...
APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...
 
APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...
APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...
APPLICABILITY OF CROWD SOURCING TO DETERMINE THE BEST TRANSPORTATION METHOD B...
 
Simultaneous Real time Graphical Representation of Kinematic Variables Using ...
Simultaneous Real time Graphical Representation of Kinematic Variables Using ...Simultaneous Real time Graphical Representation of Kinematic Variables Using ...
Simultaneous Real time Graphical Representation of Kinematic Variables Using ...
 
Integral Backstepping Approach for Mobile Robot Control
Integral Backstepping Approach for Mobile Robot ControlIntegral Backstepping Approach for Mobile Robot Control
Integral Backstepping Approach for Mobile Robot Control
 
Northwestern University Research Poster
Northwestern University Research PosterNorthwestern University Research Poster
Northwestern University Research Poster
 
Paper id 2420143
Paper id 2420143Paper id 2420143
Paper id 2420143
 
Motion recognition based 3D pedestrian navigation system using smartphone
Motion recognition based 3D pedestrian navigation system using smartphoneMotion recognition based 3D pedestrian navigation system using smartphone
Motion recognition based 3D pedestrian navigation system using smartphone
 
Gps ins odometer data fusion
Gps ins odometer data fusionGps ins odometer data fusion
Gps ins odometer data fusion
 

Smartphone Inertial Navigation

  • 2. Shrestha 2 Acknowledgements Randolph College Summer Research Program Dr. Peter Sheldon Kacey Meaker ‘08 Alex Tran ‘15 Timothy Slesinger ‘14 Mike Cheng, Virginia Episcopal School Richard Lin, Virginia Episcopal School
  • 4. Shrestha 4 Introduction Inertial navigation system (INS) use accelerometers, gyroscopes to measure the position, orientation and velocity of a moving body without the need of external devices like the Global Positioning System (GPS) (Groves 2008, Kavanagh 2007, Nawrat, et al. 2012).The position, velocity and orientation are measured by calculating the current position by using the data about previously known position and conditions. This way, past data is used to predict the movement of the object. This process is known as dead reckoning. Inertial navigation systems are currently used ships, planes, cars, submarines, and even missile systems (Chaing 2013, Sadia 2011). Devices such as accelerometers and gyroscopes are bulky and expensive and are not financially feasible for classroom setting. However, just like phones and computers, conventional accelerometers and gyroscopes have been increasingly replaced by microchips (Hwang, Yu 2012, Saeedi et al. 2014). Newer smartphones are equipped with such capabilities and can be used as an INS. This has opened new horizons regarding the academic applications of inertial navigation systems in classrooms to demonstrate kinematics. The two components of INS work seamlessly with each other and collect data that is used to predict the movement of the body. The accelerometer measures acceleration in three mutually orthogonal axes- X, Y, and Z while the gyroscope measures the rotation about these axes (Groves 2008, Kavanagh 2007, Pendrill 2011). The gyroscope also measures the rotational acceleration of the body. Rotation along the different axes have different names and are shown in the diagram below. Figure 1: Rotation around the axes which are called Pitch, Roll, and Yaw respectively.
  • 5. Shrestha 5 Dead reckoning is done by integrating the various kinematic equations and using the previous conditions as the integration constants. We use double integration to find position and orientation from acceleration. However, when integrating, we need initial conditions and orientation of the body which we can use to have definite 1st and 2nd integrals (Groves 2008, Nawrat et al. 2012, Savage 1998). It is crucial for data for initial conditions to be precise because these errors cause significant discrepancy in the results. For this research, we start the body at rest thus effectively making initial velocity equal to zero. Furthermore, the calculation methods finds the change in position rather than the final position. This makes it easier to calculate total displacement and direction of displacement. Thus, we are not interested in initial position. We simplify our calculation of the body by starting from rest and fixing our axes at the position where the body is at rest. This way both initial velocity and position is equal to zero. While, using a smartphone instead of a traditional INS is the economical choice for classrooms, it is not without its own drawbacks. Inertial navigation systems are plagued by issues like, numerical drift, bias, noise and misalignment. The microchip itself is afflicted by temperature interferences, magnetic interferences and vibrational interferences (Park 2013). Using low quality components sacrifice accuracy and precision and skews the data. This is why, filters are essential to obtain optimal data from the components. Each year, new and newer smartphones are released with more advanced technology and thus such measurements taken from new devices are increasingly more accurate. This provides the ability to teachers in classrooms to use smartphones a teaching tool to demonstrate kinematics. The goal of this research is to experiment the precision of smartphone INS in various twists and turns and also to attempt to implement a form of Kalman filter to optimize the data. In doing so, the data obtained and analyzed could be more accurate and might help facilitate in creation of a standalone app for smartphones that uses the phone as an inertial navigation system for simple and complex 3d motion.
  • 6. Shrestha 6 Literature Review As mentioned earlier, INS are used in different fields for navigation purposes. Its use is most easily seen in pedestrian navigation and vehicular navigation systems. While each of the two methods use of an accelerometer, the processes in which they use the various components and data collected are different. Pedestrian navigation systems use accelerometer, gyroscope and magnetometers to predict the movement of the object or person in an indoor setting. Vehicular navigation systems, on the other hand, merge the data from the accelerometer and GPS to provide real time and accurate location of the vehicle. The GPS integration helps to correct some of the errors inherent in inertial navigation system such as drift, bias and scale factors. However, additional errors such as ionospheric delay, tropospheric delay and the multipath effect are also added into the system and have to be considered (Chiang 2013). Each of these applications of INS demonstrate similar errors and provide multiple ways to combat them. GPS and INS are used extensively in vehicular navigation. This is done in order to error check the data obtained from both devices. GPS provide accurate data on position in open sky conditions and if the object is in clear line of sight of 4 satellites. However, repeated signals and blocked signals severely affect the quality of the data obtained. (Chaing 2013) Inertial navigation system is used to supplement these data when the vehicle enters a GPS obstructed zone. The two popular ways to link the GPS and INS is through tightly coupled (TC) scheme and loosely coupled (LC) scheme with the help of an Extended Kalman Filter (EKF) (Ayeni, Junaidu 2013). Figure 2: Loosely coupled scheme (left) and tightly coupled Scheme (Right)
  • 7. Shrestha 7 Both the schemes are similar in implementation: the GPS calculates position and velocity and sends these values to the EKF. The filter then compares this data to the data calculated by the INS via dead reckoning and then optimizes the position and velocity. While loose coupling is easier to implement, the scheme requires direct line of sight with at least four satellites in order to obtain accurate GPS data. Tightly coupled scheme tackles this problem by obtaining carrier phase, pseudo range and doppler measurement from the GPS and using the EKF to directly calculate the position and velocity. This way, even with insufficient GPS data, the filter can optimize the information. In one of the experiments, a van was equipped with an INS and GPS on the roof and the movement of the van was tracked as it drove around the city. The literature proposed a modified form of tightly coupled scheme which rejected abnormal GPS data in order to maintain accuracy (Figure 3) and reported a 60% improvement in uncertainty compared to the pure TC and the standard LC schemes. (Chiang 2013) Figure 3: Modified Tightly coupled Scheme for GPS/INS integration. However, one of the problems in using INS is the fact that conventional gyroscopes and accelerometers are expensive and cannot be used in a classroom setting. However, in the last decade, due to growing fad of miniaturization on computers, even the accelerometer and gyroscopes have been minimized into microchips. This development let to a point where both the
  • 8. Shrestha 8 accelerometer and the gyroscope can be fitted into on microchip. Nowadays, smartphones are equipped with these microchips that can help the function. This development in smartphones has allowed us to use these microchips as INS without having to exhaust funds. This brings us to the next popular use of INS. Figure 4: This microchip can be used as an inertial navigation system because it contains a gyroscope as well as an accelerometer and costs less compared to the traditional components of INS. Pedestrian Navigation System (PNS) is used to find the position and velocity of a person. Since most of the calculation about the movement of the person is done internally, the PNS is independent of Wi-Fi or GPS connection (Park 2010, Saeedi et al. 2014). This makes it easier to gather data even when the person is in a house or a cave. Similarly, either Wi-Fi can be used to increase the accuracy of the data obtained from the inertial system. In one of the experiments, an INS was attached to the top of the shoe. This application used the the rotation of the shoe in the y and z axis. When walking, we can notice that we move our foot up and down while simultaneously rotating our foot forward. Using this idea of a walking motion, the pitch is then divided into 4 sections which represent separate part of the movement. These segment represent the 4 main movements for the foot: resting on the floor, leaving the floor, moving above the floor, and
  • 9. Shrestha 9 landing on the floor. The algorithm that identifies the movement state is called the Markov Model (Park 2010). Figure 4: The figure displays the 4 different sections of the walking motion After the algorithm has been applied, state transition probabilities are used to correct the data in order to avoid non-zero velocity when not moving. These state transitions represent the probability that the movement will move from one state to the other. These probabilities are different for both walking and running motion. The experiment proposes a form of Markov model in order to analyze the state transitions for both running and walking motion while also detecting and correcting non-zero velocities (Park 2010). Figure 5: The figure demonstrates the probability of change of state during walking motion.
  • 10. Shrestha 10 These experiments all reported similar sources of errors – non-zero velocities when at rest, loss of signal, interference due to magnetic fields, interference in GPS/Wi-Fi signals, and numerical drift (Barberis 2014,Chaing 2013, Park 2010, Sadia 2011). The Markov model above was implemented in order to recalibrate for non-zero velocities when not moving. These value are contradictory because when non-zero velocity data is obtained, then the system interprets it as movement even when the body is at rest. This presents a huge problems in the data. In order to avoid this error, we have used zero as our initial position and velocity. When using a GPS/INS integrated system, due to various environmental factors such as building, clouds, and trees, the device might not receive appropriate data from the GPS which leads to incorrect data (Chaing 2013). Furthermore, while GPS systems can accurately measure the movement in 2 dimensions, it is inefficient in measuring the movement in z axis. For example, if the data of a rollercoaster ride was collected on a particularly cloudy day then, the data for movement is x,y axes will be more accurate than the data from z axis. This research is in the indoor phase of perfecting data collection and analysis for simple motion in a lab and thus will only use accelerometers and gyroscopes. This way, errors due to GPS signals attenuation are avoided. Other sources of errors can be temperature, bias, misalignment, and vibrational and magnetic interference (Barberis 2014, Chaing 2013, Park 2010, Sadia 2011). Each source of error is a significant problem for the data calculation. The process of dead reckoning uses integration and past data to predict future motion. Any error in the device, data, or the measurement of data will be amplified in the process. This leads to a numerical drift of the predicted position and velocity from the actual position and velocity (Groves 2008, Park 2010, Savage 1998). Therefore it is extremely important to deal with all sources of errors in order to obtain optimum data.
  • 11. Shrestha 11 Figure 6: This figure shows the quadratic drift in INS data compared to actual video analysis Some of the literature suggests recalibration of the accelerometer in order to improve data collection (Serra n.d). By using the gyroscope data and the movement of the normal vector perpendicular to the smartphone screen, the accelerometer looks for small changes in the orientation of the screen while the gyroscope uses this data to readjust the acceleration data. The normal vector is calculated by analyzing the components of acceleration due to gravity in order to find the plane on which the screen rests on. This way, accelerometer and gyroscope complement each other in data collection to obtain accurate data form the movement of the phone. This method of integrating the 2 components is called plane holography (Serra n.d). Various literatures suggest also suggest in adding a magnetometer in order to counteract the effects of magnetic interference on the smartphone. Filtering data is shown to improve the optimization of data. Kalman filter (KF) is used to a great extent in INS systems (Ayeni 2013, Chen et al 2015, Riaz 2011). Named after the scientist who helped formulate the algorithm, the filter is a two-step process. In the first step, the filter uses the current data to formulate an estimate for the future data and their uncertainty as well. In the next step, after the data is collected, the filter compares the current data and
  • 12. Shrestha 12 estimated data and updates the estimated data with a weighted average. The higher weight is given to the data which has more certainty. This way, the filter actively predicts the next step using current data and updates the predictions at it operates real-time (Chen et al 2015). Figure 7: This simplified flowchart demonstrates the flow of logic in a Kalman Filter However, some literature also suggest using extended Kalman filter instead of the normal Kalman filter (Enkhtur 2013, Filieri n.d, Riaz 2011). The main difference between EKF and KF is that KF is more suited to be used in a linear system. In this research, we are taking double integration of acceleration to calculate the position and velocity. Thus, any error in acceleration is seen as a quadratic drift in position. EKF is suggested because it is more suited with nonlinear motion. (Enkhtur 2013, Filieri n.d, Riaz 2011) The study further proposes including quadratic constraints on the integrals while using a TC scheme with a GPS to provide Doppler estimation. In our previous research, due to the complexity of implementing a Kalman Filter real time data analysis, moving average filter was used. However, due to the errors in such a filtering method, low pass filter was also implemented.
  • 13. Shrestha 13 Figure 8: The above figures demonstrates the how each of the filters help in improving the data. Furthermore, increasing sampling rate also helps in increasing the accuracy of the data. Just like, large pixels in a TV screen displays less information about contrast compared to a TV with more pixels, increasing the data sampling rate paints a fuller picture of the motion of the object. In addition, some studies have suggesting in adjusting of the sensors to avoid incorrect data. While, it is a trivial error, due to the tendency of errors carrying forward to amplify, even the source of slight error has to be mitigated. Finally, revising the integration methods by using quadratic constraints, abandoning simple integrations for complex but accurate ones like Boole’s rule had also been suggested. The literature review was incredibly productive in learning about the various errors and error mitigation methods that can be applied in this research. Currently our system consists of an accelerometer and a gyroscope. The gyroscope has enabled exploration into different degrees of freedom. Even though, the change of filtering methods from moving average to band had resulted in more accurate data, there is still numerical drift inherent in the system. The reduction
  • 14. Shrestha 14 of this drift is important for the proper onsite implementation of the smartphone as an INS. This literature review was beneficial because it provides the next goal of the research: experimentation of various different types of motion and implementation of best type of filter. The filter is extremely important because due to the size of the microchip and its inherent sources of errors, it is more inaccurate than a traditional INS. This prompts the search for more accurate method of data collection and data analysis if smartphones were to be used as an INS. However, implementing a real-time Kalman filter is complicated and arduous. In order to check the accuracy of each type of filter, they are implemented on the data retroactively and compared to actual video analysis of the motion. Unless the data collection and analysis methods are not fully perfected, using the smartphone as an INS is not going to be effective. Furthermore, this research is not interested in walking motion. Markov method and transition probabilities cannot be used because continuous motion cannot be divided into various states. Finally, this research is not going to use a GPS, however, it is an eventual goal to implement a tightly coupled GPS/INS integration in order to use the smartphone in an outdoor setting. One of the long term goals of this research is to use the smartphone as an INS to analyze the velocity and g-forces that one experiences in a rollercoaster ride. And as literature suggests, GPS/INS or Wi-Fi /INS coupling can greatly improve data for long term calculation.
  • 15. Shrestha 15 Apparatus Used  LoggerPro 3.0  iPod touch 4th generation  Unicycle and rotating table  Frictionless track and cart  Cart fan attachment  Digital camera and tripod  Mat lab (see appendix for programs used) Methods Our inertial navigation system is dependent on the integrated microchip in the smartphone. The microchip uses an integrated gyroscope and accelerometer to measure the acceleration and orientation of the phone. The position and velocity of the object is calculated by using this data. In this research, the smartphone was allowed to experience different types motion – 1D simple, 1D complex, 2D simple, 2D incline, and rotations around the x-y and the y-z axes. Each experiment was designed to increase the difficulty of the data analysis process by adding degrees of freedom to the motion of the smartphone. In 1D motion, the phone was affixed to a cart and was allowed to move on a straight track. The track forced the cart to move back and forth in one direction. In the simple case, a small initial force was applied onto the cart in the direction of the track. Friction from the track slowed down and eventually brought the cart to a halt. For the complex case, a battery powered fan attached onto the cart. The fan was directed to oppose the direction of the initial force and thus, the cart would slow down after the initial push and return back to the original position. For
  • 16. Shrestha 16 the incline experiment, one edge of the track was put on ledge thus allowing for analysis into horizontal as well as vertical axis.A rotating platform and a custom bicycle rig was used for the rotational motion. The smartphone was affixed on a known radius on the device and allowed to spin. Similar to 1D motion, an initial force was applied tangentially to the wheel. It was then allowed to come to a halt due to friction. Figure 9. These images show the set up for the rotational motion in the horizontal axis and the vertical axis. Finally, three straight tracks and three carts were used to build the set-up for 2D motion. A straight track was affixed on top of two carts. Two of the carts were then placed onto two parallel tracks and the cart containing the smartphone was placed on top of the uppermost track. This way, the top track could move in one direction while the cart containing the smartphone could move in a different direction thus allowing us to analyze motion in two dimensions. Special care was given to construct the setup. A builders leveling tool app was used to check if all the tracks were horizontal. Furthermore, it was necessary for the bottom tracks to be parallel in order to avoid errors in the system.
  • 17. Shrestha 17 Figure 10. This image shows the setup for the tracks that was used to analyze 2D motion. In the start of each experiment, a video camera was positioned at the most optimal location to fully capture the motion of the phone. The smartphone data measurement application was initiated and the initial force was applied towards the desired direction. When the phone came to a complete halt, the data collection was manually terminated. The camera recorded the complete motion of the phone. Using these three forms of input, data analysis was done in order to calculate position and velocity. The video of the motion helped determine the true velocity and position of the phone. The data obtained from the phone’s sensor was then compared to the data obtained from video analysis. The video analysis was done in a program called LoggerPro. It has a feature that allows the user to open video files, analyze them frame by frame, add and modify co-ordinate axes, and even set a known distance as scale for the video. In fact, the purpose of the blue ruler in Figure 10 was to serve as a known distance for video analysis. All the videos from the experiments experience the same treatment. First a known distance is set for scale and the origin of the co- ordinate axis aligned at the initial position of the smartphone. The positive X axis is rotated
  • 18. Shrestha 18 towards the direction of the initial movement. After this process, the user can click on the phone and the program records the position of the phone with respect to the co-ordinate axes and moves onto the next frame. The user can also manually change the frame skip rate of the clicks. The new position of the phone is clicked on again and the program automatically moves to the next frame. During this process, using the user specified scale, Logger Pro automatically analyses the position change and timeframe to calculate the velocity of the body. This cycle is repeated until the phone comes to a complete stop. The velocity and position obtained from this process is treated as the true velocity and position. Figure 11. This image is a screen shot of the Video analysis process. Position is measured in both axes The data from the phone sensor is analyzed through retroactively with the help of a developed algorithm (see appendix) that calculates the velocity and the position of the object. It does so by numerically integrating the acceleration to calculate the velocity. Further numerical integration is
  • 19. Shrestha 19 done in order to obtain the position of the object. This process can be described by the following equations: 𝑣 = 𝑣0 + ∫ 𝑎 𝑑𝑡 𝑡 0 𝑥 = 𝑥0 + ∫ 𝑣 𝑑𝑡 𝑡 0 In our experiments, the carts starts at rest and thus, both the initial position (x0) and initial velocity (v0) are assumed to be zero. Therefore we use these values as our constants of integration in the previous equation. Furthermore, Boole’s rule (given below) was used as the method of numerical integration. Where, The Matlab program applies this logic process to the data obtained from the phone sensors to calculate the position change and the velocity of the object. However, as noted in the literature review, this part of the data analysis is highly prone to errors like bias and noise. The developed program corrects the data for any bias in the system and then filters the data to reduce the noise level. Currently, the program uses a low pass filter which ignores data under a certain cut off level and attenuates the data above the cut off level. In addition to a low pass filter, Kalman filter will also be implemented into simple motion types. Due to the complexity of Kalman filter, applying it into motion with higher degrees of freedom is arduous. For this research, we try to filter the acceleration data for 1D and 2D motion retroactively with a Kalman filter as well as a low pass filter to compare their effectiveness.
  • 20. Shrestha 20 However, raw acceleration measured by the accelerometer does not differentiate between translational and rotational acceleration. Raw acceleration alone cannot be used to calculate the position of the body. This is where the gyroscope plays a vital role in an inertial navigation system. The gyroscope data describes the rotation and the orientation of the phone. When this data is compared to the initial values of orientation, we can determine the rotational acceleration. The data obtained from the gyroscope in the form of roll (α), pitch (β) and yaw (γ) can be converted into a rotational matrix M. This matrix is used to transform the raw acceleration vector into a new acceleration vector that consists of only translational acceleration. This way, we use the gyroscope data to correct the accelerometer data. This full procedure is shown below. If, by, then, for any raw acceleration matrix,[ 𝑋 𝑌 𝑍 ] theAnd is denoted translational acceleration [ 𝑋′ 𝑌′ 𝑍′ ] is given by, For the rotational motion, a different method is used to calculate the position of the object. In our experiments, the radius of the rotational motion is known. If we place the axes of rotation in the center of the wheel, we can see that the phone would make sinusoidal motion.
  • 21. Shrestha 21 Thus, we can calculate the position of the phone by using the formulae of angular motion which are given by: 𝑥 = 𝑅 ∗ cos( 𝛾) , where γ = yaw 𝑦 = 𝑅 ∗ sin(𝛾) Results/ Analysis The procedures of analysis of all the motions in these research are similar. Let us use the simplest of the motion in order to demonstrate the analysis process. A small initial force is applied on the cart and the cart is allowed to come to a complete stop after some time. The data was collected by the smartphone in the form of acceleration in the x ,y ,and z directions. The first issue that we had to face is that, the raw acceleration data is riddled with errors such as bias and non-zero acceleration. Figure 12: This is the plot for the raw acceleration of the cart in 1D motion. The first initial spike is the acceleration caused the applied force. We can see that there is a definite non zero acceleration before the force was introduced. This is strange because the body
  • 22. Shrestha 22 is not moving at all. A stationary body should have zero acceleration. In order to correct for that, the data analysis program calculates the average value of the acceleration before the initial push. This offset value, often referred to as bias constant, and is removed from the raw acceleration in order to correct the data. Another source of error that can be seen from the figure above is the noise after the initial push. This noise is created from the vibrations from the ground, friction, electromagnetic waves. These errors are inherent in inertial navigation systems. The raw data is put through a low pass filter in order to remove some of these spikes. In this research, an attempt was done in order to replace the low pass filter with a more efficient Kalman filter. Due to the complexity of the filter, the Kalman filter was restricted to 1D and 2D motion. However, when programing the filter, a very important detail was realized. The Kalman filter is a recursive system consisting of a measurement update step and prediction step. The filter uses the equations of motion, known control inputs and measurements from the sensors to predict and calculate the various variables associated to the system. This way, the filter requires input from a source that is deemed to accurate. However, in our experiment, we restricted the motion of the phone into strictly translational motion while preventing any rotational motion. This induced the lack of gyroscope data as the control variable and made the filter impossible to implement for the current setups. The pre-existing low pass filter was used for this experiment instead. The low pass filter eliminated part of the noise in the acceleration data The filtered acceleration is numerically integrated to give the velocity of the body throughout the motion. The values obtained are integrated again in order to obtain the position of the body. These values are then compared to the true position of the body.
  • 23. Shrestha 23 Figure 13. This is a plot for the filtered acceleration for Figure 12. Figure 14. This is the plot for the velocity of the phone. Figure 15. This is the plot for the calculated position of the phone compared to the true position of the body that was obtained from the video analysis. The average error between the true position and the calculated position was 0.25m.
  • 24. Shrestha 24 The smartphone was able to collect the data with accuracy for the initial 10-15 seconds. However, after that, the numerical drift from the accumulation of errors forces the divergence the calculated position and the true position. Due to the process of calculation and numerical integration, any error in acceleration due to biases, noise is integrated twice and thus results in quadratic drift. While, an extended Kalman filter was recommended to combat these issues effectively, the researcher was not able to implement it in these experiments. These trends were noticed in other experiments as well. Analysis of the different motions in the experiment Figure 16. This is the plot for the 1d Complex motion and shows the body moving forward and then returning back to the initial position. The average error calculated from these experiments was 0.35m. The attached fan added errors in the form of extra vibration and magnetic interference. 1D ComplexMotion
  • 25. Shrestha 25 Figure 16: This is the plot for the motion of 2D simple motion. The cart was pushed in the x direction first and then in the y direction. However, the two forces were not concurrent and can be demonstrated by the calculated position graph in the y direction. Average error in X direction = 1.0364m Average error in Y direction = 0.1985m Figure 17. This is the plot for the motion of 2D Incline motion. At the end of the incline, the cart hit a soft wall and came to an immediate stop thus increasing negative acceleration in two directions. Average error in X direction = 0.43m. Average error in Y direction = 0.079m 2D Simple 2D incline
  • 26. Shrestha 26 Figure 19. This is the plot for horizontal rotation. Average error in X = 0.0387m and Average error in Y= 0.0411m Figure 19. This is the plot for horizontal rotation. Average error in Z = 0.0772m and Average error in Y= 0.0785m Rotation along X-Y Axis Rotation along Y-Z axis
  • 27. Shrestha 27 Discussions and Conclusion This project, although frustrating at times, provided me insight in dealing with natural physical systems, large data manage and quantitative analysis of data. Recent developments in the science has allowed the miniaturization of technology. Computers like the ENIAC, which took up entire rooms have been miniaturized to small hand held phones. In fact, the computer that put the man on the moon had lower processing capabilities than the smartphone used in this experiment. Similarly, traditional devices of measurements like accelerometer and gyroscope have been miniaturized into small microchips which are used in smartphones. The technology was initially added onto a smartphone in order to rotate the screen when the user rotates the screen from a vertical orientation to a horizontal orientation. Addition of such technology has enabled people to look into more practical application of accelerometers and gyroscopes. There were multiple sources of issues in the experiment. While some of the issues were trivial and easily solved, some persisted throughout the experiment. One of the major problems faced was the algorithm itself. Since the program was written in MATLAB by the previous researcher, the input format for the video analysis and sensor data was unknown. Furthermore, the program obtained from the project hard drive was not the actual final program provided in the senior research paper. In addition to that, the program analyzed sensor data in meters while analyzing the video data in centimeters. This information was not provided in the program itself. In order to solve this issue, the program code was analyzed line by line, edited, and updated per the requirements for this experiment. The position of the video camera was also an issue. One idea was to remove the ceiling tile in order to fully capture the motion from a vertical perspective while having the tracks on the table underneath it. The problem faced that was that the table was not sturdy and trying to use the camera before and after the experiment resulted the sensor mistaking vibrations as acceleration
  • 28. Shrestha 28 data. This also resulted in the data shifting as there was no way to check if the camera was truly vertically above the track. This issue was solved by the researcher’s ingenuity. The camera was put on top of a tripod. One leg was extended longer than the other two legs so that the camera could look vertically over the track without having its view obstructed. This setup is shown in the figure below. Figure 20. This picture shows the setup of the tripod so that the user has full access to the back side of the camera as well as be sure that the camera is vertically above the track. Furthermore, Weights were added onto the longer leg in order to balance the rotational moment of the body in order to keep the entire tripod and the camera in equilibrium. In this experiment, the gyroscope data was used to correct the raw acceleration data and filtered to remove the noise and biases. The filtered acceleration data was integrated twice in order to obtain the position of the phone. Thus any error in the data that was not filtered out was integrated twice to result in quadratic drift. As mentioned earlier in the analysis, the nature of the motions experimented upon restricted the use of a Kalman filter. This research is not without its flaws however, this allows room for further improvement. As seen in the data above, low pass filter is not the most effective way to filter out the noise in the rotated acceleration. However, when investigating 1D and 2D motion with only translational degrees of freedom, Kalman filter cannot be applied because of the lack of known control values. An improvement would be to add more control values in the experiment itself. One suggestion is to add a laser pointer and a sensor during the motion. This way, the laser sensor data can be used as a known value. Another method is to attach the phone to a motor and
  • 29. Shrestha 29 use the motor to pull on the phone with a constant voltage. This way, we can have a known control value which can be used in the measurement update step of the Kalman filter. While, the goal of the research is to have the device analyze the sensor data in real time, for future research, it is advised to attempt the filter retroactively first. The types of motions experimented on are simple. It’s imperative the data collection and analysis be accurate for both short term and long term simple motion. After the program is accurate for simple motion, it should be experimented onto more complex motions as well. In this experiment, we explored the motion of using the gyroscope measurements in two different rotational axes. However, this method of calculation cannot be used for a variable radius of rotation. Thus, further research can be done into loops, twists and turns before our INS can be applied onto real life motions. Using different new smartphones might also improve the data. Newer smartphones are equipped with the latest technology and thus have better INS microchip than the previous versions. Using only one smartphone to analyze data is not enough and as such, it is important to use smartphones from different vendors and write algorithms accordingly for them. As more research is conducted, the method of filtering the data, the precision of the sensors and the method of data collection will improve and be more sophisticated.
  • 30. Shrestha 30 Appendix of Programs RotateAcc4ipod Data Condition Shiftgryo4ipod rotmatrix4ipod CalcPosINStruct4ipod Plotgryo4ipod
  • 31. Shrestha 31 function INStruct = RotateAcc4ipod(AppOutput,vid,setshift) %Appoutput is the output from the sensor %vid is the exported loggerpro data analysis file %setshift is a userdefined number that is set by the user and is used to %shift the data. % Unload time Time_ms = AppOutput(:,1); AppOutput = AppOutput(:,2:end); UnfilteredAcc = AppOutput(:,1:3); setshift; % Delete first zeros in the beginning of data collection CondAcc = DaaCondition(AppOutput); % Shift gyroscope data so that initial value would be [0 0 0] CondAcc = ShiftGyro4ipod(CondAcc,setshift); len = length(CondAcc); IniAcc=[]; for i = 1:len Gyroindex = CondAcc(i,4:6); CurrAcc = CondAcc(i,1:3); M = rotmatrix4ipod(Gyroindex); RotAcc = M*CurrAcc'; IniAcc(i,1:3) = RotAcc'; clear Gyroindex CurrAcc M RotAcc; end % Filter raw acceleration for i=1:3 b=fir1(30,.08,'low'); IniAcc(:,i)=filter(b,1,IniAcc(:,i)); end a1=IniAcc(:,1); a2=IniAcc(:,2); a3=IniAcc(:,3); %remove the first (setshift/2) data points a1(1:floor(setshift/2))=[]; a2(1:floor(setshift/2))=[]; a3(1:floor(setshift/2))=[]; Acc(:,1)=a1; Acc(:,2)=a2; Acc(:,3)=a3; %check for and correct the bias avg1=mean(Acc(1:floor(setshift/2),1)); avg2=mean(Acc(1:floor(setshift/2),2)); avg3=mean(Acc(1:floor(setshift/2),3)); Acc(:,1)=Acc(:,1)-avg1; Acc(:,2)=Acc(:,2)-avg2; Acc(:,3)=Acc(:,3)-avg3;
  • 32. Shrestha 32 % Load data into INStruct INStruct.Time_ms = Time_ms; INStruct.InitialAcc = CondAcc(:,1:3); INStruct.InitialGyro = CondAcc(:,4:6); INStruct.RotatedAcc = Acc; INStruct.UnfilteredAcc = UnfilteredAcc; INStruct.Setshift = setshift; INStruct.Vid = vid;
  • 33. Shrestha 33 function CondAcc = DaaCondition(DataArray) %used to remove the unnecessary vibrations caused by button pressing by %removing the first 10 data points. len=size(DataArray); L=len(2); for k=1:L a=DataArray(:,k); a(1:10)=[]; CondAcc(:,k)=a; end end
  • 34. Shrestha 34 function CondAcc2 = ShiftGyro4ipod(CondAcc,setshift) %clean up data %for i=4:6 % b=fir1(30,.08,'low'); % CondAcc(:,i)=filter(b,1,CondAcc(:,i)); %end %%% data is in rad Gyroindex1 = CondAcc(:,4)*(180/pi()); Gyroindex2 = CondAcc(:,5)*(180/pi()); Gyroindex3 = CondAcc(:,6)*(180/pi()); CondAcc2 = CondAcc(:,1:3); Gyroindex(:,1)=Gyroindex1; Gyroindex(:,2)=Gyroindex2; Gyroindex(:,3)=Gyroindex3; avg1=mean(Gyroindex(1:setshift,1)); avg2=mean(Gyroindex(1:setshift,2)); avg3=mean(Gyroindex(1:setshift,3)); CondAcc2(:,4)=Gyroindex(:,1)-avg1; CondAcc2(:,5)=Gyroindex(:,2)-avg2; CondAcc2(:,6)=Gyroindex(:,3)-avg3; % Offset yaw (pitch and roll)? 180 because the data goes from -180 to 180, not 0 % to 360 CondAcc2(:,6) = CondAcc2(:,6)+180; end
  • 35. Shrestha 35 function M=rotmatrix4ipod(Gyroindex) % angles must be in degrees p=Gyroindex(:,1);%roll k=Gyroindex(:,3);%yaw w=Gyroindex(:,2);%pitch M=[cosd(p)*cosd(k), cosd(w)*sind(k)+sind(w)*sind(p)*cosd(k), sind(w)*sind(k)- cosd(w)*sind(p)*cosd(k), -cosd(p)*sind(k), cosd(w)*cosd(k)-sind(w)*sind(p)*sind(k), sind(w)*cosd(k)+cosd(w)*sind(p)*sind(k), sind(p), -sind(w)*cosd(p), cosd(w)*cosd(p)]; end
  • 36. Shrestha 36 function [avgXerror avgYerror] = CalcPosINStruct4ipod(INStruct) %download the data from the structure Acc = INStruct.UnfilteredAcc; vid = INStruct.Vid; setshift=INStruct.Setshift; % Filter acceleration for i=1:3 b=fir1(30,.08,'low'); Acc(:,i)=filter(b,1,Acc(:,i)); end g=9.79941; Acc=-Acc.*g; % Code to make time vector for data and video analysis h=1/100; t=[]; t=0:h:length(Acc(:,1))*h-h; vidx=vid(:,2); vidy=-vid(:,3); h=1/31; vidt=[]; vidt=0:h:length(vid)*h-h; h=1/100; avg1=mean(Acc(1:floor(setshift/2),1)); avg2=mean(Acc(1:floor(setshift/2),2)); avg3=mean(Acc(1:floor(setshift/2),3)); Acc(:,1)=Acc(:,1)-avg1; Acc(:,2)=Acc(:,2)-avg2; Acc(:,3)=Acc(:,3)-avg3; a1=Acc(:,1); %x dir %get velocity v1=[]; v1(1)=0; v1(2)=h*0.5*(a1(1)+a1(2)); v1(3)=h*(a1(1)+4*a1(2)+a1(3))/3; v1(4)=h*(3*a1(1)+9*a1(2)+9*a1(3)+3*a1(4))/8; for i= 5:length(a1) v1(i)=v1(i-4)+h*(14*a1(i-4)+64*a1(i-3)+24*a1(i-2)+64*a1(i- 1)+14*a1(i))/45; end %get position x1=[]; x1(1)=0; x1(2)=h*0.5*(v1(1)+v1(2)); x1(3)=h*(v1(1)+4*v1(2)+v1(3))/3;
  • 37. Shrestha 37 x1(4)=h*(3*v1(1)+9*v1(2)+9*v1(3)+3*v1(4))/8; for i= 5:length(v1) x1(i)=x1(i-4)+h*(14*v1(i-4)+64*v1(i-3)+24*v1(i-2)+64*v1(i- 1)+14*v1(i))/45; end %y dir a2=Acc(:,2); %get velocity v2=[]; v2(1)=0; v2(2)=h*0.5*(a2(1)+a2(2)); v2(3)=h*(a2(1)+4*a2(2)+a2(3))/3; v2(4)=h*(3*a2(1)+9*a2(2)+9*a2(3)+3*a2(4))/8; for i= 5:length(a2) v2(i)=v2(i-4)+h*(14*a2(i-4)+64*a2(i-3)+24*a2(i-2)+64*a2(i- 1)+14*a2(i))/45; end %get position x2=[]; x2(1)=0; x2(2)=h*0.5*(v2(1)+v2(2)); x2(3)=h*(v2(1)+4*v2(2)+v2(3))/3; x2(4)=h*(3*v2(1)+9*v2(2)+9*v2(3)+3*v2(4))/8; for i= 5:length(v2) x2(i)=x2(i-4)+h*(14*v2(i-4)+64*v2(i-3)+24*v2(i-2)+64*v2(i- 1)+14*v2(i))/45; end %z dir a3=Acc(:,3); %get velocity v3=[]; v3(1)=0; v3(2)=h*0.5*(a3(1)+a3(2)); v3(3)=h*(a3(1)+4*a3(2)+a3(3))/3; v3(4)=h*(3*a3(1)+9*a3(2)+9*a3(3)+3*a3(4))/8; for i= 5:length(a3) v3(i)=v3(i-4)+h*(14*a3(i-4)+64*a3(i-3)+24*a3(i-2)+64*a3(i- 1)+14*a3(i))/45; end %get position x3=[]; x3(1)=0; x3(2)=h*0.5*(v3(1)+v3(2)); x3(3)=h*(v3(1)+4*v3(2)+v3(3))/3; x3(4)=h*(3*v3(1)+9*v3(2)+9*v3(3)+3*v3(4))/8; for i= 5:length(v3) x3(i)=x3(i-4)+h*(14*v3(i-4)+64*v3(i-3)+24*v3(i-2)+64*v3(i- 1)+14*v3(i))/45; end figure(9); clf;
  • 38. Shrestha 38 subplot(3,1,1) plot(t,v1); xlabel('Time(s)'); ylabel('Velocity(m/s)') title('X Vel') subplot(3,1,2) plot(t,v2); xlabel('Time(s)'); ylabel('Velocity(m/s)') title('Y Vel'); subplot(3,1,3) plot(t,v3); xlabel('Time(s)'); ylabel('Velocity(m/s)') title('Z Vel'); Pos(:,1)=x1; Pos(:,2)=x2; Pos(:,3)=x3; figure(10); clf; subplot(3,1,1); plot(t,Pos(:,1),'b'); xlabel('Time(Sec)'); ylabel('Position(m)') title('X displacement'); hold on; plot(vidt,vidx,'r'); subplot(3,1,2); plot(t,Pos(:,2),'b'); xlabel('Time(Sec)'); ylabel('Position(m)') title('Y displacement'); hold on; plot(vidt,vidy,'r'); legend('Calculated','Video Analysis'); subplot(3,1,3); plot(t,Pos(:,3),'b'); xlabel('Time(Sec)'); ylabel('Position(m)') title('Z displacement'); %difference between vidx and x i=3; e=0; while (i<=length(vidx)) && (i*10/3 <= length(x1)) j = i* 10/3; e=e+abs (vidx(i) - x1(j)); i=i+3; end avgXerror = e/(i/3); %difference between vidy and y
  • 39. Shrestha 39 i=3; e=0; while (i<=length(vidy)) && (i*10/3 <= length(x2)) j = i* 10/3; e=e+abs (vidy(i) - x2(j)); i=i+3; end avgYerror = e/(i/3); % subplot(3,1,1) % plot(Pos(:,1)); % title('X-direction Pos') % % subplot(3,1,2) % plot(Pos(:,2)); % title('Y-direction Pos'); % % subplot(3,1,3) % plot(Pos(:,3)); % title('Z-direction Pos'); end
  • 40. Shrestha 40 function [avgXerror avgYerror]=Plotgyro4ipod(AppOutput,vid,r) clf; a=AppOutput; %time h=1/100; t=[]; t=0:h:length(a(:,5))*h-h; %plot raw gyro figure(1); subplot(3,1,1); plot(t,sin(a(:,5))); title('roll'); subplot(3,1,2); plot(t,a(:,6)); title('pitch'); subplot(3,1,3); plot(t,a(:,7)); title('yaw'); %calculate pos yaw=a(:,7); y=r*sin(yaw); x=r*cos(yaw); %prepare vid analysis vidx=vid(:,2); vidy=vid(:,3); h=1/30; vidt=[]; vidt=0:h:length(vid)*h-h; %compair figure(2); subplot(2,1,1); plot(t,x,'b'); title('X displacement'); hold on; plot(vidt,vidx,'r'); hold off; subplot(2,1,2); plot(t,y,'b'); title('Y displacement'); hold on; plot(vidt,vidy,'r'); hold off; legend('Calculated','Video Analysis'); %difference between vidx and x i=3; e=0; while (i<=length(vidx)) & (i*10/3<=length(x)) j=i*10/3; e=e+abs(vidx(i)-x(j)); i=i+3; end avgXerror=e/(i/3);
  • 41. Shrestha 41 %difference between vidy and y i=3; e=0; while (i<=length(vidy)) & (i*10/3<=length(y)) j=i*10/3; e=e+abs(vidy(i)-y(j)); i=i+3; end avgYerror=e/(i/3); end
  • 42. Shrestha 42 Works Cited Alberto Serra , Tiziana Dessì, Davide Carboni, Vlad Popescu , Luigi Atzori.Inertial navigation systems for user - centric indoor applications Aleksander Nawrat, Karol JÄ™drasiak, Krzysztof Daniec, & Roman Koteras. (2012). Inertial navigation systems and its practical applications. () AYENI, B. K., & SAHALU, J. B. (2013). Review of performance analysis methods for real-time embedded systems design. Computer Science & Telecommunications, 39(3), 11. Barberis, C., Andrea, B., Giovanni, M., & Paolo, M. (2014). Experiencing indoor navigation on mobile devices. IT Professional, 16(1), 50-57. doi:10.1109/MITP.2013.54 Chen, Z., Zou, H., Jiang, H., Zhu, Q., Yeng, C. S., & Xie, L. (2015). Fusion of WiFi, smartphone sensors and landmarks using the kalman filter for indoor localization. Sensors (14248220), 15(1), 715-732. doi:10.3390/s150100715 Enkhtur, M., Seong, Y. C., & Kyong-Ho Kim. (2013). Modified unscented kalman filter for a multirate INS/GPS integrated navigation system. ETRI Journal, 35(5), 943-946. doi:10.4218/etrij.13.0212.0540 Filieri, A., & Melchiotti, R. (n.d.). Position Recovery from Accelerometric Sensors Algorithms analysis and implementation issues. Gao, W., Zhang, Y., & JianguoWang. (2015). Research on initial alignment and self-calibration of rotary strapdown inertial navigation systems. Sensors (14248220), 15(2), 3154-3171. doi:10.3390/s150203154 Groves, P. D. (2008). Principles of GNSS, inertial, and multi-sensor integrated navigation systems. Boston: Artech House. Hwang, S., & Yu, D. (2012). GPS localization improvement of smartphones using built-in sensors. International Journal of Smart Home, 6(3), 1-8.
  • 43. Shrestha 43 Kai-Wei Chiang, Thanh, T. D., & Jhen-Kai Liao. (2013). The performance analysis of a real-time integrated INS/GPS vehicle navigation system with abnormal GPS measurement elimination. Sensors (14248220), 13(8), 10599-10622. doi:10.3390/s130810599 Kavanagh, R. M. (2007). Gyroscopes for orientation and inertial navigation systems. Cartography & Geoinformation, 6, 254-270. Park, K., Shin, H., & Cha, H. (2013). Smartphone-based pedestrian tracking in indoor corridor environments. Personal & Ubiquitous Computing, 17(2), 359-370. doi:10.1007/s00779-011- 0499-5 Pendrill, A., & Rohl, J. (2011). Acceleration and rotation in a pendulum ride, measured using an iPhone 4, 676. Renaudin, V., Susi, M., & Lachapelle, G. (2012). Step length estimation using handheld inertial sensors. Sensors (14248220), 12(7), 8507-8525. doi:10.3390/s120708507 Riaz, S. (2011). Mathematical modeling of INS/GPS based navigation system using discrete time extended kalman filter schemes for flapping micro air vehicle. International Journal of Micro Air Vehicles, 3(1), 25-33. Saeedi, S., Moussa, A., & El-Sheimy, N. (2014). Context-aware personal navigation using embedded sensor fusion in smartphones. Sensors (14248220), 14(4), 5742-5767. doi:10.3390/s140405742 Sang, K. P., & Young, S. S. (2010). A zero velocity detection algorithm using inertial sensors for pedestrian navigation systems. Sensors (14248220), 10(10), 9163-9178. doi:10.3390/s101009163 Savage, P. G. (1998). Strapdown inertial navigation integration algorithm design part 1: Attitude algorithms. Journal of Guidance, Control, and Dynamics, 21(1), 19-28. doi:10.2514/2.4228