You are on page 1of 21

A Better Dead-Reckoning System

Spencer Fishman Derek Huang


spencer@hurricanedevelopment.com 17huangd@millburn.org
Brian Jimenez Emily Liu
brianjimenez869@gmail.com emliu@ctemc.org
Sudharshan Venkatesh
venkatesh.sudharshan@gmail.com
22 July 2016
The New Jersey Governors School of Engineering and Technology

Abstract 1 Introduction
Dead-reckoning is a self-contained method of In navigation, external aids are not always avail-
navigation that uses on-board sensors such as ro- able. In such cases, dead-reckoning offers a so-
tary encoders, accelerometers, and gyroscopes to lution. Dead-reckoning is the determination of
estimate the position of a system. However, dead- ones relative position using only system sensors;
reckoning traditionally does not take into account a pure dead-reckoning system does not use out-of-
errors that accumulate in measurements, and dead- system assistants such as GPS or celestial bearings
reckoning calculations can become extremely inac- [1]. Dead-reckoning as a navigation component can
curate very quickly. The problem is compounded be used to approximate the location of a vehicle,
when on-board system sensors are noisy, as the whether air, land, or sea. This type of system is
noise makes it difficult to determine the true state useful when there are no external sources to pro-
of the system, and when the systems propulsion is vide positional data, such as when there is no GPS
inaccurate, where large drift results even when the signal or when the clouds are obscuring the stars.
system should be traveling in a straight line. Today, dead-reckoning is most often accom-
Through experimentation with a robot con- plished through a mechanical or computerized sys-
structed with inexpensive materials, the implemen- tem, with positional data estimated using values
tation of a proportional-integral-derivative (PID) read from sensors such as gyroscopes, accelerome-
controller and various sensor data filters rectify ters, or rotary encoders. Most dead-reckoning sys-
hardware deficiencies enough to confirm the via- tems today include a full inertial navigation sys-
bility of dead-reckoning as a method of navigation. tem, which combines gyroscopes and accelerome-
Filtering methods such as the Kalman filter and ters with a guidance computer, possibly even with
the particle filter serve to significantly decrease the electronic or optical sensing units [4]. Through the
noise level in sensor readings and deliver more con- use of a dead-reckoning system achievable on a com-
sistent sensor readings to the PID control loop, pact robot with gyroscope, accelerometer, and ro-
which mostly eliminates drift and error during the tary encoders, the robot gains access to an accurate
robots movement. mobility system without relying on GPS.
Even with relatively inexpensive and inaccurate Before the advent of GPS, dead-reckoning, short
hardware, it is clear that a well-implemented dead- for deduced-reckoning, was primarily used in
reckoning system will still function at an acceptable nautical navigation. It was helpful in determin-
level of precision. For those unable to use GPS ing sunrise and sunset, predicting landfall, and con-
or celestial cues for navigation, dead-reckoning can ducive to predicting the future path of the ship and
provide an inexpensive, relatively accurate, and re- avoiding hazardous obstacles and otherwise danger-
liable alternative. ous areas.
Current examples of dead-reckoning systems in
use are found in older GPS units, which are still

1
able to reliably navigate for a few miles using an
on-board gyroscope when no GPS signal is avail-
able, and in inertial navigation units themselves,
which are inherently capable of dead-reckoning and
are used in general aviation, guided munitions, and
commercial and military navigation. The greatest
advantage and disadvantage that a dead-reckoning
system has over a guidance system relying on ex-
ternal positional data is that it is completely self-
contained, which makes it a viable method for de- Figure 1: A diagram of a PID loop illustrating con-
termining position in conditions where GPS or ce- trol flow [10]
lestial cues are unavailable but also makes it liable
to additional, cumulative error. However, because tion to how far off course the ship currently is. The
the process of dead-reckoning estimates ones posi- further off course the ship is, the more a helmsman
tion through the extrapolation of prior knowledge will turn the wheel, and vice versa.
and sensor data, the dead-reckoning position may However, proportional control is not always
only approximate the true position [6]. Further, enough to combat a accumulating error, known as
the estimated position becomes increasingly inac- integral error. A nautical example of such error
curate as errors, both from sensor input and calcu- would be long-term drift that occurs as a helmsman
lations, accumulate. Fortunately, some algorithms is attempting to steer back on course. Even as the
have been developed for the purpose of minimizing helmsman is steering the wheel proportionally with
this error, some of which have proved practical and regards to how far off course the ship currently is,
accurate for navigation purposes. integral error in the form of long-term drift, such as
Thus, with a reliable dead-reckoning system, a persisting lateral current, will still throw the ship
applications for which relative position is needed far off course. Therefore, the integral (I) control in
but access to GPS and celestial cues are unavailable a PID controller will adjust how the controller is
or unattainable become possible [5]. This enables settling, limiting large inaccuracies resulting from
further integration and the advancement of modern the development of cumulative error.
day technologies in non-optimal conditions. The last control that the PID controller imple-
ments is derivative (D) control, which takes into
account the rate of change in error. Again using
2 Background a nautical example, the error that results as the
ship travels along may increase or decrease in mag-
2.1 PID nitude, and by determining the rate of change of
2.1.1 PID Control the error, it is possible to approximately predict
the future error behavior of the ship and use this
One method to control output error is the three- knowledge to potentially improve the stability of
term PID (proportional-integral-derivative) con- the ships path. However, since an idealized deriva-
troller, a control feedback loop first designed in tive is not causal, i.e. independent of past and cur-
1911 by Elmer Sperry, on which Nicholas Minorsky rent inputs and therefore impossible to discretize,
would publish a theoretical analysis on in 1922 PID controllers often have a low-pass filter for the
based upon his observations of a helmsmans ac- derivative term, which limits higher frequency gain
tions when steering a ship [7]. As illustrated in and noise [8].
Figure 1, the three controls that the PID controller With u(t) defined as controller output, equiva-
takes into account are in its name: proportional, lent to the manipulated variable M V (t), the PID
integral, and derivative control. control algorithm is:
Proportional control is the most straightforward
to understand; again using a nautical example, pro- Z t
portional (P) control entails adjusting the ships de(t)
u(t) = Kp e(t) + Ki e( )d + Kd (1)
steering back towards the desired course in propor- 0 dt

2
Here Kp is the proportional gain of the con- ror over the duration that the controller has been
troller, Ki is the integral gain, and Kd is the deriva- active, the integral term delivers correction for ac-
tive gain, with all three gains being constants that cumulated errors that should have been corrected
must be tuned in order to generate the desired con- at previous times. Like the proportional term Pout ,
trol response. e(t) is a continuous function repre- the value of Iout is adjusted by a gain constant, in
senting process error, and can be calculated dis- this case Ki , the integral gain constant.
cretely by subtracting a measured process variable Here the integral term in (2) is represented as:
output, P V (t), from an ideal output value SP , or Z t
set point, so that et = SP P Vt . The variable Iout = Ki e( )d (4)
of integration is , which takes on time variables 0
from 0 to a current instantaneous time t, and the The integral term decreases the time for the
expression de(t)
dt
is the instantaneous current rate of desired set point SP to be reached and seeks to
change of the error e(t). counter the effects of cumulative error that result
The informal representation of the equation is: from the use of a proportional, or P controller.
However, because the integral term attempts to cor-
u(t) = Pout + Iout + Dout (2) rect past accumulated errors, it can also result in
This form clearly demonstrates the controller the controller delivering output that overshoots the
output as the sum of the proportional term Pout , desired set point SP . If the integral gain Ki is set
the integral term Iout , and the derivative term Dout . too high, the effect of the integral term will also
The proportional term, as explained earlier, lead to the oscillation of the controllers output,
produces an output proportional to the current er- increasing in severity until the controllers output
ror e(t), with the magnitude of the output and oscillates between its maximum and minimum val-
therefore the sensitivity of the response adjusted ues. This behavior effectively turns the PID con-
by the proportional gain constant, Kp . troller into a bang-bang, or hysteresis controller,
Reconciling the two representations of the PID which quickly switches back and forth between two
equation, the proportional term in (2) is illustrated extreme and opposite outputs.
as: The derivative term is based on errors rate of
change and is a preemptive form of control that
Pout = Kp e(t) (3) seeks to predict the next state of the system. Deter-
mined by the instantaneous slope of the error over
Therefore, the higher the proportional gain Kp , time, the process error derivative is then multiplied
the greater the change in the controllers output for by a gain constant, the derivative gain constant Kd ,
a given error, and the more responsive or sensitive to adjust the value of the derivative term Dout and
the controller will be. However, if the proportional its effect on the overall output of the controller u(t).
gain is too high, such that the controller consis- The derivative term in (2) is represented as:
tently overshoots the desired set point SP , the sys-
tem may become unstable, as the controllers out- de(t)
Dout = Kd (5)
put will consistently oscillate above and below the dt
set point. By predicting system behavior based on the cur-
Conversely, lowering the proportional gain will rent rate of change of the error, derivative action
decrease the controllers output and responsiveness is able to improve the stability of the system and
for a given error. However, if the gain is too low, decrease the time spent before reaching stability.
the controllers response to disturbances will be too However, if the derivative gain Kd is set too high,
small to be effective, and the system will accrue the controllers output will exhibit oscillatory be-
error. havior, reducing the stability of the system.
The integral terms value, in contrast to the
value of the proportional term, depends not just 2.1.2 PID Tuning
on how large the present error e(t) is but also on
the duration of the current error and previous er- In order for the PID controller to function op-
rors. A sum of the accumulated instantaneous er- timally, it must be tuned, which involves adjusting

3
the values of Kp , Ki , and Kd . These values vary involves setting all the constants to zero, then in-
based on the specifics of each system, and if input creasing Kp in small increments until the output os-
values are scaled up or down due to programming in cillates about the set point. Then Kd is increased in
a new library, the constants have to be scaled up or small increments until this oscillation stops. These
down accordingly. Manual tuning is generally very two steps are repeated until Kp reaches a gain so
slow and tedious, and without simulation software high that no value of Kd will stop the oscillation.
such as PIDEasy to model PID controller behav- Once this happens, Ki is increased until steady-
iors, manual tuning becomes completely empirical state error is as small as possible and the loops
and an arduous and imprecise chore. runs smoothly [12].
However, there is a well known method of tuning
that uses the Ziegler-Nichols method, which uses Closed- Rise Overshoot Settling Steady- Stability
Loop Time Time State
two parameters based on measurements. Following Response Error
this method, the integral and derivative gains Ki Increasing Decrease Increase Small Decrease Degrade
Kp Increase
and Kd are both set to zero, with the proportional Increasing Small Increase Increase Large Degrade
gain Kd being increased until it reaches the ultimate Ki Decrease
Increasing Small Decrease Decrease Minor Improve
gain Ku , where the output of the controller begins Kd Decrease Change
to oscillate in a stable and consistent manner. The
period of oscillation, Tu , is then used to set the
integral and derivative gains depending on the type Figure 3: Effects of independently increasing each
of controller that is being implemented. gain [8]
Figure 2.1.2 is a table displaying several meth-
ods of PID tuning following the Ziegler-Nichols
method or other methods to produce specialized 2.1.3 Limitations of PID Control
controller behaviors. Despite the versatility of the PID algorithm in
Rule Name Kp Ki Kd its application to many control problems, as well as
Classic Ziegler-Nichols 0.6 Ku 0.5 Tu 0.125 Tu its ability to work decently even with very rough
Pessen Integral Rule 0.7 Ku 0.4 Tu 0.15 Tu tuning, PID control can sometimes exhibit poor
Some Overshoot 0.33 Ku 0.5 Tu 0.33 Tu performance, and it is never perfect. Of course,
No Overshoot 0.2 Ku 0.5 Tu 0.33 Tu due to the nature of the controller as a feedback
loop with constant gain parameters, the PID con-
Figure 2: Parameters from Ziegler-Nichols Rule [9] troller knows nothing about real-time occurrences
in the physical system. Therefore, control is always
reactive, and some level of compromise is inherent.
The Ziegler-Nichols method is designed to give
As touched on before, one of the main difficul-
PID controllers the best disturbance rejection and
ties regarding a PID controller is its tendency to
produces a controller with an aggressive gain and
overshoot or oscillate around its set point value,
overshoot [9]. However, in some instances, it is
especially when the gains are too high. For exam-
more desirable to minimize or eliminate overshoot,
ple, such behavior can be found in amateur line-
and for these specialized scenarios, the Ziegler-
following robots that implement imperfectly and
Nichols method is not desirable.
manually tuned PID control algorithms. These
There are variations from the original Ziegler-
robots will constantly swing back and forth over
Nichols proportions, as some yield a smoother tran-
the edge of the line they are following as their con-
sition, while others provide better optimal distur-
trol algorithms constantly overshoots the set point
bance rejection. The different rules and their re-
of the light sensor value. The output to the mo-
spective proportions shown in Figure 2.1.2 reflect
tors exhibits an oscillatory pattern, as each over-
this tunable range [9] .
shooting of the set point is corrected with another
However, PID constants can also be manually
overshooting of the set point, in the reverse direc-
tuned. Ziegler-Nichols or other rules are not al-
tion. Such behavior is very similar to the actions
ways practical to use in all cases, and in some cases
of a line-following robot programmed with a much
manual tuning is the better option. Manual tuning

4
simpler hysteresis control algorithm and provides Nonlinear Asymmetric System Response
suboptimal performance. 40
Another issue with PID controllers is a result
their linear and symmetric nature, i.e. the fact that
20

System Response
they exhibit the same control behavior whether the
process variable input P V (t) is above or below a set
point SP . In other words, given some magnitude 0
k of an error et for a discrete system at a current
time t, a PID algorithm will provide an equivalent
20
proportional change in output magnitude regard-
less of whether P Vt = SP + et or P Vt = SP et ,
as presented in the Figure 4. 40
20 10 0 10 20
Linear Symmetric System Response Controller Output

Figure 5: System responds more if positive control


is applied, but responds much less to negative con-
10
System Response

trol

0 In this scenario, a control system implementing


PID would not be a good choice. PID control would
likely overshoot the set point water level due to the
10 fast flow of water into the system, while being slow
the correct the overshoot; as the flow of water is
slower out of the system, the PID control would
40 20 0 20 40 cause a significantly slower negative response by the
Controller Output water storage system. Thus, using PID control in
this situation would cause the storage to have a
Figure 4: System responds in the same way, regard- higher water level than is desired most of the time.
less of state Though it is possible to tune a PID con-
trol scheme for an asymmetric system by severely
When applied to a system with asymmetric re- damping its output in order to reduce or even pre-
sponse, where the response of a system to an ap- vent overshoot, doing so would severely affect the
plied control may be different depending on the di- performance of the control loop. Such a damped
rection that the controller is correcting, a standard PID controller would cause a sluggish reaction and
PID controller will generate a large cumulative er- be extremely slow in dealing with even moderate
ror as it attempts to apply symmetric control to error introduced into the system.
a system that responds asymmetrically. An exam-
ple of such an asymmetric system would be a water 2.2 Noise and Filtering
storage system that can be filled very quickly but
can only drain very slowly. The response graph of 2.2.1 Signal Noise
the tank to a control algorithm that manages the
As touched on earlier, a dead-reckoning sys-
flow of water in and out of the storage system to
tem requires data input from on-board sensors that
maintain a consistent water level inside the system
can deliver the required initial data to the system
would be similar to the graph in Figure 5 illustrat-
and then calculate an approximate estimated posi-
ing nonlinear asymmetric system response, where
tion, EP . In an ideal world, a sensor of any kind,
positive control elicits a steep response from the
whether an accelerometer, gyroscope, light sensor,
system as water can flow in quickly, but negative
or radar receiver, should read exactly the value that
control elicits a slow response as the system drains
should be currently measured by the sensor. In
water quite slowly.

5
other words, if a free body is accelerating at 0.5 filter is most commonly used as part of the control
m/s2 in the x direction only, an ideal accelerometer of dynamic and complex systems, such as aircraft,
would read only that value exactly for any time t ships, and continuous manufacturing processes [13].
that the free body is accelerating in such a manner. In order to apply control to one of these complex
Unfortunately, this is never true in practice. No systems, it is imperative to first understand the sys-
matter how accurate a sensor is purported to be, tem status, which is usually accomplished by read-
there are always factors that will cause measure- ing data in from sensors embedded in the system.
ment inaccuracies. Sometimes it is a fault in the Again, there is always persistent noise from the
sensor itself, but often times, signal variation from measured data, and the Kalman filter provides a
the sensor is often due to electronic noise such as method for inferring the required data from noisy
Johnson-Nyquist and shot noise, small variations measurements. By using a systems state transition
in the sensors measurement of an experimental model, known control input to the system, and an
value, and other natural sources of noise. Johnson- iterative measurement process of data (typically re-
Nyquist noise is unavoidable, caused by random ceived from various sensors), the Kalman filter can
thermal motion of charge carriers, typically elec- then form an estimate of the systems state that
trons, in an electrical conductor; shot noise is sim- is far more accurate than by estimating off of any
ilar, arising from the quantized nature of electron single measurement at some time t in the system.
flow. These two types of electrical noise affect sig- The mathematical model of the Kalman filter
nal frequencies on a wide band, and along with assumes a multidimensional model of the filter,
other sources of noise such as small vibrations, give which is shown below:
unwanted variations in sensor readings [11].
For a full PID controller, signal noise is highly xk = Fk xk1 + Bk uk + wk (6)
undesirable, as it causes the system to exhibit os- In the equation above, the term xk is the pre-
cillatory and jerky behavior. This behavior stems dicted true state of the system, and is the output
from the derivative term in a full PID; when there of the filter. The term Fk is the state transition
is significant signal noise and constant variations model of the system, which models the changes be-
in the rate of change of error, the derivative term tween each xk term and for a current term xk is
Dout will amplify the effects of the signal noise and multiplied by xk1 . Bk is a known control-input
cause large fluctuations in the controller output. model which is multiplied by the control vector uk ,
This unwanted amplification of signal noise by the which represents the control input into the system
derivative term can be attenuated by using a low- at the current time tk . wk is the process noise at
pass filter to reduce noise at higher frequencies, the time tk that has been introduced into the sys-
which create the greatest fluctuations in output, tem. In this generalized model of the Kalman filter,
but low-pass filtering can cancel out derivative con- wk is assumed to be part of a multivariate Gaus-
trol, effectively turning a PID controller into a PI sian, or normal, distribution with a zero mean and
controller [8]. Additionally, since sensor values are a covariance of Qk , and would be represented as
being read across a wide range, filters with cutoff such:
frequencies, like the high- and low-pass filters, may
not be suitable for use. wk N (0, Qk ) (7)
At the same time tk , an observation zk made is
2.2.2 Kalman Filtering
modeled in the form below:
The approach is to reduce overall sensor out-
put noise in real time and try to estimate close zk = Hk xk + vk (8)
to the true value that is being measured. One In the observation model, the term Hk is the
such method of reducing overall sensor noise is to observation model of the system which relates the
implement Kalman filtering, also known as linear true state of the system xk , with an added obser-
quadratic estimation, a recursive algorithm that vation noise vk , which like the process noise wk is
produces successive estimates of the true measured also a zero mean multivariate Gaussian distribution
value of a system corrupted by white noise [13]. The with a covariance of Rk , represented as such:

6
all measurements.
vk N (0, Rk ) (9) Following the established model, the theoret-
ical implementation of the Kalman filter can be
An important point to keep in mind is that all
generalized into two major steps, a predict step
noise vectors, including wk and vk , are assumed
and an update step. Mathematically, the steps are
to be mutually independent, i.e. none of the noise
represented below, with notation xn|m representing
values influences the value of any other noise in the
the estimation of x at a time n with observations
Kalman model. Equally important is the simple
up to and including time m, where m n:
fact that most dynamic systems in real life will not
exactly fit the theoretical Kalman model of the lin-
P redict
ear dynamic system.
In its essence, the Kalman filter creates an av-
xk|k1 = Fk xk1|k1 + Bk uk (10)
erage prediction of the particular state of a system
by reporting a weighted average of each new mea-
surement with the previous state values. Weighting Pk|k1 = Fk Pk1|k1 FT
k + Qk (11)
allows values to have more or less influence on the U pdate
filters final output, depending on their estimated
uncertainty. In other words, values that are esti- yk = zk Hk xk|k1 (12)
mated to be less uncertain carry more weight, and
the converse is also true. The weighting is deter-
mined from the calculation of covariance, a measure Sk = Hk Pk|k1 HT
k + Rk (13)
of how much two random variables change together;
the resulting weighted average is a new state esti- Kk = Pk|k1 HT 1
k Sk (14)
mate in between the predicted and measured state,
and it is therefore less uncertain than any state re-
ported from either value alone. This process is then xk|k = xk|k1 + Kk yk (15)
iterated for each discrete time interval, with each
new estimate and covariance influencing the next Pk|k = (I Kk Hk )Pk|k1 (16)
iteration, with the filters output arriving closer and
Here the term xk|k1 represents the current pre-
closer to the true measured value. An extra benefit
dicted state of the system xk given all previous ob-
of this iterative process is that the Kalman filter
servations up to and including time k 1, a product
only requires the last set of data from the previous
of the state transitional model Fk and the previous
iteration, and therefore can be implemented recur-
predicted value xk1|k1 given all previous observa-
sively.
tions up to and including time k 1 plus the prod-
However, the Kalman filters behavior is not
uct of the control input model Bk and the control
monolithic in its every implementation. The Kal-
vector uk . The current predicted covariance Pk|k1
man gain, which is calculated in every iteration of
given all previous observations up to and including
the filtering process and is therefore not constant,
time k 1 is the product of the systems state tran-
is a product of the current state estimate and the
sition model Fk and the previous predicted covari-
relative certainty of the current measurements and
ance Pk1|k1 multiplied by the transposed state
can therefore be tuned to change the behavior of
transition model Fk , added to the process noise co-
the Kalman filter. The higher the gain, the closer
variance Qk .
the filter adheres to the measurement data, while
The term yk is innovation, the difference be-
the lower the gain, the more the filter follows the
tween the observation zk and the product of the
systems state transition model. Using a lower gain
observation model Hk and the current predicted
allows the filter to reduce noise, but it also reduces
state of the system xk|k1 , given all previous obser-
how responsive the filter is when measurements be-
vations up to and including time k 1. In other
gin to change overall. A maximum gain of one
words, yk is the error between the observed state of
makes the filter ignore the state transition model,
the system and the past predicted state of the sys-
while a minimum gain of 0 makes the filter ignore
tem. The term Sk is the innovation covariance, the

7
product of the observation model Hk , the predicted network, in our case robot localization [15]. A
covariance Pk|k1 given all previous observations up Bayesian network is a graphical model of joint mul-
to and including time k 1, and the transposed tivariate probability distributions, which are char-
observational model HT k , added to the observation acterized by N random variables that are condi-
noise covariance Rk . Kk is the Kalman gain, the tionally codependent [16]. The principle behind the
product of the predicted covariance Pk|k1 given particle filter is to use a complex model to get an
all previous observations up to and including time approximate solution [15].
k 1, the transposed observation model HT k , and The robots state s is its position in the x- and
the inverse of the innovation covariance Sk , S1 k . y- directions and its angle . This can be depicted
xk|k is the updated predicted state of the system as s = (x, y, ). The particle filter is represented
given all observations up to and including the cur- by a probability density function of a set of sam-
rent time k, and is the sum of the predicted state ples for possible values of each of the variables of
of the system xk|k1 given all previous observations the state. Each sample value set is considered a
up to and including time k 1 and the product of particle, from which the filter gets its name. The
the calculated Kalman gain Kk and the innovation more particles with the same set of values, the more
yk . Finally, the term Pk|k is the updated predicted likely that this set of values is the robots current
covariance and is the difference between the iden- state [15].
tity matrix I and the product of the Kalman gain The filter improves and narrows down the possi-
Kk and the observation model Hk multiplied by ble states of the robot by taking multiple posterior
the predicted covariance Pk|k1 given all previous samples. Posterior probability is the probability of
observations up to and including time k 1. an event A occurring given that event B has already
This generalized version of the Kalman filter as- occurred, or P (A | B) [17]. This is calculated by
sumes a multidimensional application of the filter Bayes Theorem [18]:
with vectors represented as matrices. The predic-
tion steps in the filtering process calculate a new P (B | A) P (A)
P (A | B) = (17)
estimated state of the system xk|k1 and a new pre- P (B)
dicted covariance Pk|k1 each iteration using val- Samples are taken, and based on the obser-
ues calculated from the previous iteration, taking vations they are each assigned an importance
into account noise and control input into the sys- weight, which factors into the probability of each
tem as well as its state model Fk . Then, the up- respective particle. The total number of particles
date steps use xk|k1 and Pk|k1 calculated in the remains the same, so the particles are redistributed
prediction steps to find the innovation yk and the in the sample space based on their weights. Higher
innovation covariance Sl in order to calculate the weighted particles are densely clustered together,
Kalman gain Kk for the current iteration. Follow- which is statistically where the real state is more
ing, xk|k1 , Pk|k1 , yk , Kk , and the observational likely to be [15].
model of the system Hk are used to update the es- The algorithm starts with the initial belief state,
timated state of the system to xk|k and calculate a P (s0 ), which is the initial guess of the probability
new predicted covariance Pk|k . function. Typically, the position of the robot is
initially unknown so the particles are evenly scat-
2.2.3 The Particle Filter tered throughout the possible state space. To nar-
row down the location, the algorithm loops through
However, despite how straightforward the Kal- three steps: resample, update, and prediction [15].
man filter theoretically is to implement in discrete The belief state P (st | d0...t ) is calculated by
time, actual implementation runs into tricky math- evaluating
ematical complications involving multiple calcula-
tions of covariance and state matrices, which is very Z
tedious. There is, however, an alternative to the P (zt | st ) P (xt | ut1 , st1 )P (st1 | d0...t1 )dxt1
Kalman filter: the particle filter.
The particle filter is a tool for tracking the P (st | d0...t ) is the resample part of the loop,
state of a dynamic system modeled by a Bayesian which is our belief on the variables of the state.

8
Here a new sample of particles is chosen to repre-
sent the weight of each. P (zt | st ) is the update,
which assigns importance weights to the particles
based on the sample. This is multiplied by the
normalization constant , which ensures that all
the weighted
R particles add up to 1 [19]. The pre-
diction is P (xt | ut1 , st1 )P (st1 | d0...t1 )dxt1 ,
which takes each particle and adds a random sam-
ple to result in a new distribution of particles [15]. Figure 9: LCD and motor shield mounted on UNO

Wired into the breadboard as well are a pair


3 Procedure of VEX 2-wire 393 motors, a pair of VEX opti-
cal shaft encoders, and a Kootek GY-521 breakout
3.1 Starting Tools and Materials board containing an InvenSense MPU-6050 six-axis
combined accelerometer/gyroscope MEM. Power is
The basic robot provided is a skid-steer provided by a mounted KMASHI 10000 mAh exter-
drive controlled by an Arduino-compatible SainS- nal battery pack. The robots wheels and frame are
mart UNO R3 microcontroller, with an attached composed of standard VEX parts, and the robots
Adafruit v2.3 motor shield and Adafruit LCD overall dimensions are approximately 25 cm (w) by
shield. 20.5 cm (l) by 17.5 cm (h).

Figure 6: SainSmart UNO R3


Figure 10: VEX 2-wire 393 motors

Figure 7: Adafruit v2.3 motor shield Figure 11: VEX optical shaft encoders

Figure 12: Kootek GY-521; contains embedded


Figure 8: Adafruit LCD shield MPU-6050

9
many excellent and viable methods of control, but
the team settled on using PID, a widely used con-
trol algorithm generally held in high regard.
The approach was to write a PID controller to
adjust the power output of the two motors based
on the readings taken from both the quadrature
encoders and the MPU-6050 accelerometer and gy-
Figure 13: KMASHI 10000 mAh external battery roscope While the method as to how encoder and
pack MPU values would be read was being determined,
some team members went ahead to write a set of
Software initially used during the programming generic PID methods; the robot would require more
and the development of the robot were the Arduino than one implementation of PID, so the generic
IDE, Git command-line tools, and the GitHub web- methods would prove useful in more than one re-
based Git repository hosting service. The Ar- spect.
duino IDE facilitated the development of C/C++
source code to be compiled for the SainSmart UNO, 3.2.3 Reading Values From the MPU-6050
GitHub provided a way to create a centralized
After familiarization with the software libraries
repository for storage of all relevant files and li-
stated above, one of the first tasks to accomplish
braries, while Git command-line tools provided a
was to figure out how to read values from the
way to update content in the GitHub repository
MPU-6050 accelerometer/gyroscope. Lack of well-
and provide a means of version control.
commented example code and obscurity of docu-
mentation led to certain confusion in terms of how
3.2 Using the SainSmart UNO to write methods that would interface with the
3.2.1 First Steps MPU-6050 and retrieve the accelerometer and gy-
roscope data that were required.
The SainSmart UNO is a less expensive alter- However, after doing some research, a relatively
native to the original Arduino UNO and shares low-level solution was found. The MPU-6050 has
the same layout and features. Programmable a FIFO (first-in, first-out) buffer, and like any mi-
through the Arduino IDE, the SainSmart UNO per- crochip, stores data in registers. It soon became
forms comparably to the Arduino UNO and can be clear that in order for the UNO to read the values
treated similarly to a genuine UNO. measured by the MPU-6050, the values would have
After downloading and installing the necessary to be pulled directly from the MPU-6050s data reg-
software and libraries, the team spent some time isters.
getting familiar with the Arduino IDE, the Adafruit More research uncovered a listing of the regis-
software libraries that provided programming func- ters inside the MPU-6050 that store data ranging
tionality for the motors and the LCD screen and from I2 C control, user control, power management,
leverage an existing, and Jeff Rowbergs I2 C device and most importantly, the accelerometer and gyro-
libraries, which provide an interface and methods scope measurements needed. The relevant registers
for using I2 C to communicate with the MPU-6050 are reported in Figure 14.
and the VEX optical shaft encoders. It then became quite clear the appropriate
method of approaching the problem. An I2 C con-
3.2.2 Writing a PID Controller nection would have to be opened with the MPU-
6050, and from it the program would have to re-
It was quickly established that for effective con- quest fourteen 8-bit registers from the MPU-6050,
trol of the robots travel, some kind of feedback con- starting with the address of the first accelerometer
trol loop would need to be written. The VEX mo- data register ACCEL XOUT H, reassemble the single
tors are standard DC motors, and since they con- byte data chunks into seven 16-bit integers, and fi-
tain no motor controllers, they are very inaccurate nally make use of the six relevant data points: x,
without good control software. Of course, there are y, and z accelerometer values, and roll, pitch, yaw

10
Addr Addr Register Serial Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
(Hex) (Dec.) Name I/F
3B 59 ACCEL XOUT H R ACCEL XOUT[15:8]
3C 60 ACCEL XOUT L R ACCEL XOUT[7:0]
3D 61 ACCEL YOUT H R ACCEL YOUT[15:8]
3E 62 ACCEL YOUT L R ACCEL YOUT[7:0]
3F 63 ACCEL ZOUT H R ACCEL ZOUT[15:8]
40 64 ACCEL ZOUT L R ACCEL ZOUT[7:0]
41 65 TEMP OUT H R TEMP OUT[15:8]
42 66 TEMP OUT L R TEMP OUT[7:0]
43 67 GYRO XOUT H R GYRO XOUT[15:8]
44 68 GYRO XOUT L R GYRO XOUT[7:0]
45 69 GYRO YOUT H R GYRO YOUT[15:8]
46 70 GYRO YOUT L R GYRO YOUT[7:0]
47 71 GYRO ZOUT H R GYRO ZOUT[15:8]
48 72 GYRO ZOUT L R GYRO ZOUT[7:0]

Figure 14: The registers responsible for storing accelerometer, temperature, and gyroscope data

gyroscope values. The simple test program created refresh fast enough, and when the images are pro-
for this purpose is shown in Figure 15. cessed by the brain, the wheels appear to rotate the
wrong way.
3.3 Switching to the Cypress Interrupts are necessary to get good sensor data,
but the SainSmart UNO only has two interrupt pins
3.3.1 Advantages of Cypress while the encoders and MPU combined require five.
This means that, with the UNO, the sensors did
To provide an accurate picture of a systems
not read steady data streams and would report in-
state, measurements must be read from sensors
accurate values; at times, the sensor data showed
with only very short delays between each read cycle
that the robot was moving backward when in real-
and low loss. This often requires the use of inter-
ity it was moving forward. In contrast, the Cypress
rupt pins. Input received through interrupt pins
PSoC 4 has thirty-two interrupt pins, so data can
will briefly halt the execution of the main program
be read and updated as soon as it is available. Inac-
loop in order to handle incoming data from sen-
curate data due to too few interrupt pins becomes
sors, which means that sensor data is always read
a non-issue.
and processed as soon as it is available. If the sen-
Cypress PSoC 4 has programmable hardware,
sors are not connected to interrupt pins, then the
meaning that not all tasks are run on the micropro-
microcontroller will only read the data from the
cessor. As a result, the code runs much faster, and
sensors when it has the time to do so between pro-
more calculations can be done in the same amount
cess loops. Loops can vary in their execution speed,
of time. Dead-reckoning involves performing com-
and they may not be running fast enough to read
putations, sometimes complex, on sensor data in or-
in data reliably, causing data points to be missed.
der to calculate current location. Using the Cypress
For example, imagine looking at the passenger
PSoC 4 greatly improves this endeavor. Hardware
side of a car driving by on the freeway. Intuitively,
is configured in Cypress software PSoC 4 Creator
the wheels must be rotating clockwise in order for
3.3 by adding hardware components to a schematic,
the car to go forward, but sometimes the wheels
customizing those components properties, and con-
might appear to be rotating counterclockwise. This
necting the components together.
is because the human brain does not actually re-
ceive a moving picture from the eyes. Rather, as
in a movie, the brain receives a series of pictures,
updated many times per second. The eyes fail to

11
and the counter space capped at 8 bits. This means
that the status register can only hold 0.0255 sec-
onds at a time, nowhere close to the duration of
even a relatively short program. Only relative time
is necessary, so a control register was wired to the
counter reset. Control registers are the opposite of
a status register, in that the former are set by soft-
ware and read by hardware and vice versa with the
latter. Control registers in combination with status
registers allow for two-way communication between
hardware and software. With the hardware setup
diagrammed in Figure 16, the clock becomes able
to be read and reset at the same time, yielding the
time taken to execute a single loop iteration. No
loop should ever take more than a few milliseconds,
so the time cap is never an issue.

Figure 15: Reading data from the MPU-6050

3.3.2 Changing from C++ to C


The SainSmart UNO was programmed primar-
ily using C++ in the Arduino IDE. However, Cy-
press PSoC 4 runs exclusively on C. Alternative
Motor Shield and MPU 6050 libraries written in C
had to be located and implemented. This was also
used as an opportunity to reorganize code into sep-
arate files and write wrapper functions to handle
things like reading and writing encoder values.

3.3.3 Getting Relative Time


Figure 16: Hardware setup for getting relative time
Accurate and precise relative time is necessary
for the calculations involved in Dead-reckoning.
The Arduino library includes the millis() and
micros() functions, which return time in millisec- 3.3.4 Configure Hardware for Motors
onds and microseconds respectively from the initial The two motors are configured in PSoC 4 Cre-
execution of the program. However, the Cypress ator and are connected to a clock that will update
has no built-in functions that handle relative time. the motor values at 24 MHz. The outputs of the
Hardware needs to be programmed to accomplish motor controller are wired to output pins, which
this task. A clock is wired into the counter, and then direct the Adafruit v1 Motor Shield to supply
the counters value is entered into a status regis- power to the motors. The hardware component on
ter. Status registers are set by hardware and can the top of the diagram is for communicating the
be read by software. Given the hardware restric- direction of the motors. [21]
tions on the Cypress PSoC 4, CY8CKIT-042-BLE
specifically, the clock had to be limited at 10 kHz

12
3.4 Adjusting Raw MPU-6050 Data
The MPU-6050 can be initialized to measure ac-
celeration in Gs at any of the following sensitivities:
2g, 4g, 8g, or 16g. The gyroscope can also
be configured to measure angular velocity in de-
grees per second at one of the following sensitivities:
250, 500, 1000, 2000. As explained in sec-
tion 3.2.3, the MPU-6050 stores individual sensor
outputs as 16 bit signed integers. This means that
all values, from the accelerometer or gyroscope, can
be anywhere on the domain [32768, 32768]. This
means that the data ust be scaled in order for the
raw data to have the proper units.

|Range|
Scalar = (18)
216
A 2g and 250deg/sec configuration was used:

Figure 17: Motor control and operation configura- 4 9.80665


SAcceleration = (19)
tion 216
500
SGyroscope = 16 (20)
3.3.5 Configure Hardware for Encoders 2

The two quadrature encoders must also be con- Note: 1 g = 9.80665 m/s2 is used to convert g to m/s2
figured on the hardware side of PSoC 4 in order to Now that the data can be interpreted correctly,
be accessed in software. Each encoder is connected the MPU-6050 needs to be calibrated. If the sensor
to a clock that instructs them to update their val- was oriented perfectly on the robot, then the resting
ues at 24MHz and to a pin that is configured for values for acceleration and radial velocity should be
interrupts. close to zero. However, placing the sensor correctly
is exceedingly difficult, and sensor placement could
shift when transporting the robot. Instead of rely-
ing on perfect placement, the sensor is calibrated in
software before it is used. This is done by averaging
n values of accelerometer and gyroscope data, and
using that to offset the values read from the MPU-
6050. For example, if Z is measured acceleration in
the x direction, A will be the acceleration after it
has been adjusted:

n
X Sacceleration Zi
Offset = (21)
i=0
n
A = Sacceleration Z Offset (22)

3.5 Reading Precise Encoder Val-


Figure 18: Encoder connections to the main clock ues
and interrupt pins Quadrature encoders return an unsigned 16 bit
integer, which is not very useful considering that

13
encoders can move forwards and backwards. In or- onds, and wheel circumference were used to calcu-
der to capture motion in the positive and negative late an averaged meters per second speed between
directions, encoder values are offset by 215 1 re- two trials at each motor power. A linear regression
sulting in 215 1 being treated as the zero point. speed = 0.0025power0.0196 was computed with
a coefficient of determination R2 = 0.99837.
Encoder Value = Raw Value 215 (23) Power-Speed Relationship
In addition, integers have maximum and mini-
mum values that they can hold before they overpass 0.6

Speed [meters/second]
those limits and wrap around. Once encoder values
go above 216 1 or below 0, the value will over- 0.5
flow or underflow respectively and will wrap back
0.4
to 215 1. When wrapping like this happens, the
new encoder reading will have changed by at least 0.3
215 1 ticks. To counteract this, the program keeps
track of the amount of overflows and underflows. 0.2

0.1
if Current Value Previous Value 213 50 100 150 200 250
Increment overflow counter by 1 Power [Motor]
if Current Value Previous Value 213 The R2 close to 1 shows that the relationship
Increment underflow counter by 1 is almost direct, with changes in PID output elic-
iting proportional changes in motor speed. If the
The underflow and overflow counters are stored relationship was not proportional, a logarithmic re-
separately, as an alternative to using only one vari- gressions inverse would be necessary to calculate
able and increasing it or decreasing it by one de- the appropriate motor power.
pending on either underflow or overflow. This is
done because an underflow accounts is 215 away
from the zero value, but an overflow is 1 less at
3.7 Filters
215 1. So storing separate values allows for more 3.7.1 Kalman Filter
accurate readings.
In order to improve the data read from the var-
15
Encoder Value =Overflows (2 1) ious sensors, the team implemented two separate
Underflows (215 ) multidimensional extended Kalman filters (EKF).
The first EKF uses the average value between left
+ Encoder Value and right encoders in conjunction with accelerom-
eter data to estimate distance traveled (position),
3.6 Motor Calibration velocity, and acceleration. The second KF uses the
difference between left and right encoders in addi-
As explained in section 2.1, the goal of PID is
tion to gyroscope values to estimate angle and an-
to calculate what the motors should do in order to
gular velocity. Working together, these two filters
move the robot to the correct position and orienta-
will be able to provide more accurate estimations
tion. It is necessary that the robot moves in a di-
on the robots current location on the y axis and its
rect relationship to the PID output; however, many
yaw.
motor-robot combinations do not have directly pro-
portional power-speed relationships. To determine
the power vs. speed relationship, trials were exe- Single-Axis Kalman Filter The implementa-
cuted at each motor power, incrementing by 5, from tion is somewhat simplified from the standard Kal-
65 (25.5% power) to 255 (100% power), for a total man filter described by equations 10 to 16. The first
of 39 trials. Encoder readings in degrees per sec- step is to determine the state transition model, F,
ond, time taken to complete each trial in millisec- which needs to relate previous position, velocity,

14
and acceleration to the new states. Taking the first pos vel accel
and second antiderivatives of acceleration, with re- 0.0001 0 0 pos
spect to time, yields the basic physics equations 0 0.0001 0 vel
that relate position, velocity, and acceleration. 0 0 0.0001 accel
These constants are necessary to define in or-
a=a (24) der to implement a Kalman filter. An extended
Z Kalman filter library, TinyEKF, was then used to
v = a dt = at + vi (25) handle the matrix manipulation in each step [22].
at2
ZZ
y= a dt = + vi t + yi (26) Radial Kalman Filter The transition model, F,
2
for the radial Kalman filter is as follows:
Transition Matrix  
2 1 t
1 t t2 (32)
0 1
0 1 t (27)
0 0 1 The observation model, H, is as follows:
Next, the observation model, H, must be cre-  (lef t encoderright encoder)180    
ated to relate system states to observations. In this 0.192
1 0
= (33)
case, there are two sensors and three states. The gyroscope 0 1
accelerometer sensor relates directly to the accel-
The sensor variance, R, is
eration state and the average encoder value relates
directly to the position state. There are no sensors encoder gyroscope
that relate to velocity. 0.0001 0 encoder
0 0.007352 gyroscope

    position and the prediction variance, Q, is
encoders 1 0 0
= velocity (28)
accelerometer 0 0 1
acceleration
0.0001 0
The last thing to set is the variances for sen-
0 0.0001
sors, R, and prediction estimations, Q. This is how
the Kalman filter will determine the weights in the This filter is also implemented using the
weighted average. Accelerometer data was sampled TinyEKF library.
100 times while the robot was stationary and the
variance was calculated. 3.7.2 Particle Filter
n 2
X (xi x) The model for the particle filter comprises a
2 = (29)
i=0
n state vector of three states: x-position, y-position,
Accelerometer = 0.000774 m2 /s4
2
(30) and heading (angular position). Each iteration of
the filter, the living particles are incremented us-
There is no simple and accurate solution to mea- ing data from the various sensors, according to the
sure encoder variance, so a low value is assumed. following equations:
Encoder 2 = 0.0001 m2 (31) xn = d cos a + xn1 (34)
The final measurement variance is as follows:
encoder accelerometer yn = d sin a + yn1 (35)
0.0001 0 encoder In these equations, d represents the path length
0 0.000774 accelerometer traveled by the robot, and a represents the aver-
The variance for prediction is assumed as fol- age heading of the robot in a given time interval.
lows: These equations represent a linear simplification of

15
the robots motion by breaking it down into in- raw and filtered rotational data. This data is from
finitesimal chunks in time, where d is approximated the robot driving on a straight line. When the ra-
to a straight-line motion. dial displacement, departs from 0, the robot ad-
Due to time limitations, only encoder data was justs to continue on a straight path. Once again the
able to be implemented and tested. In this imple- encoder data, in blue, is very accurate, but the gy-
mentation, d is the average encoder distance and roscope data, in orange, has a lot of noise and jumps
is calculated using the difference between the left to over 20 degrees/second multiple times during the
and right encoder values and the width of the robot. trial. Once filtered with encoder data, the Kalman
An implementation incorporating accelerometer has considerably less noise and is now usable.
and gyroscope data was also created but was unable
to be tested. In this implementation, accelerome- 4.2 Particle Filtering
ter data is twice-integrated and the infinitesimal
changes in x- and y- position are combined with The particle filter implemented provided an ex-
encoder data in a weighted average to become d, cellent estimation of current position and heading
and gyroscope data is integrated once and the in- of the robot.
finitesimal changes in heading data are combined
with the angles obtained using encoder data in a
weighted average to become .

4 Results
4.1 Kalman Filtering
Both the single-axis and rotational Kalman fil-
ters did a great job of removing noise from the sen-
sors with the highest variances, the accelerometer
and gyroscope. Figure 20 in Appendix B shows
single axis robot data and its filtered counterparts.
The robot motion over this 16-second interval con-
sisted of traveling forward 2 meters, backward 2
meters, and then forward 1 meter. The next 6 os-
cillations are caused by intentional human interfer-
ence, and then the robot moving back to 1 meter
once the interference has ceased.
The encoder data, in blue, is very accurate and
does not need much filtering in this short term dis-
placement of 2 meters. However, the accelerometer
data, in orange, has a lot of noise and significant
drift towards the end of the data set. If the second
integral of raw acceleration were used to calculate
position, it would be represented by the Position
Double Integral, in purple. This calculation is in-
credibly inaccurate and cannot be used for dead-
reckoning. The Kalman filtered acceleration, in red,
is significantly less noisy, and the Kalman filtered
position, in green, is very accurate. The Kalman
filter works very well along this axis to filter ac-
celerometer data.
Figure 21 in Appendix B illustrates the robots Figure 19: Sample data from the particle filter

16
Unfortunately, due to time constraints, the par- Acknowledgements
ticle filter was unable to be as thoroughly tested as
the Kalman filter, though it appears to have sim- The authors of this paper would like to thank
ilar potential. Overall, the particle filter is highly everyone who was essential to the completion of
accurate using purely encoder data, which has low this project, namely their Residential Teaching As-
variance, but the introduction of gyroscope and ac- sistant Anthony Yang and their mentors, Rupesh
celerometer data caused some additional variance Chinta and Matthew Tantoy. Anthony Yang was
in the filter output. instrumental in the guidance and organization of
One problem with the particle filter came due the project, while Rupesh Chinta and Matthew
to the stochastic nature of the filter; its need of a Tantoy were indispensable in providing access to
large sample size of particles to be accurate in noisy hardware and technical advice. Many thanks go
data resulted in relatively slow and memory-heavy to the the individuals and organizations who orga-
calculations. This limited the effectiveness of the nized and sponsored the Governors School of En-
linear approximation used in calculations and thus gineering and Technology, in particular Dean Jean
the accuracy of the filter output. Patrick Antoine, Dean Ilene Rosen, Rutgers the
An illustration of limited sample data from the State University of NJ, Rutgers School of Engineer-
particle filter is demonstrated in Figure 19. The ing, Lockheed Martin, Printrbot, and South Jersey
green dots represent the reported position of the Industries. Sincere gratitude goes to Jeff Rowberg
robot, and the red dots represent a random sample and his excellent I2 C device library, to Adafruit In-
of the particles; not all particles are shown, in order dustries, to Simon D. Levy and his TinyEKF Kal-
to improve image visual quality. The sequence of man implementation, and to Cypress Semiconduc-
graphs shows the robots movement in the positive tor. Without their contributions this research en-
x-direction and negative y-direction. deavour would not have been possible.

5 Conclusions References
After successfully implementing a PID con- [1] The Editors of Encyclopaedia Britannica,
troller and both a Kalman and particle filter in Dead reckoning, Encyclopaedia Britannica
the robot, the team created a functioning dead- [Online]. Available:
reckoning system with the capability to accurately https://www.britannica.com/
control and estimate position and travel, despite technology/dead-reckoning-navigation.
the numerous difficulties faced regarding the qual- [Accessed: 12-Jul-2016].
ity, accuracy, and reliability of the hardware used in
[2] A. Kleusberg and R. Langley (1990, Mar.),
the robots construction. Filtering attenuated the
The limitations of GPS, GPS World
accelerometers noisy readings enough to produce
[Online]. Available:
usable readings, while the PID controller managed
http://gauss.gge.unb.ca/gpsworld/
the robots movements precisely enough to avoid
EarlyInnovationColumns/
continuous large accumulations of error.
Innov.1990.03-04.pdf. [Accessed: 12-Jul-2016].
Even though the concept of dead-reckoning is
nothing new and revolutionary, and has been imple- [3] The Editors of Encyclopaedia Britannica,
mented successfully throughout history, the team Inertial guidance system, Encyclopaedia
has proven that even with inexpensive and low- Britannica [Online]. Available:
quality equipment, the theory and implementation https://www.britannica.com/
of a usable dead-reckoning system are both possi- technology/inertial-guidance-system.
ble. For individuals without access to GPS or ce- [Accessed: 12-Jul-2016].
lestial cues, dead-reckoning can be a reliable and
accurate alternative method of navigation. [4] Tampere University of Technology, Basic
principles of inertial navigation, Aerospace
Students [Online]. Available:

17
http://aerostudents.com/files/ avionics/ [12] J. Zhong, PID Controller Tuning: A Short
InertialNavigationSystems.pdf. [Accessed: Tutorial, Mechanical Engineering, Purdue
12-Jul-2016]. University [Online]. Available:
http://saba.kntu.ac.ir/eecd/pcl/
[5] L. Ojedo and J. Borenstein, Personal download/PIDtutorial.pdf. [Accessed:
dead-reckoning system for GPS-denied 14-Jul-2016].
environments, IEEE International Workshop
on Safety, Security, and Rescue Robotics [13] A. Andrews and M. Grewal, Kalman
[Online]. Available: Filtering: Theory and Practice Using
http://citeseerx.ist.psu.edu/viewdoc/ MATLAB, New York: Wiley, 2001
download?doi=10.1.1.218.8653
&rep=rep1&type=pdf. [Accessed: [14] R. Levy, Multivariate Probability
12-Jul-2016]. Probabilistic Models in the Study of
Language [Online]. Available:
[6] National Geospatial-Intelligence Agency, http://idiom.ucsd.edu/rlevy/
Dead reckoning, Maritime Safety pmsl textbook/chapters/ pmsl 3.pdf.
Information [Online]. Available: [Accessed: 15-Jul-2016].
http://msi.nga.mil/MSISiteContent/
StaticFiles/NAV PUBS/APN/ Chapt-07.pdf. [15] K. Hsiao et al., Particle Filters and Their
[Accessed: 12-Jul-2016]. Applications, Cognitive Robotics [Online].
Available: http://web.mit.edu/16.412j/www/
[7] S. Bennett, A brief history of automatic html/Advanced%20lectures/
control, IEEE Control System Society Slides/Hsaio plinval miller
[Online]. Available: ParticleFiltersPrint.pdf. [Accessed:
http://ieeecss.org/CSM/library/ 15-Jul-2016].
1996/june1996/ 02-HistoryofAutoCtrl.pdf.
[Accessed: 13-Jul-2016]. [16] N. Friedman et al., Using Bayesian
Networks to Analyze Expression Data,
[8] K.H. Ang et al., PID control system Journal of Computational Biology [Online].
analysis, design, and technology, IEEE Available: http://online.liebertpub.com/doi/
Transactions on Control Systems Technology pdfplus/10.1089/106652700750050961.
[Online]. Available: http://eprints.gla.ac.uk/ [Accessed: 15-Jul-2016].
3817/1/IEEE3.pdf. [Accessed: 13-Jul-2016].
[17] Posterior Probability, Investopedia
[9] Microstar Laboratories, Inc., Ziegler-Nichols [Online]. Available:
tuning rules for PID, Control [Online]. http://www.investopedia.com/terms/
Available: p/posterior-probability.asp. [Accessed:
http://www.mstarlabs.com/control/ 15-Jul-2016].
znrule.html. [Accessed: 13-Jul-2016].
[18] An Intuitive (and Short) Explanation of
[10] T. Idehara et al., Development of feedback Bayes Theorem, BetterExplained [Online].
control scheme for the stabilization of Available:
gyrotron output power, Research Center for https://betterexplained.com/articles/
the Development of Far-Infrared Region an-intuitive-and-short-explanation-of-bayes-
[Online]. Available: http://fir.u-fukui.ac.jp/ theorem/. [Accessed:
FileStoreFolder/firreport/FIR FU120.pdf. 15-Jul-2016].
[Accessed: 13-Jul-2016].
[19] R. Fitzpatrick, Normalization of the
[11] D. Perepelitsa, Johnson Noise and Shot Wavefunction, Richard Fitzpatrick Professor
Noise, MIT Department of Physics [Online]. of Physics The University of Texas at Austin
Available: http://web.mit.edu/dvp/Public/ [Online]. Available:
noise-paper.pdf. [Accessed: 14-Jul-2016]. http://farside.ph.utexas.edu/

18
teaching/qmech/Quantum/node34.html.
[Accessed: 15-Jul-2016].

[20] MPU-6000 and MPU-6050 Product


Specification Revision 3.4, InvenSense Inc.
[Online]. Available:
https://www.invensense.com/wp-
content/uploads/2015/02/MPU-6000-
Datasheet1.pdf

[21] cy.wbz PSoC 4 Pioneer Kit Community


Project#043 Rise of the Machines (Rolling
Robot), Element 14 [Online]. Available:
https://www.element14.com/community/
message/81714/l/ psoc-4-pioneer-kit-
community-project043-rise-of-
the-machines-rolling-robot#81714

[22] S. Levy, TinyEKF: Lightweight C/C++


Extended Kalman Filter with Arduino Sensor
Fusion Example and Python prototyping,
GitHub [Online]. Available:
https://github.com/simondlevy/TinyEKF.
[Accessed: 16-Jul-2016]

19
Appendix A
Single Axis Kalman Filter Rotational Kalman Filter
P redict P redict

xk|k1 = Fk xk1|k1 xk|k1 = Fk xk1|k1

2
    
yk|k1 1 t t2 yk1|k1 k|k1 1 t k1|k1
vk|k1 = 0 1 t vk1|k1 =
ak|k1 ak1|k1
k|k1 0 1 k1|k1
0 0 1

Pk|k1 = Fk Pk1|k1 FT
k + Qk
Pk|k1 = Fk Pk1|k1 FT
k + Qk

       
2
1 t 1 0 0.0001 0
2
1 t t2 1 0 0 0 0
= 0 1 t t 1 0 + 0 0 0 = +
t2
0 1 t 1 0 0.0001
0 0 1 2
t 1 0 0 2
U pdate
U pdate

1
1 Kk = Pk|k1 HT T
k (Hk Pk|k1 H + Rk )
Kk = Pk|k1 HT
k (Hk Pk|k1 H
T
+ Rk )

          1
1 0 1 0 1 0 0.0001 0
 1 = +

1 0   1 0  0 1 0 1 0 1 0 0.007352
= 0 0 1 0 0 0 0 + 0
0 0 1 0
0 1 0 1

xk|k = xk|k1 + Kk (Zk Hk xk|k1 )


xk|k = xk|k1 + Kk (Zk Hk xk|k1 )

          
k|k k|k1 enc 1 0 k|k1
= +
yk|k yk|k1     yk|k1 k|k k|k1 gyro 0 1 k|k1
vk|k = vk|k1 + enc 1 0 0 vk|k1
acc 0 0 1
ak|k ak|k1 ak|k1
Pk|k = (I Kk Hk )Pk|k1
Pk|k = (I Kk Hk )Pk|k1
        
1 0 1 0
=
0 1 0 1
1 0 0  
= 0 1 0 1 0 0
0 0 1
0 0 1

20
Appendix B

Figure 20: Single-Axis Robot Data

Figure 21: Rotational Robot Data

21

You might also like