From ab10e68a40bf659e659d00443acd8a9d11a96c65 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 9 Apr 2021 17:50:09 +0200 Subject: [PATCH] update Quadchute trigger from mavlink PR 1569 --- msg/vtol_vehicle_status.msg | 1 - src/modules/vtol_att_control/vtol_att_control_main.cpp | 1 + src/modules/vtol_att_control/vtol_att_control_main.h | 3 +++ src/modules/vtol_att_control/vtol_type.cpp | 8 ++++---- src/modules/vtol_att_control/vtol_type.h | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/msg/vtol_vehicle_status.msg b/msg/vtol_vehicle_status.msg index 48d87fd702..7bc79768b5 100644 --- a/msg/vtol_vehicle_status.msg +++ b/msg/vtol_vehicle_status.msg @@ -4,7 +4,6 @@ uint8 VEHICLE_VTOL_STATE_TRANSITION_TO_FW = 1 uint8 VEHICLE_VTOL_STATE_TRANSITION_TO_MC = 2 uint8 VEHICLE_VTOL_STATE_MC = 3 uint8 VEHICLE_VTOL_STATE_FW = 4 -uint8 VEHICLE_VTOL_STATE_QC = 5 uint64 timestamp # time since system start (microseconds) diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index 0cf205742f..88978c53e8 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -160,6 +160,7 @@ void VtolAttitudeControl::vehicle_cmd_poll() } else { _transition_command = int(vehicle_command.param1 + 0.5f); + _immediate_transition = int(vehicle_command.param2 + 0.5f); } if (vehicle_command.from_external) { diff --git a/src/modules/vtol_att_control/vtol_att_control_main.h b/src/modules/vtol_att_control/vtol_att_control_main.h index d0dc23b427..46c8455858 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.h +++ b/src/modules/vtol_att_control/vtol_att_control_main.h @@ -109,6 +109,8 @@ public: bool is_fixed_wing_requested(); void quadchute(const char *reason); int get_transition_command() {return _transition_command;} + bool get_immediate_transition() {return _immediate_transition;} + void reset_immediate_transition() {_immediate_transition = false;} struct actuator_controls_s *get_actuators_fw_in() {return &_actuators_fw_in;} struct actuator_controls_s *get_actuators_mc_in() {return &_actuators_mc_in;} @@ -222,6 +224,7 @@ private: * for fixed wings we want to have an idle speed of zero since we do not want * to waste energy when gliding. */ int _transition_command{vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC}; + bool _immediate_transition{false}; VtolType *_vtol_type{nullptr}; // base class for different vtol types diff --git a/src/modules/vtol_att_control/vtol_type.cpp b/src/modules/vtol_att_control/vtol_type.cpp index 2f17c703d6..cebc96b382 100644 --- a/src/modules/vtol_att_control/vtol_type.cpp +++ b/src/modules/vtol_att_control/vtol_type.cpp @@ -235,16 +235,16 @@ bool VtolType::can_transition_on_ground() void VtolType::check_quadchute_condition() { - if (_attc->get_transition_command() == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_QC && !_quadchute_command_treated) { - _attc->quadchute("QuadChute by command"); + if (_attc->get_transition_command() == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC && _attc->get_immediate_transition() + && !_quadchute_command_treated) { + _attc->quadchute("QuadChute by external command"); _quadchute_command_treated = true; + _attc->reset_immediate_transition(); } else { _quadchute_command_treated = false; } - - if (!_tecs_running) { // reset the filtered height rate and heigh rate setpoint if TECS is not running _ra_hrate = 0.0f; diff --git a/src/modules/vtol_att_control/vtol_type.h b/src/modules/vtol_att_control/vtol_type.h index 7334611298..64bd48f128 100644 --- a/src/modules/vtol_att_control/vtol_type.h +++ b/src/modules/vtol_att_control/vtol_type.h @@ -250,7 +250,6 @@ protected: bool _quadchute_command_treated = 0; - /** * @brief Sets mc motor minimum pwm to VT_IDLE_PWM_MC which ensures * that they are spinning in mc mode.