problem is that the heading is not comosated. when i did a roll or a pitch the value of the heading change, so i want to fix this prblem, i want the value of heading stay correct event i did a pitch or a roll.
thanks
is there something wrong with the formula ??
i'mo working on autonomous flight so i need the correct value of heading, please helpe
i tried to use this formula "m for the magnet field"
float Yh = my * cos(pitch) - mz * sin(pitch);
float Xh = mx* cos(roll) + mz * sin(pitch) * sin(roll) + mz* (pitch) * sin(roll);
heading = atan2(Yh, Xh);
if (heading < 0) heading += 2 * M_PI;
i tried a lot of test but idid'nt recognize the probleme
here it is my test
when the heading is between 250 and 300 degrees. the tilt composation works fine when i do a negative ROLL. but if a do a positive ROLL or positive and negative PITCH it does'nt composate. when the heading is on 0 degrees, the tilt composaton works fine when i do a negative PITCH. but if a do a positive PITCH or positive and negative ROLL it does'nt composate.
is there something wrong with the formula
please help
thanks you for the idea. i did some change and now the heading is a litle bit componsated but still getting error and i think is due to the calibartion. i didn't finde a code that calibarte my magnetometer.
could you help me how to code the calibartion of hmc5883l please