> ## Documentation Index
> Fetch the complete documentation index at: https://aegean.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Motion Planning

> Odometry models and motion planning for mobile robots.

## Odometry Motion Model

Odometry is commonly obtained by integrating wheel encoders information; most commercial robots make such integrated pose estimation available in periodic time intervals (e.g., every tenth of a second).

<img src="https://mintcdn.com/aegeanaiinc/8QUGbQnxBRbEKIZV/aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-model.png?fit=max&auto=format&n=8QUGbQnxBRbEKIZV&q=85&s=f9ea0490214416c1774addea76ea2c25" alt="Odometry model" width="1191" height="702" data-path="aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-model.png" />

<img src="https://mintcdn.com/aegeanaiinc/8QUGbQnxBRbEKIZV/aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-measured.png?fit=max&auto=format&n=8QUGbQnxBRbEKIZV&q=85&s=64670a116f3345e8c16b78067154ecbb" alt="Measured Odometry model" width="1191" height="702" data-path="aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-measured.png" />

<img src="https://mintcdn.com/aegeanaiinc/8QUGbQnxBRbEKIZV/aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-sampling.png?fit=max&auto=format&n=8QUGbQnxBRbEKIZV&q=85&s=317d21edb3524d910d3baffb3fffa769" alt="Sampled Odometry model" width="1191" height="691" data-path="aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-sampling.png" />

<img src="https://mintcdn.com/aegeanaiinc/8QUGbQnxBRbEKIZV/aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-belief.png?fit=max&auto=format&n=8QUGbQnxBRbEKIZV&q=85&s=1b2c7c1785eb58a137c293604a3e89e3" alt="Odometry belief over time" width="1286" height="1169" data-path="aiml-common/lectures/planning/local-planning/motion-planning/images/odometry-belief.png" />

Wheel displacements derived from encoder readings produce noisy pose update:
$p(x_t \mid x_{t-1}, u_t) = p(\widehat{\Delta_{\text{rot}_1}}) \, p(\widehat{\Delta_{\text{trans}}}) \, p(\widehat{\Delta_{\text{rot}_2}}),$

factorized by initial rotation, translation, final rotation.

Compute noisy components:

$$
\Delta_{\text{rot}_1} = \operatorname{atan2}(y_t - y_{t-1}, x_t - x_{t-1}) - \theta_{t-1}
$$

$$
\Delta_{\text{trans}} = \sqrt{(x_t - x_{t-1})^2 + (y_t - y_{t-1})^2}
$$

$$
\Delta_{\text{rot}_2} = \theta_t - \theta_{t-1} - \Delta_{\text{rot}_1}
$$

Sample corrupted increments:

$\widetilde{\Delta_{\text{rot}_1}} = \Delta_{\text{rot}_1} - \mathcal{N}(0, \alpha_1 \Delta_{\text{rot}_1}^2 + \alpha_2 \Delta_{\text{trans}}^2)$

and similarly for $\widetilde{\Delta_{\text{trans}}}$ and $\widetilde{\Delta_{\text{rot}_2}}$.

Updated pose:

$$
x_t = x_{t-1} + \widetilde{\Delta_{\text{trans}}} \cos(\theta_{t-1} + \widetilde{\Delta_{\text{rot}_1}})
$$

$$
y_t = y_{t-1} + \widetilde{\Delta_{\text{trans}}} \sin(\theta_{t-1} + \widetilde{\Delta_{\text{rot}_1}})
$$

$$
\theta_t = \theta_{t-1} + \widetilde{\Delta_{\text{rot}_1}} + \widetilde{\Delta_{\text{rot}_2}}
$$

## Velocity Motion Model

Given commanded $(v,\omega)$ and noise parameters $\alpha_i$:

$$
\hat{v} = v + \mathcal{N}(0, \alpha_1 v^2 + \alpha_2 \omega^2)
$$

$$
\hat{\omega} = \omega + \mathcal{N}(0, \alpha_3 v^2 + \alpha_4 \omega^2)
$$

$$
\hat{\gamma} = \mathcal{N}(0, \alpha_5 v^2 + \alpha_6 \omega^2)
$$

then sample the next pose $(x_t,y_t,\theta_t)$ via standard velocity model equations.

$$
x_t = x_{t-1} - \frac{\hat{v}}{\hat{\omega}}\sin \theta_{t-1} + \frac{\hat{v}}{\hat{\omega}}\sin(\theta_{t-1}+\hat{\omega} \Delta t)
$$

$$
y_t = y_{t-1} + \frac{\hat{v}}{\hat{\omega}}\cos \theta_{t-1} - \frac{\hat{v}}{\hat{\omega}}\cos(\theta_{t-1}+\hat{\omega} \Delta t)
$$

$$
\theta_t = \theta_{t-1} + \hat{\omega} \Delta t + \hat{\gamma} \Delta t
$$

If $|\hat{\omega}| < \epsilon$ treat as straight motion:

$$
x_t = x_{t-1} + \hat{v} \Delta t \cos \theta_{t-1}, \quad y_t = y_{t-1} + \hat{v} \Delta t \sin \theta_{t-1}, \quad \theta_t = \theta_{t-1} + \hat{\gamma} \Delta t
$$

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit this page on GitHub](https://github.com/aegean-ai/eaia/edit/main/src/aiml-common/lectures/planning/local-planning/motion-planning/index.mdx) or [file an issue](https://github.com/aegean-ai/eaia/issues/new/choose).
</Callout>
