From 9c767ff1eea9ac53a9fbbab03119353eb6ec8635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 24 Nov 2021 10:46:36 +0100 Subject: [PATCH] control_allocator: make effective source name a class member --- .../ActuatorEffectiveness.hpp | 5 +++++ .../ActuatorEffectivenessMultirotor.hpp | 2 ++ .../ActuatorEffectivenessStandardVTOL.hpp | 2 ++ .../ActuatorEffectivenessTiltrotorVTOL.hpp | 2 ++ .../control_allocator/ControlAllocator.cpp | 18 ++---------------- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectiveness.hpp b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectiveness.hpp index a99947b6c6..ad8714eda0 100644 --- a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectiveness.hpp +++ b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectiveness.hpp @@ -103,6 +103,11 @@ public: */ virtual int numActuators() const = 0; + /** + * Display name + */ + virtual const char *name() const = 0; + protected: matrix::Vector _trim; ///< Actuator trim FlightPhase _flight_phase{FlightPhase::HOVER_FLIGHT}; ///< Current flight phase diff --git a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessMultirotor.hpp b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessMultirotor.hpp index 9c87f08754..678ed40a09 100644 --- a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessMultirotor.hpp +++ b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessMultirotor.hpp @@ -79,6 +79,8 @@ public: bool getEffectivenessMatrix(matrix::Matrix &matrix, bool force) override; int numActuators() const override { return _num_actuators; } + + const char *name() const override { return "Multirotor"; } private: bool _updated{true}; int _num_actuators{0}; diff --git a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.hpp b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.hpp index e3de20e583..473e522f1a 100644 --- a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.hpp +++ b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.hpp @@ -59,6 +59,8 @@ public: void setFlightPhase(const FlightPhase &flight_phase) override; int numActuators() const override { return 7; } + + const char *name() const override { return "Standard VTOL"; } protected: bool _updated{true}; }; diff --git a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.hpp b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.hpp index 1204fc8e86..a947ad32b5 100644 --- a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.hpp +++ b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.hpp @@ -59,6 +59,8 @@ public: void setFlightPhase(const FlightPhase &flight_phase) override; int numActuators() const override { return 10; } + + const char *name() const override { return "VTOL Tiltrotor"; } protected: bool _updated{true}; }; diff --git a/src/modules/control_allocator/ControlAllocator.cpp b/src/modules/control_allocator/ControlAllocator.cpp index 73c908ffa9..90c1797ffd 100644 --- a/src/modules/control_allocator/ControlAllocator.cpp +++ b/src/modules/control_allocator/ControlAllocator.cpp @@ -442,22 +442,8 @@ int ControlAllocator::print_status() } // Print current airframe - switch ((EffectivenessSource)_param_ca_airframe.get()) { - case EffectivenessSource::NONE: - PX4_INFO("EffectivenessSource: None"); - break; - - case EffectivenessSource::MULTIROTOR: - PX4_INFO("EffectivenessSource: MC parameters"); - break; - - case EffectivenessSource::STANDARD_VTOL: - PX4_INFO("EffectivenessSource: Standard VTOL"); - break; - - case EffectivenessSource::TILTROTOR_VTOL: - PX4_INFO("EffectivenessSource: Tiltrotor VTOL"); - break; + if (_actuator_effectiveness != nullptr) { + PX4_INFO("Effectiveness Source: %s", _actuator_effectiveness->name()); } // Print current effectiveness matrix