Runtime

FormaK provides runtime tools that are designed to work with the filters generated by FormaK to create a performant, easy to use, reference runtime.

The FormaK runtime can also be used by non-FormaK filters and FormaK filters do not require the runtime.

ManagedFilter

Features available in the runtime via ManagedFilter:

  • Easier to use interface

  • Automated handling of sensor readings that arrive at any time in any order

Setting up a ManagedFilter:

formak::runtime::ManagedFilter<featuretest::ExtendedKalmanFilter> mf(
    initial_time,
    {
        .state = state,
        .covariance = {},
    }
);

Updating the filter with new data:

mf.tick(
    output_time,
    control,
    {
        mf.wrap<Readingtype>(reading_time, reading),
    }
);

Note: The call to wrap is used to provide a uniform interface for all reading types. Multiple reading types can be wrapped into the same vector of inputs to the ManagedFilter.

Requirements for Filters used with ManagedFilter

  • The type passed to the ManagedFilter must be default constructable

A type can be checked for compatibility at compile time against these rules and any additional features as the library evolved with the following static function:

static_assert(formak::runtime::ManagedFilter<featuretest::ExtendedKalmanFilter>::compatible);

Required runtime properties for instance of the filter type can be checked with the following static function:

ASSERT_TRUE(formak::runtime::ManagedFilter<featuretest::ExtendedKalmanFilter>::runtime_compatible());

Python Interface

FormaK also provides a Python implementation of a ManagedFilter.

Setting up a ManagedFilter:

mf = ManagedFilter(ekf=ekf, start_time=3.0, state=state, covariance=covariance)

Note: The Python ManagedFilter takes the EKF as a constructor argument instead of default constructing the EKF.

Updating the filter with new data:

state0p1 = mf.tick(3.1, control=control, readings=[
    StampedReading(3.05, "simple", np.zeros((1, 1))),
])