Using even Madgwick provided raw data, algorithm gives inaccuracies on roll and yaw when only pitch angle applied. This is also valid for our data which is collected with BMX055. We apply only pitch, the algorithm gives roll and yaw angles too. But there is a point I doubt about mathematics with positive pitch, roll&yaw show similar characteristics, with negative pitch their response similar to mirrored to each other. I'm sure about pure pitch with 1 axis motor. Why is such behaviour of the algorithm?
2 Answers
From the figure it looks like the yaw and roll angles become significant only when the pitch angle come close to +-90 deg. If pitch angle is the middle angle in the Euler angle representation for your algorithm, perhaps your algorithm calculations are running into a singularity.
Solution
- Choose a different algorithm or
- A different representation of attitude other than Euler angles or
- Don't operate your platform (aircraft / quad copter / other) at high pitch angles.
Edit
OP has commented
Algorithm works in quaternion base in its math. Euler only represantation, after getting quaternion. So Euler post-processed.
The conversion from quaternion to Euler also has singularity / gimbal lock. The conversion equation taken from Wikipedia is
$$ \begin{bmatrix}\phi \\\theta \\\psi \end{bmatrix} = \begin{bmatrix} \arctan{\frac {2(q_{0}q_{1}+q_{2}q_{3})}{1-2(q_{1}^{2}+q_{2}^{2})}} \\ \arcsin(2(q_{0}q_{2}-q_{3}q_{1})) \\ \arctan{\frac {2(q_{0}q_{3}+q_{1}q_{2})}{1-2(q_{2}^{2}+q_{3}^{2})}}\end{bmatrix} $$
At pitch angle \$\rightarrow 90\$ deg, \$q_2 \rightarrow sin(90/2)\cdot1 = \frac{1}{\sqrt2}\$. The denominator in the calculation of \$\psi\$ becomes
$$ 1-2(q_{2}^{2}+q_{3}^{2}) = 1 - 2 (\frac{1}{\sqrt2^2} + 0^2) = 0 $$
Division by zero results. Using \$\arctan2\$ may stop any software error from occurring, but it doesn't solve the illposedness of the underlying problem.
-
\$\begingroup\$ Now, how to solve this problem? There're a lot of commercial products, they don't say, don't use the sensor out of +-80 degrees. \$\endgroup\$ Nov 24, 2020 at 17:01
-
\$\begingroup\$ You have indicated that the algorithm uses quaternion math inside. If is provides a quaternion as output, use it directly without converting to Euler angles. I think most (or all) navigation / guidance / control algorithms have quaternion based alternatives to Euler angle methods. Can't say more without a description of the equations used and the final application where the IMU is used. \$\endgroup\$– AJNNov 24, 2020 at 17:36
If image a plain whitch make a pitch to more then 90 or - 90 degrees as an example 180 deg. After that the plain will fly upside pown (rol chamges to 180 deg) and curse (yaw) also changes to 180 deg (plain fly back)
The points 1, 2, 3 at the picture is place where pitch had besame more than 90 or - 90 deg, the yaw and roll changes on 180 deg
arctan2(.,.)
also wont fundamentally solve the problem. \$\endgroup\$