1272  Particle Filters for Indoor Localization

Learning Objectives

After completing this chapter, you will be able to:

  • Understand particle filter principles and when to use them
  • Implement the propagate-correct-resample cycle
  • Apply particle filters to indoor localization
  • Handle non-linear systems and multi-modal distributions
  • Choose between Kalman and particle filters

1272.1 Introduction to Particle Filters

Particle filters are powerful tools for tracking and localization in non-linear, non-Gaussian environments. Unlike Kalman filters, which assume Gaussian noise and linear dynamics, particle filters can handle arbitrary probability distributions and complex constraints like walls and obstacles.

1272.1.1 The Core Idea: A Swarm of Hypotheses

Instead of maintaining a single estimate (like Kalman filters), particle filters represent the probability distribution using a “swarm” of particles - each particle is a hypothesis about the true state.

Imagine you’re blindfolded in a shopping mall trying to figure out where you are:

The Swarm Approach: Your brain generates 1000 guesses (particles) about your location, scattered across the entire floor plan.

Step 1 - Move (Propagate): You walk 10 steps forward. Each of your 1000 hypothetical locations also “walks” 10 steps. Some guesses might now be inside walls (impossible).

Step 2 - Listen (Correct): You hear a fountain. Hypotheses near the fountain get “rewarded” (high weight), while hypotheses far from water get “penalized” (low weight).

Step 3 - Regenerate (Resample): You create 1000 new hypotheses, favoring the high-weight ones. Your swarm concentrates near likely locations.

After 30 seconds of walking: 95% of your particles cluster within 2 meters of your true location!

Why This Works for IoT:

  • Wi-Fi/BLE signals aren’t perfect circles (non-Gaussian)
  • Buildings have walls that block paths (non-linear constraints)
  • Multiple possible locations might match sensor readings initially

1272.2 The Propagate-Correct-Resample Algorithm

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2C3E50', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#f5f5f5'}}}%%
flowchart TD
    subgraph Sample["1. PROPAGATE"]
        S1["Move particles<br/>according to motion model"]
        S2["Add process noise"]
    end
    subgraph Weight["2. CORRECT"]
        W1["Weight each particle<br/>by measurement likelihood"]
        W2["Particles in walls = 0"]
    end
    subgraph Resample["3. RESAMPLE"]
        R1["Clone high-weight particles"]
        R2["Eliminate low-weight particles"]
    end

    Sample --> Weight --> Resample
    Resample -.->|"Next iteration"| Sample

    style Sample fill:#2C3E50,color:#fff
    style Weight fill:#E67E22,color:#fff
    style Resample fill:#16A085,color:#fff

1272.2.1 Step 1: Propagate (Prediction)

Move each particle according to the motion model, adding noise:

\[x_i^{k|k-1} = f(x_i^{k-1}, u_k) + w_k\]

Where:

  • \(f(\cdot)\): Motion model (position = position + velocity x dt)
  • \(u_k\): Control input (e.g., commanded velocity from IMU)
  • \(w_k\): Process noise (adds randomness)

Example: If a person walks 10 steps north, move each particle 10 steps north plus Gaussian noise (+/-0.5 meters) for GPS drift, variable stride, etc.

1272.2.2 Step 2: Correct (Update Weights)

Weight each particle by how well it matches sensor observations:

\[w_i^k = w_i^{k-1} \cdot p(z_k | x_i^{k|k-1})\]

Where:

  • \(p(z_k | x_i)\): Likelihood of measurement given particle state
  • Particles matching measurements get high weights
  • Particles in impossible locations (walls) get zero weight

Example: If Wi-Fi AP “AP-FoodCourt” shows -65 dBm:

  • Particles 5m from AP (expected -65 dBm) get high weight
  • Particles 50m away (expected -85 dBm) get low weight
  • Particles inside concrete walls get zero weight

1272.2.3 Step 3: Resample (Regenerate)

Create a new generation of particles by sampling with probability proportional to weights:

  • High-weight particles: Duplicated (likely locations get more samples)
  • Low-weight particles: Eliminated (unlikely locations discarded)
  • Result: Particles concentrate around high-probability regions

Resampling methods:

  • Multinomial resampling: Draw N particles randomly with replacement
  • Systematic resampling: Deterministic, lower variance (preferred)
  • Residual resampling: Guarantees high-weight particles survive

Why resample? Without resampling, all particles eventually get near-zero weights (degeneracy problem). Resampling maintains particle diversity.

1272.3 When to Use Particle Filters

TipParticle Filter vs Kalman Filter
Challenge Kalman Filter Particle Filter
Non-linear motion Requires EKF/UKF Handles arbitrary non-linearity
Non-Gaussian noise Assumes Gaussian Works with any distribution
Multi-modal distributions Single peak only Multiple peaks naturally
Map constraints Difficult Particles outside walls = 0
Computational cost Low (matrix ops) Higher (scales with particle count)

When to use particle filters:

  • Indoor localization with Wi-Fi/BLE (signal propagation is non-linear)
  • Robot kidnapping problem (unknown initial position)
  • Tracking with ambiguous measurements (bearing-only tracking)
  • Systems with map constraints (buildings, road networks)

When to avoid:

  • Linear systems with Gaussian noise (Kalman is optimal and faster)
  • Real-time embedded systems with limited CPU
  • High-dimensional state spaces (curse of dimensionality)

1272.4 Worked Example: Mall Navigation System

Scenario: Navigate a 3-floor shopping mall using smartphone Wi-Fi/BLE signals and IMU.

Setup:

  • State: [x position, y position, floor level, heading]
  • Sensors: 15 Wi-Fi access points, 3 BLE beacons per floor, IMU
  • Particle count: 1000 particles
  • Update rate: 1 Hz

Initial State (t=0):

  • User enters main entrance
  • 1000 particles uniformly distributed across all 3 floors
  • Each particle has weight = 1/1000

Step 1: User Walks 10 Steps North (t=1-10s):

Propagate: Move each particle 10 steps north (15m total)

  • Add Gaussian noise: sigma = 0.5m per step, sigma_total = sqrt(10) x 0.5 = 1.6m
  • Particles that moved into walls: weight = 0

Step 2: Receive Wi-Fi Measurements (t=10s):

  • “AP-Entrance”: -55 dBm (very strong, must be near entrance)
  • “AP-FoodCourt”: -75 dBm (moderate, probably 30-50m away)

Correct: Calculate weight for each particle based on expected vs observed RSSI:

For each particle i at position (x,y):
    expected_entrance = RSSI_model(distance(particle, entrance_AP))
    expected_foodcourt = RSSI_model(distance(particle, foodcourt_AP))
    likelihood = gaussian_pdf(observed_entrance - expected_entrance)
                 * gaussian_pdf(observed_foodcourt - expected_foodcourt)
    weight[i] = previous_weight[i] * likelihood

Particles near entrance (matching -55 dBm): weight increases 10x Particles near food court (wrong signal): weight decreases 100x

Step 3: Resample:

  • 800 particles now clustered near entrance on floor 1
  • 150 particles near escalator (alternative path)
  • 50 particles scattered (low weight, will likely be eliminated next round)

Convergence (t=60s):

After walking through store, taking elevator, hearing escalator sounds:

  • 95% of particles within 2m of true location
  • Floor correctly identified (100% confidence)
  • Heading accurate to +/-10 degrees

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2C3E50', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#f5f5f5'}}}%%
flowchart LR
    subgraph T0["t=0: Initial"]
        I0["1000 particles<br/>uniformly distributed<br/>across 3 floors"]
    end

    subgraph T10["t=10s: After Walk + WiFi"]
        I10["800 near entrance<br/>150 near escalator<br/>50 scattered"]
    end

    subgraph T60["t=60s: Converged"]
        I60["950 within 2m<br/>of true position<br/>Floor: 100% correct"]
    end

    T0 --> T10 --> T60

    style I0 fill:#7F8C8D,color:#fff
    style I10 fill:#E67E22,color:#fff
    style I60 fill:#27AE60,color:#fff

1272.5 Particle Filter Design Decisions

1272.5.1 Number of Particles

Application Particles Accuracy CPU Memory
Simple 2D tracking 100-500 Good Low ~4KB
Indoor localization 500-2000 Very good Medium ~20KB
Multi-floor building 1000-5000 Excellent High ~100KB
Autonomous vehicle 5000-50000 Precise Very high ~1MB

Rule of thumb: Start with 500-1000 particles, increase if output is noisy or convergence is slow.

1272.5.2 Resampling Strategies

Low Variance Resampling (recommended):

  • Deterministic selection with single random offset
  • Lower variance than multinomial
  • Guarantees representative sample

Effective Sample Size:

\[N_{eff} = \frac{1}{\sum_i (w_i)^2}\]

Resample when \(N_{eff} < N/2\) (too many low-weight particles)

1272.5.3 Map Integration

Particle filters excel with map constraints:

  1. Wall collision detection: Set weight = 0 for particles inside walls
  2. Semantic constraints: Elevator particles can only move vertically
  3. Floor transitions: Only allow through stairs, elevators, escalators
  4. Occupancy grids: Precompute traversable areas

1272.6 Comparison with Other Filters

Filter Linearity Noise Modality Computation Best For
Kalman Linear Gaussian Unimodal O(n^3) GPS tracking
EKF Weakly nonlinear Gaussian Unimodal O(n^3) GPS-IMU fusion
Particle Any Any Any O(N particles) Indoor localization

1272.7 Summary

Particle filters provide flexible state estimation for complex IoT scenarios:

  • Swarm of hypotheses: Represent uncertainty with many particles
  • Propagate-Correct-Resample: The fundamental algorithm cycle
  • Map constraints: Natural handling of walls and obstacles
  • Multi-modal: Can track multiple possible locations simultaneously
  • Trade-off: More computation than Kalman, but handles non-linearity

1272.8 What’s Next