Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copter: Is there any problem in function euler_accel_limit()? #7327

Closed
luweiagi opened this issue Nov 30, 2017 · 6 comments
Closed

Copter: Is there any problem in function euler_accel_limit()? #7327

luweiagi opened this issue Nov 30, 2017 · 6 comments
Assignees
Labels

Comments

@luweiagi
Copy link
Contributor

luweiagi commented Nov 30, 2017

Vector3f AC_AttitudeControl::euler_accel_limit(Vector3f euler_rad, Vector3f euler_accel)

The function euler_accel_limit(...) is to translate the angle accel limitations from body frame to euler frame.

In this function, rot_accel(in euler frame) is calculated below:

rot_accel.x = euler_accel.x;
rot_accel.y = MIN(euler_accel.y/cos_phi, euler_accel.z/sin_phi);
rot_accel.z = MIN(MIN(euler_accel.x/sin_theta, euler_accel.y/sin_phi), euler_accel.z/cos_phi);

.But I can not figure it out. Whereas I think the right way is like the euler kinematical equation, just use angle accel instead of angle rate.

The euler kinematical equation is indicated below

Namely, the code may be written below:

// translates body frame acceleration limits to the euler axis
Vector3f AC_AttitudeControl::euler_accel_limit(Vector3f euler_rad, Vector3f euler_accel)
{
    // body frame angular acceleration max limitation must be positive
    euler_accel.x = fabsf(euler_accel.x);
    euler_accel.y = fabsf(euler_accel.y);
    euler_accel.z = fabsf(euler_accel.z);
	
    float sin_phi = sinf(euler_rad.x);
    float cos_phi = cosf(euler_rad.x);
    float cos_theta = constrain_float((cosf(euler_rad.y)), 0.1f, 1.0f);// prevent 1/cos_theta being infinity
    float tan_theta = constrain_float(tanf(euler_rad.y), -10.0f, 10.0f);// prevent tan_theta  being infinity

    Vector3f rot_accel;

    rot_accel.x =  fabsf(euler_accel.x + tan_theta * (euler_accel.y * sin_phi + euler_accel.z * cos_phi));
    rot_accel.y =  fabsf(euler_accel.y * cos_phi - euler_accel.z * sin_phi);
    rot_accel.z =  fabsf((1 / cos_theta) * (euler_accel.y * sin_phi + euler_accel.z * cos_phi));

    return rot_accel;
}

But my solutions still seems having some problems, because it means that the rot_accel is calculated based on this situations that body accel at three body axises is reaching the max euler_rad at the same time. It definitely does not fit the reality.

@lthall
Copy link
Contributor

lthall commented Nov 30, 2017

Hi @luweikxy,

Thanks again for going over this so thoroughly!

So the problem here is we need to calculate the acceleration limits that will not let us increase past any one individual axis acceleration limit. I think you are calculating the maximum acceleration limits possible, not the minimum that we need.

So for example, if we are banked over by 45 degrees in roll. If we ask apply full yaw then the acceleration will be shared by both the body pitch and body yaw. However, if we apply full yaw and push the pitch stick forward then that euler yaw acceleration is applied only to the body frame yaw and is increased in magnitude because the aircraft is banked by 45 degrees. So we need to limit the yaw acceleration based on this limit rather than the vector addition of both body pitch and body yaw.

I realise this is poorly worded but does it make sense?

Thanks again!

@lthall
Copy link
Contributor

lthall commented Dec 1, 2017

I have been thinking about this. Perhaps what we need to do here is look at the maximum possible acceleration in the direction of that acceleration rather than the maximum safe acceleration in each axis with no knowledge of what is happening in any other axis.

The function would need a little more information though.

@OXINARF OXINARF added the Copter label Dec 4, 2017
@IamPete1
Copy link
Member

@lthall Is there any action we should take due to this? It sounds like the there is not a problem so we should close, but maybe there is a enhancement that we could open a new issue for?

@luweiagi
Copy link
Contributor Author

luweiagi commented Mar 7, 2023

@lixiaowei123
Copy link

@lthall He wanted to ask how the formula was derived, but you didn't answer his question

@lthall
Copy link
Contributor

lthall commented Jul 28, 2023

@lixiaowei123 I don't agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants