Skip to main content
emobility.academy
M.TechSensor fusion & trackingAdvanced About 8 weeksADAS & AUTOSAR

IMM Filter for Manoeuvring Vehicles (Constant Velocity / Turn Models)

Build an interacting multiple model (IMM) filter that switches between constant-velocity, constant-acceleration and constant-turn models to track vehicles that brake, change lanes and turn. Its accuracy and responsiveness are compared with single-model filters on scripted manoeuvres.

Tools: MATLAB · Sensor Fusion and Tracking Toolbox

IMM Filter for Manoeuvring Vehicles (Constant Velocity / Turn Models): Engineering workstations in the DIYguru EV lab
Representative photo from DIYguru's EV lab, not of this specific project.

The problem

A vehicle ahead may drive steadily, brake suddenly, change lanes or turn at a junction or roundabout, all within seconds. A single motion model is either too stiff to follow manoeuvres or too loose and noisy in steady driving. ADAS functions such as AEB and lane-change assist need both accuracy and fast response. The IMM filter runs several models in parallel and blends them by probability, and this project measures how much it actually gains.

Objectives

  • Build manoeuvre scenarios with steady driving, hard braking, lane changes and turns.
  • Implement single-model CV, CA and CT filters as baselines.
  • Configure an IMM filter with these models and tune its transition probabilities.
  • Compare RMSE, peak error during manoeuvres and NEES across filters.
  • Use the IMM model probabilities as a manoeuvre indicator and assess its timing.

What you need

Tools and toolboxes

  • MATLAB — Scenario scripting, Monte Carlo runs and plotting of errors and model probabilities.
  • Sensor Fusion and Tracking Toolbox — trackingEKF with constvel, constacc and constturn models, trackingIMM and initekfimm, and trackerGNN for the multi-target extension.
  • Automated Driving Toolbox — drivingScenario and drivingRadarDataGenerator to generate realistic manoeuvres and radar detections.
  • Python with NumPy (optional) — A two-model IMM written from scratch to show the mixing and probability update.

Software

  • MATLAB R2023b or later
  • Sensor Fusion and Tracking Toolbox
  • Automated Driving Toolbox
  • Python 3 with NumPy (optional)

Extra parts and data

None beyond the software above.

Key concepts

Motion models
Constant velocity assumes steady speed and direction, constant acceleration allows steady speed change, and constant turn allows a steady yaw rate. Each fits a different phase of driving.
Model probability
The IMM keeps a probability for each model, updated from how well each one predicted the latest measurement. The output is the probability-weighted combination of the models.
Mixing step
Before each prediction, the IMM mixes the model estimates according to the transition probabilities, so a model that has just become likely starts from a sensible state.
Transition probability matrix
The assumed probability of switching from one model to another between scans. It controls how quickly the IMM reacts to a manoeuvre and how stable it is in steady driving.

Step-by-step guide

  1. 1

    Define manoeuvres and requirements

    List the manoeuvres the tracker must handle: steady following, braking at 3 and 6 m/s², a lane change in 3 s, a 90-degree turn at a junction and a roundabout. Set targets for position and velocity error in steady phases and for peak error and recovery time during manoeuvres. State the sensor (forward radar at 20 Hz) and its noise. These requirements tie the filter design to ADAS needs such as AEB timing.

    Checkpoint: A manoeuvre list with targets for steady-state error, peak error and recovery time.

  2. 2

    Build the scenarios

    Create each manoeuvre with drivingScenario using waypoints and speed profiles that give realistic accelerations and yaw rates. Mount a forward radar with drivingRadarDataGenerator, or generate position measurements with known noise directly for the first experiments. Save ground truth including the true acceleration and yaw rate, and mark the manoeuvre start and end times for later analysis. Check that the yaw rate during the roundabout stays physically plausible for the chosen speed, so the constant-turn model is tested fairly.

    Checkpoint: Plots of each scenario's path, speed, acceleration and yaw rate with manoeuvre times marked.

  3. 3

    Implement single-model baselines

    Create three trackingEKF filters using constvel, constacc and constturn state transition functions with matching measurement functions. Tune each one's process noise on a separate tuning scenario to give its best overall RMSE. Run all three on every manoeuvre scenario and record errors. Expect CV to lag in braking and turns, CA to be noisy in steady driving and CT to struggle with braking.

    Checkpoint: Error plots for the three single-model filters showing their individual weaknesses.

  4. 4

    Write a two-model IMM by hand

    In Python, implement an IMM with CV and CA models. Code the four stages: mixing with the transition matrix, model-matched prediction and update, model probability update from measurement likelihoods, and combined output. Run it on the braking scenario and plot model probabilities over time. This hand version makes every stage of the toolbox filter explainable and is a strong viva asset.

    Checkpoint: Model probability plot where CA probability rises shortly after braking starts.

  5. 5

    Configure the toolbox IMM

    Create a trackingIMM with the three EKFs as its TrackingFilters, a ModelConversionFcn to map between different state sizes (the toolbox's switchimm function), initial model probabilities and a TransitionProbabilities matrix with high diagonal values such as 0.95. Run it on all scenarios and log combined state and model probabilities. Compare its braking-scenario result with your hand-written IMM. Differences usually come from model conversion or noise settings, so check those first. Keep the configuration in one script so it can be reused later in the multi-target tracker.

    Checkpoint: Toolbox IMM and hand-written IMM give similar model probabilities on the braking scenario.

  6. 6

    Tune transition probabilities

    Sweep the diagonal of the transition matrix from 0.8 to 0.99 and, separately, the process noise of each model. For each setting, record steady-state RMSE, peak manoeuvre error and recovery time on the tuning scenario. Plot these against the diagonal value. High values give smooth steady tracking but slow switching; low values switch fast but produce noise. Choose a setting that meets the requirements.

    Checkpoint: A tuning plot of steady error against recovery time with the chosen setting marked.

  7. 7

    Run the Monte Carlo comparison

    Run the three single-model filters and the IMM over at least 100 seeds on every manoeuvre scenario. Compute RMSE in steady phases, peak error and recovery time during manoeuvres, and NEES for consistency. Present results by scenario and phase, because averaging over a whole run hides the difference that matters. Include confidence intervals. Split each run into steady, manoeuvre and recovery phases using the marked times before computing statistics, and keep the phase boundaries identical for every filter compared.

    Checkpoint: A results table by scenario and phase for all four filters with confidence intervals.

  8. 8

    Use model probabilities as a manoeuvre indicator

    Define a manoeuvre-detected flag when the CA or CT model probability exceeds a threshold. Measure detection delay against the true manoeuvre start and the rate of false flags during steady driving. Discuss how such a flag could feed ADAS logic, for example earlier AEB arming when the lead vehicle starts braking, or cut-in prediction from a rising turn model probability.

    Checkpoint: Detection delay and false-flag rate for braking, lane-change and turn manoeuvres.

  9. 9

    Extend to multiple targets

    Plug the IMM into trackerGNN with initekfimm as the FilterInitializationFcn and run a multi-vehicle scenario with simultaneous manoeuvres, such as a cut-in while the lead vehicle brakes. Compare with a CV-only tracker using trackGOSPAMetric and track swap counts. This shows whether better motion modelling also improves association, since better predictions give tighter, more accurate gates. Record per-scan run time as well, because three models per track triple the filter cost and that matters on an ECU with many objects in view.

    Checkpoint: GOSPA and swap counts for IMM and CV-only trackers on the multi-vehicle scenario.

  10. 10

    Report

    Write up the motion models, IMM theory with your hand-written implementation, tuning, Monte Carlo results by phase, manoeuvre detection and the multi-target extension. Explain where IMM clearly helps and where a single well-tuned model is enough. Note computational cost as the number of models grows. Release scripts and scenarios with fixed seeds. Include the hand-written IMM as an appendix with comments, because it shows your understanding better than any toolbox call. Add a summary table that maps each manoeuvre to the best filter found and its margin over the next best.

    Checkpoint: A report with phase-wise results, tuning evidence and reproducible code.

Testing & validation

  • Hand-written IMM matches toolbox trackingIMM on the braking scenario.
  • Steady-phase RMSE, peak manoeuvre error and recovery time for all filters.
  • NEES consistency across 100 Monte Carlo runs.
  • Manoeuvre detection delay and false-flag rate from model probabilities.
  • Multi-target GOSPA and swaps with IMM against CV-only tracking.

Expected results

A tuned IMM tracker with phase-wise evidence of its accuracy and response gains over single-model filters, plus a manoeuvre indicator usable by ADAS decision logic.

Research angle for your M.Tech thesis

Research questions: how much does an IMM improve peak error and recovery time during typical urban manoeuvres compared with tuned single-model filters, and how early can its model probabilities flag a manoeuvre for AEB or cut-in logic? Metrics: phase-wise RMSE, peak error, recovery time, NEES, detection delay and false-flag rate. Baselines: tuned CV, CA and CT filters and an adaptive-noise filter. A study linking tracker design to downstream ADAS timing, using mixed traffic manoeuvres typical of Indian roads, is a reasonable conference contribution.

Take it further

  • Add a model for stationary or stop-and-go behaviour in city traffic.
  • Use road geometry to constrain the turn model at junctions.
  • Run the IMM tracker on recorded radar data from nuScenes.
  • Compare IMM with an adaptive single-model filter that scales its process noise online.

Viva and review questions

Why not simply use the constant-acceleration model all the time?

Its extra state adds noise in steady driving, where acceleration is near zero; the IMM gets CA's responsiveness only when it is needed.

What does the mixing step do?

It combines the previous model estimates according to the transition probabilities, so each model starts its prediction from a state that reflects the chance a switch has just happened.

How do the transition probabilities affect behaviour?

High self-transition probabilities make the IMM stable but slow to switch; lower values make it switch quickly but noisier in steady driving.

Learn it at DIYguru

These DIYguru courses and programmes teach what this project needs.

Related EV projects

All 100 ADAS & AUTOSAR projects