LiDAR and sensor fusion
UAT 458 Indoor Autonomous UAS and Navigation Technology
Lesson
By the end of this module you will be able to
- Explain LiDAR positioning by successive scan matching and by matching against a map, with its limits indoors
- Use ICP to find the rotation and translation between two LiDAR scans, and detect degenerate matching from the eigenvalues of the information matrix
- Design a Kalman filter that predicts with the IMU and corrects with UWB while estimating accelerometer bias
- Use an EKF with raw UWB ranges and a chi-square gate to reject blocked ranges
Why this matters
Modules 6 and 7 reached three conclusions. The IMU is fast and continuous but drifts quickly; tags and VIO need good images; UWB covers the whole hall but gives poor height and can be blocked. No single sensor meets Hall 3’s needs on its own. This module adds one more sensor from the course description, LiDAR, which works in the dark and measures the shape of the surroundings directly, and then covers sensor fusion: producing one position that is better than any of the sources combined into it.
The basics of the Kalman filter were covered in UAT 305 as an autopilot height estimator. Here it is applied to problems specific to indoor navigation: estimating the IMU bias along the way, using raw, nonlinear UWB ranges, and rejecting blocked ranges before they distort the position.
LiDAR indoors
LiDAR fires laser pulses and times their return, giving range as covered in UAT 205. A spinning or solid-state LiDAR produces a scan, a set of many points around the sensor, tens of times per second. Indoors, LiDAR can localize in two ways.
- LiDAR odometry matches the current scan with the previous one, finds how far the sensor moved, and adds the steps up. It is still a motion measurement, so it drifts slowly.
- Matching against a map aligns the scan with a map built earlier, giving position directly in the map frame with no accumulation. Cartographer, by Hess and colleagues (2016), matches scans to submaps and closes loops in real time at 5 cm resolution. Building maps and closing loops are covered in module 9.
LiDAR’s limits in the hall are that glass and glossy surfaces reflect the laser away, so no point returns or a point appears in the wrong place; matte black surfaces absorb light and shorten the range; haze from stage smoke machines produces points floating in mid-air; and a long, featureless wall makes scan matching degenerate in one direction, as Example 2 shows.
Scan matching with ICP
ICP (iterative closest point), by Besl and McKay (1992), finds the rotation and translation that best lay the current scan over a reference scan. Each iteration has two steps.
- Match each point of the current scan (moved by the latest estimate) with its nearest point in the reference scan.
- Find the best transform for those pairs, which has a closed-form solution. Arun and colleagues (1987) showed that after subtracting the centroids of both sets and forming , the SVD gives and (if the determinant of is negative, flip the sign of the last row of to avoid a mirror image).
Repeat until the result settles. Nearest-point matching is often wrong in early iterations, so ICP needs an initial guess close to the truth, which on a drone comes from the IMU or VIO. Started too far away, it can converge to a wrong local solution.
Example 1 Matching scans of a booth corner and a round column
A 2D LiDAR on the drone scans two sides of a booth corner and a round column of radius 0.4 m. Between the two scans the drone rotates 4° and moves (0.30, −0.15) m, and every point has 1 cm of noise (assumed). ICP starts by assuming no motion at all.
import numpy as np
# Example 1: point-to-point ICP between two 2D LiDAR scans of a booth corner and a column
rng = np.random.default_rng(7)
wall_a = np.c_[np.linspace(0, 6, 121), np.zeros(121)] # booth wall along x (m)
wall_b = np.c_[np.zeros(66), np.linspace(0.25, 3.5, 66)] # booth wall along y
ang = np.linspace(0, 2 * np.pi, 32, endpoint=False)
column = np.c_[4 + 0.4 * np.cos(ang), 2.5 + 0.4 * np.sin(ang)] # round column, radius 0.4 m
ref = np.vstack([wall_a, wall_b, column])
th = np.radians(4.0); t_true = np.array([0.30, -0.15]) # motion between scans (assumed)
R_true = np.array([[np.cos(th), -np.sin(th)], [np.sin(th), np.cos(th)]])
cur = (ref - t_true) @ R_true + rng.normal(0, 0.01, ref.shape) # same scene seen from the moved drone
def best_fit(P, Q): # rigid transform that maps P onto Q (Arun et al., 1987)
mp, mq = P.mean(0), Q.mean(0)
U, _, Vt = np.linalg.svd((P - mp).T @ (Q - mq))
R = Vt.T @ U.T
if np.linalg.det(R) < 0:
Vt[-1] *= -1; R = Vt.T @ U.T
return R, mq - R @ mp
R, t = np.eye(2), np.zeros(2)
for it in range(30):
moved = cur @ R.T + t
nn = np.argmin(((moved[:, None, :] - ref[None, :, :]) ** 2).sum(2), axis=1) # nearest neighbours
R, t = best_fit(cur, ref[nn])
rms = np.sqrt(((cur @ R.T + t - ref[nn]) ** 2).sum(1).mean())
if it in (0, 4, 9, 29):
print(f"iteration {it + 1:2d}: rotation {np.degrees(np.arctan2(R[1, 0], R[0, 0])):5.2f} deg, "
f"translation ({t[0]:.3f}, {t[1]:.3f}) m, RMS {rms * 100:.1f} cm")
iteration 1: rotation 1.00 deg, translation (0.077, 0.001) m, RMS 12.0 cm
iteration 5: rotation 2.78 deg, translation (0.222, -0.079) m, RMS 4.6 cm
iteration 10: rotation 3.50 deg, translation (0.270, -0.119) m, RMS 2.4 cm
iteration 30: rotation 4.03 deg, translation (0.301, -0.150) m, RMS 1.3 cm
The first iteration finds only 1° of rotation because the nearest-point pairs are still badly wrong. Each iteration improves the pairs, and the RMS distance between pairs falls from 12.0 cm to 1.3 cm, close to the sensor’s 1 cm noise. The final 4.03° and (0.301, −0.150) m match the true motion. The round column helps a great deal because it provides information in every direction, not just perpendicular to the walls.
When scan matching degenerates
Imagine walking down a long corridor whose two walls look identical all the way. Close your eyes and open them again: you know the distance to each wall but cannot tell how many steps forward you have taken. LiDAR is the same. If every point it sees has its surface normal in one direction, matching can only determine translation in that direction.
Degeneracy is measured by the information matrix of the translation part, , where is the surface normal at point . Each eigenvalue says how strongly the data constrain translation along its eigenvector. A zero or very small eigenvalue means that direction is unobservable.
Example 2 The long wall of an empty hall
On a night when every booth has been removed, the drone flies along the hall’s long side. The LiDAR sees two parallel wall panels with 200 points each, compared with a stretch where a booth face stands across the view with 60 points (assumed).
# Example 2: why a long empty hall wall breaks scan matching (information matrix of point-to-line ICP)
def information(normals):
N = np.array(normals, float)
return N.T @ N # sum of n n^T over all points (translation part only)
corridor = [[0, 1]] * 200 + [[0, -1]] * 200 # two long parallel walls: every normal is along y
corner = [[0, 1]] * 200 + [[1, 0]] * 60 # the same wall plus a booth face across it
for name, n in (("long walls only", corridor), ("wall plus booth face", corner)):
w = np.linalg.eigvalsh(information(n))
print(f"{name:20s}: eigenvalues {w[0]:5.0f} and {w[1]:5.0f}")
long walls only : eigenvalues 0 and 400
wall plus booth face: eigenvalues 60 and 200
Parallel walls alone give eigenvalues 0 and 400: there is no information at all along the wall, so ICP can return anything in that direction while still reporting a low RMS as if it had succeeded. With the booth face across the view, the smaller eigenvalue becomes 60 and every direction is constrained. A good system computes this value for every scan and, when it falls below a threshold, down-weights LiDAR in that direction and leans on UWB or the IMU instead. This is the mathematical reason for sensor fusion.
A Kalman filter fusing IMU and UWB
A Kalman filter (Kalman, 1960) always carries two things: the state estimate and the covariance matrix that says how uncertain it is. It loops through two steps (Welch & Bishop, 2004).
- Predict with a motion model and IMU acceleration, ; uncertainty grows, .
- Update when a measurement arrives from a reference sensor: compute the gain and move the state towards the measurement in proportion to the uncertainty on each side.
In Hall 3 the IMU at 100 Hz drives the prediction, while UWB at 10 Hz, LiDAR at 10 Hz and VIO at 30 Hz correct it whenever they arrive. A key technique for indoor navigation is to include the IMU bias in the state. The filter learns the bias from the repeated difference between prediction and measurement and removes it before the next prediction. When reference measurements disappear for a while, a bias-corrected IMU carries the drone far longer than in Example 1 of module 6 (Groves, 2013).
Example 3 A one-axis Kalman filter that also estimates bias
This example is reduced to one axis. The state has three elements: position, velocity and accelerometer bias. The 100 Hz IMU has a true bias of 0.05 m/s² and 0.05 m/s² of noise; the 10 Hz UWB is accurate to 0.10 m. The filter does not know the bias in advance (assumed).
# Example 3: Kalman filter along one axis: IMU predicts, UWB corrects, accelerometer bias is a state
dt, n = 0.01, 1000 # IMU at 100 Hz for 10 s
sig_a = 0.05 # accelerometer noise (m/s^2)
r_uwb = 0.10 ** 2 # UWB position variance (0.10 m standard deviation)
bias = 0.05 # true accelerometer bias (m/s^2), unknown to the filter
rng = np.random.default_rng(1)
F = np.array([[1, dt, -0.5 * dt ** 2], [0, 1, -dt], [0, 0, 1]]) # state: position, velocity, bias
Bu = np.array([0.5 * dt ** 2, dt, 0.0]); H = np.array([[1.0, 0.0, 0.0]])
Q = np.diag([0.0, (sig_a * dt) ** 2, (1e-4) ** 2]) # noise on velocity, slow bias wander
x_true = np.zeros(2); x_imu = np.zeros(2)
x = np.zeros(3); P = np.diag([0.5 ** 2, 0.1 ** 2, 0.1 ** 2])
err, sig = [], []
for k in range(1, n + 1):
a = 0.4 * np.sin(0.8 * k * dt) # true acceleration of the drone
x_true = np.array([x_true[0] + x_true[1] * dt + 0.5 * a * dt ** 2, x_true[1] + a * dt])
a_meas = a + bias + rng.normal(0, sig_a)
x_imu = np.array([x_imu[0] + x_imu[1] * dt + 0.5 * a_meas * dt ** 2, x_imu[1] + a_meas * dt])
x = F @ x + Bu * a_meas; P = F @ P @ F.T + Q # predict with the IMU
if k % 10 == 0: # UWB fix at 10 Hz
z = x_true[0] + rng.normal(0, 0.10)
S = (H @ P @ H.T).item() + r_uwb
K = (P @ H.T).ravel() / S
x = x + K * (z - x[0]); P = (np.eye(3) - np.outer(K, H)) @ P
err.append(x[0] - x_true[0]); sig.append(np.sqrt(P[0, 0]))
print(f"after 10 s: IMU only error {x_imu[0] - x_true[0]:.2f} m")
print(f"fused RMS error (last 8 s) {np.sqrt(np.mean(np.square(err[200:]))):.3f} m, filter sigma {np.sqrt(np.mean(np.square(sig[200:]))):.3f} m")
print(f"estimated bias {x[2]:.3f} m/s^2 (true {bias})")
after 10 s: IMU only error 2.37 m
fused RMS error (last 8 s) 0.046 m, filter sigma 0.040 m
estimated bias 0.048 m/s^2 (true 0.05)
The IMU alone is 2.37 m off after 10 seconds, consistent with the formula of module 6. The filter is off by only 0.046 m RMS, better than UWB alone at 0.10 m, because the IMU smooths UWB noise between measurements, and it estimates the bias as 0.048 m/s², close to the true value. The filter’s own sigma of 0.040 m is close to the actual 0.046 m error, meaning the filter judges its own uncertainty sensibly. That matters as much as accuracy, because the gate in the next section relies on it.
EKF with raw ranges and a gate
Example 3 used a position already computed from UWB. A better system feeds each anchor’s raw range into the filter directly, because that works even when only one anchor is in view and lets each range be checked individually. The range is nonlinear in position, so an extended Kalman filter (EKF) linearizes it about the current estimate at every step, with the Jacobian as in module 7 (Thrun and colleagues, 2005).
Before using a measurement, the EKF compares the innovation with its expected variance . The quantity is the squared Mahalanobis distance. For normal measurements, follows a chi-square distribution with one degree of freedom, which exceeds 3.84 only 5% of the time, so the gate is set at 3.84 and anything above it is treated as an outlier and rejected. This is the same idea as the innovation test in the autopilot EKF covered in UAT 305.
Example 4 Rejecting a range blocked by a steel stand
The drone’s predicted position is (40, 30) m with 0.2 m uncertainty per axis. Anchor A3 is at (120, 72) m and UWB ranges are good to 0.10 m. The first range is normal; the second is blocked by a steel stand and is about 0.8 m too long (assumed).
# Example 4: one EKF update with a raw UWB range and a chi-square gate against NLOS
x = np.array([40.0, 30.0]); P = np.diag([0.2 ** 2, 0.2 ** 2]) # predicted horizontal position
anchor = np.array([120.0, 72.0]); R_r = 0.10 ** 2
GATE = 3.84 # chi-square 95% for one measurement
for z in (90.38, 91.20): # a clean range and one 0.8 m too long
pred = np.linalg.norm(x - anchor)
Hr = ((x - anchor) / pred)[None, :] # Jacobian of the range
S = (Hr @ P @ Hr.T).item() + R_r
nu = z - pred
d2 = nu ** 2 / S
if d2 <= GATE:
K = (P @ Hr.T / S).ravel()
print(f"z {z:.2f} m: innovation {nu:+.2f} m, d2 {d2:5.2f} -> used, new x ({x[0] + K[0] * nu:.2f}, {x[1] + K[1] * nu:.2f})")
else:
print(f"z {z:.2f} m: innovation {nu:+.2f} m, d2 {d2:5.2f} -> rejected")
z 90.38 m: innovation +0.03 m, d2 0.01 -> used, new x (39.98, 29.99)
z 91.20 m: innovation +0.85 m, d2 14.29 -> rejected
The normal range has an innovation of 0.03 m, = 0.01, and nudges the position slightly. The blocked range has an innovation of 0.85 m, = 14.29, far beyond the gate, so it is rejected. Unlike module 7, where the bad range pulled the position 1.20 m off, here the prediction from the IMU and other sensors provides something to compare against. But gating has a catch: if the filter is overconfident ( too small), correct ranges are rejected too, and if rejections continue, the position drifts with the IMU. The system must count rejections and raise an alert when they become unusually frequent.
Module lab
Lab: LiDAR scan matching and an IMU and UWB fusion filter
- Record two 2D LiDAR scans in a room with wall corners and a column, moving the sensor by a measured amount between them; use the code in Example 1 to find the motion and compare it with the tape measurement
- Record a scan in a long corridor with plain walls, compute the eigenvalues of the information matrix as in Example 2, then place a box across the corridor and compute them again
- Log IMU and UWB together while walking a tag along a line marked on the floor; adapt the code in Example 3 to the real data and compare IMU alone, UWB alone and the filter
- Have a person block one anchor during the walk, use the gate of Example 4 to count rejected ranges, and report how much the position improves compared with no gate
Common mistakes
Watch out
- Starting ICP from zero when the drone has moved a lot; use an initial guess from the IMU or VIO
- Trusting a low ICP RMS in a long corridor or beside a plain wall, when the along-wall direction is unobservable
- Using LiDAR near glass, glossy surfaces or haze without checking the data
- Leaving the IMU bias out of the state, so the filter drifts every time measurements are missing
- Setting and that do not match the real sensors, so the filter is overconfident and rejects good data, or underconfident and chases noise
- Widening the gate to silence warnings instead of finding out why the sensors disagree
- Fusing sensors without checking their frames and timestamps; timing is covered in module 10
Summary
- LiDAR localizes by successive scan matching (slow drift) or by matching against a map (no accumulation), but struggles with glass, glossy surfaces, haze and long plain walls
- ICP alternates nearest-point matching with a closed-form SVD transform and needs a good initial guess
- The eigenvalues of reveal directions LiDAR cannot observe and decide where to trust it
- A Kalman filter predicts with the IMU and corrects with reference sensors; including the bias in the state lets the IMU bridge longer gaps
- An EKF can use raw ranges, and a gate rejects blocked ranges, provided is realistic
Check your understanding
- Why does ICP need an initial guess close to the truth?
- What do information-matrix eigenvalues of 0 and 400 mean?
- A one-axis Kalman filter predicts 10.0 m with variance 0.04 m²; UWB measures 10.3 m with variance 0.01 m². What is the new estimate?
- An innovation of 0.5 m with innovation variance = 0.05 m²: does it pass a 3.84 gate?
- Why does including the accelerometer bias in the state help when UWB drops out for a while?
Answers
- Because matching uses nearest points; if the scans are far apart the pairs are wrong, and the computed transform leads to a wrong local solution
- The eigenvector with eigenvalue 0 carries no information, so scan matching cannot determine translation in that direction, such as along a long wall
- ; new estimate m with variance m²
- , above 3.84, so it fails and is rejected
- The filter removes the estimated bias before integrating, so only the part it estimated wrongly remains, and the position drifts far more slowly while measurements are missing
Key formulas
| ICP objective | |
| Closed-form solution by SVD | |
| Predict step | |
| Update step | |
| Chi-square gate |
Key references
- Besl, P. J., & McKay, N. D. (1992). A method for registration of 3-D shapes. IEEE Transactions on Pattern Analysis and Machine Intelligence, 14(2), 239–256. link
- Arun, K. S., Huang, T. S., & Blostein, S. D. (1987). Least-squares fitting of two 3-D point sets. IEEE Transactions on Pattern Analysis and Machine Intelligence, PAMI-9(5), 698–700. link
- Hess, W., Kohler, D., Rapp, H., & Andor, D. (2016). Real-time loop closure in 2D LIDAR SLAM. In 2016 IEEE International Conference on Robotics and Automation (ICRA) (pp. 1271–1278). IEEE. https://doi.org/10.1109/ICRA.2016.7487258 link
- Kalman, R. E. (1960). A new approach to linear filtering and prediction problems. Journal of Basic Engineering, 82(1), 35–45. link
- Welch, G., & Bishop, G. (2004). An introduction to the Kalman filter (TR 95-041). University of North Carolina at Chapel Hill. link
- Thrun, S., Burgard, W., & Fox, D. (2005). Probabilistic robotics. MIT Press. link
- Groves, P. D. (2013). Principles of GNSS, inertial, and multisensor integrated navigation systems (2nd ed.). Artech House. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
LiDAR เรดาร์ และเซนเซอร์หลบหลีกสิ่งกีดขวาง
การประมาณสถานะด้วย Kalman filter/EKF
In class / field
Lab or field practice from worksheets with a safety checklist
Learning evidence: Checked worksheets and quiz results