Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent estimator tasks from running once at start up #1203

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/modules/src/estimator_kalman.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@

#define DEBUG_MODULE "ESTKALMAN"
#include "debug.h"
#include "cfassert.h"


// #define KALMAN_USE_BARO_UPDATE
Expand Down Expand Up @@ -153,7 +154,7 @@ bool resetEstimation = false;
static kalmanCoreParams_t coreParams;

// Data used to enable the task and stabilizer loop to run with minimal locking
static state_t taskEstimatorState; // The estimator state produced by the task, copied to the stabilzer when needed.
static state_t taskEstimatorState; // The estimator state produced by the task, copied to the stabilizer when needed.

// Statistics
#define ONE_SECOND 1000
Expand Down Expand Up @@ -185,7 +186,10 @@ STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(kalmanTask, KALMAN_TASK_STACKSIZE);
void estimatorKalmanTaskInit() {
kalmanCoreDefaultParams(&coreParams);

vSemaphoreCreateBinary(runTaskSemaphore);
// Created in the 'empty' state, meaning the semaphore must first be given, that is it will block in the task
// until released by the stabilizer loop
runTaskSemaphore = xSemaphoreCreateBinary();
ASSERT(runTaskSemaphore);

dataMutex = xSemaphoreCreateMutexStatic(&dataMutexBuffer);

Expand Down
5 changes: 4 additions & 1 deletion src/modules/src/estimator_ukf.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(errorUkfTask, ERROR_UKF_TASK_STACKSI
// Called one time during system startup
void errorEstimatorUkfTaskInit()
{
vSemaphoreCreateBinary(runTaskSemaphore);
// Created in the 'empty' state, meaning the semaphore must first be given, that is it will block in the task
// until released by the stabilizer loop
runTaskSemaphore = xSemaphoreCreateBinary();
ASSERT(runTaskSemaphore);

dataMutex = xSemaphoreCreateMutexStatic(&dataMutexBuffer);

Expand Down