### RMAT utilization for display of roll and pitch

HI all,I m on developing a GCS on the basis of rotation matrix elements. Is it possible to display the roll and pitch on the basis of rotation matrix at the output . I m using Bill's UAV DEVboard and getting rmat data at output .After little analysis i have got few reference to calculate the euler's angle from the rmat data. So i have got these formulas for calculation.g=atan2(rmat[7],rmat[8]); // rolla=atan2(rmat[3],rmat[0]); // yawb=atan2( -rmat[6],sqrt(rmat[7]^2 + rmat[8]^2)); // pitchthis is what i got , but as i rotate my board roll and yaw results r quite satisfactory , but pitch doesnot make a logic. Is there any mistake in calculations.I have also gone thru jordi IMU code in which he calculated these parameters like thisSerial.print("RLL:");Serial.print(ToDeg(atan2(DCM_Matrix[2][1],DCM_Matrix[2][2])));Serial.print(",PCH:");Serial.print(ToDeg(asin(DCM_Matrix[2][0])));Serial.print(",YAW:");Serial.print(ToDeg(atan2(DCM_Matrix[1][0],DCM_Matrix[0][0])));1.Are these angles can be used to show the roll and pitch of plane?2. Is the format of RMAT is different in both codes?Thanks

#### Replies

• T3
Viky,

Try this:

g=atan2(rmat[6],rmat[8]); // roll
a=atan2(rmat[3],rmat[0]); // yaw
b=atan2( -rmat[7],sqrt(rmat[6]^2 + rmat[8]^2)); // pitch

Bill
• T3
Viky,

Jordi and I use two different coordinate systems, that is the problem.

When I started, the coordinate system I used was based on the labeling that SparkFun put on the board, and the way the board would normally be mounted: X positive is toward the left wing. Y positive is toward the nose. Z positive is down.

After my board and firmware was done, Paul Bizard pointed out to me that the aviation standard is X positive is toward the nose, Y positive is toward the right wing, and Z positive is down. But it was too late, and too confusing for me to change. (When I do any coding, I look at the labels on the board.)

Jordi asked for my help in developing his IMU firmware, we decided to use the aviation standard, since he was still free to select his hardware design and axis labeling.

So, your equations are probably inconsistent with my implementation. Certainly you cannot use Jordi's equations with my rmat.

I think that you can use Jordi's equations if you swap the X and Y rows and columns of my rmat and put the results into Jordi's equations.

Regarding the format, the rmat values in my firmware are stored as scaled signed integers. The scaling is such that the real values of + or - 1 are mapped to the integer values of + or - 16384.

Let me know if you are able to rearrange your equations to match the coordinate system that I used. I think that you will be able to do it, if not, let me know, I will give it a try.

I apologize for not using the same coordinate system for both my IMU and when I helped Jordi.

Best regards,
Bill
• Hi,

I thing that to have de right angle you need to know witch is the order of the euler angles you need regarding to the physics of you gimball.

if the gimball . is suspend you will have
- first a yaw rotation around Y
- then a tilt rotation around x
- then a roll but this angle is not need if your gimball do not compensate roll.

so , you just need to do the math multiplying the 3 rotation matrix.
and from there extract the angles .

Best regards

Sandra