2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
5 * @addtogroup State Estimation
6 * @brief Acquires sensor data and computes state estimate
9 * @file filterstationary.c
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
11 * @brief Provides "fake" stationary state data for indoor mode
13 * @see The GNU Public License (GPL) Version 3
15 ******************************************************************************/
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "inc/stateestimation.h"
33 // Fake pos rate in uS
34 #define FILTERSTATIONARY_FAKEPOSRATE 100000
37 #define STACK_REQUIRED 64
48 static int32_t init(stateFilter
*self
);
49 static filterResult
filter(stateFilter
*self
, stateEstimation
*state
);
52 int32_t filterStationaryInitialize(stateFilter
*handle
)
55 handle
->filter
= &filter
;
56 handle
->localdata
= pios_malloc(sizeof(struct data
));
57 return STACK_REQUIRED
;
60 static int32_t init(stateFilter
*self
)
62 struct data
*this = (struct data
*)self
->localdata
;
64 this->lastUpdate
= PIOS_DELAY_GetRaw();
68 static filterResult
filter(stateFilter
*self
, stateEstimation
*state
)
70 struct data
*this = (struct data
*)self
->localdata
;
72 if (PIOS_DELAY_DiffuS(this->lastUpdate
) > FILTERSTATIONARY_FAKEPOSRATE
) {
73 this->lastUpdate
= PIOS_DELAY_GetRaw();
77 state
->updated
|= SENSORUPDATES_pos
;
82 state
->updated
|= SENSORUPDATES_vel
;
84 return FILTERRESULT_OK
;