Description
and Evaluation of an Example with Fiducial Accelerometer Inputs
The test
case that I executed involves imitating an accelerometer sitting
still on a table. The accelerometer is motionless, but the
accelerometers still have nonzero inputs. This is a good way to
estimate the accelerometer biases. In order to get a player to hold
the Wiimote still for a short amount of time while receiving position
updates is easy enough. Just make an excuse, have them choose the
club with the pointer and make the player hold that pose for a half
to one second. I assume there is a position measurement every 1/100
of a second and the noise parameters are as follows:.
If you play with these values you can adjust how fast the filter
estimates the accelerometer bias and what the spread is of the
estimations. Adjusting these parameters for the specific purpose at
hand is another balancing act of Kalman Filter design.
In a
fiducial run of the filter with random spreads in the position and
accelerometer inputs the time it takes to estimate the accelerometer
bias is shown in Figure 1. Even though the filter in this run does
not settle down to exactly the .25 m/s/s of the 'real'
accelerometer bias, it does settle down to .28 m/s/s. An error
of .03 m/s/s is much better than the original error of .25
m/s/s, an improvement of approximately 88%. Many of the runs will
settle down to values closer than this, and some not but if they are
kept track of over time then these can be statistically analyzed to
further improve the bias estimate.
The best
thing about all this is that once the bias is estimated for the
accelerometer, the trajectory of the Wiimote is estimated much more
accurately than without the use of a Kalman Filter, even without
further position measurements. Position measurements for the Wiimote
are best when it is pointed at the base station receiver, but for
games that involve swinging the Wiimote the pointer is often not
aimed at the TV, hence this will greatly improve the estimation of
the Wiimote's movement.
Figure 1.
The estimate of the accelerometer bias as a function of time for a
fiducial run. Note that the value it closes in on is not exactly the
.25 m/s/s that is assumed in the test.
Issues
with Kalman Filtering
Model
issues
This is
the difficult part of all of this, if you have a poor model things
will not work well. If you have a poor model and know it, making the
time propagation noise vectors larger can help a little. But for a
filter to work well the model must represent reality accurately
enough or the filter will end up saying strange things. And you do
not get to blame the Kalman Filter, it is your own fault.
Memory
and speed issues
Once
models become complicated, the state vectors get big fast. Most
navigation Kalman Filters have between 12 and 29 states. The trouble
comes with the time propagation matrix, F(t),
and with the matrix inversion in the equation (5). The measurement
vectors also get bigger, but since most measurements are not larger
than 3 dimensions this increase in size does not occur as fast.
The
states on airplanes are not updated all that often, once every few
seconds, since the airplane motion is in general smooth and
accurately described by the time evolution equations. For something
like the Wiimote the time between measurements is not as long so some
worry about computation is justified.
Possible
numerical issues
The
Covariance matrix is supposed to be positive semi-definite. Basically
this means that all of the eigenvalues should be 0 or greater. If the
ratio of the eigenvalues of the matrix are greater than precision of
the number type, then negative numbers can sometimes creep in. So if
the largest eigenvalue is 10,000,000 and the smallest is 1.0 there
will be trouble with making the various matrices out of floats.
For
our example there is fairly little trouble with this but it is
something to keep in mind if you set up a more complicated system and
try to estimate small corrections to big numbers. Reference [4] has
several elegant and impressive solutions to many numerical issues.
Conclusion
What was
all of this complicated math for anyway? Well, the actual
accelerometer outputs from the Wiimote are neither precise nor
accurate. In order to use them as a better input, to simple sports
games, sword fighting games, or any other game that allows the player
to swing their arms around without always pointing the Wiimote at the
base station and that requires accuracy to follow the Wiimote around.
Once this is programming is done, the flexibility of the Wiimote as a
unique input device will go well beyond its current capabilities.
Another
potential use of Kalman Filter's is in AI. An example would be in a
military game, it would be useful for the AI to estimate where it
thinks the player is and how spread out his forces are. The mean and
the covariance of the Kalman Filter give precisely this information.
Much more appropriate and complicated models could be derived that
would improve the AI's abilities.
References
[1]
Maybeck, Peter S., Stochastic Models, Estimation, and Control
Volume 1, Navtech Book & Software Store, 1994. Overall this
reference is more formal mathematically than some of the other
references, but the first chapter contains another 'simple' example
and is a good place to start learning about Kalman Filtering.
[2]
http://www.cs.unc.edu/~welch/kalman/ This is a nice site with
many additional references. It focuses more on the computing aspects
and less on the modeling aspects of Kalman Filter. Plus it has a
picture of Mr. Kalman himself.
[3] Gelb,
Arthur, Applied Optimal Estimation, M.I.T. Press, Cambridge,
Massachusetts, 1974. This is a classic reference for engineers.
[4]
Bierman, Gerald J., Factorization Methods for Discrete Sequential
Estimation, Academic Press, New York, 1977. This is a reference
that is full of optimized algorithms that tackle the many numerical
issues involved in complex filters, even if they are in FORTRAN.