Accelerometer distance

I want to move objects on the iPhone screen (rectangle, circle, etc.) by moving the iPhone. For example, I move the iPhone along the X axis, and the object moves along the X axis. The same goes for the Y, Z axis.

How can i do this? Can I get an algorithm for this?

Thank.

PS: Iโ€™ve been looking for some time and it seems that this is possible with the help of an accelerometer.

+6
iphone xcode accelerometer distance
Jul 11 2018-11-11T00:
source share
3 answers

You gain a position by integrating linear acceleration twice, but the error is terrible. In practice, this is useless.

Here is an explanation of why (Google Tech Talk) at 23:20. I highly recommend this video.

However, a gyro mouse may work for your application, see between 37: 00-38: 25 in the video.

Related questions:

track small iphone movements without GPS
What is the real accuracy of the phoneโ€™s accelerometers when used for positioning?
How to calculate the movement of the phone in the vertical direction from rest?
iOS: accuracy of movement in 3D space
How to use an accelerometer to measure distance to develop Android applications
How to find the distance traveled by the gyroscope and accelerometer?

+13
Jul 11 '11 at 10:16
source share

Itโ€™s not easy to do for sure. The accelerometer reports only acceleration, not motion. You can try (numerically) integrating acceleration over time, but you will most likely encounter cumulative errors that add up and lead to inadvertent movement.

Pseudo code, clearly unverified:

init: loc = {0, 0, 0} ; location of object on screen vel = {0, 0, 0} ; velocity of object on screen t = 0 ; last time measured step: t0 = time ; get amount of time since last measurement dt = t0 - t accel = readAccelerometer() vel += accel * dt ; update velocity loc += vel * dt ; update position displayObjectAt(loc) 
+3
Jul 11 2018-11-11T00:
source share

Why arenโ€™t you using acceleration itself, but the distance is moved? For example; If your acceleration is 1.4G east, your object should go east 14pixels per second until your acceleration changes.

Thus, the movement of the object will look like it is under relative strength, and I think it is more realistic. Fast movement of the device, more effort to create an object.

Also see:

http://www.freescale.com/files/sensors/doc/app_note/AN3397.pdf

and

Using an accelerometer, gyroscope and compass to calculate the movement of a device in the 3D world

+1
Nov 27 2018-11-11T00:
source share



All Articles