Monday, February 13, 2012

[android-developers] Orientation of de device while the screen it's not facing the user

Hi all!
        What I'm trying to achieve is calculate if a runner is running, stopping, etc. (and I can't use the GPS), where the runner can have the device in different positions (portrait facing the user, portrait facing the user, upside down, not facing the users, etc.
       
        I must know which axle is the one parallel to the floor in order to check if there is any acceleration or deceleration and not check on other axle and get an acceleretion/deceleration when the device is really just "jumping" with the runner, meaning I checked the wrong axle. 

        I'm trying to get the orientation of the device in every position it might be. I'm not using the TYPE_ORIENTATION sensor as it is deprecated, I'm using acceleration and magnetic sensor values or rotation_vector sensor, in that way I can get the rotation matrix, Once I have it, if the screen if facing the user I can get azimuth, pitch and roll remapping the coordinate system, knowing the X and Y axles with this table:

ROTATION_0

X

Y

ROTATION_90

-Y

X

ROTATION_180

-X

-Y

ROTATION_270

Y

-X


I get the rotation with getDefaultDisplay().getRotation()

Now, If the device if flat on the table, What will the getRotation retrieve?  What if I rotate it while it's flat on the table? What should I be sending to the the remapCoordinateSystem?

Is this ok?

ROTATION_0

X

Z

ROTATION_90

Z

-X

ROTATION_180

-X

-Z

ROTATION_270

-Z

X

BTW, getRotationMatrix documentation says that I must send gravity values, but everyone is sending accelerometer values (which are acceleration + gravity), 

If the device has TYPE_GRAVITY sensor, Should I send its values instead TYPE_ACCELEROMETER sensor values?

Thanks in advance! Guillermo.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment