Gyroscope: read pitch, roll, yaw instead of angular velocity.

Currently, to read the attitude of an iOS device, Corona lets us read event rotation in x,y,z from the gyroscope. That is, we can read event.xRotation, multiply it by event.deltaTime, and then calculate the change in the X rotation.

However, this method does not deal with the gyroscope drift, which rather significant! That is, the gyro is drifting easily 1 degree per second. If you put down your device, you can watch the values change even though the device is not moving.

I have read that iOS also provides pitch, roll, and yaw readings.
See: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html
One reads (assuming one has nothing better to do, such as yanking one’s teeth with a rusty nail puller):
“A CMDeviceMotion object encapsulates processed device-motion data that derives from both the accelerometer and the gyroscope. Core Motion’s sensor fusion algorithms process both accelerometer and gyroscope data and provide an application with highly accurate measurements of device attitude, the (unbiased) rotation rate of a device, the direction of gravity on a device, and the acceleration that the user is giving to a device. A CMAttitude object, which is contained in an CMDeviceMotion instance, contains properties giving different measurements of attitude, including the Euler angles indicated by roll, pitch, and yaw.”
Elsewhere on the Web I found this comment:

"Did you try using the pitch, roll, and yaw instead of calculating (angular velocity*time) yourself? I’m seeing some drift, but not at 1 degree a second. It’s rock-steady when standing still and only drifts a degree or so if I spin around in place a few times. It was surprisingly accurate.

“Yes there is a way to access the actual Euler angles (pitch, roll, yaw) through the API. It’s called device motion. Instead of calling for CMMotionManager to start gyro updates, call startDeviceMotionUpdates. Then you can access all device motion including Euler angles, prefiltered gravity, prefiltered acceleration, and so on. The drift on these measurements is very small. It drifts a barely noticeable amount only when moving it fast, and this can be reset periodically with some filtered compass readings if needed. Check out the docs for CMMotionManager and follow the links to the contents of the deviceMotion property. Its a little confusing because they’re using a combination of structs and classes, but its not too bad. For Euler angles check out the attitude class. I think its CMAttitude.”
In other words, Corona could be feeding us pitch, roll, and yaw, and iOS uses some nifty calculations to make these “rock steady”.

Please, can we get these values? It would greatly improve the system!!! I need it to show virtual reality imagery. [import]uid: 37366 topic_id: 19314 reply_id: 319314[/import]

Any updates on this? I’d be interested in what’s happening as I see the same gyroscope only drift.

Or is there another fancy formula to use that we can implement in Corona ourselves to put the gyroscope and accelerometer data together? [import]uid: 42145 topic_id: 19314 reply_id: 77191[/import]

I’m sure there isn’t. I looked into the math, etc., and it’s mega complicated. We await the Corona team reading this and giving us access to the “proper” values. [import]uid: 37366 topic_id: 19314 reply_id: 77192[/import]

I ended up up adding a filter to the changes, such that it had to be more than a degree of change before I did anything. Not good for small movements, but works great for my purpose to remove that little bit of drift. [import]uid: 42145 topic_id: 19314 reply_id: 78337[/import]

I need this feature also. Otherwise the deviation is too big
For now I’ll try to recalculate the orientation with the accelerometer at some interval [import]uid: 76413 topic_id: 19314 reply_id: 86940[/import]

Old topic: just checking that there are no news on this… ?  Or solutions?  Have anyone tried the dumb way of pulling gyroscope data and see if the drift is constant with time and subtract a constant to each angle change?  Dirty and hardware specific but easier than a Kalman filter :slight_smile:

Old topic: just checking that there are no news on this… ?  Or solutions?  Have anyone tried the dumb way of pulling gyroscope data and see if the drift is constant with time and subtract a constant to each angle change?  Dirty and hardware specific but easier than a Kalman filter :slight_smile: