Skip to content

Commit

Permalink
Tumble check can be disabled via parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkarasek committed Sep 9, 2024
1 parent d7425d2 commit ed55d64
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
12 changes: 11 additions & 1 deletion src/modules/src/supervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ static void postTransitionActions(SupervisorMem_t* this, const supervisorState_t
}
}

uint8_t tumbleCheckEnabled = 1;

static supervisorConditionBits_t updateAndPopulateConditions(SupervisorMem_t* this, const sensorData_t *sensors, const setpoint_t* setpoint, const uint32_t currentTick) {
supervisorConditionBits_t conditions = 0;

Expand All @@ -311,7 +313,10 @@ static supervisorConditionBits_t updateAndPopulateConditions(SupervisorMem_t* th

const bool isTumbled = isTumbledCheck(this, sensors, currentTick);
if (isTumbled) {
conditions |= SUPERVISOR_CB_IS_TUMBLED;
if (tumbleCheckEnabled)
{
conditions |= SUPERVISOR_CB_IS_TUMBLED;
}
}

const uint32_t setpointAge = currentTick - setpoint->timestamp;
Expand Down Expand Up @@ -534,4 +539,9 @@ PARAM_ADD(PARAM_UINT8, infdmp, &supervisorMem.doinfodump)
*/
PARAM_ADD(PARAM_UINT16 | PARAM_PERSISTENT, landedTimeout, &landingTimeoutDuration)

/**
* @brief Set to zero to disable tumble check
*/
PARAM_ADD(PARAM_UINT8 | PARAM_PERSISTENT, tmblChckEn, &tumbleCheckEnabled)

PARAM_GROUP_STOP(supervisor)
18 changes: 6 additions & 12 deletions src/modules/src/supervisor_state_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ static const char* const conditionNames[] = {
};
static_assert(sizeof(conditionNames) / sizeof(conditionNames[0]) == supervisorCondition_NrOfConditions);

#if SUPERVISOR_TUMBLE_CHECK_ENABLE
#define SUPERVISOR_CB_CONF_IS_TUMBLED (SUPERVISOR_CB_IS_TUMBLED)
#else
#define SUPERVISOR_CB_CONF_IS_TUMBLED (SUPERVISOR_CB_NONE)
#endif

// State transition definitions
static SupervisorStateTransition_t transitionsNotInitialized[] = {
{
Expand All @@ -93,7 +87,7 @@ static SupervisorStateTransition_t transitionsPreFlChecksNotPassed[] = {

.triggerCombiner = supervisorAlways,

.blockers = SUPERVISOR_CB_CONF_IS_TUMBLED,
.blockers = SUPERVISOR_CB_IS_TUMBLED,
.negatedBlockers = SUPERVISOR_CB_NONE,
.blockerCombiner = supervisorAny,
}
Expand All @@ -112,7 +106,7 @@ static SupervisorStateTransition_t transitionsPreFlChecksPassed[] = {
{
.newState = supervisorStatePreFlChecksNotPassed,

.triggers = SUPERVISOR_CB_CONF_IS_TUMBLED,
.triggers = SUPERVISOR_CB_IS_TUMBLED,
.negatedTriggers = SUPERVISOR_CB_NONE,
.triggerCombiner = supervisorAny,

Expand All @@ -125,7 +119,7 @@ static SupervisorStateTransition_t transitionsPreFlChecksPassed[] = {
.negatedTriggers = SUPERVISOR_CB_NONE,
.triggerCombiner = supervisorAll,

.blockers = SUPERVISOR_CB_CONF_IS_TUMBLED,
.blockers = SUPERVISOR_CB_IS_TUMBLED,
.negatedBlockers = SUPERVISOR_CB_NONE,
.blockerCombiner = supervisorAny,
},
Expand All @@ -144,7 +138,7 @@ static SupervisorStateTransition_t transitionsReadyToFly[] = {
{
.newState = supervisorStatePreFlChecksNotPassed,

.triggers = SUPERVISOR_CB_CONF_IS_TUMBLED,
.triggers = SUPERVISOR_CB_IS_TUMBLED,
.negatedTriggers = SUPERVISOR_CB_ARMED,
.triggerCombiner = supervisorAny,

Expand Down Expand Up @@ -174,7 +168,7 @@ static SupervisorStateTransition_t transitionsFlying[] = {
{
.newState = supervisorStateCrashed,

.triggers = SUPERVISOR_CB_CONF_IS_TUMBLED,
.triggers = SUPERVISOR_CB_IS_TUMBLED,
.negatedTriggers = SUPERVISOR_CB_ARMED,
.triggerCombiner = supervisorAny,

Expand Down Expand Up @@ -235,7 +229,7 @@ static SupervisorStateTransition_t transitionsWarningLevelOut[] = {
{
.newState = supervisorStateExceptFreeFall,

.triggers = SUPERVISOR_CB_COMMANDER_WDT_TIMEOUT | SUPERVISOR_CB_CONF_IS_TUMBLED | SUPERVISOR_CB_EMERGENCY_STOP,
.triggers = SUPERVISOR_CB_COMMANDER_WDT_TIMEOUT | SUPERVISOR_CB_IS_TUMBLED | SUPERVISOR_CB_EMERGENCY_STOP,
.negatedTriggers = SUPERVISOR_CB_ARMED,
.triggerCombiner = supervisorAny,

Expand Down
4 changes: 0 additions & 4 deletions src/platform/interface/platform_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@
#endif

// Tumble detection settings
#ifndef SUPERVISOR_TUMBLE_CHECK_ENABLE
#define SUPERVISOR_TUMBLE_CHECK_ENABLE true
#endif

// 60 degrees tilt (when stationary)
#ifndef SUPERVISOR_TUMBLE_CHECK_ACCEPTED_TILT_ACCZ
#define SUPERVISOR_TUMBLE_CHECK_ACCEPTED_TILT_ACCZ 0.5f
Expand Down
1 change: 0 additions & 1 deletion src/platform/interface/platform_defaults_flapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@

// Tumble check settings //
///////////////////////////
#define SUPERVISOR_TUMBLE_CHECK_ENABLE true
#define SUPERVISOR_TUMBLE_CHECK_ACCEPTED_TILT_ACCZ 0.0f
#define SUPERVISOR_TUMBLE_CHECK_ACCEPTED_TILT_TIME 2000
#define SUPERVISOR_TUMBLE_CHECK_ACCEPTED_UPSIDEDOWN_ACCZ -0.5f
Expand Down

0 comments on commit ed55d64

Please sign in to comment.