Contents
Where's the Wiimote? Using Kalman Filtering To Extract Accelerometer Data
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
November 22, 2009
 
Video Game Watchdog National Institute On Media And The Family Shutting Down [11]
 
Modern Warfare 2 Infinity Ward's 'Most Successful PC Version' Yet [12]
 
New Tech, Design Details Of Project Natal To Emerge At Gamefest In February
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 22, 2009
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
3D Environment Artist
 
Sucker Punch Productions
Network Programmer
 
Sucker Punch Productions
Texture Artist
 
Sony Online Entertainment
Brand Manager
 
Monolith Productions
Sr. Software Engineer, Engine - Monolith Productions - #113767
 
Crystal Dynamics
Sr. Level Designer
 
Gargantuan Studios
Lead World Designer
spacer
Latest Features
spacer View All spacer
 
November 22, 2009
 
arrow Upping The Craft: Susan O'Connor On Games Writing [6]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part II [6]
 
arrow iPhone Piracy: The Inside Story [48]
 
arrow And Yet It Grows: Analyzing the Size and Growth of the European Game Market [5]
 
arrow NPD: Behind the Numbers, October 2009 [13]
 
arrow Reflecting On Uncharted 2: How They Did It [5]
 
arrow Sponsored Feature: Rasterization on Larrabee -- Adaptive Rasterization Helps Boost Efficiency
 
arrow Postmortem: Wadjet Eye's The Blackwell Convergence [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 22, 2009
 
Accepting the Inherent Value of Games
 
Planckogenesis, Part II: Song Structure & Gravy Train [1]
 
Designing Games Is About Matching Personalities [1]
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Features
  Where's the Wiimote? Using Kalman Filtering To Extract Accelerometer Data
by Bertis Rasco
0 comments
Share RSS
 
 
June 20, 2007 Article Start Previous Page 4 of 4
 

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.

Advertisement

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.

Code Samples

KalmanFilter.cpp
KalmanFilter.hpp
MainLoop.cpp

Note: These samples contain almost workable code. However, you will need your own vector classes, matrix classes, and file classes.

Acknowledgments

The author would like to thank Sam Denham, Ph.D. and Nathan Morse for their helpful comments in the preparation of this manuscript.

 
Article Start Previous Page 4 of 4
 
Comments

none
 
Comment:
 


Submit Comment