1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

Refactor Baro to floats, filter at position rate

convert pressure to altitude early
remove median filter
PT2 filtering upsampled to altitude function in position.c - thanks KarateBrot
baro task synced to position task - thanks Steve
PT2 implementation - thanks KarateBrot
ground altitude from filtered altitude
baro cali by average of calibration samples over cal period
adjust vario and smoothing defaults
don't say haveBaroAlt until cal is complete
reduce PIDs since Baro is faster
add baro smoothing values to blackbox header

Co-Authored-By: Jan Post <post@stud.tu-darmstadt.de>
Co-Authored-By: Steve Evans <SteveCEvans@users.noreply.github.com>
This commit is contained in:
ctzsnooze 2022-08-02 15:21:38 +10:00
parent 21594c62e1
commit b2241b32c3
16 changed files with 209 additions and 212 deletions

View file

@ -294,9 +294,25 @@ void taskUpdateRangefinder(timeUs_t currentTimeUs)
#endif
#if defined(USE_BARO) || defined(USE_GPS)
static void taskCalculateAltitude(timeUs_t currentTimeUs)
static bool taskAltitudeCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs)
{
calculateEstimatedAltitude(currentTimeUs);
UNUSED(currentTimeUs);
#if defined(USE_BARO)
if (isBaroSampleReady()) {
return true;
}
#endif
if (currentDeltaTimeUs > getTask(TASK_ALTITUDE)->attribute->desiredPeriodUs) {
return true;
}
return false;
}
static void taskCalculateAltitude()
{
calculateEstimatedAltitude();
}
#endif // USE_BARO || USE_GPS
@ -374,11 +390,11 @@ task_attribute_t task_attributes[TASK_COUNT] = {
#endif
#ifdef USE_BARO
[TASK_BARO] = DEFINE_TASK("BARO", NULL, NULL, taskUpdateBaro, TASK_PERIOD_HZ(20), TASK_PRIORITY_LOW),
[TASK_BARO] = DEFINE_TASK("BARO", NULL, NULL, taskUpdateBaro, TASK_PERIOD_HZ(TASK_BARO_RATE_HZ), TASK_PRIORITY_LOW),
#endif
#if defined(USE_BARO) || defined(USE_GPS)
[TASK_ALTITUDE] = DEFINE_TASK("ALTITUDE", NULL, NULL, taskCalculateAltitude, TASK_PERIOD_HZ(40), TASK_PRIORITY_LOW),
[TASK_ALTITUDE] = DEFINE_TASK("ALTITUDE", NULL, taskAltitudeCheck, taskCalculateAltitude, TASK_PERIOD_HZ(TASK_ALTITUDE_RATE_HZ), TASK_PRIORITY_LOW),
#endif
#ifdef USE_DASHBOARD