### Deeply confused by the earth to body frame conversion code...

Hi all~

I am very confused by the earth to body frame conversion code when I compare it with the frame conversion matrix that I found on the pixhawk website. Could someone please help me out... I cannot believe how much time I have wasted on this... Many thanks!

What are the exact definitions of "earth frame" and "body frame"?

earth frame = inertial frame?

body frame = body-NED frame? Or body-fixed frame?

The conversion code is here:

https://github.com/diydrones/ardupilot/blob/ArduCopter-3.2.1/libraries/AC_AttitudeControl/AC_AttitudeControl.cpp

Line 425

// earth-frame <-> body-frame conversion functions
//
// frame_conversion_ef_to_bf - converts earth frame vector to body frame vector
void AC_AttitudeControl::frame_conversion_ef_to_bf(const Vector3f& ef_vector, Vector3f& bf_vector)
{
// convert earth frame rates to body frame rates
bf_vector.x = ef_vector.x - _ahrs.sin_pitch() * ef_vector.z;
bf_vector.y = _ahrs.cos_roll()  * ef_vector.y + _ahrs.sin_roll() * _ahrs.cos_pitch() * ef_vector.z;
bf_vector.z = -_ahrs.sin_roll() * ef_vector.y + _ahrs.cos_pitch() * _ahrs.cos_roll() * ef_vector.z;
}

The frame conversion matrix that I am referring to is here:

http://www.pixhawk.org/dev/know-how/frames_of_reference

Based on this matrix, I was expecting something like (take the x-axis as an example):

bf_vector.x = _ahrs.cos_pitch() * ef_vector.x - _ahrs.sin_pitch() * ef_vector.z;

### Activity

RT @chr1sa: We've got another virtual @DIYRobocars race tomorrow at 9:00am PT. Two dozen autonomous cars will compete, four at a time. Ther…
Sep 4
sam liked Jimmy Oliver's profile
Aug 25
RT @ExplorerRobocar: Sometimes, I am really a big kid!! Having fun with my virtual RC car on the @diyrobocars track 😜😉, by using the « AR R…
Aug 24
RT @grepLeigh: @donkey_car @unity3d @TensorFlow ~1050 episodes into training, my agent learned to erratically drive in the left lane. 🤖😆 ht…
Aug 24
RT @EclipseCyclone: Sweet! http://Robotec.ai high performance #ROS 2 @unity3d #CycloneDDS bridge for @AutowareFdn @SVLSimulator now…
Aug 24
RT @a1k0n: My car had a lot of trouble getting around the track at the last @diyrobocars event -- only one actual finished lap during the r…
Aug 24
RT @SmallpixelCar: This is the run time map https://t.co/VzykOkUt2G
Aug 24
RT @SmallpixelCar: Made a lot progress on Warm Spring Raceways track. Almost finished one lap. https://t.co/nUVpufZQyP
Aug 24