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

Correction of the kalman estimator rate #1301

Merged
merged 1 commit into from
Jul 4, 2023
Merged
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: 5 additions & 3 deletions src/modules/src/estimator/estimator_kalman.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ static StaticSemaphore_t dataMutexBuffer;
/**
* Tuning parameters
*/
#define PREDICT_RATE RATE_100_HZ // this is slower than the IMU update rate of 500Hz
#define PREDICT_RATE RATE_100_HZ // this is slower than the IMU update rate of 1000Hz
const uint32_t PREDICTION_UPDATE_INTERVAL_MS = 1000 / PREDICT_RATE;

// The bounds on the covariance, these shouldn't be hit, but sometimes are... why?
#define MAX_COVARIANCE (100)
#define MIN_COVARIANCE (1e-6f)
Expand Down Expand Up @@ -233,12 +235,12 @@ static void kalmanTask(void* parameters) {
axis3fSubSamplerFinalize(&gyroSubSampler);

kalmanCorePredict(&coreData, &accSubSampler.subSample, &gyroSubSampler.subSample, nowMs, quadIsFlying);
nextPredictionMs = nowMs + (1000.0f / PREDICT_RATE);
nextPredictionMs = nowMs + PREDICTION_UPDATE_INTERVAL_MS;

STATS_CNT_RATE_EVENT(&predictionCounter);

if (!rateSupervisorValidate(&rateSupervisorContext, nowMs)) {
DEBUG_PRINT("WARNING: Kalman prediction rate low (%lu)\n", rateSupervisorLatestCount(&rateSupervisorContext));
DEBUG_PRINT("WARNING: Kalman prediction rate off (%lu)\n", rateSupervisorLatestCount(&rateSupervisorContext));
}
}

Expand Down