xyControl  0.1
Quadrotor Flight Controller on AVR Basis
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Files | Data Structures | Functions
Complementary-Filter

Complementary-Filter. More...

Files

file  complementary.h
 Complementary-Filter Header.
 
file  complementary.c
 Complementary-Filter Implementation.
 

Data Structures

struct  Complementary
 Cmplementary-Filter State data. More...
 

Functions

void complementaryExecute (Complementary *data, double acc, double gyro)
 Step the Complementary Filter. More...
 
void complementaryInit (Complementary *data)
 Initialize a Complementary-State. More...
 

Detailed Description

Complementary-Filter.

Inspired by this presentation...

Function Documentation

void complementaryExecute ( Complementary data,
double  acc,
double  gyro 
)

Step the Complementary Filter.

Parameters
dataComplementary-Filter State
accAngle from Accelerometer
gyroCorresponding Gyroscope data

Definition at line 50 of file complementary.c.

References COMPLEMENTARY_TAU, and getSystemTime().

Referenced by orientationTask().

50  {
51  double dt = (getSystemTime() - data->lastExecute) / 1000.0;
52  data->angle = (data->angle + (gyro * dt)); // Gyro Integrator
53  data->angle *= COMPLEMENTARY_TAU / (COMPLEMENTARY_TAU + dt); // High-Pass
54  data->angle += (1 - (COMPLEMENTARY_TAU / (COMPLEMENTARY_TAU + dt))) * acc; // Low-Pass
55  data->lastExecute = getSystemTime();
56 }
void complementaryInit ( Complementary data)

Initialize a Complementary-State.

Parameters
dataComplementary-State to be initialized

Definition at line 45 of file complementary.c.

References getSystemTime().

Referenced by orientationInit().

45  {
46  data->angle = 0;
47  data->lastExecute = getSystemTime();
48 }