control_allocator: limit status publication rate to 200Hz

Reduces CPU load by ~3.5% on F4 @2khz.
And compute getAllocatedControl as needed (~1.5% CPU reduction)
This commit is contained in:
Beat Küng
2021-11-11 11:13:21 +01:00
committed by Daniel Agar
parent 93a54ee63d
commit b29d9db7f1
6 changed files with 10 additions and 25 deletions
@@ -132,7 +132,8 @@ public:
*
* @return Control vector
*/
const matrix::Vector<float, NUM_AXES> &getAllocatedControl() const { return _control_allocated; }
matrix::Vector<float, NUM_AXES> getAllocatedControl() const
{ return (_effectiveness * _actuator_sp).emult(_control_allocation_scale); }
/**
* Get the control effectiveness matrix
@@ -189,11 +190,6 @@ public:
*/
void clipActuatorSetpoint(matrix::Vector<float, NUM_ACTUATORS> &actuator) const;
/**
* Compute the amount of allocated control thrust and torque
*/
void updateControlAllocated();
/**
* Normalize the actuator setpoint between minimum and maximum values.
*
@@ -218,7 +214,6 @@ protected:
matrix::Vector<float, NUM_ACTUATORS> _actuator_max; //< Maximum actuator values
matrix::Vector<float, NUM_ACTUATORS> _actuator_sp; //< Actuator setpoint
matrix::Vector<float, NUM_AXES> _control_sp; //< Control setpoint
matrix::Vector<float, NUM_AXES> _control_allocated; //< Allocated control
matrix::Vector<float, NUM_AXES> _control_trim; //< Control at trim actuator values
int _num_actuators{0};
};