60
Shrestha 1 Smartphon e Inertial

Smartphone Inertial Navigation

Embed Size (px)

Citation preview

Page 1: Smartphone Inertial Navigation

Shrestha 1

Smartphone

Inertial

Navigation

-Pujan Shrestha

Page 2: Smartphone Inertial Navigation

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

Page 3: Smartphone Inertial Navigation

Shrestha 3

Page 4: Smartphone Inertial Navigation

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.

Page 5: Smartphone Inertial Navigation

Shrestha 5

Figure 1: Rotation around the axes which are called Pitch, Roll, and Yaw respectively.

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

Page 6: Smartphone Inertial Navigation

Shrestha 6

smartphones that uses the phone as an inertial navigation system for simple and complex 3d

motion.

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).

Page 7: Smartphone Inertial Navigation

Shrestha 7

Figure 2: Loosely coupled scheme (left) and tightly coupled Scheme (Right)

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

Page 8: Smartphone Inertial Navigation

Shrestha 8

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

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

Page 9: Smartphone Inertial Navigation

Shrestha 9

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

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).

Page 10: Smartphone Inertial Navigation

Shrestha 10

Figure 5: The figure demonstrates the probability of change of state during walking motion.

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

Page 11: Smartphone Inertial Navigation

Shrestha 11

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.

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.

Page 12: Smartphone Inertial Navigation

Shrestha 12

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

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

Page 13: Smartphone Inertial Navigation

Shrestha 13

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.

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.

Page 14: Smartphone Inertial Navigation

Shrestha 14

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

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.

Page 15: Smartphone Inertial Navigation

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.

Page 16: Smartphone Inertial Navigation

Shrestha 16

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

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

Page 17: Smartphone Inertial Navigation

Shrestha 17

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.

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.

Page 18: Smartphone Inertial Navigation

Shrestha 18

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

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.

Page 19: Smartphone Inertial Navigation

Shrestha 19

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

done in order to obtain the position of the object. This process can be described by the following

equations:

v=v0+∫0

t

a dt

x=x0+∫0

t

v dt

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

Page 20: Smartphone Inertial Navigation

Shrestha 20

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.

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,

Page 21: Smartphone Inertial Navigation

Shrestha 21

And is denoted by, then, for any raw acceleration matrix,[XYZ ] the translational acceleration [X '

Y 'Z ' ]

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.

Thus, we can calculate the position of the phone by using the formulae of angular motion which

are given by:

x=R∗cos ( γ ) , where γ = yaw

y=R∗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

Page 22: Smartphone Inertial Navigation

Shrestha 22

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

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

Page 23: Smartphone Inertial Navigation

Shrestha 23

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.

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.

Page 24: Smartphone Inertial Navigation

Shrestha 24

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.

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

Page 25: Smartphone Inertial Navigation

Shrestha 25

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 Complex Motion

2D Simple

Page 26: Smartphone Inertial Navigation

Shrestha 26

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

Figure 19. This is the plot for horizontal rotation. Average error in X = 0.0387m and

Average error in Y= 0.0411m

2D incline

Rotation along X-Y Axis

Page 27: Smartphone Inertial Navigation

Shrestha 27

Figure 19. This is the plot for horizontal rotation. Average error in Z = 0.0772m and

Average error in Y= 0.0785m

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.

Rotation along Y-Z axis

Page 28: Smartphone Inertial Navigation

Shrestha 28

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

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.

Page 29: Smartphone Inertial Navigation

Shrestha 29

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

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.

Page 30: Smartphone Inertial Navigation

Shrestha 30

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.

Appendix of Programs

RotateAcc4ipod

Data Condition

Shiftgryo4ipod

rotmatrix4ipod

CalcPosINStruct4ipod

Plotgryo4ipod

Page 31: Smartphone Inertial Navigation

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 timeTime_ms = AppOutput(:,1);AppOutput = AppOutput(:,2:end);UnfilteredAcc = AppOutput(:,1:3);setshift; % Delete first zeros in the beginning of data collectionCondAcc = 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';

Page 32: Smartphone Inertial Navigation

Shrestha 32

IniAcc(i,1:3) = RotAcc'; clear Gyroindex CurrAcc M RotAcc;end % Filter raw accelerationfor i=1:3 b=fir1(30,.08,'low'); IniAcc(:,i)=filter(b,1,IniAcc(:,i));enda1=IniAcc(:,1);a2=IniAcc(:,2);a3=IniAcc(:,3); %remove the first (setshift/2) data pointsa1(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; % Load data into INStructINStruct.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;

Page 33: Smartphone Inertial Navigation

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;endend

Page 34: Smartphone Inertial Navigation

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 radGyroindex1 = 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;

Page 35: Smartphone Inertial Navigation

Shrestha 35

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 360CondAcc2(:,6) = CondAcc2(:,6)+180;end

function M=rotmatrix4ipod(Gyroindex)% angles must be in degreesp=Gyroindex(:,1);%rollk=Gyroindex(:,3);%yaww=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

Page 36: Smartphone Inertial Navigation

Shrestha 36

function [avgXerror avgYerror] = CalcPosINStruct4ipod(INStruct) %download the data from the structureAcc = INStruct.UnfilteredAcc;vid = INStruct.Vid;setshift=INStruct.Setshift; % Filter accelerationfor i=1:3b=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 analysish=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;

Page 37: Smartphone Inertial Navigation

Shrestha 37

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 velocityv1=[];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 positionx1=[];x1(1)=0;x1(2)=h*0.5*(v1(1)+v1(2));x1(3)=h*(v1(1)+4*v1(2)+v1(3))/3;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 dira2=Acc(:,2); %get velocityv2=[];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 positionx2=[];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)

Page 38: Smartphone Inertial Navigation

Shrestha 38

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 dira3=Acc(:,3); %get velocityv3=[];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 positionx3=[];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;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;

Page 39: Smartphone Inertial Navigation

Shrestha 39

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 xi=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;endavgXerror = e/(i/3); %difference between vidy and yi=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;endavgYerror = 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

Page 40: Smartphone Inertial Navigation

Shrestha 40

function [avgXerror avgYerror]=Plotgyro4ipod(AppOutput,vid,r)clf;a=AppOutput;%timeh=1/100;t=[];t=0:h:length(a(:,5))*h-h; %plot raw gyrofigure(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 posyaw=a(:,7);y=r*sin(yaw);x=r*cos(yaw); %prepare vid analysisvidx=vid(:,2);vidy=vid(:,3);h=1/30;vidt=[];vidt=0:h:length(vid)*h-h;

Page 41: Smartphone Inertial Navigation

Shrestha 41

%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 xi=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;endavgXerror=e/(i/3); %difference between vidy and yi=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;endavgYerror=e/(i/3); end

Page 42: Smartphone Inertial Navigation

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

Page 43: Smartphone Inertial Navigation

Shrestha 43

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.

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

Page 44: Smartphone Inertial Navigation

Shrestha 44

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