Currently, I'm trying to rotate 3D Cube using orientation sensor values, using getRotation() method. Some unexpected behaviors are observed when the android device is rotated above some bounds. For instance, if I make the device 'stand up', the value of the 'roll' just becomes crazy.
Also I'm experiencing the phenomenon similar to so-called gimbal-lock. The only difference is I'm experiencing the very problem even before applying the sensor values to the 3D rotation. When I try to change the 'pitch' value by rotating the device around only 'pitch' axis, the 'yaw' value also changes according to the rotation of the pitch. It seems completely unreasonable to me.
Could somebody help me?? I'm stuck in this problem for a month.
Then in the onSensorChanged () method, through the values array of SensorEvent, you can get all the sensor values output. The orientation sensor or direction in android will record the rotation angle of the phone in all directions, as shown in the below Figure.
But unfortunately, Android has long abandoned Sensor.TYPE_ORIENTATION. For this type of sensor, although the code is still valid, it is no longer recommended. In fact, Android gets hand’s direction and angle of the machine’s rotation are calculated by the accelerometer sensor and the geomagnetic sensor. This is also the purpose of Android.
To say that another commonly used sensor in Android should be the direction sensor. Use of direction sensor in android the scene is wider than other sensors. It can accurately determine the rotation angle of the mobile phone in all directions. Use this from these angles, useful tools such as compass and horizon can be written.
The only answer is to monitor the device orientation manually using the sensor manager. I'll show you how to do that in this tutorial. Follow along with the step-by-step instructions, or download and import the project directly into Eclipse. 1. Create a new Android project in Eclipse. Target SDK 9 (Gingerbread) or better. 2.
This is a common problem with yaw, pitch and roll. You cannot get rid of it as long as you are using yaw, pitch and roll (Euler angles). This video explains why.
I use rotation matrices instead of Euler angles in my motion sensing application. For an introduction to rotation matrices I recommend:
Direction Cosine Matrix IMU: Theory
Rotation matrices work like a charm.
Quaternions are also very popular and said to be the most stable.
[This answer was copied from here.]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With