Merge branch 'next' into corvuscorax/OP-1483_leaky-integrals-and-post-filtering
[librepilot.git] / flight / modules / StateEstimation / inc / stateestimation.h
blob38d21e599b73317519ebd96ed2631cdda8c595f1
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
4 * @{
5 * @addtogroup StateSetimation Module
6 * @{
8 * @file stateestimation.h
9 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
10 * @brief Acquires sensor data and fuses it into attitude estimate for CC
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #ifndef STATEESTIMATION_H
31 #define STATEESTIMATION_H
33 #include <openpilot.h>
36 // Enumeration for filter result
37 typedef enum {
38 FILTERRESULT_UNINITIALISED = -1,
39 FILTERRESULT_OK = 0,
40 FILTERRESULT_WARNING = 1,
41 FILTERRESULT_CRITICAL = 2,
42 FILTERRESULT_ERROR = 3,
43 } filterResult;
46 typedef enum {
47 SENSORUPDATES_gyro = 1 << 0,
48 SENSORUPDATES_accel = 1 << 1,
49 SENSORUPDATES_mag = 1 << 2,
50 SENSORUPDATES_boardMag = 1 << 10,
51 SENSORUPDATES_auxMag = 1 << 9,
52 SENSORUPDATES_attitude = 1 << 3,
53 SENSORUPDATES_pos = 1 << 4,
54 SENSORUPDATES_vel = 1 << 5,
55 SENSORUPDATES_airspeed = 1 << 6,
56 SENSORUPDATES_baro = 1 << 7,
57 SENSORUPDATES_lla = 1 << 8,
58 } sensorUpdates;
60 #define MAGSTATUS_OK 1
61 #define MAGSTATUS_AUX 2
62 #define MAGSTATUS_INVALID 0
63 typedef struct {
64 float gyro[3];
65 float accel[3];
66 float mag[3];
67 float attitude[4];
68 float pos[3];
69 float vel[3];
70 float airspeed[2];
71 float baro[1];
72 float auxMag[3];
73 uint8_t magStatus;
74 float boardMag[3];
75 sensorUpdates updated;
76 } stateEstimation;
78 typedef struct stateFilterStruct {
79 int32_t (*init)(struct stateFilterStruct *self);
80 filterResult (*filter)(struct stateFilterStruct *self, stateEstimation *state);
81 void *localdata;
82 } stateFilter;
85 int32_t filterMagInitialize(stateFilter *handle);
86 int32_t filterBaroiInitialize(stateFilter *handle);
87 int32_t filterBaroInitialize(stateFilter *handle);
88 int32_t filterVelocityInitialize(stateFilter *handle);
89 int32_t filterAltitudeInitialize(stateFilter *handle);
90 int32_t filterAirInitialize(stateFilter *handle);
91 int32_t filterStationaryInitialize(stateFilter *handle);
92 int32_t filterLLAInitialize(stateFilter *handle);
93 int32_t filterCFInitialize(stateFilter *handle);
94 int32_t filterCFMInitialize(stateFilter *handle);
95 int32_t filterEKF13iInitialize(stateFilter *handle);
96 int32_t filterEKF13Initialize(stateFilter *handle);
97 int32_t filterEKF16iInitialize(stateFilter *handle);
98 int32_t filterEKF16Initialize(stateFilter *handle);
100 #endif // STATEESTIMATION_H