Skip to content

Commit

Permalink
FW Position Control: handle invalid z or vz measurement in case of na…
Browse files Browse the repository at this point in the history
…v_state DESCEND

Signed-off-by: Silvan Fuhrer <[email protected]>
  • Loading branch information
sfuhrer committed Oct 22, 2024
1 parent 6dfe951 commit e234b58
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit e234b58

Please sign in to comment.