"Separation of Concerns" and "Composability" are two core principles
you need to understand to build good robotic systems
We want to build a high level "Task Planner", AKA "Coordinator / Orchestrator" that executes complex behaviors in a Service Oriented system.
An alternative to Hierarchical State Machines.
A Domain Specific Language to describe Behaviors.
Complexity increases exponentially with size.
The complexity of BehaviorTree grows more slowly
With FSM, the graphic representation rapidly becomes complex and "hard to read".
Tick the children, from left to right, while they return SUCCESS.
if a child returns FAILURE, stop and return FAILURE.
Tick the children, from left to right, while they return FAILURE.
If a child returns SUCCESS, stop and return SUCCESS.
Decorators are a very simple and powerful way to implement more complex logic.
It would be very complicated to do the same with state machines
There are no beers in the fridge and I don't want to keep the door of the fridge open
bool FetchBeer()
{
if( GoTo("kitchen") &&
OpenFridge() &&
Grasp("beer") &&
CloseFridge() )
{
return true;
}
else{
return false;
}
}
In the context of Behavior Trees this mean:
If we think about SubTrees and Nodes as functions, it is easy to understand how we need input and output to be modeled explicitly.
This is done in Behavior Tree using the Blackboard, a simple key-value storage
About Behavior Trees in general
About BehaviorTree.CPP