This is perhaps too near this query however I hope not.
I am engaged on an iOS app the place I would prefer to get person acceleration in North/South and East/West. So I am utilizing CoreMotion with the .xTrueNorthZVertical
body of reference. After rotating the accelerometer with the transpose of the angle rotation matrix it appears to work wonderful at first however then the built-in hint drifts off into nothing land. Which can be regular however I needed to test to see if I am doing something incorrect.
Begin motionManager
if self.motionManager.isDeviceMotionAvailable {
self.motionManager.deviceMotionUpdateInterval = 1.0 / 50.0
self.motionManager.startDeviceMotionUpdates(utilizing: .xTrueNorthZVertical)
self.motionManager.showsDeviceMovementDisplay = true
}
Then inside a timer I am getting and rotating the accelerometer with the next
// load the accel into SIMD for matrix multiplication
let userAccelSIMD = simd_double3(motionData.userAcceleration.x, motionData.userAcceleration.y, motionData.userAcceleration.z)
// get inverse of angle rotation matrix
let userAttitude = motionData.angle.rotationMatrix
let userAttitudeInverse = simd_double3x3(rows: [
simd_double3(userAttitude.m11, userAttitude.m12, userAttitude.m13),
simd_double3(userAttitude.m21, userAttitude.m22, userAttitude.m23),
simd_double3(userAttitude.m31, userAttitude.m32, userAttitude.m33)
]).transpose
// rotate acceleration into world body
let rotatedUserAccel = matrix_multiply(userAttitudeInverse, userAccelSIMD)
Under is a plot the place I combine that rotated accelerometer and evaluate it to the GPS factors. The plot additionally shows the cellphone heading for each nth accelerometer worth, we will see that the course of journey would not match the cellphone heading after some time.