diff --git a/sw/airborne/firmwares/rotorcraft/actuators/supervision.c b/sw/airborne/firmwares/rotorcraft/actuators/supervision.c index 6d96d6c0e6..e4fbddc52d 100644 --- a/sw/airborne/firmwares/rotorcraft/actuators/supervision.c +++ b/sw/airborne/firmwares/rotorcraft/actuators/supervision.c @@ -58,14 +58,6 @@ */ #endif -/** total supervision command scale. - * scales a command input [-MAX_PPRZ,MAX_PPRZ] - * to the final supervision motor command with range of - * [SUPERVISION_MIN_MOTOR,SUPERVISION_MAX_MOTOR] - * or sets it to SUPERVISION_STOP_MOTOR - */ -#define SUPERVISION_CMD_SCALE (SUPERVISION_MAX_MOTOR - SUPERVISION_MIN_MOTOR) / (MAX_PPRZ * SUPERVISION_SCALE) - static const int32_t roll_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_ROLL_COEF; static const int32_t pitch_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_PITCH_COEF; static const int32_t yaw_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_YAW_COEF; @@ -152,13 +144,15 @@ void supervision_run(bool_t motors_on, bool_t override_on, int32_t in_cmd[] ) { if (motors_on) { int32_t min_cmd = INT32_MAX; int32_t max_cmd = INT32_MIN; + /* do the mixing in float to avoid overflows, implicitly casted back to int32_t */ for (i=0; i max_cmd)