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

Remove mode_req_local_alt from Descend mode and handle it in FW position controller #23840

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/modules/commander/ModeUtil/mode_requirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ void getModeRequirements(uint8_t vehicle_type, failsafe_flags_s &flags)
// NAVIGATION_STATE_DESCEND
setRequirement(vehicle_status_s::NAVIGATION_STATE_DESCEND, flags.mode_req_angular_velocity);
setRequirement(vehicle_status_s::NAVIGATION_STATE_DESCEND, flags.mode_req_attitude);
setRequirement(vehicle_status_s::NAVIGATION_STATE_DESCEND, flags.mode_req_local_alt);
setRequirement(vehicle_status_s::NAVIGATION_STATE_DESCEND, flags.mode_req_prevent_arming);

// NAVIGATION_STATE_TERMINATION
Expand Down
13 changes: 13 additions & 0 deletions src/modules/fw_pos_control/FixedwingPositionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,12 @@ FixedwingPositionControl::control_auto_fixed_bank_alt_hold(const float control_i
_att_sp.thrust_body[0] = min(get_tecs_thrust(), _param_fw_thr_max.get());
}

// Special case: if z or vz estimate is invalid we cannot control height anymore. To prevent a
// "climb-away" we set the thrust to 0 in that case.
if (!_local_pos.z_valid || !_local_pos.v_z_valid) {
_att_sp.thrust_body[0] = 0.f;
}

const float pitch_body = get_tecs_pitch();
const Quatf attitude_setpoint(Eulerf(roll_body, pitch_body, yaw_body));
attitude_setpoint.copyTo(_att_sp.q_d);
Expand Down Expand Up @@ -1001,6 +1007,13 @@ FixedwingPositionControl::control_auto_descend(const float control_interval)
const float yaw_body = 0.f;

_att_sp.thrust_body[0] = (_landed) ? _param_fw_thr_min.get() : min(get_tecs_thrust(), _param_fw_thr_max.get());

// Special case: if vz estimate is invalid we cannot control height rate anymore. To prevent a
// "climb-away" we set the thrust to 0 in that case.
if (!_local_pos.v_z_valid) {
_att_sp.thrust_body[0] = 0.f;
}

const float pitch_body = get_tecs_pitch();
const Quatf attitude_setpoint(Eulerf(roll_body, pitch_body, yaw_body));
attitude_setpoint.copyTo(_att_sp.q_d);
Expand Down
Loading