mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-01 15:40:36 +08:00
VehicleControlMode: add flag_control_allocation_enabled
Allows (external) modes to directly publish actuator_{motors,servos}.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user