Gyroscope, native code


I’ve spent like 6h looking for a way to get Gyroscope data on an Android device, but looks like UE Input Motion implementation doesn’t provide the Y axis information. It gives the Rotation Rate which uses Gyroscope, but that’s not the data that I can use. Why doesn’t it provide the current Gyroscope state?

So if Epic doesn’t provide this data I should be able to get it through Java code as I did it in an AIR application using Native Extension. The problem is I have no idea what to write in Android Java, how to pack it, where to put it and what to write in UE C++, and I can’t find any introduction in the net. Please help.

bump bump bump

If I understand correctly, the motion sensors on phones only detect acceleration. Whenever you get data for rotation on iOS using the built in rotation sensor polling, for example, it’s abstracted from you that the device is actually computing it from a combination of rotation rate and gravity. And I think the gyroscope does something extra to help clean up the rotation input.

Just last week I actually was able to get the current device rotation using rotation rate. I think I’m not quite done yet since I’m not taking gravity into account and I get some unexpected results if I rotate the device around just right. Also, I get some unwanted rotation even when the device is sitting flat on my table. Hopefully taking gravity into account will help eliminate that as well. I can post the code I have tonight when I get home.

It would definitely be nice to get just the derived device rotation instead of having to get it manually.

Here’s my original post as well:

Thanks for the reply. What I understand is that you are trying to say that there is no straight forward way to get current device yaw rotation. I don’t get it. Mobile devices have gyroscopes and magnetometers. It’s easy to get magnetic north direction in Java or iOS, but I can’t do it in UE4? Why?
I don’t really understand how gravity can help in getting the yaw rotation.

Also very interested in an answer to this

I think I’ve found a good starting point for this…

Is a good white paper on how to do this.

You’ll see equation 2 and 3 on page 2 is how you figure out the Roll/Tilt (via the Gravity vector)

The Roll can then be deducted directly from the Tilt vector

Hi Community,

I’ve put out a $50 bounty, on Upwork, to get this problem finally resolved. You can see it here:

If you’re interested, please PM me or apply on Upwork.

I know it’s not much, but I’ll be sure to credit you and share your work back to the Forum/community.