Atlas Robotics
Nav2Advanced

Behavior trees: how bt_navigator coordinates Nav2

Atlasbot · 17/8/2026 · 12 min read

Behavior trees: how bt_navigator coordinates Nav2
Behavior Tree Coordinate Planner, Controller, and Recovery by Tree Structure

The problems Planner and Controller address "path counting" and "path following" — but who decides which order calls those two things, and what to do when one step fails? This is the role of Behaviour Tree, coordinated by node bt_navigator.

Key concepts

State Machine: states connected by transitions (IF condition THEN change state)
Behavior Tree: a TREE structure where each node returns one of 3 results:
    SUCCESS — completed
    FAILURE — failed
    RUNNING — still running, not finished

Advantages of a Behavior Tree over the traditional State Machine: easy to (compose) small behaviors into larger ones without redrawing the entire — transition scheme just by adding a subnode to the right position in the tree.

How it works

Two main types of nodes:

Control Node — determines the order/conditions for running child nodes:
    Sequence   — run in order, stop as soon as 1 child returns FAILURE
    Fallback   — try in order, stop as soon as 1 child returns SUCCESS (try the next option on failure)

Action Node — performs actual work:
    ComputePathToPose  — calls planner_server (Planner article)
    FollowPath         — calls controller_server (Controller article)
    Spin, BackUp, Wait — call recovery behaviors (Recovery article)

Simple tree examples for basic navigation:

<BehaviorTree>
  <PipelineSequence>
    <ComputePathToPose goal="{goal}" path="{path}"/>
    <FollowPath path="{path}"/>
  </PipelineSequence>
</BehaviorTree>

PipelineSequence (Variant of Sequence) runs ComputePathToPose before — if SUCCESS, switches to FollowPath. If ComputePathToPose FAILURE (no path found), the entire tree returns FAILURE immediately, not running FollowPath.

Finally: Behavior Tree contains no algorithmic logic (planner/controller does it) — it contains only logical coordination: what to call, in what order, what to do when it fails. Separating regulatory logic from algorithmic logic makes each part much easier to understand, test, and stand-alone than chunking into one big block of code.

Technical details

Formulas

Combination of recovery when Fallback fails — nested constructs between Major Sequence and Fallback recovery:

<Fallback>
  <PipelineSequence>
    <ComputePathToPose goal="{goal}" path="{path}"/>
    <FollowPath path="{path}"/>
  </PipelineSequence>
  <ReactiveFallback>
    <Spin spin_dist="1.57"/>
    <Wait wait_duration="5"/>
  </ReactiveFallback>
</Fallback>

If the main stream (Sequence above) fails — e.g. FollowPath gets stuck — Fallback the higher level switches to trial recovery behavior (the Recovery problem): rotate in place to "see" better, then try again. This is exactly the mechanism underlying the "robot rotating itself when stuck" behavior commonly seen in AMR real-world.

Parameters

Type of nodeOutput when SUCCESS childResults when child FAILURE
SequenceSwitch to Next ChildStop now, sequence FAILURE
FallbackStop it, Fallback SUCCESS.Try next child

Practical applications

The Tree Behavior in Nav2 is defined using separate XML files (not embedded in C++/Python code) — to change the coordination structure (add new recovery step, change the trial order) just to edit the XML file and restart bt_navigator, without recompiling any node — in the spirit of configurational separation from code seen many times in the articles Parameter and Launch File . With AMR operating in specific environments (e.g., a high-traffic warehouse needs to prioritize Wait over Spin), direct XML tree structure editing — without touching the C++ code of planner_server/controller_server — helps to fine-tune robot behavior much faster than code editing and rebuild.

Practical example

Trace 1 navigation command through a Behavior Tree with Fallback recovery:

1. bt_navigator receives a goal and starts PipelineSequence
2. ComputePathToPose -> SUCCESS (a path is found)
3. FollowPath -> RUNNING, then an unexpected obstacle completely blocks the path -> FAILURE
4. The higher-level Fallback detects main-branch FAILURE and switches to ReactiveFallback
5. Spin (rotate 90°) -> SUCCESS (rotation completes)
6. Fallback reports SUCCESS for the recovery branch -> retry the main branch
7. ComputePathToPose replans (the costmap has updated after rotation) -> SUCCESS
8. FollowPath continues -> the robot resumes normal motion

No human intervention is needed — the Behavior Tree automatically retries
according to the structure defined in XML

Common mistakes

  • Comparison between Sequence and Fallback when designing trees— uses the wrong type of node which causes coordination logic to run against desired (e.g., using the Sequence when it is intrinsically necessary to try each node in turn until it works).
  • Injecting algorithmic logic to Behavior Tree instead of Private Action Node— violates the principle of separating coordination logic from algorithmic logic, making the tree difficult to read and difficult to test independently.
  • Do not check XML files after editing before deploying— XML syntax errors or non-existing nodes cause bt_navigator to fail to load trees, which are usually detected only when the robot does not respond to the new goal.
  • The Fallback recovery tree design is too simple for complex environments — with only 1-2 recovery behaviors that may not be sufficient for all real-world jamming situations, see the Recovery article for a complete understanding of the options.

Conclusion

Behavior Tree explicitly separates coordination logic (what to call, what order, what to do when it fails) from algorithmic logic (planner/controller doing their own work) — Tree structures with Sequence/Fallback and XML definitions help refine robot behavior without rebuilding code. The next article in the column goes into Recovery Behaviors — detailing the behaviors robots perform to free themselves from stalemate.

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.

Behavior trees: how bt_navigator coordinates Nav2 — Atlas Robotics