### 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
This reply was deleted.

### Activity

DIY Robocars via Twitter
7 hours ago
DIY Robocars via Twitter
RT @breadcentric: Bingo card for AWS DeepRacer Finale, starting in 10 minutes on https://www.twitch.tv/aws ! #AWSDeepRacer #DeepRacer #Machin…
11 hours ago
DIY Robocars via Twitter
RT @NVIDIAEmbedded: It's #NanoFriday - the RB-0 uses the same suspension concept as #NASA's newer differential-bar rovers. This educational…
11 hours ago
DIY Robocars via Twitter
RT @chr1sa: On May 22, we're returning to in-person AI @DIYRobocar racing at @circuitlaunch. The Amazon @awscloud DeepRacer team will be pr…
Wednesday
DIY Robocars via Twitter
RT @breadcentric: On my CV: Hobbies: Training bananas to race on tracks #AWSDeepRacer #DeepRacer https://t.co/MKe14hNyux
Wednesday
DIY Robocars via Twitter
RT @breadcentric: See how the April AWS DeepRacer races have ended and a couple bits of news: https://blog.deepracing.io/2021/05/09/aws-deepracer-league-2021-update-11-end-of-april-special/ #AWSDeepRacer #Machin…
Monday
DIY Robocars via Twitter
RT @sunilmallya: Representation Learning +Instance Transfer to learn new reward functions along with advantage based filtering of new exper…
Monday
DIY Robocars via Twitter
Apr 27
DIY Robocars via Twitter
Apr 27
DIY Robocars via Twitter
RT @f1tenth: Sliding (autonomously) into the weekend like ... 🤖😎 #f1tenth #robots #AutonomousVehicles @OpenRoboticsOrg @NVIDIAEmbedded @Aut…
Apr 25
DIY Robocars via Twitter
RT @chr1sa: One of the problems with autonomous car racing is that watching software drive is not a very exciting spectator sport. To help…
Apr 25
DIY Robocars via Twitter
RT @SmallpixelCar: Replaced AGX Xavier with @NVIDIAEmbedded Jetson Xavier NX. Now both cars look fast and clean https://t.co/jlcoY2EjZf
Apr 25
DIY Robocars via Twitter
RT @chr1sa: Yesterday we had a record number of competitors (36) in our monthly @DIYRobocars virtual autonomous car race. We kept it going…
Apr 25
DIY Robocars via Twitter
Apr 16
DIY Drones via Twitter
RT @chr1sa: After more than a year of only virtual races, @DIYRobocars returns to the newly renovated @circuitlaunch on May 22 for the resu…
Apr 11