Core Classes
Error
Invariant Extended Kalman Filter
- class inekf.InEKF(pModel, x0, error)
The Invariant Extended Kalman Filter
- Parameters
pModel (
ProcessModel
) – Process modelstate (
inekf.LieGroup
) – Initial state, must be of same group that process model uses and must be uncertainerror (
ERROR
) – Right or left invariant error
Methods:
addMeasureModel
(name, m)Add measurement model to the filter.
predict
(u[, dt])Prediction Step.
update
(name, m)Update Step.
Attributes:
Current state estimate.
- addMeasureModel(name, m)
Add measurement model to the filter.
- Parameters
name (
str
) – Name of measurement model.m (
MeasureModel
) – A measure model pointer, templated by the used group.
- predict(u, dt=1)
Prediction Step.
- Parameters
u (control) – Must be same as what process model uses.
dt (
float
) – Delta t. Used sometimes depending on process model. Defaults to 1.
- Returns
State estimate
- Return type
- property state
Current state estimate. May be read or wrriten, but can’t be edited in place.
- Returns
state
- Return type
- update(name, m)
Update Step.
- Parameters
name (
str
) – Name of measurement model.z (
np.ndarray
) – Measurement. May vary in size depending on how measurement model processes it.
- Returns
State estimate.
- Return type
Measure Model
- class inekf.MeasureModel(b, M, error)
Base class measure model. Written to be inherited from, but in most cases this class will be sufficient. More information on inheriting can be seen in Custom Models.
We have overloaded the
[]
operator to function as a python template. Example of this can be seen in Getting Started.Templates:
Group
State’s group that is being tracked, of typeinekf.LieGroup
.
Attributes:
Linearized matrix H.
This is the converted H used in InEKF if it's a right filter with left measurement or vice versa.
Measurement covariance.
b vector used in measure model.
Type of error of the filter (right/left)
Methods:
calcSInverse
(state)Calculate inverse of measurement noise S, using H_error.
calcV
(z, state)Computes innovation based on measurement model.
makeHError
(state, iekfERROR)Sets and returns H_error for settings where filter error type != measurement error type.
processZ
(z, state)Process measurement before putting into InEKF.
setHandb
(b)Sets measurement vector b and recreates H accordingly.
- property H
Linearized matrix H. Will be automatically created from b in constructor unless overriden. May be read or written, but not modified in place.
- Returns
np.ndarray
- property H_error
This is the converted H used in InEKF if it’s a right filter with left measurement or vice versa. Used in calcSInverse if overriden. Probably won’t need to be overwritten. May be read or written, but not modified in place.
- Returns
np.ndarray
- property M
Measurement covariance.
- Returns
np.ndarray
- property b
b vector used in measure model.
- Returns
np.ndarray
- calcSInverse(state)
Calculate inverse of measurement noise S, using H_error. Called fourth in the update step.
- Parameters
state (
inekf.LieGroup
) – Current state estimate.- Returns
Inverse of measurement noise.
- Return type
np.ndarray
- calcV(z, state)
Computes innovation based on measurement model. Called third in the update step.
- Parameters
z (
np.ndarray
) – Measurement.state (
inekf.LieGroup
) – Current state estimate.
- Returns
Truncated innovation.
- Return type
np.ndarray
- makeHError(state, iekfERROR)
Sets and returns H_error for settings where filter error type != measurement error type. Done by multiplying H by adjoint of current state estimate. Called second in update step.
- Parameters
state (
inekf.LieGroup
) – Current state estimate.iekfERROR (
ERROR
) – Type of filter error.
- Returns
H_error
- Return type
np.ndarray
- processZ(z, state)
Process measurement before putting into InEKF. Can be used to change frames, convert r/b->x/y, or append 0s. By default is used to append zeros/ones onto it according to b vector set. Called first in update step.
- Parameters
z (
np.ndarray
) – Measurementstate (
inekf.LieGroup
) – Current state estimate.
- Returns
Processed measurement.
- Return type
np.ndarray
- setHandb(b)
Sets measurement vector b and recreates H accordingly. Useful if vector b isn’t constant.
- Parameters
b (
np.ndarray
) – Measurement model b
Process Model
- class inekf.ProcessModel
Base class process model. Must be inheriting from, base class isn’t implemented. More information on inheriting can be seen in Custom Models.
We have overloaded the
[]
operator to function as a python template. Example of this can be seen in Getting Started.Templates:
Group
State’s group that is being tracked, of typeinekf.LieGroup
.U
Form of control. Can be either a group ofinekf.LieGroup
, or a vector. Vectors can be used for example by “Vec3” or 3 for a vector of size 3. -1, “D”, or “VecD” for dynamic control size.
Attributes:
Process model covariance.
Methods:
f
(u, dt, state)Propagates state forward one timestep.
makePhi
(u, dt, state)Make a discrete time linearized process model matrix, with $Phi = exp(ADelta t)$.
- property Q
Process model covariance. May be read or written, but not modified in place.
- Returns
np.ndarray
- f(u, dt, state)
Propagates state forward one timestep. Must be overriden, has no default implementation.
- Parameters
u (control) – Control
dt (
float
) – Delta timestate (
inekf.LieGroup
) – Current state
- Returns
Updated state estimate
- Return type
- makePhi(u, dt, state)
Make a discrete time linearized process model matrix, with $Phi = exp(ADelta t)$. Must be overriden, has no default implementation.
- Parameters
u (control) – Control
dt (
float
) – Delta timestate (
inekf.LieGroup
) – Current state estimate (shouldn’t be needed unless doing an “Imperfect InEKF”)error (
ERROR
) – Right or left error. Function should be implemented to handle both.
- Returns
Phi
- Return type
np.ndarray