VehicleControlMode: add flag_control_allocation_enabled

Allows (external) modes to directly publish actuator_{motors,servos}.
This commit is contained in:
Beat Küng
2023-07-26 13:31:20 +02:00
committed by Daniel Agar
parent 22e613a24a
commit 03365658d5
4 changed files with 17 additions and 0 deletions
@@ -359,6 +359,14 @@ ControlAllocator::Run()
}
}
{
vehicle_control_mode_s vehicle_control_mode;
if (_vehicle_control_mode_sub.update(&vehicle_control_mode)) {
_publish_controls = vehicle_control_mode.flag_control_allocation_enabled;
}
}
// Guard against too small (< 0.2ms) and too large (> 20ms) dt's.
const hrt_abstime now = hrt_absolute_time();
const float dt = math::constrain(((now - _last_run) / 1e6f), 0.0002f, 0.02f);
@@ -641,6 +649,10 @@ ControlAllocator::publish_control_allocator_status(int matrix_index)
void
ControlAllocator::publish_actuator_controls()
{
if (!_publish_controls) {
return;
}
actuator_motors_s actuator_motors;
actuator_motors.timestamp = hrt_absolute_time();
actuator_motors.timestamp_sample = _timestamp_sample;