![]() |
Attitude sensor experiment has inverted euler angles - Printable Version +- phyphox Forums (https://phyphox.org/forums) +-- Forum: App-Feedback (https://phyphox.org/forums/forumdisplay.php?fid=6) +--- Forum: Bugs and Problems (https://phyphox.org/forums/forumdisplay.php?fid=9) +--- Thread: Attitude sensor experiment has inverted euler angles (/showthread.php?tid=1795) |
Attitude sensor experiment has inverted euler angles - pietropicerno - 09-06-2023 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 RE: Attitude sensor experiment has inverted euler angles - Jens Noriʇzsɔɥ - 09-06-2023 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). RE: Attitude sensor experiment has inverted euler angles - pietropicerno - 09-06-2023 (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… 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. ![]() 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! RE: Attitude sensor experiment has inverted euler angles - Jens Noriʇzsɔɥ - 09-07-2023 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 ![]() RE: Attitude sensor experiment has inverted euler angles - pietropicerno - 09-07-2023 thanks Jens! I really appreciate it. Best, Pietro PS: thanks for th great app you developed!! RE: Attitude sensor experiment has inverted euler angles - pietropicerno - 09-12-2023 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. RE: Attitude sensor experiment has inverted euler angles - pietropicerno - 09-19-2023 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.php?tid=1758&pid=3559#pid3559 2) your reply from another thread of mine also helped me understanding https://phyphox.org/forums/showthread.php?tid=1758&pid=3559#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 RE: Attitude sensor experiment has inverted euler angles - Jens Noriʇzsɔɥ - 09-21-2023 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. RE: Attitude sensor experiment has inverted euler angles - pietropicerno - 09-21-2023 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 |