aboutsummaryrefslogblamecommitdiff
path: root/src/modules/position_estimator_inav/inertial_filter.c
blob: acaf693f17a7733b3e26ef43d10c9fd88ca3ff1c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                             
                                                                   
 

                             

                     
                                 
                                           

                            
                                 

         
/*
 * inertial_filter.c
 *
 *   Copyright (C) 2013 Anton Babushkin. All rights reserved.
 *   Author: 	Anton Babushkin	<rk3dov@gmail.com>
 */

#include "inertial_filter.h"

void inertial_filter_predict(float dt, float x[3])
{
	x[0] += x[1] * dt + x[2] * dt * dt / 2.0f;
	x[1] += x[2] * dt;
}

void inertial_filter_correct(float edt, float x[3], int i, float w)
{
	float ewdt = w * edt;
	x[i] += ewdt;

	if (i == 0) {
		x[1] += w * ewdt;
		x[2] += w * w * ewdt / 3.0;

	} else if (i == 1) {
		x[2] += w * ewdt;
	}
}