1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

airspeed filter added

This commit is contained in:
Corvus Corax 2013-05-20 12:36:20 +02:00
parent 2f082dbf87
commit 7ea258a895
2 changed files with 99 additions and 14 deletions

View File

@ -0,0 +1,84 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup State Estimation
* @brief Acquires sensor data and computes state estimate
* @{
*
* @file filterair.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
* @brief Airspeed filter, calculates true airspeed based on indicated
* airspeed and uncorrected barometric altitude
* NOTE: This Sensor uses UNCORRECTED barometric altitude for
* correction -- run before barometric bias correction!
*
* @see The GNU Public License (GPL) Version 3
*
******************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "inc/stateestimation.h"
// Private constants
// simple IAS to TAS aproximation - 2% increase per 1000ft
// since we do not have flowing air temperature information
#define IAS2TAS(alt) (1.0f + (0.02f * (alt) / 304.8f))
// Private types
// Private variables
static float altitude = 0.0f;
// Private functions
static int32_t init(void);
static int32_t filter(stateEstimation *state);
void filterAirInitialize(stateFilter *handle)
{
handle->init = &init;
handle->filter = &filter;
}
static int32_t init(void)
{
altitude = 0.0f;
return 0;
}
static int32_t filter(stateEstimation *state)
{
// take static pressure altitude estimation for
if (ISSET(state->updated, bar_UPDATED)) {
altitude = state->bar[0];
}
// calculate true airspeed estimation
if (ISSET(state->updated, air_UPDATED)) {
state->air[1] = state->air[0] * IAS2TAS(altitude);
}
return 0;
}
/**
* @}
* @}
*/

View File

@ -94,10 +94,10 @@ static stateFilter ekf16iFilter;
// preconfigured filter chains selectable via revoSettings.FusionAlgorithm
static const filterQueue *cfQueue = &(filterQueue) {
.filter = &magFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &cfFilter,
.next = NULL,
@ -107,10 +107,10 @@ static const filterQueue *cfQueue = &(filterQueue) {
};
static const filterQueue *cfmQueue = &(filterQueue) {
.filter = &magFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &cfmFilter,
.next = NULL,
@ -120,12 +120,12 @@ static const filterQueue *cfmQueue = &(filterQueue) {
};
static const filterQueue *ekf13iQueue = &(filterQueue) {
.filter = &magFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &stationaryFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &ekf13iFilter,
.next = NULL,
@ -136,10 +136,10 @@ static const filterQueue *ekf13iQueue = &(filterQueue) {
};
static const filterQueue *ekf13Queue = &(filterQueue) {
.filter = &magFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &ekf13Filter,
.next = NULL,
@ -149,12 +149,12 @@ static const filterQueue *ekf13Queue = &(filterQueue) {
};
static const filterQueue *ekf16iQueue = &(filterQueue) {
.filter = &magFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &stationaryFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &ekf16iFilter,
.next = NULL,
@ -165,10 +165,10 @@ static const filterQueue *ekf16iQueue = &(filterQueue) {
};
static const filterQueue *ekf16Queue = &(filterQueue) {
.filter = &magFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &airFilter,
.next = &(filterQueue) {
.filter = &baroFilter,
.next = &(filterQueue) {
.filter = &ekf16Filter,
.next = NULL,
@ -338,6 +338,7 @@ static void StateEstimationCb(void)
}
SANITYCHECK1(BaroSensor, bar, Altitude, 1);
SANITYCHECK1(AirspeedSensor, air, CalibratedAirspeed, s.SensorConnected == AIRSPEEDSENSOR_SENSORCONNECTED_TRUE);
states.air[1] = 0.0f; // sensor does not provide true airspeed, needs to be calculated by filter
// GPS is a tiny bit more tricky as GPSPosition is not float (otherwise the conversion to NED could sit in a filter) but integers, for precision reasons
if (ISSET(states.updated, pos_UPDATED)) {