# Probabilistic motion models

## Overview

For data fusion, SLAM, and localization
(for example using a particle filter such as the well-known `amcl`

Adaptive MonteCarlo Localization),
we need to handle the uncertainty in SE(2) or SE(3) pose increments.

Within a particle filter, pose samples are propagated at each time step using some given proposal distribution. A common approach for mobile robots is taking the probabilistic motion model directly as this proposal. In EKF or other graphical models (factor graphs) we would also need a probability distribution for pose increments, in this case, typically a parametric unimodal one such as the multivariate Gaussian distribution, defined via one mean pose and one covariance matrix for the “noise” (uncertainty).

In MRPT there are two **motion models** for probabilistic motion in SE(2), and
one for SE(3), with the relevant classes being
mrpt::obs::CActionRobotMovement2D
and
mrpt::obs::CActionRobotMovement3D
, respectively.

The **next video** shows a comparison of pose samples propagated using the **Gaussian** (left)
and the **Thrun’s sample-based** (right) motion models:

The rest of this page explains the **different theoretical models and equations** for
those motion models. A C++ API usage example would be:

```
using namespace mrpt::literals; // _deg
// Select the motion model and its parameters:
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions opts;
opts.modelSelection = mrpt::obs::CActionRobotMovement2D::mmThrun;
opts.thrunModel.alfa3_trans_trans = 0.10f;
// The odometry pose increment:
mrpt::poses::CPose2D actualOdometryReading(0.20, 0.05, 1.2_deg );
// Create the probability density distribution (PDF) from a 2D odometry reading:
mrpt::obs::CActionRobotMovement2D actMov;
actMov.computeFromOdometry( actualOdometryReading, opts );
// Next, for example, draw one sample from the PDF:
mrpt::poses::CPose2D sample;
actMov.drawSingleSample( sample );
```

## Gaussian probabilistic motion model

Note

This model is used for SE(2) pose increments when:

opts.modelSelection = mrpt::obs::CActionRobotMovement2D::mmGaussian;

Assume the odometry is read as incremental changes in the 2D robot pose. The odometry readings are denoted as:

The model for these variables is:

Following [EP04], the equations that relate the prior robot pose \(\left( x ~ y ~ \phi \right)\) and the new pose \(\left( x' ~ y' ~ \phi' \right)\) after the incremental change are:

Within the context of a particle filter for localization, the aim at this point will be to obtain a multivariate Gaussian distribution of the new pose given a prior pose with a perfectly-known value (it is the particle being propagated). In this case we can just model how to draw samples from a prior pose at the origin (\((0~0~0)\)), and then the samples can be composed using the actual prior pose.

Using this simplification:

The mean of the Gaussian can be simply computed from the composition of the prior and the odometry increment. For the covariance, we need to estimate the variances of the three variables of the odometry increment. We model them as having independent, zero-mean Gaussian errors. The errors will be composed of terms that capture imperfect odometry and potential drift effects. We denote as \(\Sigma\) the diagonal matrix having the three variances of the odometry variables, modeled as:

The default parameters (loaded in the constructor and available in RawLogViewer) are:

And finally, the covariance of the new pose after the odometry increment \(C\) is computed by means of:

where J stands for the Jacobian of H. See [Arr98] for a derivation of this formula for error propagation.

## Sampling-based model for planar motion

Note

This model is used for SE(2) pose increments when:

opts.modelSelection = mrpt::obs::CActionRobotMovement2D::mmThrun;

As above, denote the odometry readings as \(\left( \Delta^{odo}_x ~ \Delta^{odo}_y ~ \Delta^{odo}_\phi \right)\), and let’s assume that the prior robot pose is \((0~0~0)\), which means that we want to draw samples of the robot increment, not the final robot pose (to simplify the equations without loss of generality). Then, the new robot pose, which we want to draw samples from is:

where the variables correspond to the robot pose increment as is shown in the figure:

Here, the variables \(\hat\delta_{trans}\), \(\hat\delta_{rot1}\) and \(\hat\delta_{rot2}\) are the result of adding a Gaussian, zero-mean random noise to the actual odometry readings:

The model described in [TBF05] employs the following approximations for the values of the standard deviations required for the equations above:

The MRPT implementation of this model includes an additional optional (white, additive Gaussian) noise which may be added to each pose component (\(x,y,\phi\)) to prevent that a null odometry increment leads to absolute no motion for a set of particles, which may lead to particle filter degeneration.

The next figure illustrates an example of the “banana shaped distribution”, which comes out from this model for large values of \(\alpha_2\) (a very large “slippage”), generated with Application: RawLogViewer:

## Sampling-based model for 3D motion

Note

This model is used for SE(3) pose increments when:

opts.modelSelection = mrpt::obs::CActionRobotMovement3D::mm6DOF;

MRPT also implements a sampling-based algorithm to estimate the equivalent Gaussian distribution of a set of samples generated from a raw SE(3) pose increment, based on [BFurlanG+12]. Refer to the paper, and to the implementation source code of mrpt::obs::CActionRobotMovement3D for further details.