AtsushiSakai/PythonRobotics · error · ValueError
Children are not set
Error message
Children are not set
What it means
Raised by ControlNode.not_set_children_raise_error, called from tick. A control node (sequence, selector, while-do-else) cannot execute without at least one child, so ticking an empty control node is rejected.
Source
Thrown at MissionPlanning/BehaviorTree/behavior_tree.py:84
pass
class ControlNode(Node):
"""
Base class for all control nodes in a behavior tree.
Control nodes manage the execution flow of their child nodes according to specific rules.
They typically have multiple children and determine which children to execute and in what order.
"""
def __init__(self, name):
super().__init__(name)
self.children = []
self.type = NodeType.CONTROL_NODE
def not_set_children_raise_error(self):
if len(self.children) == 0:
raise ValueError("Children are not set")
def reset_children(self):
for child in self.children:
child.reset()
class SequenceNode(ControlNode):
"""
Executes child nodes in sequence until one fails or all succeed.
Returns:
- Returns FAILURE if any child returns FAILURE
- Returns SUCCESS when all children have succeeded
- Returns RUNNING when a child is still running or when moving to the next child
Example:
.. code-block:: xml
View on GitHub (pinned to 1fe4fb980f)
Solutions
- Add at least one child node via add_child before ticking.
- Validate the tree structure after construction (len(node.children) > 0).
- If loading from XML, ensure every control tag encloses at least one child element.
Example fix
// before
seq = SequenceNode('seq')
tree.tick() # no children added
// after
seq = SequenceNode('seq')
seq.add_child(ActionA('a'))
tree.tick() Defensive patterns
Strategy: validation
Validate before calling
assert len(control_node.children) > 0, f'{control_node.name} has no children' Type guard
def has_children(node) -> bool:
return getattr(node, 'children', None) and len(node.children) > 0 Try / catch
try:
tree.tick()
except ValueError as e:
if 'Children are not set' in str(e):
# attach children or skip this tick
pass
raise Prevention
- Build trees through a factory that validates structure before returning.
- Treat empty control nodes as a build-time error, not runtime.
When it happens
Trigger: Creating a SequenceNode/SelectorNode/WhileDoElseNode, never calling add_child, and then ticking the tree containing it. Also triggered by building a tree from XML where a control tag has no child tags.
Common situations: Dynamically assembled trees where children are conditionally appended and the list ends up empty, or XML tree definitions with a control node that has no children.
Related errors
- Child is not set
- {root.name} Control node must have children
- Node is not implemented
- Unknown status
- WhileDoElseNode must have exactly 3 or 2 children
AI-assisted analysis of AtsushiSakai/PythonRobotics@1fe4fb980f (2026-08-28).
Data as JSON: /api/errors/5c47ae10f14605c4.
Report an issue: GitHub.