From 4f8e6a954809240a48e85b4cc060e65b23e08d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 3 Dec 2021 11:55:50 +0100 Subject: [PATCH] control_allocator: do not update params while armed As a precaution --- src/modules/control_allocator/ControlAllocator.cpp | 4 +++- src/modules/control_allocator/ControlAllocator.hpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/control_allocator/ControlAllocator.cpp b/src/modules/control_allocator/ControlAllocator.cpp index 3a740c2f30..75d22be801 100644 --- a/src/modules/control_allocator/ControlAllocator.cpp +++ b/src/modules/control_allocator/ControlAllocator.cpp @@ -270,7 +270,7 @@ ControlAllocator::Run() perf_begin(_loop_perf); // Check if parameters have changed - if (_parameter_update_sub.updated()) { + if (_parameter_update_sub.updated() && !_armed) { // clear update parameter_update_s param_update; _parameter_update_sub.copy(¶m_update); @@ -287,6 +287,8 @@ ControlAllocator::Run() if (_vehicle_status_sub.update(&vehicle_status)) { + _armed = vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED; + ActuatorEffectiveness::FlightPhase flight_phase{ActuatorEffectiveness::FlightPhase::HOVER_FLIGHT}; // Check if the current flight phase is HOVER or FIXED_WING diff --git a/src/modules/control_allocator/ControlAllocator.hpp b/src/modules/control_allocator/ControlAllocator.hpp index 12789956c6..963040df34 100644 --- a/src/modules/control_allocator/ControlAllocator.hpp +++ b/src/modules/control_allocator/ControlAllocator.hpp @@ -173,6 +173,7 @@ private: perf_counter_t _loop_perf; /**< loop duration performance counter */ + bool _armed{false}; hrt_abstime _last_run{0}; hrt_abstime _timestamp_sample{0}; hrt_abstime _last_status_pub{0};