A class implementation of an alpha beta filter for position and velocity estimation. More...
Public Member Functions | |
def | __init__ (self, alpha=0.85, beta=0.005, prescaler=10 **6, x_not=0, v_not=0, t_not=0, useUtime=True) |
A method to initialize an ABFilter. More... | |
def | update (self, x_new, t_new) |
Used to update estimate a new velocity and position based on a measured position and time. More... | |
def | setAB (self, alpha=None, beta=None) |
A method to change the alpha and beta values used for position and velocity estimation. More... | |
def | setState (self, x=None, v=None, t=None) |
A method to reset the ABFilter to a specified position, velocity, and time. More... | |
Public Attributes | |
alpha | |
The alpha value used for velocity estimation. | |
beta | |
The beta value used for velocity estimation. | |
x | |
The most recent filtered x position. | |
v | |
The most recent filtered y position. | |
t | |
The most recent time tick, typically in microseconds. | |
useUtime | |
wether or not time ticks are generated with utime | |
prescaler | |
The prescaler to multiply the velocity by to get x units per second. | |
A class implementation of an alpha beta filter for position and velocity estimation.
Alpha beta filters are usefull for more acuratley estimating position and velocity from granular readings, such as a slow spinning encoder or a one pole hall efect rpm sensor.
def ME405_FP_ABFilter.ABFilter.__init__ | ( | self, | |
alpha = 0.85 , |
|||
beta = 0.005 , |
|||
prescaler = 10**6 , |
|||
x_not = 0 , |
|||
v_not = 0 , |
|||
t_not = 0 , |
|||
useUtime = True |
|||
) |
A method to initialize an ABFilter.
alpha | The alpha value |
beta | The beta value |
prescaler | Used to correct velocity into units/sec. Prescaler value is |
x_not | Initial position |
v_not | Initial velocity |
t_not | Initial tick (typically in micro seconds) |
useUtime | Wether or not to use utime.ticks_diff(). Set to false if time ticks arent generated using utime.ticks_ms() or utime.ticks_us(). |
def ME405_FP_ABFilter.ABFilter.setAB | ( | self, | |
alpha = None , |
|||
beta = None |
|||
) |
A method to change the alpha and beta values used for position and velocity estimation.
alpha | The new alpha value, should be < 1. |
beta | The new beta value, should be small, typically < 0.1 |
def ME405_FP_ABFilter.ABFilter.setState | ( | self, | |
x = None , |
|||
v = None , |
|||
t = None |
|||
) |
A method to reset the ABFilter to a specified position, velocity, and time.
x | The set position. |
v | The set velocity. |
t | The set time tick. |
def ME405_FP_ABFilter.ABFilter.update | ( | self, | |
x_new, | |||
t_new | |||
) |
Used to update estimate a new velocity and position based on a measured position and time.
x_new | new x reading |
t_new | new t tick, typically in us from utime.ticks_us() |