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.

views:2749 update:2011/12/27 8:54:37
corona forums © 2003-2011