Real-time localization and navigation-system evaluation
UAT 458 Indoor Autonomous UAS and Navigation Technology
Lesson
By the end of this module you will be able to
- Compute the latency budget and processing load of a localization pipeline, and explain latency compensation with timestamps
- Explain Monte Carlo localization and interpret the particle spread while position is still ambiguous
- Compute ATE and RPE after aligning trajectories with Umeyama's method, and report results so they can be compared
- Design a robustness test plan that changes one factor at a time, and judge pass or fail against accuracy and availability criteria
Why this matters
Modules 6 to 9 built every part of the navigation system, from sensors and filters to maps and planners. Two questions remain that decide whether the system can be used. First, is it on time? A position that is accurate but arrives late can still put the drone into a truss. Second, how do we know it is accurate and robust enough? A nice-looking trajectory plot is not evidence; the system must be measured in numbers against a ground truth and tested in the conditions the hall will actually present.
This module closes the last two topics of the course description: real-time localization and the evaluation of navigation accuracy and robustness. Its outcome is the report the facilities team uses to decide whether to fly real roof-truss inspections. Flight-test procedures and autopilot configuration are in modules 1–5 of this course.
Real-time localization
Real-time localization does not mean as fast as possible; it means every result is finished before its deadline and reaches the flight controller at a rate and latency the controller can use. The PX4 guide states that positions from vision or motion-capture systems should be streamed into EKF2 at 30 to 50 Hz, that EKF2 will not fuse them if the rate is too low, and that the filter must be told how much later the data arrive than the moment they were measured (PX4 Autopilot, n.d.).
Latency is dangerous because the position that arrives describes the past. If the drone flies at speed and the position is late without compensation, it is off by . The standard remedy is to timestamp each measurement at the moment it was taken, using the same clock as the IMU, and have the filter keep a short history of past states. When a measurement arrives, the filter applies it at its own time, then predicts forward to the present with the stored IMU data.
The other issue is processing load. Each task takes per run and must run times per second. The total load must sit comfortably within the processor’s capacity, and each task must finish before its next run is due.
Example 1 Latency budget and load on the onboard computer
The team times each stage of the localization pipeline on the companion computer, along with the per-run time of the three main tasks. The drone inspects at 2 m/s (assumed).
import math
# Example 1: latency and timing budget of the localization pipeline (assumed measurements)
v = 2.0 # inspection speed (m/s)
stages = {"camera exposure + transfer": 18, "VIO front-end": 22, "fusion + publish": 6, "link to flight controller": 14}
lat = sum(stages.values())
print(f"total latency {lat} ms -> {v * lat / 1000 * 100:.0f} cm of motion if not compensated")
tasks = {"VIO": (22, 30), "LiDAR scan matching": (38, 10), "UWB + fusion": (2, 100)} # (ms per run, Hz)
u = 0
for name, (ms, hz) in tasks.items():
share = ms * hz / 1000
u += share
print(f"{name:20s} {ms:3d} ms x {hz:3d} Hz = {share:.0%} of one core, deadline {1000 / hz:.1f} ms")
print(f"total {u:.0%} of one core")
total latency 60 ms -> 12 cm of motion if not compensated
VIO 22 ms x 30 Hz = 66% of one core, deadline 33.3 ms
LiDAR scan matching 38 ms x 10 Hz = 38% of one core, deadline 100.0 ms
UWB + fusion 2 ms x 100 Hz = 20% of one core, deadline 10.0 ms
total 124% of one core
The 60 ms total latency is within module 6’s 80 ms requirement, but uncompensated it would cost 12 cm, 40% of the 0.30 m budget, so timestamping and compensation are essential. On load, every task meets its own deadline, but together they need 124% of one core. Placed on a single core, tasks would queue up and miss deadlines. The team must put VIO and LiDAR scan matching on separate cores or lower the scan-matching rate, and must measure these times on the computer that will actually fly.
Monte Carlo localization
The Kalman filter of module 8 represents uncertainty with a single normal distribution, which works well when the position is already roughly known. But when the system starts in the middle of the hall, or after it has lost track, the position may be in several places at once. Monte Carlo localization (MCL), by Dellaert and colleagues (1999), represents belief with many particles, each one a hypothesis of the position, and loops through three steps (Thrun and colleagues, 2005).
- Predict: move every particle by odometry plus noise.
- Weight: compare the measurement with what each particle would expect to measure from the map; better-matching particles get more weight.
- Resample: draw a new set of particles according to the weights, so inconsistent hypotheses gradually disappear.
MCL’s strength is that it handles multi-peaked beliefs, so it works both for global localization from an unknown start and for recovery after getting lost.
Example 2 Finding position on the roof-truss walkway
The maintenance walkway under the roof trusses is 120 m long, with hanger columns every 12 m except at 72 m, which is left open above the stage. A forward LiDAR measures the range to the next column with 0.10 m error. The drone starts at an unknown place and moves forward 3 m per step, with 2000 particles (assumed, reduced to one dimension).
# Example 2: Monte Carlo localization along the 120 m truss walkway using range to the next column
import numpy as np
rng = np.random.default_rng(11)
columns = np.array([0, 12, 24, 36, 48, 60, 84, 96, 108, 120.0]) # a gap: no column at 72 m (assumed)
def range_to_next(x): # forward LiDAR beam: distance to the next column ahead
ahead = columns[columns > x]
return ahead[0] - x if len(ahead) else 30.0
N = 2000
particles = rng.uniform(0, 120, N) # no idea where we are along the walkway
x_true = 38.0
for step in range(1, 11):
move = 3.0
x_true += move
particles += move + rng.normal(0, 0.15, N) # predict with odometry
z = range_to_next(x_true) + rng.normal(0, 0.10) # measure
pred = np.array([range_to_next(p) for p in particles])
w = np.exp(-0.5 * ((z - pred) / 0.20) ** 2) + 1e-12 # weight by likelihood
w /= w.sum()
particles = particles[rng.choice(N, N, p=w)] # resample
spread = np.percentile(particles, 95) - np.percentile(particles, 5)
print(f"step {step}: true {x_true:5.1f} m, estimate {np.median(particles):5.1f} m, 90% spread {spread:5.1f} m")
step 1: true 41.0 m, estimate 53.0 m, 90% spread 108.1 m
step 2: true 44.0 m, estimate 56.0 m, 90% spread 108.1 m
step 3: true 47.0 m, estimate 59.0 m, 90% spread 108.1 m
step 4: true 50.0 m, estimate 38.1 m, 90% spread 96.1 m
step 5: true 53.0 m, estimate 41.1 m, 90% spread 96.1 m
step 6: true 56.0 m, estimate 44.1 m, 90% spread 96.2 m
step 7: true 59.0 m, estimate 47.3 m, 90% spread 96.2 m
step 8: true 62.0 m, estimate 62.1 m, 90% spread 0.5 m
step 9: true 65.0 m, estimate 65.0 m, 90% spread 0.5 m
step 10: true 68.0 m, estimate 68.0 m, 90% spread 0.5 m
From step 1 to step 7 the 90% spread covers almost the whole walkway, because columns evenly spaced every 12 m make the same range fit many places, so the median is a meaningless number. During this phase the position must not be sent to the autopilot. At step 8 the drone sees the unique 24 m gap and every particle collapses into one 0.5 m cluster at the true position. The lessons are that a system must check the spread before using the centre value, and that rhythmically repeating surroundings are the enemy of localization; unique tag IDs or an asymmetric landmark help a great deal.
Accuracy metrics: ATE and RPE
Evaluating accuracy needs a ground truth far more accurate than the system under test; in Hall 3 this is the infrared camera system in the test cage from module 7. There are two standard metrics (Sturm and colleagues, 2012).
- ATE (absolute trajectory error): the root mean square of the distances between estimated and true positions at matching times, describing the overall error of the whole trajectory.
- RPE (relative pose error): compares motion over short intervals, such as every 5 seconds, describing local drift regardless of how much error has accumulated since the start.
Before computing ATE, the estimated trajectory must be aligned with the ground-truth frame, because VIO starts in its own frame. Zhang and Scaramuzza (2018) show that the right alignment depends on what the system cannot observe. A monocular camera does not know scale, so it is aligned with a similarity transform (Sim(3)) that also adjusts scale; a stereo camera with a rigid-body transform (SE(3)), rotation plus translation; and a system with an IMU, which already knows the direction of gravity, should be aligned only with a translation and a rotation about the vertical axis (4 degrees of freedom). The best rotation and translation are found with Umeyama’s method (1991), a closed-form SVD solution like the ICP of module 8. Every report must state the alignment method, because different methods give different numbers. The open-source tool evo computes ATE and RPE with these alignment and scale options (Grupp, 2017).
Example 3 ATE and RPE of VIO in the test cage
The drone flies loops in the test cage for 60 seconds. The infrared system provides ground truth every 0.5 s. VIO reports in its own frame, rotated by 3° and shifted by (1.0, −0.5, 0.2) m, with slow drift and 2 cm of noise (assumed).
# Example 3: ATE and RPE of a VIO run in the motion-capture test cage
rng = np.random.default_rng(5)
t = np.arange(0, 60, 0.5)
gt = np.c_[3 * np.cos(0.2 * t), 2 * np.sin(0.4 * t), 1.5 + 0.3 * np.sin(0.1 * t)] # mocap ground truth (m)
yaw = math.radians(3.0)
Rz = np.array([[math.cos(yaw), -math.sin(yaw), 0], [math.sin(yaw), math.cos(yaw), 0], [0, 0, 1]])
drift = np.c_[0.004 * t, -0.002 * t, 0.001 * t] # slow drift (assumed)
est = gt @ Rz.T + np.array([1.0, -0.5, 0.2]) + drift + rng.normal(0, 0.02, gt.shape) # VIO in its own frame
def umeyama(src, dst): # rotation + translation, no scale (Umeyama, 1991)
ms, md = src.mean(0), dst.mean(0)
U, _, Vt = np.linalg.svd((dst - md).T @ (src - ms))
S = np.eye(3); S[2, 2] = np.sign(np.linalg.det(U @ Vt))
R = U @ S @ Vt
return R, md - R @ ms
def rmse(e):
return math.sqrt(np.mean(np.sum(e ** 2, axis=1)))
print(f"ATE without alignment {rmse(est - gt):.3f} m")
R, tr = umeyama(est, gt)
aligned = est @ R.T + tr
e = np.linalg.norm(aligned - gt, axis=1)
print(f"ATE after SE(3) alignment {rmse(aligned - gt):.3f} m, max {e.max():.3f} m")
k = 10 # RPE over 5 s windows (10 samples)
d_est = aligned[k:] - aligned[:-k]; d_gt = gt[k:] - gt[:-k]
print(f"RPE (5 s windows) {rmse(d_est - d_gt):.3f} m")
path_len = np.sum(np.linalg.norm(np.diff(gt, axis=0), axis=1))
print(f"path length {path_len:.1f} m, final drift {np.linalg.norm(drift[-1]):.3f} m")
ATE without alignment 1.283 m
ATE after SE(3) alignment 0.087 m, max 0.150 m
RPE (5 s windows) 0.056 m
path length 40.7 m, final drift 0.273 m
Without alignment, ATE is 1.283 m, almost all of it the difference between frames rather than any fault of VIO. After SE(3) alignment, ATE is 0.087 m with a maximum of 0.150 m (a 4-degree-of-freedom alignment, as recommended for VIO, gives almost the same value here because the VIO frame differs from the ground truth only by a rotation about the vertical axis and a shift). RPE over 5-second windows is 0.056 m. Note that the true final drift, 0.273 m, is larger than ATE: alignment pulls the whole trajectory onto the ground truth as well as it can, which absorbs part of the drift. For a drifting system, always look at ATE, RPE, the maximum and the distance flown (40.7 m) together.
Robustness testing
Robustness is the system’s ability to stay accurate enough and keep producing positions when conditions depart from normal. Good testing follows three rules. First, change one factor at a time from a baseline, using the same route and duration, so the cause of any degradation is clear. Second, measure both accuracy at the 95th percentile and availability, the percentage of time a usable position exists, because many tools compute errors only over periods where tracking succeeded, so a low average can hide periods of being lost. Third, set pass criteria before testing, not after seeing the results.
The factors Hall 3 must test come from every module so far: low light (images and VIO), failed UWB anchors and blocked signals (module 7), long plain walls and haze (LiDAR, module 8), and changing booth layouts (maps, module 9).
Example 4 Robustness test matrix for the combined VIO, UWB and LiDAR system
The criteria set before testing are a horizontal p95 error no larger than 0.30 m and availability of at least 99%. Test flights in six scenarios give the following results (assumed).
# Example 4: robustness test matrix, pass if p95 error <= 0.30 m and availability >= 99%
tests = { # scenario: (p95 horizontal error m, % of time with a valid estimate) from test flights (assumed)
"baseline, hall lights on": (0.12, 100.0),
"lights dimmed to 20 lux": (0.21, 99.6),
"one UWB anchor switched off": (0.19, 99.8),
"steel stand blocks anchor 3": (0.41, 99.9),
"long empty wall, no booths": (0.27, 97.4),
"smoke-machine haze": (0.35, 98.1),
}
for name, (p95, avail) in tests.items():
ok = p95 <= 0.30 and avail >= 99.0
print(f"{name:28s} p95 {p95:.2f} m, available {avail:5.1f}% -> {'pass' if ok else 'FAIL'}")
print(f"passed {sum(p <= 0.30 and a >= 99.0 for p, a in tests.values())} of {len(tests)}")
baseline, hall lights on p95 0.12 m, available 100.0% -> pass
lights dimmed to 20 lux p95 0.21 m, available 99.6% -> pass
one UWB anchor switched off p95 0.19 m, available 99.8% -> pass
steel stand blocks anchor 3 p95 0.41 m, available 99.9% -> FAIL
long empty wall, no booths p95 0.27 m, available 97.4% -> FAIL
smoke-machine haze p95 0.35 m, available 98.1% -> FAIL
passed 3 of 6
Three of six pass. The system tolerates low light and one failed anchor because the other sensors cover for them. But the steel stand blocking anchor A3 pushes p95 to 0.41 m, meaning the gate does not yet catch all NLOS ranges or there are too few anchors. The long plain wall passes on accuracy but availability falls to 97.4% because LiDAR often degenerates along the wall. Haze fails both criteria. The team’s recommendations are to add UWB anchors so that at least five are visible everywhere, to place tags on the long walls, and to make it a rule that no flights take place while stage haze is present, rather than relaxing the criteria until the system passes.
Module lab
Lab: evaluate your group’s navigation system against ground truth (mini-project)
- Time each stage of your group’s localization pipeline on the computer that will actually be used, compute total latency and load with the code in Example 1, and check whether timestamps come from the same clock as the IMU
- Run the MCL code of Example 2 with the landmark layout of the lab room, then add one asymmetric landmark and report how many steps sooner the system localizes
- Carry or fly the drone (under the safety conditions of modules 1–5 of this course) in an area with motion-capture ground truth; compute ATE after alignment, RPE and the maximum with the code in Example 3 or evo, stating the alignment method
- Set pass criteria first, then test at least four scenarios that change one factor at a time; summarise them in a table like Example 4 with proposed fixes for any that fail
Common mistakes
Watch out
- Not timestamping at the moment of measurement, or using clocks from different machines without synchronisation, so the position is off by speed times latency
- Timing the pipeline on a development machine and applying the numbers to a slower onboard computer
- Sending the particle mean while the spread still covers several clusters
- Reporting ATE without the alignment method, or reporting the unaligned value that includes the frame difference
- Looking only at ATE and missing the maximum and the drift that alignment absorbs
- Reporting errors only over successfully tracked periods without stating availability
- Changing several factors at once, or setting criteria after seeing the results
Summary
- Real time means every result meets its deadline. Uncompensated latency costs , so measurements must be timestamped and applied at their own time, and the total load must fit the processor
- MCL uses particles to represent multi-peaked beliefs, suiting global localization and recovery, but the spread must be checked before using the centre value
- ATE measures overall error after alignment and RPE measures local drift; always report the alignment method, the maximum and the distance flown
- Robustness tests change one factor at a time, measure both p95 accuracy and availability, and fix the pass criteria before testing
Check your understanding
- A drone flies at 1.5 m/s and its position is 40 ms late without compensation. How large is the error?
- A task takes 15 ms per run at 40 Hz. What share of a core does it use, and does it meet its deadline?
- Why can MCL perform global localization when a single-Gaussian Kalman filter struggles to?
- ATE is 1.3 m before alignment and 0.09 m after. Which value reports VIO accuracy, and what else must be stated?
- A system has a p95 of 0.25 m but 96% availability. Does it pass criteria of p95 at most 0.30 m and availability at least 99%?
Answers
- m, or 6 cm
- ; it meets the deadline because 15 ms is less than the 25 ms period
- MCL particles can form several clusters at once, keeping several position hypotheses until the data decide; a Kalman filter represents belief with one normal distribution and so holds only one hypothesis
- The aligned 0.09 m, stating the alignment type (4 degrees of freedom, SE(3) or Sim(3)), the maximum error and the distance flown
- No, because availability of 96% is below 99% even though accuracy passes
Key formulas
| Error from uncompensated latency | |
| Processing load | |
| Particle weight | |
| ATE after alignment | |
| RPE over interval k |
Key references
- PX4 Autopilot. Using vision or motion capture systems for position estimation. PX4 user guide (main). link
- Dellaert, F., Fox, D., Burgard, W., & Thrun, S. (1999). Monte Carlo localization for mobile robots. In Proceedings 1999 IEEE International Conference on Robotics and Automation (Vol. 2, pp. 1322–1328). IEEE. link
- Thrun, S., Burgard, W., & Fox, D. (2005). Probabilistic robotics. MIT Press. link
- Sturm, J., Engelhard, N., Endres, F., Burgard, W., & Cremers, D. (2012). A benchmark for the evaluation of RGB-D SLAM systems. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems (pp. 573–580). link
- Zhang, Z., & Scaramuzza, D. (2018). A tutorial on quantitative trajectory evaluation for visual(-inertial) odometry. In 2018 IEEE/RSJ International Conference on Intelligent Robots and Systems (pp. 7244–7251). link
- Umeyama, S. (1991). Least-squares estimation of transformation parameters between two point patterns. IEEE Transactions on Pattern Analysis and Machine Intelligence, 13(4), 376–380. link
- Grupp, M. (2017). evo: Python package for the evaluation of odometry and SLAM [Computer software]. GitHub. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
How to know an estimated position is reliable
Exercise: measuring trajectory error
In class / field
Lab or field practice from worksheets with a safety checklist
Learning evidence: Checked worksheets and quiz results