iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::UKF< StateDefinitionType, ObservationDefinitionType, FilterModel > Class Template Reference

#include <nrt/Probabilistic/BayesFilters/UKF.H>

template<class StateDefinitionType, class ObservationDefinitionType, class FilterModel>
class nrt::UKF< StateDefinitionType, ObservationDefinitionType, FilterModel >

An Unscented Kalman Filter.

  The Unscented Kalman Filter is a very general and robust filter used for
  prediction and tracking of potentially non-linear states. The
  implementation here requires only that you provide definitions of the
  state and the observation, as well as a filter model containing two
Template Parameters
StateDefinitionTypeAn nrt::StateDefinition defining the fields of the target to be tracked. For example, this State Definition may include the current position, velocity and acceleration of a tracked vehicle.
ObservationDefinitionTypeAn nrt::StateDefinition defining the fields that your sensor will return. For example, if you are tracking vehicles with a radar system, this State Definition may include the measured range and bearing from the radar sensor to the target.
FilterModelA simple struct which defines how your tracked target changes over time, and how your sensor observes it. Read on for more information.
The Filter Model
  The FilterModel template parameter should be a struct which you define to
  tell the UKF how your target interacts with the world, and how the world
  senses your target. The FilterModel that you provide must have the following definition:
// In this example, we model our target as a vehicle with x,y,theta position
// and translational,angular velocity
NRT_CREATE_STATE_FIELD_GROUP(Position, (x)(y)(theta));
NRT_CREATE_STATE_FIELD_GROUP(Velocity, (translational)(angular));
// ... And, we observe our vehicle with a range and angle
NRT_CREATE_STATE_FIELD_GROUP(PolarPosition, (range)(angle));
struct MyCoolFilterModel
// This can be any kind of custom data that your predict method may need to
// help it make predictions. For example, if you know the positions of the
// gas and brake pedals in the tracked vehicle (which would certainly help
// with the tracking!), then your ControlType struct could contain these
// values.
struct ControlType;
// A function which takes as arguments a state of your target from the last timestep, and a control struct,
// and must return the predicted position for the current timestep. In our example, we should integrate the
// Velocity::translational and Velocity::angular into the Position::x, Position::y, and Position::theta
predict(nrt::StateVector<VehicleState> const & state, ControlType const & control);
// A function which takes as an argument a state of the target, and must return what you expect your sensor would retrun
// if your target was in this state. In our example, we should return the PolarPosition::range and PolarPosition::angle
// from the given state to the radar station.
observe(nrt::StateVector<VehicleState> const & state)
The Unscented Kalman Filter works by running the predict and observe methods for a few well-chosen points around the current believed state in order to estimate how the state is moving. Because of this, you should make sure that your predict and observe methods are completely re-entrant.

The neat thing about the UKF is that it can automatically predict portions of your state which are not directly observable by your sensor. In our vehicle tracking example above, notice that the sensor cannot measure the speed or orientation of the vehicle - only the position. However, the filter will quickly start estimating the orientation and velocity fields automatically after a few timesteps.

See Also

Definition at line 125 of file UKF.H.

Public Member Functions

 UKF (GaussianPDF< StateDefinitionType > const &initialState, Eigen::Matrix< double, itsNS, itsNS > const &predictionCovariance, double alpha=1e-3, double k=0, double beta=2.0)
 Construct an Unscented Kalman Filter.
< StateDefinitionType > & 
state ()
 Get a reference to the current estimated state of the system.
void predict (typename FilterModel::ControlType const &control=typename FilterModel::ControlType())
 Predict the current state of the system with optional control. More...
void update (GaussianPDF< ObservationDefinitionType > const &observation)
 Update the filter with an observation. More...
void setPredictionCovariance (Eigen::Matrix< double, itsNS, itsNS > const &predictionCovariance)
 Change the prediction covariance of the model.

Member Function Documentation

template<class StateDefinitionType, class ObservationDefinitionType, class FilterModel>
void nrt::UKF< StateDefinitionType, ObservationDefinitionType, FilterModel >::predict ( typename FilterModel::ControlType const &  control = typename FilterModel::ControlType())

Predict the current state of the system with optional control.

The predict method will extrapolate the new state of the system from the current estimated state by running FilterModel::predict a few times to try to estimate where your model is heading.

controlAn optional FilterModel::ControlType value. This value is just directly forwarded to the FilterModel::predict method
Calling predict() too many times without a call to update() will cause the filter's covariance to grow, and may make the state() become unstable.

Definition at line 73 of file UKFImpl.H.

template<class StateDefinitionType , class ObservationDefinitionType , class FilterModel >
void nrt::UKF< StateDefinitionType, ObservationDefinitionType, FilterModel >::update ( GaussianPDF< ObservationDefinitionType > const &  observation)

Update the filter with an observation.

The update method is used to incorporate real measurements from the system into the estimated state

observationA real observation taken from your sensor as a Gaussian PDF.

Definition at line 102 of file UKFImpl.H.

References NRT_WARNING.

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