2014-04-18 10:15 AM
In the Demo code for the stm32f3discovery the Rollang calculation appears to be incorrect.
The author chose to use the acos function and apply quadrant correction instead of using atan2(x,y) function which handles the sign of the two terms.the code linefCosRoll = sqrt(1.0-(fSinRoll * fSinRoll));will always be a positive number.The quadrant test will always take the the postive branch in this code, if (fCosRoll>0) { RollAng = acos(fCosRoll)*180/PI; } else { RollAng = acos(fCosRoll)*180/PI + 180; }The calculated value for RollAng will always be positive since fCosRoll is always positive.Is my logic correct? Has this been brought up before? Is there any revised code from st?