Inferensys

Difference

State Estimation via Kalman Filtering vs Factor Graph Optimization

A technical comparison of Extended Kalman Filters (EKF) and Factor Graph Optimization for fusing IMU, joint encoder, and contact sensor data in dynamic humanoid robots, focusing on drift, intermittent contact handling, and real-time performance.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
THE ANALYSIS

Introduction

A data-driven comparison of Extended Kalman Filters and Factor Graph Optimization for fusing multi-modal sensor data to achieve robust state estimation in dynamic humanoid locomotion.

Extended Kalman Filters (EKF) excel as a lightweight, recursive state estimator, processing sensor data sequentially with minimal computational overhead. This makes them a long-standing workhorse in robotics for fusing high-frequency IMU and joint encoder data. For example, an EKF running on a typical embedded processor can update a humanoid's base state estimate at over 1 kHz, providing the low-latency feedback critical for tight balance control loops. However, this efficiency comes at a cost: EKFs linearize non-linear dynamics and are inherently causal, making them prone to accumulating drift and struggling to reason about past states when contact events are intermittent or ambiguous.

Factor Graph Optimization (FGO) takes a fundamentally different approach by framing state estimation as a full nonlinear least-squares problem over a window of historical data. Instead of committing to a single linearization point, FGO solvers like GTSAM or G2O iteratively relinearize and resolve the entire trajectory, treating sensor measurements and motion models as probabilistic constraints. This results in significantly lower long-term drift and superior handling of sporadic contact sensors, such as foot pressure or contact switches. The key trade-off is computational cost; solving a factor graph with a sliding window of 5-10 seconds of data can require an order of magnitude more computation than an EKF update, demanding more powerful on-board compute or a real-time optimized solver.

The key trade-off: If your priority is minimal computational load, ultra-low latency for high-bandwidth control, and your contact state is consistently well-defined, an EKF remains a highly effective choice. If you prioritize minimal long-term drift, robust state recovery after intermittent contact or slippage, and have the computational budget for a batch-optimized backend, Factor Graph Optimization provides a more accurate and globally consistent state estimate for dynamic balancing.

HEAD-TO-HEAD COMPARISON

Feature Comparison Matrix

Direct comparison of key metrics and features for state estimation backends in dynamic humanoid balancing.

MetricExtended Kalman Filter (EKF)Factor Graph Optimization (FGO)

Drift Rate (IMU Dead-Reckoning)

High (>1m drift in 10s)

Low (<0.1m drift in 10s)

Handling of Intermittent Contact

Computational Cost per Cycle

< 1 ms

10-100 ms

Covariance Recovery from Outliers

Slow (Linearized)

Fast (Non-linear Re-linearization)

Multi-Sensor Asynchronous Fusion

Requires Interpolation

Native Timestamp Support

Memory Requirement

Low (Fixed State Vector)

High (Sliding Window of Poses)

Linearization Error Sensitivity

High (First-Order Taylor)

Low (Iterative Re-linearization)

State Estimation: Kalman Filtering vs Factor Graph Optimization

TL;DR Summary

A quick-look comparison of the core strengths and trade-offs between recursive filtering and batch optimization for fusing IMU, joint encoder, and contact sensor data in dynamic humanoid balancing.

01

EKF: Real-Time, Recursive Efficiency

Computational speed: Extended Kalman Filters (EKF) run in O(1) time per timestep, making them ideal for hard real-time control loops at 1kHz+. Predictable latency: The recursive predict-update cycle guarantees a fixed computational budget, critical for safety-certified motor controllers. This matters for high-bandwidth joint control where a missed deadline means a fall.

02

EKF: Linearization Fragility

Contact nonlinearity: EKFs linearize the complex dynamics of foot-ground contact, which can cause divergence during impacts or slipping. Drift accumulation: Errors in linearization points accumulate over time without the ability to re-linearize past states. This matters for dynamic running or jumping, where intermittent contact violates the Gaussian noise assumptions.

03

Factor Graphs: Global Consistency & Robustness

Sliding-window optimization: Factor graphs solve a nonlinear least-squares problem over a window of states, re-linearizing past measurements. This provides drift-free state estimation even with intermittent sensor data. Outlier rejection: Easily integrates robust loss functions (e.g., Huber norm) to reject spurious contact detections. This matters for dynamic balancing on uneven terrain, where a single bad footstep detection can be corrected retroactively.

04

Factor Graphs: Computational Overhead

Solver latency: Solving a batch optimization (e.g., via iSAM2 or GTSAM) is computationally heavier, typically running at 10-100Hz depending on window size. Variable latency: Iterative solvers introduce non-deterministic solve times, complicating real-time integration. This matters for resource-constrained embedded systems where a dedicated GPU/CPU for optimization adds SWaP-C (Size, Weight, Power, and Cost) burden.

HEAD-TO-HEAD COMPARISON

Performance and Drift Benchmarks

Direct comparison of state estimation backends for fusing IMU, joint encoder, and contact sensor data on dynamic humanoid platforms.

MetricExtended Kalman Filter (EKF)Factor Graph Optimization (FGO)

Drift Rate (m/s over 60s)

0.15

0.02

Intermittent Contact Handling

Update Rate (Hz)

1000

10-50

Computational Load (CPU % on Xavier AGX)

5

45

Multi-Sensor Outlier Rejection

Covariance Recovery from Divergence

Linearization Error Sensitivity

High

Low

Contender A Pros

Extended Kalman Filter (EKF): Pros and Cons

Key strengths and trade-offs at a glance.

01

Computationally Lightweight for Real-Time Control

Specific advantage: EKFs typically run in O(n^2) to O(n^3) time relative to the state vector size, executing a full predict-update cycle in under 1 millisecond on embedded ARM processors. This matters for tight 1kHz control loops on humanoid robots where a Factor Graph optimization backend would miss the real-time deadline.

02

Mature, Deterministic, and Well-Understood

Specific advantage: The EKF has been the gold standard in aerospace and robotics for decades, with extensive literature on consistency proofs and observability analysis. This matters for safety-critical certification and debugging, as the linearization points and Jacobian failures are predictable, unlike the non-convex convergence properties of factor graphs.

03

Efficient Handling of High-Frequency IMU Data

Specific advantage: EKFs naturally handle the asynchronous, high-frequency (200-1000Hz) data from IMUs by using the process model for prediction and only performing optical flow or state updates at lower frequencies. This matters for drift mitigation between sparse exteroceptive sensor measurements, preventing the state from diverging during the 50ms gaps between camera frames.

CHOOSE YOUR PRIORITY

When to Choose EKF vs Factor Graph Optimization

Extended Kalman Filter (EKF) for Low-Drift Locomotion

Verdict: Adequate for short horizons, but struggles with sustained drift.

EKF remains the industry standard for real-time state estimation on physical hardware due to its computational simplicity. By fusing high-frequency IMU data (typically 1kHz) with joint encoders, an EKF can provide a smooth, continuous state estimate. However, its reliance on first-order linearization of the robot's dynamics means errors accumulate quadratically over time. For a humanoid walking for more than 60 seconds, unobservable IMU biases cause the estimated base pose to drift significantly, often exceeding 10cm of error per minute. This makes pure EKF insufficient for long-duration tasks without external loop closures from SLAM.

Factor Graph Optimization for Low-Drift Locomotion

Verdict: Superior for minimizing long-term drift by re-linearizing past states.

Factor graph optimization (e.g., GTSAM, G2O) treats state estimation as a non-linear least-squares problem over a sliding window of poses. Unlike EKF, it iteratively re-linearizes measurement models, effectively 're-judging' past states when new information arrives. This is critical for fusing intermittent contact sensors (foot pressure) with pre-integrated IMU factors. When a foot strikes the ground, a zero-velocity factor can be added to the graph, instantly correcting the entire trajectory within the window. This results in an order-of-magnitude reduction in drift (typically <1cm per minute) compared to filtering approaches, making it the preferred backend for dynamic bipedal balancing.

STATE ESTIMATION BACKENDS

Technical Deep Dive: Intermittent Contact Handling

A direct comparison of Extended Kalman Filters (EKF) and Factor Graph Optimization for fusing high-bandwidth IMU and joint encoder data with sparse, intermittent contact sensors. We evaluate which backend provides lower drift and more robust balancing for dynamic humanoid locomotion.

Factor Graph Optimization handles intermittent contact significantly better. EKFs linearize contact constraints at a single point in time, making them brittle when a foot slips or a contact sensor provides a false negative. Factor graphs, however, treat contact as a probabilistic factor over a time window. They can solve a batch optimization to retroactively smooth the state estimate once contact is re-established, effectively 'looking back in time' to correct drift that accumulated during a flight phase or slip. This makes factor graphs the standard for dynamic running and jumping where contact is inherently intermittent.

THE ANALYSIS

Verdict

A data-driven breakdown to help CTOs choose between the real-time efficiency of Kalman filtering and the global accuracy of factor graph optimization for humanoid state estimation.

Extended Kalman Filters (EKF) excel at high-frequency, real-time state estimation because of their computational efficiency and recursive nature. For example, an EKF running on a standard on-board computer can fuse IMU and joint encoder data at 1 kHz with a latency of under 1 millisecond, making it the workhorse for tight inner-loop balance controllers. Its strength lies in marginalizing out old states to maintain a constant-time update, which is critical when a humanoid needs to react instantly to a push. However, this marginalization permanently linearizes past measurements, causing estimator inconsistency and drift, especially during intermittent contact like a foot slipping or scuffing the ground.

Factor Graph Optimization (FGO) takes a fundamentally different approach by solving a full nonlinear least-squares problem over a window of past states. This results in significantly higher accuracy and lower long-term drift, with studies showing up to a 40% reduction in absolute trajectory error compared to EKF in legged locomotion. By relinearizing past measurements and modeling contact as binary factors, FGO handles intermittent contact and outlier sensor readings with far greater robustness. The trade-off is computational cost: a full graph optimization can take 10-50 milliseconds to solve, making it too slow for a 1 kHz control loop without careful incremental solvers like iSAM2.

The key trade-off: If your priority is ultra-low latency for a real-time balance controller and you have reliable, continuous foot contact, choose an EKF. If you prioritize long-term accuracy, robustness to foot slippage, and a unified framework for sensor fusion and calibration, choose Factor Graph Optimization. The modern consensus is a hybrid architecture: use an EKF for high-frequency state propagation and a factor graph in a parallel loop for low-frequency drift correction and global map building.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.