Tracking device's location in physical space using CoreMotion

I want to be able to use the motion sensors in my iPhone XS to get realtime data as to where the device is loacted in physical space. If the start of tracking is considered the origin (x=0,y=0,z=0,rotation values all 0), I want to be able to show the device's x,y,&z positions in real time, as well as its rotation. I have already figured out how to do the rotation part using the gyro (that was easy), but the translation aspect of this is causing me trouble. I thought the accelerometer's values it outputted would show how fast the device is moving in any direction, but instead it shows how many Gs are being felt in every direction. Is there a way to use this data to figure out how much the device has moved in the three axes every device motion update so I can show accurate x y and z values?

Accepted Reply

Ca't you use GPS ? Or is precision not enough ?


you can compute the new position by integrating the acceleration over time using acceleration.


Here I assume if you are not moving when you start,


At each step, in each coordinate (e.g., x axis)

dVx = Gx(t) * dt

hence Vx(t) = sum(all dVx)


dx = 0.5 * Gx(t) * dt*dt + Vx(t) * dt

where Gx(t) is the acceleration on x at time t, Vx(t) speed at time t on x

dt is the time lapse between 2 measurements


Maybe you'd better move this post to Maps & Locations forum (which deals with CoreMotion).

https://forums.developer.apple.com/community/system-frameworks/maps-and-location

Replies

What I mean by that is some number of units away from the origin point (whatever that unit is, it doesnt really matter)

Ca't you use GPS ? Or is precision not enough ?


you can compute the new position by integrating the acceleration over time using acceleration.


Here I assume if you are not moving when you start,


At each step, in each coordinate (e.g., x axis)

dVx = Gx(t) * dt

hence Vx(t) = sum(all dVx)


dx = 0.5 * Gx(t) * dt*dt + Vx(t) * dt

where Gx(t) is the acceleration on x at time t, Vx(t) speed at time t on x

dt is the time lapse between 2 measurements


Maybe you'd better move this post to Maps & Locations forum (which deals with CoreMotion).

https://forums.developer.apple.com/community/system-frameworks/maps-and-location