From 9b8de8275052ab2818a284d9b3e1cb1ca8ff0176 Mon Sep 17 00:00:00 2001 From: Tobias Antonsson Date: Thu, 17 Aug 2017 15:17:51 +0200 Subject: [PATCH] Eanbled crash/tubled detection. Closes #248 I the sitaw module the crash/tumbled detection was enabled in case the kalman estimator is used. Currently it is automatically used for the flow and the LPS decks. It checks if the attitude angle is above 60 deg for a period of time. If so shuts of motors until it comes back below 60 deg again. --- src/modules/interface/sitaw.h | 6 +++++- src/modules/src/sitaw.c | 6 ++++++ src/modules/src/stabilizer.c | 7 ++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/interface/sitaw.h b/src/modules/interface/sitaw.h index 42df88928b..714050f631 100644 --- a/src/modules/interface/sitaw.h +++ b/src/modules/interface/sitaw.h @@ -42,7 +42,11 @@ void sitAwInit(void); void sitAwUpdateSetpoint(setpoint_t *setpoint, const sensorData_t *sensorData, const state_t *state); /* Enable the situation awareness framework. */ -//#define SITAW_ENABLED +#define SITAW_ENABLED +/* Enable the different functions of the situation awareness framework. */ +//#define SITAW_FF_ENABLED /* Uncomment to enable */ +//#define SITAW_AR_ENABLED /* Uncomment to enable */ +#define SITAW_TU_ENABLED /* Uncomment to enable */ /* Configuration options for the 'Free Fall' detection. */ #define SITAW_FF_THRESHOLD 0.1 /* The default tolerance for AccWZ deviations from -1, indicating Free Fall. */ diff --git a/src/modules/src/sitaw.c b/src/modules/src/sitaw.c index 5b2c568fab..f472caec99 100644 --- a/src/modules/src/sitaw.c +++ b/src/modules/src/sitaw.c @@ -322,7 +322,13 @@ bool sitAwTuDetected(void) */ void sitAwInit(void) { +#ifdef SITAW_FF_ENABLED sitAwFFInit(); +#endif +#ifdef SITAW_AR_ENABLED sitAwARInit(); +#endif +#ifdef SITAW_TU_ENABLED sitAwTuInit(); +#endif } diff --git a/src/modules/src/stabilizer.c b/src/modules/src/stabilizer.c index 4ffb710d65..eccc70983c 100644 --- a/src/modules/src/stabilizer.c +++ b/src/modules/src/stabilizer.c @@ -65,9 +65,10 @@ void stabilizerInit(StateEstimatorType estimator) stateEstimatorInit(estimator); stateControllerInit(); powerDistributionInit(); -#if defined(SITAW_ENABLED) - sitAwInit(); -#endif + if (estimator == kalmanEstimator) + { + sitAwInit(); + } xTaskCreate(stabilizerTask, STABILIZER_TASK_NAME, STABILIZER_TASK_STACKSIZE, NULL, STABILIZER_TASK_PRI, NULL);