EKF in Nav2: a two-layer local and global model
Atlasbot · 17/8/2026 · 12 min read
The article EKF ( Robotics Fundamentals column) explained the generalized predict-update algorithm. In the Nav2 real-world architecture, the package robot_localization is usually implemented in a particular pattern: two separate EKFs, each in proper charge of a segment in the TF tree learned in Coordinate in Robot .
Key concepts
- EKF Local (Local) — fusion odometry + IMU only, publish transform
odom → base_link - EKF Global (Global)— adds pose from AMCL, publish transform
map → odom
Two non-overlapping — EKFs each publish exactly one different TF segment, concatenating exactly the complete map → odom → base_link sequence.
How it works
ekf_local:
ros__parameters:
frequency: 30.0
odom0: /wheel_odom
imu0: /imu/data
world_frame: odom
publish_tf: true # publish transform odom → base_link
This EKF does not receive data from AMCL — only combining odometry wheel and IMU (correct article Sensor Fusion ), publish transform odom → base_link. Characteristics: slip, high-frequency, continuous— but still drifting over time as no absolute source is calibrated.
ekf_global:
ros__parameters:
frequency: 30.0
odom0: /wheel_odom
imu0: /imu/data
pose0: /amcl_pose # add AMCL source
world_frame: map
publish_tf: true # publish transform map → odom
The second EKF receives additional pose from AMCL as absolute "neo" source, publish transform map → odom — corrects the "sparser update, periodic correction" transform section stated in Coordinates in Robot and Odometry in Localization .
If only a straight publish EKF map → base_link is used, nodes that need high-frequency smoothing data (such as the path-tagging controller) will receive "shock" data every time the sparsely updated AMCL — corrects the "robot jerk every time the AMCL recalibates" problem mentioned in the Coordinate System article. Separation of 2 tiers allows each data type (high-frequency vs. long-term precision) to exist independently in its correct TF segment, without conflict.
Finally: The local layer guarantees smooth, high-frequency data for nodes requiring fast feedback (such as controller_server); the global layer guarantees infinite non-fading absolute position, for nodes requiring long-term precision (such as planner_server).
Technical details
Formulas
the updated frequency of TF odom→base_link (from EKF local) versus map→odom (from EKF global, limited by AMCL frequency) — the effective latency for the node requiring absolute position equals the sum of both segments' latencies:
Map_pose_latency = Latency(odom→base_link) + Latency(map→odom)
Example: local EKF runs at 30Hz (latency ~33ms), AMCL updates at 2Hz (latency ~500ms)
Map_pose_latency ≈ 33ms + 500ms ≈ 533ms
But the pose in the odom frame (requiring only the local EKF) has latency of just ~33ms
→ this is why the path-following controller should use odom, rather than map directly
Parameters
| EKF Layer | Data Sources | Transform publish | Traits |
|---|---|---|---|
| Local | Odometry + IMU | odom → base_link | Smooth, high frequency, time - lapse |
| Global | Odometry + IMU + AMCL pose | map → odom | Sparsely updated, periodic drift correction |
Practical applications
This EKF 2-tiered architecture matches 2 different needs in the entire Nav2 pipeline: controller_server needs relatively high-frequency smoothed position data for exact path-tagging (using segment odom→base_link), whereas planner_server needs exact absolute position in the map for correct path-taking to the destination (using full segment map→odom→base_link). Splitting the 2 levels allows each node in Nav2 to get the right kind of data it needs without knowing the details of how the EKF behind works.
Practical example
# Debug: Checks the correct paragraph for the published TF
ros2 run tf2_ros tf2_echo map odom # should see sparse update, from ekf_global
ros2 run tf2_ros tf2_echo odom base_link # should see constant update, from ekf local
Expected result:
tf2_echo odom base_link -> updates ~30 times/second (matching frequency: 30.0 in ekf_local)
tf2_echo map odom -> updates much less often, depending on AMCL frequency (~2-5Hz)
If map odom does not update at all:
-> check whether ekf_global has publish_tf: true
-> check whether pose0: /amcl_pose is receiving data from AMCL
-> check that world_frame: map is set on the correct instance (a common mistake
is setting world_frame: map on ekf_local, breaking the entire two-layer structure)
If either of the above commands does not return data, re-check that publish_tf: true and world_frame are properly configured for each EKF instance — confusing the configuration between the two instances is the most common error when implementing this 2-tiered pattern.
Common mistakes
- Misassigned
world_framebetween 2 instances of EKF— as the above example, breaks the entire 2-tiered TF structure, causing the publish transform system to miss the segment. - Common use of 1 EKF for both map and odom— as stated in the Operating Principles section, causes data "unlock" for nodes requiring high-frequency smoothing positions each time sparse AMCL updates.
- Do not check
publish_tf: trueat both instances of— one of the two TF fragments is not published, causing "could not transform" errors at the later nodes depending on that fragment. - Communicating which node should use
odomframe and which node should usemapframe — using the wrong frame causes the controller to receive data later than needed, or the planner to receive data incorrectly long-term.
Conclusion
The EKF 2-tiered architecture (local for odom→base_link, global for map→odom) is how Nav2 simultaneously addresses two opposing needs: high-frequency smoothing data for instantaneous control, and long-term accurate absolute location for scheduling. This is a direct real-world application of the cascading principle that has been encountered throughout the AMR architecture. The next article in the column goes into RF2O — a different source of odometry than the encoder, useful precisely when the wheel slides.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.