4

After a lot of searching and wasted hours, I have been trying to get a stable set of roll, pitch and yaw values from an Android device using the Sensor manager. I have tried a couple of options, SensorManager.getRotationMatrix(... and also SensorManager.getOrientation(...

When I tried to get the roll, pitch and yaw values with getOrientation, the movement was smooth and desirable, however, when I got past the horizon, the rotational direction flipped making it impossible to look up.

I then tried with getRotationMatrix(..., I have mostly implemented this but the motion judders horribly even though I have interpolated the values.

I suspect that the issue with my first test was that the values that come back from getOrientation are the pitch, roll and azimuth? I would like to know if there is a way to get the devices local roll, pitch and yaw values within the closed range of [0...360] for each axis and using a system that doesn't involve gravity fields and magnetic poles.

Gary Paluk
  • 1,038
  • 1
  • 14
  • 28

1 Answers1

2

You need to low pass filter TYPE_ACCELEROMETER or use TYPE_GRAVITY and also average out the resulting value to get a stable value. See my implementation at Android getOrientation Azimuth gets polluted when phone is tilted

Community
  • 1
  • 1
Hoan Nguyen
  • 18,033
  • 3
  • 50
  • 54