Class Complementary
Fuses a drifting rate, such as a gyroscope's, with a noisy absolute reading, such as an accelerometer's tilt, into one steady estimate.
public sealed class Complementary : IDisposable
- Inheritance
-
Complementary
- Implements
- Inherited Members
Remarks
Each update integrates the rate onto the estimate, then nudges that toward the absolute
reading by 1 - alpha, so the rate rules the short term and the absolute reading the
long term. An update with a rate, reading, or time step that is not a finite number is
ignored.
Constructors
Complementary(float, float)
Creates a filter.
public Complementary(float alpha, float initial)
Parameters
alphafloatThe weight on the integrated rate, held to 0 to 1: near 1 trusts the rate and corrects slowly. One that is not a number is taken as 0.
initialfloatThe starting estimate.
Properties
Estimate
Gets the current estimate.
public float Estimate { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Update(float, float, float)
Fuses a rate and an absolute reading over a time step.
public float Update(float rate, float absolute, float dt)
Parameters
ratefloatThe rate of change, such as degrees per second from a gyroscope.
absolutefloatThe absolute reading, such as a tilt from an accelerometer.
dtfloatThe time since the last update.
Returns
- float
The fused estimate.