My Samsung galaxy S2 has an accelerometer and gyroscope. With these 2 sensors I need to determin开发者_JAVA技巧e a man's falling. How do I implement it in the best way?
Relevant data is here: SensorEvent values.
Acceleration coordinates are relative to phone. So if phone is turning while falling than acceleration vector would "rotate". To normalize it you'd need to also use gyroscope data.
You trying to detect speed in some direction. Look at motion equations. You'd basically need to integrate acceleration over time. (You'd already need to have normalized acceleration as described above).
I don't know the context of your "man falling", but you might also look at Free Fall info.
The accelerometer is the only Sensor
you need to determine a fall: the gyroscope has no use here as the device have a random orientation during the fall and may be rolling.
In absolute free fall the accelerometer returns an accleration value of (0, 0, 0)
, so when the cellphone starts falling, the value is close to that. Up to you to determine the ceil that triggers the "fall mode".
You can find more on the accelerometer on that page.
Edit, further to the comments below:
When lying on a table, tilted or not, the accelerometer returns the vector G (the decomposition on the various axis is depending of the tilt).
And during the fall, an acceleration rotating over the axis can be detected if the device is turning on itself. This means the fall detection system should be done over the time unless the acceleration is very close to (0,0,0).
精彩评论