vtol_att_control: limit excessive scheduling

- this is to prevent vtol_att_control running at absurdly high rates (kilohertz) from every single actuator controls publication from both the multicopter and fixed wing controllers
 - I don't really like this solution, but it works for now until there are larger VTOL architectural changes in place
This commit is contained in:
Daniel Agar
2020-07-21 11:40:04 -04:00
committed by GitHub
parent 5c5005fa58
commit e4f65f81f7
2 changed files with 16 additions and 0 deletions
@@ -51,6 +51,7 @@
#include <uORB/Publication.hpp>
using namespace matrix;
using namespace time_literals;
VtolAttitudeControl::VtolAttitudeControl() :
WorkItem(MODULE_NAME, px4::wq_configurations::rate_ctrl),
@@ -342,6 +343,19 @@ VtolAttitudeControl::Run()
return;
}
const hrt_abstime now = hrt_absolute_time();
#if !defined(ENABLE_LOCKSTEP_SCHEDULER)
// prevent excessive scheduling (> 500 Hz)
if (now - _last_run_timestamp < 2_ms) {
return;
}
#endif // !ENABLE_LOCKSTEP_SCHEDULER
_last_run_timestamp = now;
if (!_initialized) {
parameters_update(); // initialize parameter cache
@@ -213,6 +213,8 @@ private:
param_t mpc_land_alt2;
} _params_handles{};
hrt_abstime _last_run_timestamp{0};
/* for multicopters it is usual to have a non-zero idle speed of the engines
* for fixed wings we want to have an idle speed of zero since we do not want
* to waste energy when gliding. */