You are on page 1of 33

Better motion control using accelerometer/gyroscope sensor fusion

Gabor Paller gaborpaller@gmail.com Sfonge Ltd. http://www.sfonge.com

Where were we

!roidcon "#$$% London: &otion recognition on 'ndroid de(ices

http://mylifewithandroid.blogspot.com/"#$$/$#/my) presentation)about)motion.html

Processing only the accelerometer for motion recognition

'cceleration
'cceleration caused by the change of direction 'cceleration caused by the change of (elocity

($ d* (" (" ($

d*

V a= t

+,tract motion information from accelerometer data

'ccelerometer data is a (ector% ha(ing - a,es .,%y%/0 1his (ector has the following components:

Gra(ity acceleration

Pointing toward the center of the +arth *alue of about $# m/s" 1hat2s what we measure when the accelerometer is used to calculate tilt 'dded to the gra(ity acceleration 4!isturbs5 tilt measurement in gaming .swift mo(ements cause acceleration0 6 hence the reason for gyroscopes 7an be used for mo(ement detection

'ny other acceleration the de(ice is sub3ect to


&easured acceleration

'bsolute (alue

,% y% /: acceleration (ector components g 6 (alue of the gra(ity acceleration .can be appro,imated as $#0

a= x + y + z g
2 2 2

Snap 6 one way &o(ement starts: accelerating


&o(ement ends: decelerating

!roidcon "#$$ flashbac8

7onclusions:

Power consumption is a problem Some neat functionality can be implemented by doing pattern recognition on the acceleration (ector2s absolute (alue 9n general case the gra(ity and motion acceleration components cannot be separated You can try to use an additional sensor like the gyro to help the separation

Gyroscope

*ery new phenomenon as gyroscopes suitable for consumer electronic de(ices appeared (ery recently :irst appearance: Wii &otion Plus accessory% "##; <une :irst 'ndroid smart phone: =e,us S .end of "#$#0 Pros:

=ot sensiti(e to gra(ity 7urrently supported only by high)end 'ndroid phones !rift problems .more about that later0

7ons:

7ompass

&easures the de(ice orientation wrt. the magnetic (ector of the +arth

1his (ector points toward the magnetic center of the +arth

9t has a component that points to the magnetic =orth pole 6 that2s what we use for orientation Beware of the / component> .also called magnetic inclination0. 9f the de(ice is not held hori/ontally% the downward (ector element influences the measurement

Pros:

7an be used to deduce gra(ity% not sensiti(e to motion acceleration Widely a(ailable in 'ndroid de(ices ?e@uires calibration Sensiti(e to metal ob3ects% magnetic fields .e.g. electric motors0

7ons:

1his time it is gyroscope only

Gyroscope

Gyroscope measurement data


&easures rotation around - a,es &ore e,actly: measures rotation speed .angular (elocity0 around the a,es

v x= t

Getting the rotation angle

Get the angle difference

= v x t

Get the absolute angle

' =+

!rift

=oise

Gyro as support sensor

Because of accumulating error% gyro alone can be rarely used But

1he accelerometer has no accumulated error but has the gra(ity component problem 1he gyro has accumulated error but is not sensiti(e to gra(ity

Sensor fusion: the use of multiple sensors so that they compensate each other2s wea8nesses

'ccelerometer)gyro fusion

1he easy way

Ase the (irtual sensors that calculate gra(ity and linear acceleration from multiple sensors Process raw accelerometer and gyroscope data to yield the motion information you need

1he hard way

*irtual sensors

Gra(ity and motion acceleration deduced from the accelerometer and the gyroscope ?oll/pitch/yaw from the compass !rift)compensated gyroscope

!rift)compensated gyroscope

1he hard way

Why would you go the hard way

Sensor fusion co)processing pro(ided by the phone is not precise enough or can ha(e undesirable properties .li8e auto)calibration in =e,us S0 *irtual sensors are not a(ailable .is there any such case with gyro)e@uipped phone 0 Bou would li8e to understand how it wor8s and what to e,pect from built)in sensor fusion <ust for the fun of it :)0

What we want

?emember: accelerometer measures the sum of gra(ity and motion acceleration Cills two use cases:

9f you need de(ice tilt% the motion acceleration component corrupts the measurement 9f you want motion acceleration% it is impossible to subtract the gra(ity acceleration in a general case

Separate gra(ity and motion acceleration with the help of the gyroscope

9dea

9dea in words

Pic8 a reliable gra(ity (ector measurement .ma8e sure that there2s no motion then0 9f you detect motion .more about later0% rotate the pre(ious gra(ity (ector using the gyroscope data and use it as gra(ity (ector estimation Subtract this gra(ity (ector estimation from the measured acceleration 6 this yields the motion acceleration

Apdating the gra(ity (ector estimation

1he gra(ity (ector estimation has to be updated time to time as rotation angle errors accumulate 9f we detect an acceleration measurement where there is no motion acceleration% we can ta8e it as new reliable gra(ity (ector estimation ?emember slide DE: if the absolute (alue of the accelerometer output is close to the +arth2s gra(ity% we can assume that there2s no motion F the gra(ity (ector estimation can be updated with the current accelerometer output

9mplementation

+,ample program: http://www.sfonge.com/forum/topic/e,ample) application)accelerometergyroscope) processing)android

=ow what

-! linear acceleration signal of a well)8nown motion

?ecogni/ing motion

-! linear acceleration signals are not so intuiti(e &otion recognition:

?ecord acceleration pattern of reference motion and compare with these references 7on(ert from acceleration domain to something more intuiti(e li8e (elocity

'ccelerometer/gyroscope bias will become linearly growing drift after you integrate the acceleration signal>

Wal8ing with swinging hand

Wal8ing with steady hand

7utting corners

7onclusions

+ach sensor has strengths and wea8nesses 7ombine them and they compensate each other Some sensor fusion is already built)in 9f not F don2t worry% come up with your own% it2s fun> &otion recognition based on -! linear acceleration signal is much more e,act than doing the same from $! signal

Guestions

You might also like