How to calculate Roll, Pitch?

Hello Everyone,

I’d like to know how to calculate roll, pitch by SITL.
I’ve used the formula below to calculate the value respectively.

pitch = 180 * atan2(accelX, sqrt(accelY*accelY + accelZ*accelZ))/PI;
roll = 180 * atan2(accelY, sqrt(accelX*accelX + accelZ*accelZ))/PI;

I used the input value like below regarding RAW_IMU.


but, the result of a formula is “90”, “90” which is not close enough with roll, pitch described in RAW_IMU


Could anyone let me know how to get roll, pitch values with xacc, yacc, xacc?

Thanks for the reply in advance.