33 #define INT32_MIN (-2147483647-1)
37 #define INT32_MAX (2147483647)
40 #if defined MOTOR_MIXING_MIN_MOTOR || defined MOTOR_MIXING_MAX_MOTOR
41 #error MIN_MOTOR and MAX_MOTOR have to be set via neutral/max of the respective servo
43 #define MOTOR_MIXING_MIN_MOTOR 0
44 #define MOTOR_MIXING_MAX_MOTOR MAX_PPRZ
46 #ifndef MOTOR_MIXING_STOP_MOTOR
47 #define MOTOR_MIXING_STOP_MOTOR -MAX_PPRZ
50 #ifndef MOTOR_MIXING_TRIM_ROLL
51 #define MOTOR_MIXING_TRIM_ROLL 0
54 #ifndef MOTOR_MIXING_TRIM_PITCH
55 #define MOTOR_MIXING_TRIM_PITCH 0
58 #ifndef MOTOR_MIXING_TRIM_YAW
59 #define MOTOR_MIXING_TRIM_YAW 0
68 #ifndef MOTOR_MIXING_MAX_SATURATION_OFFSET
69 #define MOTOR_MIXING_MAX_SATURATION_OFFSET MAX_PPRZ/10
72 #ifndef MOTOR_MIXING_MIN_MOTOR_STARTUP
73 #define MOTOR_MIXING_MIN_MOTOR_STARTUP MOTOR_MIXING_MIN_MOTOR
76 #if defined (MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP) || defined (MOTOR_MIXING_MAX_POSITIVE_MOTOR_STEP)
77 #define MOTOR_MIXING_USE_MAX_MOTOR_STEP_BINDING
79 #ifndef MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP
80 #define MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP INT32_MIN
96 #if PERIODIC_TELEMETRY
100 int16_t motors[MOTOR_MIXING_NB_MOTOR];
101 for (
uint8_t i = 0; i < MOTOR_MIXING_NB_MOTOR; i++)
105 pprz_msg_send_MOTOR_MIXING(trans,
dev, AC_ID , MOTOR_MIXING_NB_MOTOR, motors);
112 for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {
123 #if PERIODIC_TELEMETRY
131 for (j = 0; j < MOTOR_MIXING_NB_MOTOR; j++) {
139 for (j = 0; j < MOTOR_MIXING_NB_MOTOR; j++) {
146 #ifdef MOTOR_MIXING_USE_MAX_MOTOR_STEP_BINDING
148 static int32_t prev_commands[MOTOR_MIXING_NB_MOTOR];
149 static uint8_t initialized = 0;
151 if (initialized == 1) {
152 for (j = 0; j < MOTOR_MIXING_NB_MOTOR; j++) {
154 Bound(new_command_diff,
155 MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP, MOTOR_MIXING_MAX_POSITIVE_MOTOR_STEP);
162 for (j = 0; j < MOTOR_MIXING_NB_MOTOR; j++) {
171 for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {
172 #ifdef MOTOR_MIXING_STARTUP_DELAY
173 if (
counter > i * max_counter / (MOTOR_MIXING_NB_MOTOR + MOTOR_MIXING_STARTUP_DELAY)) {
174 if (
counter > MOTOR_MIXING_NB_MOTOR * max_counter /
175 (MOTOR_MIXING_NB_MOTOR + MOTOR_MIXING_STARTUP_DELAY))
186 if (
counter < i * max_counter / MOTOR_MIXING_NB_MOTOR) {
209 for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {
217 tmp_cmd /= MOTOR_MIXING_SCALE;
220 if (-tmp_cmd > max_overflow) {
221 max_overflow = -tmp_cmd;
223 else if (tmp_cmd -
MAX_PPRZ > max_overflow) {
229 int32_t yaw_authority = ABS(in_cmd[COMMAND_YAW]) - max_overflow;
231 int32_t bounded_yaw_cmd = in_cmd[COMMAND_YAW];
232 BoundAbs(bounded_yaw_cmd, yaw_authority);
239 for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {
273 if (motors_on && override_on) {
274 for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {
283 for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {