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

RTL: cone: never climb more than to RTL_RETURN_ALT #23558

Merged
merged 1 commit into from
Aug 19, 2024
Merged
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
7 changes: 4 additions & 3 deletions src/modules/navigator/rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,14 @@ float RTL::calculate_return_alt_from_cone_half_angle(const PositionYawSetpoint &
// avoid the vehicle touching the ground while still moving horizontally.
const float return_altitude_min_outside_acceptance_rad_amsl = rtl_position.alt + 2.0f * _param_nav_acc_rad.get();

float return_altitude_amsl = rtl_position.alt + _param_rtl_return_alt.get();
const float max_return_altitude = rtl_position.alt + _param_rtl_return_alt.get();

float return_altitude_amsl = max_return_altitude;

if (destination_dist <= _param_nav_acc_rad.get()) {
return_altitude_amsl = rtl_position.alt + 2.0f * destination_dist;

} else {

if (destination_dist <= _param_rtl_min_dist.get()) {

// constrain cone half angle to meaningful values. All other cases are already handled above.
Expand All @@ -549,7 +550,7 @@ float RTL::calculate_return_alt_from_cone_half_angle(const PositionYawSetpoint &
return_altitude_amsl = max(return_altitude_amsl, return_altitude_min_outside_acceptance_rad_amsl);
}

return max(return_altitude_amsl, _global_pos_sub.get().alt);
return constrain(return_altitude_amsl, _global_pos_sub.get().alt, max_return_altitude);
}

void RTL::init_rtl_mission_type()
Expand Down
Loading