This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Attitude sensor experiment has inverted euler angles
#1
dear Sirs,
I've just downloaded and tried the "Attitude sensor" experiment I found here:

https://phyphox.org/wiki/index.php/Attitude_sensor

but I've noticed that "pitch" is actually roll, "yaw" is pitch and "roll" is actually yaw. Could you please fix it and upload an updated version of the experiment?
Thanks for your support!
Best regards,
Pietro
Reply
#2
Hm, if I hold my iPhone in landscape orientation with the display facing to me, the angles are exactly as expected. This is the difficulty with Euler angles: the axes could be arbitrary — and they quickly start to mix…

If you would like to have different labels, you could simply exchange these with a text editor in the .phyphox file (“views” block).
Reply
#3
(09-06-2023, 04:28 PM)Jens Noritzsch Wrote: Hm, if I hold my iPhone in landscape orientation with the display facing to me, the angles are exactly as expected. This is the difficulty with Euler angles: the axes could be arbitrary — and they quickly start to mix…

If you would like to have different labels, you could simply exchange these with a text editor in the .phyphox file (“views” block).

Hallo Jens, thanks for replying! I might be wrong, but according to Android's notes here:

,%20float[])]SensorManager  |  Android Developers

the output of the experiment doesn't agree with that. 

As far as I know, with the phone flat and screen facing up, roll is defined about the phone's y-axis (the long axis), pitch is about the x-axis (short axis) and yaw is about the z-axis (out of the screen). As these angles defines the rotation of the phone's axes with respect to the global reference frame (i.e., gravity and magnetic North), with the phone kept vertical then roll is around the phone's z-axis, pitch around the phone's x-axis and yaw around the phone's y-axis. Basically, pitch and roll are about the horizontal axes and yaw is around gravity irrespectively of the phone's orientation (either flat or vertical).

I had a look to the xml code (thanks for the hint!) and it looks like euler angles are derived from a quaternion/rotation vector (rather than directly  from SensorManager.getOrientation)...which is fine!
But, assuming that the scalar part of the quaternion in the code is referred to as "q1" (as it is used for compute the variable named "direct" that should be the magnitude of the 3D rotation), then the formulas that output Euler angles look wrong. Quaternion multiplication formulas look wrong too. I tried to fix it according to standard math and what I got is some much conistent angles except for the fact that now rotation about the phone's y-axis is pitch and about x-axis is roll, which is strange as android tells the opposite. I could solve this just replacing roll with pitch as output name in the formula but I'd like to understand.
.phyphox   Attitude-euler_mod.phyphox (Size: 9.87 KB / Downloads: 1,122)
I'm attaching the xml I modified (using Notepad++). I wish I could contact the developer of the experiment but I couldn't find any reference.
Thanks for the support Jens!
Reply
#4
AFAICR, iOS and Android handle attitude or orientation differently, so I am not surprised that we differ from one documentation.

We will have a look at it again next week and perhaps document it better in the wiki (I am part of the phyphox team and mostly as good as a contact as Sebastian who has originally put the xml together Smile)…
Reply
#5
thanks Jens! I really appreciate it. Best, Pietro

PS: thanks for th great app you developed!!
Reply
#6
Hi Jens,
I've just realized that in this experiment quaternions (and, hence, euler angles) are derived from "Acceleration with g" input. This is probably the cause of the inconsistency I found. Question: wouldn't it be easier to retrieve euler angles directl from " SensorManager.getOrientation()"? Note that " SensorManager.getOrientation()" is normally fed by a rotation matrix. The rotation matrix comes from "getRotationMatrixFromVector()" that converts in rotation matrix the output (quaternion) provided either by SENSOR_TYPE_ROTATION_VECTOR (phone's orientation as computed using sensor fusion from acc+gyro+mag) or SENSOR_TYPE_GAME_ROTATION_VECTOR (phone's orientation as computed using sensor fusion from acc+gyro).

PS: I'm not able to write code in Java and I do not know Android platform....so I'm just guessing on the base of what I read so please forgive me in case what I've wrote does not make any sense.
Reply
#7
ok Jens,
I finally got the point!
1) the inconsistencies I found in roll, pitch and yaw are just a matter of convention as well explained here by Sebastian: https://phyphox.org/forums/showthread.ph...59#pid3559

2) your reply from another thread of mine also helped me understanding https://phyphox.org/forums/showthread.ph...59#pid3559

So the most of the questions I raised have been solved.

What I still don't understand is how the "attitude sensor" experiment by Sebastian takes "acceleration with g" as input even if it is said that it consists of "a virtual sensor provided by the manufacturer of the phone combining accelerometer, gyroscope and often the magnetometer" (type_rotation_vector or the deprecated "type_orientation"?).

Thanks, Pietro
Reply
#8
The other inputs are used elsewhere and the “attitude sensor” is still entirely the virtual sensor fusion provided by the OS. Sebastian has put two separate experiments into one file.
Reply
#9
ok got it! Good to know Jens. So why don't provide "rotation vector" as input in the drop down menu of the editor?
Chhers,
Pietro
Reply


Forum Jump: