@@ -70,28 +70,42 @@ A serious problem was detected by a user
7070> If a ** ControlNode** or ** DecoratorNode** has synchronous children only,
7171 it is impossible to interrupt it.
7272
73- The only way to solve this was to add a ` return RUNNING ` statement
74- every time a ** Synchronous** child is executed (unless it is the last one).
75-
76- For instance, given a tree:
73+ Consider this example:
7774
7875``` xml
79- <Sequence name =" synch_sequence" >
80- <SyncActionA />
81- <SyncActionB />
82- <SyncActionC />
83- <Sequence >
76+ <ReactiveSequence >
77+ <AbortCondition />
78+ <Sequence name =" synch_sequence" >
79+ <SyncActionA />
80+ <SyncActionB />
81+ <SyncActionC />
82+ <Sequence >
83+ </ReactiveSequence >
8484```
85- Version ** 3.X** would execute this in a single ** tick()** .
8685
87- In version ** 4.X** the node ` Sequence ` will return ** RUNNING**
88- twice: after executing ` SyncActionA ` and ` SyncActionB ` .
86+ ::: danger
87+ Once the Sequence "synch_sequence" starts, with BT.CPP 3.X
88+ it is impossible for ** AbortCondition** to stop it.
89+ :::
90+
91+ In BT.CPP 4.X we modified our Controls and Decorators to
92+ prevent this potential issue.
93+
94+ Now, when a Synchronous child is executed, ** RUNNING is returned** before moving to the next child.
95+ In this way, we give the opportunity to the tree to check ReactiveSequences or other Conditions.
8996
90- The advantage is that now ** synch_sequence** can be pontentially interrupted.
91- The drawback is that we need to tick the tree more often.
97+ From a practical point of view, this means that we must call ** tick()** more often.
98+
99+ ::: tip
100+ This new behavior should NOT introduce any additional latency, at least not a significant one.
101+
102+ When Controls and Decorator return RUNNING, the method ` Tree::sleep() ` will ** not**
103+ block and won't introduce any additional delay. This is the reason why you should never use
104+ "normal" sleep functions.
105+ :::
92106
93- To be sure that this is done correctly and ** to avoid introducing any additional latency"
94- (no sleep between the children), we changed the API of ` Tree::tickRoot() ` :
107+ To make this new behavior more explicit, the method ` Tree::tickRoot() ` was removed,
108+ and we introduce these two new methods instead :
95109
96110- ` Tree::tickOnce() ` works as usual. It should run inside a while-loop.
97111- ` Tree::tickWhileRunning() ` has its own while-loop, and will continue ticking until either
0 commit comments