## Crazyflie 2 body frame of reference

Firmware/software/electronics/mechanics
asr
Beginner
Posts: 15
Joined: Sun May 31, 2020 3:07 am

### Crazyflie 2 body frame of reference

I had assumed that the Crazyflie's body frame followed a standard right-hand rule coordinate system, with the positive x-axis pointing forward along the CF's longitudinal axis, the y-axis pointing left along the CF's lateral axis, and the z-axis pointing up, similar to the image below:
Similarly, I had also assumed that positive roll, pitch and yaw rotations were given by counter-clockwise rotations about the x, y and z axes respectively. However, after looking at some parts of the controller code, and how the final motor mixing is done, it seems that this is not the case. An example is the mixing of the pitch commands, in the powerDistribution() function, which indicates that a positive pitching moment causes the quadrotor to pitch its nose upwards. However, this is opposite to that assumed by the right-hand coordinate system given in the image above, which would have a positive pitch rotation being counter-clockwise about the y-axis, causing the Crazyflie to pitch its nose downwards. As such, it seems like there are two possibilities for how the Crazyflie's body frame is aligned:

1) If the body frame follows a standard right-hand coordinate system with x-axis forward, y-axis left, and z-axis up, then a positive pitch is being regarded as a clockwise rotation about the y-axis in the code, instead of the standard counter-clockwise rotation about axes that is assumed in right-hand coordinate systems
2) If we are using the right-hand thumb rule to consider rotations about axes, then if a positive pitch is being regarded as a counter-clockwise rotation about the y-axis in the code, then the y-axis must be pointing right instead of left. In this case we wouldn't have a standard right-hand coordinate system.

Instead of scratching my head for hours and working off potentially incorrect assumptions, I wanted to ask where I could find a document or online link that explains the Crazyflie's coordinate system in more detail. This would make development a lot easier, and would limit erroneous code due to incorrect coordinate system assumptions being made. Any help would be appreciated, thanks!
Last edited by asr on Wed Jul 29, 2020 5:36 pm, edited 2 times in total.
kimberly
Bitcraze
Posts: 523
Joined: Fri Jul 06, 2018 11:13 am

### Re: Crazyflie 2 body frame of reference

You are absolutely right. The pitch rotation only is left hand thumb rule while the rest is right-hand.

Why... I guess the ones that originally implemented this can answer that one. All I can say that the crazyflie was not designed in the regular aerosp conventions but more of what seemed logical, which can seem not logical for those who are used to something different (myself included). My guess is that the East North Down coordinate system seemed more logical, which required the pitch to be negative when going up according to the right-thumb rule, which is maybe not intuitive in terms of controlling the crazyflie manually...

Anyway, I made this page on the website since you are right that it should be there somewhere (The LPS tutorial only shows the global coordinate system)
asr
Beginner
Posts: 15
Joined: Sun May 31, 2020 3:07 am

### Re: Crazyflie 2 body frame of reference

Thanks Kimberly, this clears up a lot of things!