mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 14:03:33 +08:00
control_allocator: implement trim + slew rate limits configuration
This commit is contained in:
@@ -81,6 +81,17 @@ void ActuatorTest::update(int num_outputs, float thrust_curve)
|
||||
FunctionMotors::updateValues(motors.reversible_flags >> motor_idx, thrust_curve, &value, 1);
|
||||
}
|
||||
|
||||
// handle servos: add trim
|
||||
if (actuator_test.function >= (int)OutputFunction::Servo1 && actuator_test.function <= (int)OutputFunction::ServoMax) {
|
||||
actuator_servos_trim_s trim{};
|
||||
_actuator_servos_trim_sub.copy(&trim);
|
||||
int idx = actuator_test.function - (int)OutputFunction::Servo1;
|
||||
|
||||
if (idx < actuator_servos_trim_s::NUM_CONTROLS) {
|
||||
value += trim.trim[idx];
|
||||
}
|
||||
}
|
||||
|
||||
_current_outputs[i] = value;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <uORB/topics/actuator_test.h>
|
||||
#include <uORB/topics/actuator_motors.h>
|
||||
#include <uORB/topics/actuator_servos_trim.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
|
||||
static_assert(actuator_test_s::FUNCTION_MOTOR1 == (int)OutputFunction::Motor1, "define mismatch");
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
|
||||
uORB::Subscription _actuator_test_sub{ORB_ID(actuator_test)};
|
||||
uORB::Subscription _actuator_motors_sub{ORB_ID(actuator_motors)};
|
||||
uORB::Subscription _actuator_servos_trim_sub{ORB_ID(actuator_servos_trim)};
|
||||
bool _in_test_mode{false};
|
||||
hrt_abstime _next_timeout{0};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
*
|
||||
* Minimum time allowed for the motor input signal to pass through
|
||||
* a range of 1000 PWM units. A value x means that the motor signal
|
||||
* can only go from 1000 to 2000 PWM in maximum x seconds.
|
||||
* can only go from 1000 to 2000 PWM in minimum x seconds.
|
||||
*
|
||||
* Zero means that slew rate limiting is disabled.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user