FixTheRobot Explore Robotics / Navigation / M7 / M7-L3

This lab works on phones, but writing code is much easier on a laptop.

Navigation · Safety, Uncertainty and Recovery · M7-L3 · Intermediate

Build a Recovery Behavior Tree

15:45. A patient trolley is parked half across the corridor. Scout's follow-path action fails once and the whole mission is aborted. In another run it spins in a narrow corridor because the recovery list is a sequence and runs every item, whatever went wrong.

You will write the tick of a small behaviour tree, build the tree that recovers in a sensible order and asks for help last, and give a retry node its budget.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math and heapq. Your code runs in a background worker: an endless loop is stopped after a few seconds and the page stays usable. It runs in your browser and is never sent anywhere.

    Hints

    What this lab teaches

    Stage 1 is the tick: a sequence stops at the first child that is not a success, a fallback at the first child that is not a failure, and a running child ends the tick. Stage 2 builds the recovery tree: try to drive, then recoveries cheapest and safest first with a new attempt after each, then ask for help. Stage 3 adds a retry decorator whose attempts are bounded and that does not repeat finished work.

    Grading is result-based: ticks are compared on freshly generated trees, and your tree is run against several causes of failure to see what it does and what it costs.

    Theory for this lab

    Safety, Uncertainty and Recovery labs

    1. M7-L1: Size the Safety Margin
    2. M7-L2: Plan with Pose Uncertainty
    3. M7-L3: Build a Recovery Behavior Tree: this lab.
    4. M7-L4: Detect and Escape a Stuck Robot

    Educational simplification: trees are plain dictionaries, actions finish within a tick, and there is no blackboard or halting of running children. Real libraries such as BehaviorTree.CPP, and the Nav2 navigator built on it, do much more (lessons M7-T5 and M7-T6).

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.