This lab works on phones, but writing code is much easier on a laptop.
Navigation · Navigation in the Real World · M9-L3 · Advanced
Validate a Behavior Tree
Incident report · Meridian General Hospital
17:30. A refactor of the navigation behaviour tree went out at lunchtime. Since then one Scout has driven into the supply trolley and stood there for an hour, one has asked the planner for a route to a ward that was locked and not stopped asking, and the recovery behaviours Facilities asked for are "in the file" but have never been seen to run.
The tree is 60 lines of XML. Nobody wants to read it again; you will write the checker that does.
Your task
Lab complete: post-mortem
You have passed every stage. Now connect it back to the theory and move on:
Plain Python with math and heapq. The tree arrives as nested dicts {"tag", "attrs", "children"}; the starter code includes all_nodes(trees), which lists every node with its path and the tags above it. No XML module is available or needed; attribute values are strings. Your code runs in a background worker and is never sent anywhere.
Hints
What this lab teaches
In Nav2 the navigator is a behaviour tree: a small program whose nodes call the planner, the controller and the recovery behaviours, and whose control nodes decide what happens when a step fails. Like any program it can contain dead code (a tree nothing calls, a step after one that always fails), missing error handling (a path-following step with no recovery above it), unbounded loops (an endless retry) and wiring mistakes (a blackboard name that nobody writes, an action without its required ports, a node type that is not registered).
The page has no paste-in text box, so each stage gives your Python the tree already parsed (the XML of the practice example is shown on the page, and the same reader produced the nested dictionaries). You write lint(trees, main, registered) and return findings that name a rule and a node as TreeId/0/1. Grading is result-based on hidden trees: some have several problems, some have none, and some contain valid constructs that a careless validator would flag.
The node and port names (ComputePathToPose, FollowPath, RecoveryNode, PipelineSequence, RoundRobin, ClearEntireCostmap, Spin, Wait, BackUp) follow Nav2's behaviour-tree nodes, and RetryUntilSuccessful is a node of the BehaviorTree.CPP library that Nav2 uses. Names, ports and the XML format differ between releases, so check the documentation for your distribution. The rules are this lab's rules.
Educational simplification: the trees are generated and much smaller than the default Nav2 trees, each BehaviorTree has a single root node, the XML is read by a small reader that handles only what these files use, and the rules are this lab's own. A real validator has to know the node types and ports of your release, including custom plugins.
Get the next lab
Get notified when new robotics labs are released. One email per new lab, nothing else.