CALPOLY MECHATRONICS
Documentation for all Mechatronics Labs
ME405_FP_ABFilter.ABFilter Class Reference

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.
 

Detailed Description

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.

Author
Eliot Briefer

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
alphaThe alpha value
betaThe beta value
prescalerUsed to correct velocity into units/sec. Prescaler value is
x_notInitial position
v_notInitial velocity
t_notInitial tick (typically in micro seconds)
useUtimeWether or not to use utime.ticks_diff(). Set to false if time ticks arent generated using utime.ticks_ms() or utime.ticks_us().

Member Function Documentation

◆ setAB()

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.

Parameters
alphaThe new alpha value, should be < 1.
betaThe new beta value, should be small, typically < 0.1

◆ setState()

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.

Parameters
xThe set position.
vThe set velocity.
tThe set time tick.

◆ update()

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.

Parameters
x_newnew x reading
t_newnew t tick, typically in us from utime.ticks_us()
Returns
A tuple of (estimated position, estimated velocity)

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