From 769efc2bf74b3de26787c18cb34c3f9e07e8d5b5 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Thu, 5 May 2011 15:20:09 -0700 Subject: [PATCH] Added motor command output step binding in supervision. --- .../rotorcraft/actuators/supervision.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/sw/airborne/firmwares/rotorcraft/actuators/supervision.c b/sw/airborne/firmwares/rotorcraft/actuators/supervision.c index 012b2402a0a..b158fae8255 100644 --- a/sw/airborne/firmwares/rotorcraft/actuators/supervision.c +++ b/sw/airborne/firmwares/rotorcraft/actuators/supervision.c @@ -38,6 +38,19 @@ #define SUPERVISION_MIN_MOTOR_STARTUP SUPERVISION_MIN_MOTOR #endif +#if defined (SUPERVISION_MAX_NEGATIVE_MOTOR_STEP) || defined (SUPERVISION_MAX_POSITIVE_MOTOR_STEP) +#define SUPERVISION_USE_MAX_MOTOR_STEP_BINDING + +#ifndef SUPERVISION_MAX_NEGATIVE_MOTOR_STEP +#define SUPERVISION_MAX_NEGATIVE_MOTOR_STEP INT32_MIN +#endif +/* +#ifndef SUPERVISION_MAX_POSITIVE_MOTOR_STEP +#define SUPERVISION_MAX_POSITIVE_MOTOR_STEP INT32_MAX +#endif +*/ +#endif + 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; @@ -72,6 +85,31 @@ __attribute__ ((always_inline)) static inline void bound_commands(void) { SUPERVISION_MIN_MOTOR, SUPERVISION_MAX_MOTOR); } +#ifdef SUPERVISION_USE_MAX_MOTOR_STEP_BINDING +__attribute__ ((always_inline)) static inline void bound_commands_step(void) { + uint8_t j; + static int32_t prev_commands[SUPERVISION_NB_MOTOR]; + static uint8_t initialized = 0; + + if (initialized == 1) { + for (j=0; j