Hi~

I am new to the attitude control method of arducopter codes. In the AC_attitude_control library,  in the function:

void AC_AttitudeControl::angle_ef_roll_pitch_rate_ef_yaw_smooth

there is a frame conversion from earth frame to body frame:

 frame_conversion_ef_to_bf(angle_ef_error, _angle_bf_error);

I am confused about this point since I think roll and pitch angles are used to describe the transforming relationship between the body frame and the earth frame, so what is the meaning of this frame conversion here? 

Thanks a lot for you help!

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hi Henry. Sorry that I don't have an answer to your question, but I have a related question and I hope that you wouldn't mind I posting it here:

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

    I thought the transformation was from NED to body-fixed, but from the code I don't think it is the case, actually I was really confused of the transformation and that's why I am searching for threads on the forum.

    //
    // 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;
    }

    Now when I compare the code with this link:

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

    I would expect something like (take the x-axis as an example):

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

    I think I am getting something wrong here... Would someone be kind enough to help me out? Many thanks~

    • I was running into the same confusion...but I think I've sorted it out. It's a terminology problem in the code.

      To me, the Euler angles (Phi, Theta, and Psi) are the set of rotations that define the transformation between the earth frame and the body frame. To go from earth to body we rotate by yaw about the z axis, then pitch about the y and finally roll about the x. To go from body to earth we undo the angular rotations in reverse order. The angles themselves aren't in one coordinate system or the other; they describe the transformations between the coordinate systems.

      But, it's important to remember that the derivatives of the Euler angles (Phi dot, Theta dot, and Psi dot) are not equal to the body axis rates (P, Q and R). This is what the "earth frame to body frame" conversion accomplishes. The attitude controller establishes a desired Euler angle (Phi, Theta, Psi), and a ultimately a target rate to get there (Phi dot, Theta dot, and Psi dot), then we need to turn those into the desired roll pitch and yaw rates (P,Q,R) for use in the inner loop PID controller. 

      P = Phi_dot - Psi_dot*sinTheta

      Q = Theta_dot*cosPhi + Psi_dot*cosTheta*sinPhi

      R = Psi_dot*cosTheta*cosPhi - Theta_dot*sinTheta

      Cheers

      Kris

This reply was deleted.

Activity