Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello everybody..
How to use Android Accelerometer feature to measure the distance when phone is moved from one hand to another? What is the best way to build this kind of application
Posted
Updated 19-Dec-16 9:52am
Comments
Sergey Alexandrovich Kryukov 25-Jan-12 17:37pm    
Who told you it's possible?
--SA
mr_kikuk 26-Jan-12 6:42am    
hehe i don't know SAKryukov.. do u think it's possible?

You practically can't: please see the following thread at 'The Competitors' website: "How to use Accelerometer to measure distance for Android Application Development"[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Jan-12 17:11pm    
Wow, now you see that my colleague really knows some physics; and I'm sure -- not from the discussion referenced. :-)
My 5.
--SA
Sergey Alexandrovich Kryukov 25-Jan-12 17:31pm    
In case somebody needs real explanation -- I tried provide some, please see.
--SA
Espen Harlinn 25-Jan-12 17:33pm    
5'ed! - it's not what it's designed for
Sergey Alexandrovich Kryukov 25-Jan-12 17:39pm    
Agree, not at all.
--SA
I can add some explanation to the correct answer by CPallini.

To acceleration is the second derivative of the coordinate and the only measurable characteristic of motion. According to Galilean relativity principle, it is impossible to tell the difference between coordinate systems moving with different speeds and having different reference point using any mechanical measurements. According to Einstein, no physical phenomena can be used to tell that, please see:
http://en.wikipedia.org/wiki/Principle_of_relativity[^],
http://en.wikipedia.org/wiki/Galilean_invariance[^].

It is theoretically possible to estimate the displacement (and thus coordinates in case initial coordinate are known) of a device by measurement of the acceleration, but it needs permanent double integration of the acceleration (again, acceleration is the second derivative of the coordinates). It is quite apparent that all the errors tend to accumulate during integration. And any accelerometer is a device with inherent accuracy limitations: one can put it under conditions (certain vibration frequencies and accelerations) which could cause fatal loss of accuracy.

There is a very important technical problem here: the measurement and integration should be performed non-stop with regular time intervals which should never exceed some maximum sample rate. In other words, the computing system should be required to be a real-time system or near real-time. I don't think Android is anything close to such system. Also, I'm not sure the device's accelerometer is a true 3D sensor.

Please see:
http://en.wikipedia.org/wiki/Real-time_computing[^],
http://en.wikipedia.org/wiki/Real-time_operating_system[^].

Nevertheless, such problem is successfully solved in rocket science. But motion in open space is much, much smoother and simpler than on the Earth. I would say, on Earth this problem is nearly hopeless.

—SA
 
Share this answer
 
v4
Comments
Espen Harlinn 25-Jan-12 17:34pm    
Useful stuff, my 5 :)
Sergey Alexandrovich Kryukov 25-Jan-12 17:39pm    
Thank you, Espen.
--SA
CPallini 26-Jan-12 3:18am    
My 5.
Sergey Alexandrovich Kryukov 26-Jan-12 3:25am    
Thank you.
--SA
mr_kikuk 26-Jan-12 7:03am    
ok thnk you SAKryukov. ", on Earth this problem is nearly hopeless" .. i tired about accelerometer. i give up. huff.
i just want measure near distance about 20 cm- 30 cm by android. can u give me idea? how if i use proximity sensor?
I've done this before on earth and in rocketry.

Earth bound, best I saw was a robot at Draper labs, cambridge. They had errors of a few cm without GPS after tens of minutes.
Much better gyros, accelerometers, and timing than on a phone.

Outdoors in good weather, it's easier to use GPS and filter to get submeter than using the accelerometers.

The inherent problems are: the sensor has noise, non-linearity and bias, AND you can't sample it fast enough or with good enough time precision.
That doesn't mean it can't be solved but it's hard :)

Looking at 1 senor say the acceleration going left/right, we'll call that "X".
Note how "x" real value is very different from the measured:

Xmeasured = bias + guassianNoise + a0*x + a1*x^2 + a2*x^3 + a3*x^3 ...

Where a0 is almost 1, and a1 - an are nearly (not quite) zero, but for most applications you could treat them as zero.
The bias (minor drift over temperature) is somewhat fixed and you can find it for a particular sensors datasheet, but its small but not zero.

You can use low pass / high pass filters to reject noise and the bias (respectively), or Kalman filter estimate the bias comparing it to GPS over a few minutes, but neither work very well (I've tried).

When you integrate, you end up integrating all those errors. Very small things cause meters of error.

Also when you rotate the phone, you rotate your coordinate system so finding the updated GPS position or location in a room is also compounded by the gyroscope errors AND how the gyroscope / magnetometer updates.

So many errors, so many years to fix it :)

This is a fantastic problem to try to solve, so please don't be completely discouraged, but it's not something you can do in a weekend.

Rocket science is easier, but this is a great problem to solve, one I've spent some time on. Lots of fun.

Good luck :)
 
Share this answer
 
Comments
Dave Kreskowiak 19-Dec-16 16:44pm    
Good luck? You know this question is FIVE YEARS OLD, right? I doubt the OP is still looking for an answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900