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: No unnecessary operations #26791

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ArduCopter/mode_poshold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,17 @@ void ModePosHold::update_brake_angle_from_velocity(float &brake_angle, float vel
float brake_rate = g.poshold_brake_rate;

brake_rate /= (float)LOOP_RATE_FACTOR;
if (brake_rate <= 1.0f) {
if (brake_rate < 1.0f) {
brake_rate = 1.0f;
}

// calculate velocity-only based lean angle
if (velocity >= 0) {
if (is_positive(velocity)) {
lean_angle = -brake.gain * velocity * (1.0f + 500.0f / (velocity + 60.0f));
} else {
} else if (is_negative(velocity)) {
lean_angle = -brake.gain * velocity * (1.0f + 500.0f / (-velocity + 60.0f));
} else {
lean_angle = 0.0f;
Comment on lines -538 to +541
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this if velocity is zero the result will be lean_angle = 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When velocity is 0, it is explicitly stated whether the operation is performed or not.

}

// do not let lean_angle be too far from brake_angle
Expand Down
Loading