Key takeaways
- A behavior tree divides a complex mission into a hierarchy of reusable condition and action nodes.
- A repeated tick travels from the root through the tree while nodes report SUCCESS, FAILURE or RUNNING.
- A Sequence advances in order, while a Fallback tries another branch when an earlier option fails.
- Nav2 can use this structure to compute and follow a path, then clear data, rotate, back up and replan after failure.
- A behavior tree organizes decision flow; it is not itself collision protection, an emergency stop or safety certification.
A behavior tree draws the robot’s job as a hierarchy
Imagine a hospital delivery robot carrying a medicine box through a corridor. It must confirm that its battery is sufficient, calculate a route, avoid people and carts, and choose another response if a door is closed or the path becomes blocked. Putting every rule into one long procedure makes changes risky and debugging difficult. A behavior tree organizes the mission as a hierarchy of smaller decisions and actions.
The root may represent the overall goal, such as “complete the delivery.” Its branches contain smaller tasks such as check battery, compute path, follow path and recover from an obstacle. At the leaves are condition nodes that read the world and action nodes that call a planner, controller or device. The BehaviorTree.CPP documentation compares these reusable leaves to Lego bricks: well-designed nodes can be composed into many different missions.

Ticks and three states keep the decision moving
A behavior tree is not a checklist that is read once and discarded. A signal called a tick repeatedly enters the root and travels to children according to each control node’s rules. Every node returns one of three states: SUCCESS, FAILURE or RUNNING. A condition asking whether a door is open can answer immediately, while an action driving along a corridor may remain RUNNING until the robot arrives or encounters a problem.
On the next tick, the tree can inspect the world again. A corridor that was empty a moment ago may now contain a person, so the path-following result can change. This repeated evaluation makes a behavior tree more reactive than a fixed sequence. A faster tick rate does not automatically make every part of the robot faster, however. Motor loops, sensor latency, network delays and planning time still have their own timing requirements.
Sequence and Fallback answer different questions
Two common control nodes are Sequence and Fallback. A Sequence means “do this first, then continue only after success.” Battery checking, route computation and path following may all need to succeed for the delivery branch to succeed. If one child fails, later children are skipped and the Sequence reports failure. This prevents the robot from starting motion before its prerequisites are ready.
A Fallback means “if the first option fails, try the next one.” A navigation branch might first ask whether the goal has already been reached, then attempt normal navigation, and finally invoke recovery. By combining conditions, actions, Sequences and Fallbacks, engineers can express a rule such as: pass through an open door; otherwise request access; if that also fails, select another door.

Nav2, the widely used ROS 2 navigation framework, uses behavior trees to organize real navigation workflows. A typical tree coordinates path computation and path following while allowing replanning. If a box appears in a corridor, the robot does not have to insist on the original route. The tree can call the appropriate planner and controller servers again using the latest map and sensor information.
If planning or control still fails, execution can move to a recovery subtree. Nav2 documentation describes recovery actions such as clearing local or global costmap data, rotating to observe the surroundings again, waiting, backing up and then retrying. The point is not that backing up always works. Recovery should match the failure: an occluded sensor, stale map data and a physically sealed corridor require different responses.

More readable than a large state machine—but not magic
A finite state machine can also control a robot, but a design with dozens of states and hundreds of transitions can become difficult to review. Nav2 uses the example of a soccer robot whose primitives—walk, find the ball and kick—can become reusable nodes. Behavior trees offer hierarchy, modularity and a centralized view of execution flow, which can make large missions easier to inspect and test.
A poorly designed behavior tree can still be dangerous or confusing. It may repeat the same recovery forever, overwrite shared blackboard data, or fail to stop an asynchronous action cleanly when a branch is halted. A very large XML tree can become another form of complexity. State machines, task planners, learned policies and behavior trees are therefore complementary tools used at different layers, not mutually exclusive choices.
What to inspect before deployment
Behavior trees must also be separated from functional safety. Engineers can place a “stop when a person is detected” condition in the tree, but an ordinary software branch does not create safety certification. Deployments still need independently validated collision detection, speed and force limits, emergency stops, safety PLCs and risk assessment. The robot’s safe state after a process crash or communication loss must be tested outside the happy path.
Before deployment, inspect failure behavior rather than the beauty of the diagram. Are success and failure measurable for every node? Does canceling a RUNNING action leave motors and tools safe? Are retries bounded by count and time? Does repeated failure escalate to a person instead of looping forever? The value of a behavior tree is not magical intelligence. It is the ability to turn complex autonomy into a structure that people can read, test and repair.
Sources reviewed
- BehaviorTree.CPP 4.8: Introduction to Behavior Trees
- BehaviorTree.CPP 4.8: Main Concepts
- Nav2: Behavior Trees
- Nav2: Detailed Behavior Tree Walkthrough
- Colledanchise & Ögren: Behavior Trees in Robotics and AI (v6, 2022)
Related reading

Sean Woo — I have spent more than 15 years shaping robotics technology and business direction. Drawing on public technical documents, research papers and company announcements, I explain changes in robotics and AI in accessible terms. The interpretations in this publication do not represent the official position of any company or organization.