@@ -11,17 +11,24 @@ For instance, in a service-oriented architecture, the leaves would contain
1111the "client" code that communicate with the "server" that performs the
1212operation.
1313
14- ![ Leaf To Component Communication] ( images/LeafToComponentCommunication.png )
14+ In the following example, we can see two Actions executed in a sequence,
15+ ` DetectObject ` and ` GraspObject ` .
1516
17+ ![ Leaf To Component Communication] ( images/LeafToComponentCommunication.png )
1618
17- The other nodes of the tree, those which are not leaves , control the
19+ The other nodes of the tree, those which are __ not leaves __ , control the
1820"flow of execution".
1921
20- To better understand how this flow takes place , imagine a signal, that we will further
21- call "__ tick__ "; it is executed at the __ root__ of the tree and propagates through
22- the branches until it reaches one or multiple leaves.
22+ To better understand how this control flow takes place , imagine a signal
23+ called "__ tick__ "; it is executed at the __ root__ of the tree and it propagates
24+ through the branches until it reaches one or multiple leaves.
25+
26+ !!! Note
27+ The word __ tick__ will be often used as a * verb* (to tick / to be ticked) and it means
28+
29+ "To invoke the callback ` tick() ` called of a ` TreeNode ` ".
2330
24- The ` tick() ` callback returns a ` NodeStatus ` that will be either:
31+ Then a ` TreeNode ` is ticked, it returns a ` NodeStatus ` that can be either:
2532
2633- __ SUCCESS__
2734- __ FAILURE__
@@ -37,7 +44,7 @@ and they needs more time to return a valid result.
3744This C++ library provides also the status __ IDLE__ ; it means that the node is ready to
3845start.
3946
40- The result of a node is propagated back to the parent, that will decide
47+ The result of a node is propagated back to its parent, that will decide
4148which child should be ticked next or will return a result to its own parent.
4249
4350## Types of nodes
@@ -57,7 +64,7 @@ alter the state of the system.
5764![ UML hierarchy] ( images/TypeHierarchy.png )
5865
5966
60- ## Learn by example
67+ ## Examples
6168
6269To better understand how a BehaviorTrees work, let's focus on some practical
6370examples. For the sake of simplicity we will not take into account what happens
@@ -83,11 +90,11 @@ In short:
8390
8491- If a child returns SUCCESS, tick the next one.
8592- If a child returns FAILURE, then no more children are ticked and the Sequence returns FAILURE.
86- - If all the children return SUCCESS, then the Sequence returns SUCCESS too.
93+ - If __ all __ the children return SUCCESS, then the Sequence returns SUCCESS too.
8794
88- ??? warning "Exercise: find the bug! Expand to read the answer. "
95+ !!! warning "Have you spotted the bug? "
8996 If the action __ GrabBeer__ fails, the door of the
90- fridge would remain open, since the last action __ CloseDoor __ is skipped.
97+ fridge would remain open, since the last action __ CloseFridge __ is skipped.
9198
9299
93100### Decorators
@@ -113,14 +120,15 @@ __Apparently__, the branch on the right side means:
113120
114121 If the door is closed, then try to open it.
115122 Try up to 3 times, otherwise give up and return FAILURE.
116-
117-
118- __ But__ there is an error. Can you find it?
119123
120- ??? warning "Exercise: find the bug! Expand to read the answer."
124+ But...
125+
126+ !!! warning "Have you spotted the bug?"
121127 If __ DoorOpen__ returns FAILURE, we have the desired behaviour.
122128 But if it returns SUCCESS, the left branch fails and the entire Sequence
123- is interrupted.
129+ is interrupted.
130+
131+ We will see later how we can improve this tree.
124132
125133
126134### Second ControlNode: Fallback
@@ -140,37 +148,37 @@ In the next example, you can see how Sequence and Fallbacks can be combined:
140148![ FallbackNodes] ( images/FallbackBasic.png )
141149
142150
143- > In the door open?
151+ > Is the door open?
144152>
145- > I not, try to open the door.
153+ > If not, try to open the door.
146154>
147155> Otherwise, if you have a key, unlock and open the door.
148156>
149157> Otherwise, smash the door.
150158>
151- > If any of these actions succeeded, then enter the room.
159+ > If __ any __ of these actions succeeded, then enter the room.
152160
153161### "Fetch me a beer" revisited
154162
155- We can now improve the "Fetch Me a Beer" example, which leaves the door open
156- if the beer was not there .
163+ We can now improve the "Fetch Me a Beer" example, which left the door open
164+ if the beer was not inside the fridge .
157165
158- We use the color "green" to represent nodes which will return
166+ We use the color "green" to represent nodes which return
159167SUCCESS and "red" for those which return FAILURE. Black nodes are never executed.
160168
161169![ FetchBeer failure] ( images/FetchBeerFails.png )
162170
163-
164171Let's create an alternative tree that closes the door even when __ GrabBeer__
165172returns FAILURE.
166173
167174
168175![ FetchBeer failure] ( images/FetchBeer.png )
169176
170- Both the trees will close the door of the fridge, eventually, but:
177+ Both these trees will close the door of the fridge, eventually, but:
171178
172179- the tree on the __ left__ side will always return SUCCESS if we managed to
173180 open and close the fridge.
181+
174182- the tree on the __ right__ side will return SUCCESS if the beer was there,
175183FAILURE otherwise.
176184
0 commit comments