Recovery behaviors: what a robot should do when it gets stuck
Atlasbot · 17/8/2026 · 11 min read
The article Behavior Tree has shown Fallback to switch to the recovery branch when the main stream fails. This unit goes into detail the recovery behavior specific — behaviors robots perform to self-release from a stalemate situation, before actually reporting errors to the application layer.
Key concepts
Four common recovery behaviors, each dealing with a different stuck situation:
Spin — rotate in place through an angle to see the surroundings more clearly;
sometimes this is enough to refresh the costmap and reveal a new path
BackUp — reverse a short distance to move away from a nearby obstacle
in front, giving the planner more room to replan
Wait — stay still for a period; useful when the obstacle is
a moving person/object that will pass
ClearEntireCostmap — clear the local costmap and rebuild it from the latest
sensor data; useful when stale, incorrect data is stuck in the costmap
How it works
Without recovery: 1 failure → robot stops and waits for human intervention
With recovery: failure → try Spin → still fails → try BackUp
→ still fails → try Wait → ... → only then report an error
Much of the drag in the real-world is temporary (people moving sideways through, costmap with temporary noise data) — recovery behavior gives robots a chance to escape without human intervention at all, in the spirit of automation that the navigation system is all about.
Summarized: Recovery is not "error-engineering" — planners/controllers are still true to their logic, it is just the current situation (costmap has erroneous interim data, or the robot is in a difficult position) that makes them fail. Recovery changes the situation (rotate to see another angle, reverse to gain more space, wait for the dynamic obstacle to move away) and lets the planner/controller try again with the new situation, not replace their logic.
Technical details
Formulas
bt_navigator:
ros__parameters:
default_nav_to_pose_bt_xml: navigate_to_pose_w_replanning_and_recovery.xml
recoveries_server:
ros__parameters:
recovery_plugins: ["spin", "backup", "wait"]
spin:
plugin: "nav2_behaviors::Spin"
The number of recover sequence iterations before actually returning FAILURE to the application layer is typically configured immediately within the XML Behavior Tree file (via RecoveryNode with the number_of_retries parameter) — which is not hard - bound in code, easily adjusted to the particular operating environment:
Maximum_recovery_time = number_of_retries × (Time_per_attempt + Main_branch_retry_time)
Example: number_of_retries = 3, each Spin takes ~3s, retrying ComputePathToPose+FollowPath takes ~2s
Maximum_time ≈ 3 × (3+2) = 15 seconds before reporting FAILURE to the application layer
Parameters
| Recovery behavior | Solving the Situation | Time cost |
|---|---|---|
| Spin | Costmap lacks current-angle data | Low (few seconds) |
| BackUp | Too close to forward obstacle | Low (few seconds) |
| Wait | temporary dynamic obstacle (passer) | Medium (depending on configuration timeout) |
| ClearEntireCostmap | Costmap jamming bad old data | Very low (temporary) |
Practical applications
A crowded environment may need more Wait tries than a static environment — this is a specific example for fine-tuning number_of_retries and order of recovery behavior according to the real-world operating environment specificity, not using the same default configuration for all types of warehouses. After an expiration of configurable recovery attempts, the Behavior Tree returns the final FAILURE to the node that called it (typically the action server NavigateToPose) — application layer (specific operationslogic, mentioned in Robot software panorama ) receiving this failure notification and deciding the next step — may be to inform the operator, retry after some time, or switch to another task, correct for the state machine role learned in the Application Layer in AMR.
Practical example
<RecoveryNode number_of_retries="3" name="NavigateRecovery">
<PipelineSequence>
<ComputePathToPose goal="{goal}" path="{path}"/>
<FollowPath path="{path}"/>
</PipelineSequence>
<ReactiveFallback>
<Spin spin_dist="1.57"/>
<Wait wait_duration="5"/>
<BackUp backup_dist="0.3"/>
</ReactiveFallback>
</RecoveryNode>
Scenario: an AMR in a busy warehouse encounters a person blocking a narrow passage
Attempt 1: FollowPath FAILURE (person blocks the path) -> Spin (another viewing angle does not help)
Attempt 2: still FAILURE -> Wait 5 seconds (the person may move away)
Attempt 3: FollowPath SUCCESS (the person passed during Wait)
If all 3 attempts fail: RecoveryNode returns FAILURE to bt_navigator,
the NavigateToPose action reports an error to the Application Layer, and the system can
notify the operator or retry later
Common mistakes
- Set
number_of_retriestoo low for regular crowded/obstacle-dynamic — robots report errors too soon even though the real-world situation just needs a little more time. - Setting
number_of_retriestoo high, waiting time for recovery too long— as calculated in the Formulation, the robot may "flip" the recovery test too long before reporting an error, affecting the real-world operating experience if the situation really needs early human intervention. - Only one type of recovery behavior is used for every situation — each behavior correctly addresses a specific type of deadlock (the Parameter table), the lack of diversity makes it impossible for robots to escape multiple situations on their own.
- Differentiating recovery for a temporary problem and a real problem requiring intervention— trial indefinite recovery for an unsolvable situation (e.g., the real path is permanently blocked) wasting time rather than early error reporting to the operator.
Conclusion
Recovery behaviors give robots the opportunity to escape temporary stasis before human intervention — Each behavior (Spin, BackUp, Wait, ClearEntireCostmap) correctly addresses a specific type of situation, not "error algorithm" but changing the situation for the planner/controller to retry. Correct number_of_retries configuration and order of recovery according to operating environment characteristics are key refinements. The last article in Nav2, Waypoint Follower, goes into the problem of repeatedly passing multiple points — extending from navigation to 1 point learned throughout this section.
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.