diff --git a/src/modules/control_allocator/ControlAllocator.cpp b/src/modules/control_allocator/ControlAllocator.cpp index 7e5d635033..3b44f7cdb5 100644 --- a/src/modules/control_allocator/ControlAllocator.cpp +++ b/src/modules/control_allocator/ControlAllocator.cpp @@ -339,6 +339,8 @@ ControlAllocator::Run() const hrt_abstime now = hrt_absolute_time(); const float dt = math::constrain(((now - _last_run) / 1e6f), 0.0002f, 0.02f); + bool is_vtol = false; + { vehicle_status_s vehicle_status; @@ -370,6 +372,9 @@ ControlAllocator::Run() } } + // Set this here to avoid another class member + is_vtol = vehicle_status.is_vtol; + // Forward to effectiveness source _actuator_effectiveness->setFlightPhase(flight_phase); } @@ -433,7 +438,7 @@ ControlAllocator::Run() } preflight_check_update_state(now); - preflight_check_overwrite_torque_sp(c); + preflight_check_overwrite_torque_sp(c, is_vtol); for (int i = 0; i < _num_control_allocation; ++i) { @@ -562,7 +567,7 @@ void ControlAllocator::preflight_check_update_state(hrt_abstime now) } void ControlAllocator::preflight_check_overwrite_torque_sp(matrix::Vector - (&c)[ActuatorEffectiveness::MAX_NUM_MATRICES]) + (&c)[ActuatorEffectiveness::MAX_NUM_MATRICES], bool is_vtol) { if (!_preflight_check_running) { return; } @@ -586,17 +591,13 @@ void ControlAllocator::preflight_check_overwrite_torque_sp(matrix::Vector 1) { - c[1](0) = 0.; - c[1](1) = 0.; - c[1](2) = 0.; - c[1](axis) = _preflight_check_input; - } + c[instance](0) = 0.; + c[instance](1) = 0.; + c[instance](2) = 0.; + c[instance](axis) = _preflight_check_input; } void ControlAllocator::preflight_check_handle_tilt_control(hrt_abstime now) diff --git a/src/modules/control_allocator/ControlAllocator.hpp b/src/modules/control_allocator/ControlAllocator.hpp index c1d91a9ab8..c670e60918 100644 --- a/src/modules/control_allocator/ControlAllocator.hpp +++ b/src/modules/control_allocator/ControlAllocator.hpp @@ -144,7 +144,8 @@ private: void publish_actuator_controls(); - void preflight_check_overwrite_torque_sp(matrix::Vector (&c)[ActuatorEffectiveness::MAX_NUM_MATRICES]); + void preflight_check_overwrite_torque_sp(matrix::Vector (&c)[ActuatorEffectiveness::MAX_NUM_MATRICES], + bool is_vtol); void preflight_check_handle_command(hrt_abstime now); void preflight_check_update_state(hrt_abstime now); void preflight_check_handle_tilt_control(hrt_abstime now);