quat2angle / atan2 strange quadrant change when calculating angle
조회 수: 12 (최근 30일)
이전 댓글 표시
Hi,
I'm working with IMU systems and calculating rotation angles from quaternions using the quat2angle function. I encountered a problem I believe in the atan2 function. As you can see in the first figure below the computed angle becomes negative.
In Fig1, you can see three lines:
- In blu, the angle was computed using the quat2angle function with the rotation sequence 'YZX', (it is the first output).
- In orange, the angle was computed with an Android app (Dart language).
- In dashed yellow, the angle was computed with my Dart algorithm translated into Matlab code.
I think the problem is in the atan2 function because it is used to compute the angle in my algorithm.
This behavior doesn't always happen. I have recordings where the angle computation is fine, like here:
Do you know what the reason is, and do you have a solution for it?
I have attached the files containing the quaternions of the two recordings
댓글 수: 2
David Goodmanson
2024년 2월 23일
Hi Matteo,
How do you know that your dart calculation in Matlab is the one that's incorrect? It always agrees with quat2angle so if anything the data seems to imply that the dart calculation in red is the one with the problem..
답변 (1개)
James Tursa
2024년 3월 4일
You don't show us your code, but in general I would note that angle changes like this are sometimes the result of whole quaternion sign flips. I.e., q and -q represent the same orientation, but depending on the algorithm you use when you extract angles you can get different sign flipped results. In these cases, you can sometimes fix things by ensuring that the largest magnitude element of the quaternion doesn't change sign from one sample to the next. That is, at each step beyond the first step, find the largest magnitude element and compare it to the same element in the previous quaternion. If the sign has changed, then flip the signs of all the elements of the current quaternion. Do this one step at a time to your entire stream.
참고 항목
카테고리
Help Center 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!