
EECE 5550 Mobile Robotics
Lecture 6
Sensors, Fusion, and Localization
Dr. Xian Li
Department of Electrical and Computer Engineering
Northeastern University
Back to the question
Ten minutes of driving. Which estimate would you trust?
Today
Every estimate is only as good as the models behind it.
- The Bayes filter, revisited. Belief, and the two models it needs.
- Choosing a filter. KF, EKF, UKF, and particles, step by step on small problems.
- The motion model. Odometry predicts the pose, as a distribution.
- Measurement models. What each TurtleBot 4 sensor reports, to correct the prediction: p(z | x).
- Localization. The EKF and Monte Carlo localization on the TurtleBot pose.
- Fusion and AMCL in practice. Count each sensor once; map → odom, in simulation and on the robot.
- Thrun, Burgard, and Fox, Probabilistic Robotics, Ch. 3 to 6, and 8
- Moore and Stouch, robot_localization, IAS 2014
- Fox, KLD-sampling, IJRR 2003
- Nav2 documentation: AMCL
Lecture 5 derived the Bayes and Kalman filters. Today: the filters that cope when models are nonlinear or non-Gaussian, the models the TurtleBot 4 needs, and AMCL, which puts them together.
The Bayes filter, revisited
From Lecture 5. Every filter today runs these two steps; they differ only in how they store the belief.
Try it: a Bayes filter in a hallway
The robot has the map (three doors) but not its position. Alternate Sense and Move, and watch the belief.
KF, EKF, UKF, and PF: what each filter assumes
Same predict and correct steps. Choose by two questions: are the models linear, and is the noise Gaussian?
| Filter | Linear models? | Gaussian noise? | Belief stored as | How it handles nonlinearity | On the TurtleBot 4, ROS 2 Jazzy |
|---|---|---|---|---|---|
| Kalman filter (KF) | required | required | mean and covariance | not needed: exact, and optimal, for linear-Gaussian systems | Not in the default stack. Lecture 5's wall_kf.py; Lab 3's complementary filter is a fixed-gain KF. |
| Extended KF (EKF) | not required | required | mean and covariance | first-order : Jacobians G and H at the mean | Not launched by default. Available as robot_localization's ekf_node. |
| Unscented KF (UKF) | not required | required | mean and covariance | 2n + 1 through the exact model; no Jacobians | Not launched by default. Available as robot_localization's ukf_node. |
| Particle filter (PF) | not required | not required | M , any shape | every sample goes through the exact model; cost grows with M | Yes: AMCL (nav2_amcl), from turtlebot4_navigation; it publishes map → odom. |
Keep the value and the slope at the mean, and drop the curvature terms, ½g″(μ)(x − μ)² and beyond. A Gaussian through a line stays Gaussian: mean g(μ), covariance GΣGT.
Accurate when g is nearly straight over the belief, about ±2σ. The EKF slide shows one case where it is, the UKF slide one where it is not.
2n + 1 points whose weighted mean and covariance are exactly μ and Σ. Each goes through the exact model; the weighted mean and covariance of the results form the new Gaussian.
(√·)i is column i of a matrix square root, such as a Cholesky factor. For the TurtleBot pose, n = 3: seven points, and no Jacobians.
Each sample x[m] is one hypothesis of the state. Its weight says how well it explains the measurement, and the weights sum to one. Any shape is possible, including several peaks.
Resampling turns weights back into counts. Neff = 1 / ∑w² tracks how many samples still matter.
The KF, step by step: distance to a wall
Lecture 5's wall: the robot drives toward it and the lidar measures the distance d. Both models are linear.
- Belief at t − 1.
- Predict. u: odometry, 1 m toward the wall
- Measurement model. Linear already: the EKF's Jacobian H is just C.
- Measure. innovation z − Cμ̄ = −0.12 m
- Gain. The lidar is the better source here, so K is near 1.
- Correct.
- Check. Lecture 5's precision-weighted mean, 1/σ² = 1/σ̄² + 1/Q, gives the same σ = 0.096 m. Linear and Gaussian, so this is the exact posterior, not an approximation.
The EKF, step by step: range to a pillar
The same robot, now measuring its range to a pillar at (4, 1) m. The motion is still linear; the range is not.
- Belief at t − 1.
- Predict.
- Linearize h at μ̄.
- Measure. innovation z − h(μ̄) = −0.25 m
- Gain. Q = 0.10². K < 0 because a larger x gives a shorter range.
- Correct.
- Check. The exact posterior is 2.26 ± 0.11 m. Over ±σ̄ the tangent fits h well, so the EKF is accurate here.
The UKF: sigma points instead of a tangent
When the belief is wide, the tangent is a poor fit. The unscented transform pushes a few chosen points through h instead.
- The question. A wide belief near the pillar: what is the distribution of the range y = h(x)?
- Ground truth. 10⁵ samples through h: skewed, never below 1 m. Mean 1.44, std 0.44 m.
- EKF. Tangent at μ: N(1.28, 0.50²). The mean is too low, and 29% lies below 1 m, an impossible range.
- Sigma points. n = 1, λ = 2: 1.81, 3.20, 4.59 m; weights 1/6, 2/3, 1/6.
- Propagate. Through the exact h: Yi = 2.40, 1.28, 1.16 m.
- Recombine. σy = 0.43 m: close to the truth, and no Jacobian.
- The trade. Cost like the EKF (2n + 1 evaluations), accurate to second order. Still one Gaussian: the 1 m floor and multiple peaks need particles.
The particle filter, step by step: the hallway again
Same hallway, same three doors. Fifty particles replace the histogram; each click runs one line of the algorithm.
- Initialize
- Predict
- Weight
- Resample draw M particles with probability ∝
The odometry motion model
Thrun et al., Table 5.6, and nav2_amcl: each increment is a rotation, a translation, and a second rotation.
Try it: where could the robot be?
Sample the motion model 800 times and compare the cloud with the EKF's linearized 95% ellipse.
The odometry increment, repeated
Noise (Nav2 alpha1 to alpha4)
The TurtleBot 4 sensors and their models
Each sensor needs a model p(z | x): the reading it should give at pose x, and how real readings scatter around it.
What the readings look like
Illustrative shapes of p(z | x): for a known true state, where the readings land and how likely each value is.
Try it: the beam model for one lidar beam
One beam, with the map predicting range z*. The reading comes from one of four causes; the weights sum to one.
The world
The sensor
Try it: the likelihood field, as AMCL scores a scan
Given an occupancy grid (Lecture 7 builds one), AMCL precomputes each cell's distance d to the nearest wall and scores each beam endpoint by its d.
The model
The candidate pose (one particle)
The EKF on the TurtleBot pose
The same steps on the full pose (x, y, θ): predict with the odometry model, correct with the lidar.
Monte Carlo localization: the same loop in 2D
Fox, Burgard, Dellaert, and Thrun, 1999. Each particle is a pose (x, y, θ); the scan is scored with the likelihood field.
resample_interval updates (default 1). Cost grows as particles × beams.Try it: a particle filter in a room
Press Global localization: the cloud splits between look-alike places until the room's asymmetry resolves it.
The filter
A complementary filter, for heading
High-pass the integrated gyro, low-pass an absolute heading; the two filters sum to one. You build one in Lab 3.
wrap(z − θ̂), the atan2(sin, cos) of the difference, never raw angles.Try it: blending a gyro with an absolute heading
Sixty seconds of turning. The gyro has a bias; the absolute heading is noisy. Find the gain that outperforms both.
The gyro
The absolute heading
The blend
Count each sensor once
A Kalman filter assumes independent measurement errors. Fusing /imu on top of /odom counts the same gyro twice.
AMCL, as Nav2 runs it
Each parameter maps to a model or a Try-it from this lecture.
| Parameter | Nav2 default | Controls |
|---|---|---|
min_particles, max_particles | 500, 2000 | how many hypotheses (KLD adapts between them) |
update_min_d, update_min_a | 0.25 m, 0.2 rad | how far to move before updating |
laser_model_type, max_beams | likelihood_field, 60 | the measurement model, and how many beams it scores |
sigma_hit, z_hit, z_rand | 0.2 m, 0.5, 0.5 | the likelihood field's width and mixture weights |
alpha1 to alpha4 | 0.2 | the odometry motion model's noise |
resample_interval | 1 | how many updates between resampling steps |
recovery_alpha_slow, _fast | 0.0, 0.0 | random particles injected when the fit drops: off |
ros2 param get /amcl max_particles.What AMCL publishes: map → odom
The answer to Lecture 2's question.
/amcl_pose and /particle_cloudVerify in simulation
Exercise 1: watch AMCL converge, then kidnap it
Run this on your Ubuntu PC: no robot needed
Press Play in Gazebo. In RViz, use 2D Pose Estimate to drop the robot roughly where it is, and watch the particle cloud. Then give it a deliberately wrong pose, about a meter off, and drive.
map → odom change while the robot sits still?/amcl_pose before and after a turn near a wall.Verify on your TurtleBot
Exercise 2: characterize your sensors before you trust a filter with them
Run this on your Ubuntu PC, with the robot on the network
If /imu is missing, it may only exist in the hidden namespace, as /wheel_ticks did in Lecture 4: ros2 topic list --include-hidden-topics | grep imu.
| Quantity | Predict | Measured |
|---|---|---|
/scan rate | Hz | |
/imu rate | Hz | |
/odom rate | Hz | |
range_min, range_max | m | |
| beams per scan | ||
| gyro bias at rest | °/s |
ros2 bag record /imu, and average angular_velocity.z.Verify on your TurtleBot
Exercise 3: localize on your own map
Run these on your Ubuntu PC, with the map from Lab 3
Set the initial pose in RViz, then drive one lap of the room. Keep a fourth terminal on ros2 run tf2_ros tf2_echo map odom.
When localization fails
Review these before Lab 4: every Nav2 plan depends on the pose AMCL reports.
What to take away
Predict with the motion model, correct with the measurement model.
KF if linear-Gaussian; EKF or UKF if nonlinear but single-peaked; particles for many peaks.
Odometry noise is Gaussian in (δrot1, δtrans, δrot2), not in x and y.
Beam model or likelihood field for the lidar, σZ ∝ Z² for stereo, bias plus noise for the gyro.
Complementary filter: τ sets the crossover. Count each sensor once.
AMCL publishes the correction. Check its parameters on your robot.