mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
Fix quadchute logic so that it also works during back transition
This commit is contained in:
@@ -106,7 +106,19 @@ void Standard::update_vtol_state()
|
|||||||
float mc_weight = _mc_roll_weight;
|
float mc_weight = _mc_roll_weight;
|
||||||
float time_since_trans_start = (float)(hrt_absolute_time() - _vtol_schedule.transition_start) * 1e-6f;
|
float time_since_trans_start = (float)(hrt_absolute_time() - _vtol_schedule.transition_start) * 1e-6f;
|
||||||
|
|
||||||
if (!_attc->is_fixed_wing_requested()) {
|
if (_vtol_vehicle_status->vtol_transition_failsafe) {
|
||||||
|
// Failsafe event, engage mc motors immediately
|
||||||
|
_vtol_schedule.flight_mode = vtol_mode::MC_MODE;
|
||||||
|
_pusher_throttle = 0.0f;
|
||||||
|
_reverse_output = 0.0f;
|
||||||
|
|
||||||
|
//reset failsafe when FW is no longer requested
|
||||||
|
if (!_attc->is_fixed_wing_requested()) {
|
||||||
|
_vtol_vehicle_status->vtol_transition_failsafe = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if (!_attc->is_fixed_wing_requested()) {
|
||||||
|
|
||||||
// the transition to fw mode switch is off
|
// the transition to fw mode switch is off
|
||||||
if (_vtol_schedule.flight_mode == vtol_mode::MC_MODE) {
|
if (_vtol_schedule.flight_mode == vtol_mode::MC_MODE) {
|
||||||
@@ -117,21 +129,10 @@ void Standard::update_vtol_state()
|
|||||||
_reverse_output = 0.0f;
|
_reverse_output = 0.0f;
|
||||||
|
|
||||||
} else if (_vtol_schedule.flight_mode == vtol_mode::FW_MODE) {
|
} else if (_vtol_schedule.flight_mode == vtol_mode::FW_MODE) {
|
||||||
// transition to mc mode
|
// Regular backtransition
|
||||||
if (_vtol_vehicle_status->vtol_transition_failsafe) {
|
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_TO_MC;
|
||||||
// Failsafe event, engage mc motors immediately
|
_vtol_schedule.transition_start = hrt_absolute_time();
|
||||||
_vtol_schedule.flight_mode = vtol_mode::MC_MODE;
|
_reverse_output = _params_standard.reverse_output;
|
||||||
_pusher_throttle = 0.0f;
|
|
||||||
_reverse_output = 0.0f;
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Regular backtransition
|
|
||||||
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_TO_MC;
|
|
||||||
_vtol_schedule.transition_start = hrt_absolute_time();
|
|
||||||
_reverse_output = _params_standard.reverse_output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_TO_FW) {
|
} else if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_TO_FW) {
|
||||||
// failsafe back to mc mode
|
// failsafe back to mc mode
|
||||||
@@ -162,7 +163,7 @@ void Standard::update_vtol_state()
|
|||||||
if (_vtol_schedule.flight_mode == vtol_mode::MC_MODE || _vtol_schedule.flight_mode == vtol_mode::TRANSITION_TO_MC) {
|
if (_vtol_schedule.flight_mode == vtol_mode::MC_MODE || _vtol_schedule.flight_mode == vtol_mode::TRANSITION_TO_MC) {
|
||||||
// start transition to fw mode
|
// start transition to fw mode
|
||||||
/* NOTE: The failsafe transition to fixed-wing was removed because it can result in an
|
/* NOTE: The failsafe transition to fixed-wing was removed because it can result in an
|
||||||
* unsafe flying state. */
|
* unsafe flying state. */
|
||||||
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_TO_FW;
|
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_TO_FW;
|
||||||
_vtol_schedule.transition_start = hrt_absolute_time();
|
_vtol_schedule.transition_start = hrt_absolute_time();
|
||||||
|
|
||||||
|
|||||||
@@ -207,27 +207,14 @@ VtolAttitudeControl::is_fixed_wing_requested()
|
|||||||
to_fw = (_transition_command == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW);
|
to_fw = (_transition_command == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle abort request
|
|
||||||
if (_abort_front_transition) {
|
|
||||||
if (to_fw) {
|
|
||||||
to_fw = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// the state changed to mc mode, reset the abort request
|
|
||||||
_abort_front_transition = false;
|
|
||||||
_vtol_vehicle_status.vtol_transition_failsafe = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return to_fw;
|
return to_fw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VtolAttitudeControl::abort_front_transition(const char *reason)
|
VtolAttitudeControl::abort_front_transition(const char *reason)
|
||||||
{
|
{
|
||||||
if (!_abort_front_transition) {
|
if (!_vtol_vehicle_status.vtol_transition_failsafe) {
|
||||||
mavlink_log_critical(&_mavlink_log_pub, "Abort: %s", reason);
|
mavlink_log_critical(&_mavlink_log_pub, "Abort: %s", reason);
|
||||||
_abort_front_transition = true;
|
|
||||||
_vtol_vehicle_status.vtol_transition_failsafe = true;
|
_vtol_vehicle_status.vtol_transition_failsafe = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,7 +222,6 @@ private:
|
|||||||
* for fixed wings we want to have an idle speed of zero since we do not want
|
* for fixed wings we want to have an idle speed of zero since we do not want
|
||||||
* to waste energy when gliding. */
|
* to waste energy when gliding. */
|
||||||
int _transition_command{vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC};
|
int _transition_command{vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC};
|
||||||
bool _abort_front_transition{false};
|
|
||||||
|
|
||||||
VtolType *_vtol_type{nullptr}; // base class for different vtol types
|
VtolType *_vtol_type{nullptr}; // base class for different vtol types
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user