Android/ iOS how to determine small changes in distance using sensors? - iphone

I have been doing a bit of research, but I cannot seem to find a way to determine small distances (centimeters and meters) using the sensors in Android or iOS devices.
Bluetooth appears too inaccurate and require more than one device, GPS only works over larger variations in distance, and small variations in rotation seem to make using the accelerometer nearly impossible.
Is there a method that I am unaware of that would allow me to do such a thing? I am familiar with Calculus, so using Integrals to determine distance based on changes in time and velocity/ acceleration is not a problem for me, I just do not know how to determine those things.
Thank you.

There's no sensor in these devices which is able to give you the desired accuracy without exterior help.
If your use case allows for a bit of external setup, here are some ideas:
You could use the camera and computer vision to calculate device movement. You could, for example, use ARToolkit to measure the distance to a visual tag fixed to a wall. In close distances you can get pretty high accuracy (mm) using this technique.
Another idea would be to measure the distance to a solid object, like a wall, by emitting a short audio signal using the speaker and measure the time until the echo arrives at the microphone. This would be more of a research project, though.

You CAN use the accelerometer to measure distance travelled
(if ONLY absolute displacement is involved).
Have the user hold the device flat and walk from pointA to pointB.
The user presses a "Start" button in ur app as he starts from A and
presses an "End" button in ur app as he reaches B.
Calculate the double-intergral of AccelX & AccelY seperately over time
between the 2 button presses. These will be distX & distY respectively.
Total displacement will be sqrt( (distXsquared) + (distY squared) ).
GoodLUCK!!
Regards
CVS#2600Hertz

Just as a thought experiment, you should be able to do this using a combination of the accelerometer and the compass on each device.
However, whether the accuracy of these sensors is enough for what you want to do...well I think you'd just have to try it.

Related

Get distance height with accelerometer

I have searched for hours now and still didn't find a definitive answer to my problem.
The scenario is this: the user throw an iPhone as high as he can and I want to measure the height that the iPhone has done.
I want to use the accelerometer with Core Motion and I successfully implemented a simple system that gives me the acceleration on the 3 axis. This is an acceleration though.
Based on my physics knowledge, the formula to calculate the maximum height is (V0^2)/2*g where V0 is the starting velocity.
I have the acceleration velocity though.
Any idea how can I convert the acceleration to velocity or directly get the velocity from my accelerometer?
I know it's not a completely programming related question, but I just want to have some help on this :)
First of all there is alredy an app that does exactly what you are up to: Send Me To Heaven. You won't find it in Apple's App Store because it never passed the review, guess why ;-)
As you stated you only have access to accelerations. h = v02/(2*g) is correct. To get the starting velocity v0 you need to integrate the acceleration numerically over the time. The trickiest part will be to find necessary and sufficient conditions to determine the time interval [t1, t2]. When did the acceleration phase start and when did it stop.
Another thing to consider is to avoid cheating users who just perform a rotation around there axis for a couple of seconds, then simulate the flying phase. There you might consider the landing phase too: when the user grabs the device you should register a strong deceleration.
However, don't expect this app to ever get in the store and at Google Play the competitors were faster.
Problems:
There's a number of problems physics impose on you (other than the velocity), to get the result.
The angle of the throw, relative to the direction of gravity. You cant know the relative vertical distance, unless you know this angle.
Orientation of reference throughout the throw (you cannot deduct the speed from the acceleration, from the device itself, unless you account for the changes in rotation while the phone accelerates).
However! You can decide to assume certain things, which will make these annoying problems go away!
Reasonable assumption:
The device is caught again, at the same relative height it was thrown.
This assumption reduce the problem to a much simpler one, in which we only really need to find the duration of time, where the device is in free fall, in order to determine the relative height of the throw.
All you have to do:
To determine if the device is in free fall, is relatively easy, since the total gravity would be near 0 m/s^2.
However, there's still one smallish problem to this, because the accelerometer is probably not located at the center of mass of the phone, so it will experience a constant acceleration (if the phone rotates around itself) in exactly one particular direction, throughout the free fall.
The maths of determining the height of a vertical throw, based on the airtime duration is left as an exercise to the reader :-)

How can I detect if the user is walking/running with his device?

simple question hard answer:
I'd like to be able to read if the device (and the user) is running/walking holding his device. I know that the iPhone accelerometer calculates acceleration so if the user runs at a constant speed, there will be no signal spotted.
Any help on that ?
I actually used to work on that...what you can do is to detect with the accelerometer and gyro the frequency of the movement. If you plot a chart, you will see a periodic behavior when you walk or run. Do some "field" testing and you could see how those frequency change between walking and running. It's pretty cool.
Try dynamic time warping (DTW).
First, you build a small "database" of motions that you would like to recognize.
Then, in your application you compare the current sensor readings with DTW to the ones in the database and pick the most similar one.

accelerometers uses- smartphone

It is known that the raw accelerometer data is combination of both linear acceleration and gravity. In order to isolate them w need to apply appropriate filters. I would like to know the real time applications where we would need only "gravity" or only "linear acceleration".
Gravity is used when you are trying to figure out the orientation of the phone. In other words, when you are trying to figure out how the user holds the phone. It is good for tilt games, for example you use the phone to drive a car, etc.
Linear acceleration is used when you are trying to figure out how the phone is shaken. It good for shaking games.
I highly recommend this video. In particular, between 4:15-6:10 and staring from 33:30 you see demos.

Detecting movement with an iphone

Can the iphone detect its movement in terms of distance?
Would one be able to use a built in function on an iphone to determine the distance the phone has moved so that the speed of movement can be calculated?
Basically my question is
can an iphone detect its position and distance moved without using the gps?
thanks
You probably could with some clever math.
Basically, integrate over the accelerometer data.
For all the details, see http://www.freescale.com/files/sensors/doc/app_note/AN3397.pdf
No, the only sensor that the device has that can calculate "distance" is via the Location API, which will make use of the GPS. Accelerometer and gyros (in iPhone 4) can give precise measurements of changes in orientation, but not distance travelled.
Not easily, there are a couple of ways you can do this but they have severe limitations and you'll have to write all the code yourself.
One way is to use the accelerometer and try and calculate the distance from the forces on the phone, this is never going to be very reliable.
Another way is to use wifi, essentially looking at the signal strength to determine distance from the router (I think this is only possible using private APIs and requires several routers to be at all accurate). Or listen from a router to find out how far away the iPhone is.

IPhone Accelerometer Determine Motion

Using the accelerometer output, how do I determine if the user (iphone mounted on waist) is walking?
Looking for a good algorithm to determine if the user is walking to determine activity transitions- standing-to-walking or walking-to-standing.
please help.
Thank you for your time.
For a previous project, I tried calculating the magnitude of the acceleration vector, and just setting a threshold of about 2g, and that worked pretty well in testing. A typical (hardware) pedometer will ignore single jolts that happen more than about a second apart, which seems like a good way to filter out occasional movement that isn't "walking".
Additionally, you could automatically adjust the threshold by examining the data for a while.