Phone angle from Gyroscope data

I’m having a bit of trouble understanding how to get the phone orientation in a human readable angle. I’ve been building test code for my Android device - but I only seem to get x,y,z acceleration or gravity values.

I’d essentially like to get a degree angle for the phone along 1 axis - can anyone help with some example code please?

Thanks, Alex [import]uid: 140429 topic_id: 27928 reply_id: 327928[/import]

I don’t have Corona or my device here at work, so I can’t test, but I suggest you take a look at this example:
http://developer.anscamobile.com/forum/2010/10/24/accelerometer-control

I believe the values you get from x/y/zInstant and x/y/zGravity are between -1 and 1. In theory, can you multiply that result by 180 and get your angle in the value of -180 to 180?

There’s also this example:
http://developer.anscamobile.com/forum/2012/04/24/help-making-object-rotate-accelerometer

I hope it points you in the right direction. If you are still having issues, I can assist when I get home from work. [import]uid: 6084 topic_id: 27928 reply_id: 113070[/import]

Thanks for the reply. That’s made a bit more sense - the acceleration on an axis due to gravity * 180 has given some better figures. I’m using event.xGravity and event.zGravity to get ‘roll’ and ‘pitch’ respectively. The data doesn’t seem perfect, but I assume this is where I’d need to build in a calibration from the base gravity, and add/subtract this from all further calculations.

Lastly, the data seems quite sluggish. Am I better using the instant values and doing my own smoothing maths?

Thanks again for your help thus far, Alex [import]uid: 140429 topic_id: 27928 reply_id: 113210[/import]

I’m not sure between Instant and Gravity, so it’s best to experiment. Also, you can change the interval to your specific needs.

http://docs.coronalabs.com/api/library/system/index.html

system.setAccelerometerInterval()
system.setGyroscopeInterval()

[import]uid: 6084 topic_id: 27928 reply_id: 113213[/import]