Treehopper C# API
ComplementaryFilter Class Reference

A simple filter for fusing accelerometer and gyroscope data together to determine roll and pitch. More...

Inheritance diagram for ComplementaryFilter:

Public Member Functions

delegate void FilterUpdateEventHandler (object sender, EventArgs e)
 Delegate of the callback function to be invoked when the filter is updated More...
 
 ComplementaryFilter (IAccelerometer accelerometer, IGyroscope gyroscope, int samplePeriodMs=10, bool useHighResolutionTimer=false)
 Construct a new Complementary filter with the specified accelerometer and gyroscope (which is often the same IC) More...
 
void Dispose ()
 Shut down the polling loop and dispose of this filter More...
 

Properties

double Pitch [get]
 The current calculated pitch More...
 
double Roll [get]
 The current calculated roll More...
 
double Yaw [get]
 The yaw reported by the gyroscope. More...
 

Events

PropertyChangedEventHandler PropertyChanged
 Fires whenever a property has been updated More...
 
FilterUpdateEventHandler FilterUpdate
 Fires after the filter update function has executed More...
 

Detailed Description

A simple filter for fusing accelerometer and gyroscope data together to determine roll and pitch.

Constructor & Destructor Documentation

◆ ComplementaryFilter()

ComplementaryFilter ( IAccelerometer  accelerometer,
IGyroscope  gyroscope,
int  samplePeriodMs = 10,
bool  useHighResolutionTimer = false 
)

Construct a new Complementary filter with the specified accelerometer and gyroscope (which is often the same IC)

Parameters
accelerometerThe accelerometer to use
gyroscopeThe gyroscope to use
samplePeriodMsThe sample period to poll these devices at
useHighResolutionTimerWhether to use an accurate (but CPU-hungry) timer

Member Function Documentation

◆ FilterUpdateEventHandler()

delegate void FilterUpdateEventHandler ( object  sender,
EventArgs  e 
)

Delegate of the callback function to be invoked when the filter is updated

Parameters
senderThe filter that called this function
eAn empty EventArgs object

◆ Dispose()

void Dispose ( )

Shut down the polling loop and dispose of this filter

Property Documentation

◆ Pitch

double Pitch
get

The current calculated pitch

◆ Roll

double Roll
get

The current calculated roll

◆ Yaw

double Yaw
get

The yaw reported by the gyroscope.

This value will drift, as the accelerometer cannot correct for it

Event Documentation

◆ PropertyChanged

PropertyChangedEventHandler PropertyChanged

Fires whenever a property has been updated

◆ FilterUpdate

Fires after the filter update function has executed


The documentation for this class was generated from the following file: