BehaviorTree.CPP icon indicating copy to clipboard operation
BehaviorTree.CPP copied to clipboard

Reactive async

Open miccol opened this issue 6 years ago • 3 comments
trafficstars

Hello,

this is an attempt to solve Issue #83.

The main important change is the implementation of the function propagateHalt that lets a node to trigger the haltChildren routine of its parent.

@facontidavide The idea behind this is, before ticking an async child, the BT should halt the other running children (if any). Let me know what do you think about this.

There are also gtests to test that tests that no race condition occurs.

https://github.com/BehaviorTree/BehaviorTree.CPP/blob/82cb1c7b579013cc45557a00326d1b5b5d2c1cf3/tests/gtest_reactive_tree.cpp#L100-L101

Thank you MC

miccol avatar Apr 30 '19 13:04 miccol

i will take my time and look at this carefully. Thanks!!!

facontidavide avatar May 01 '19 14:05 facontidavide

Nice to see someone working on this, thanks! I'm also going to try to have a look next week.

This caught my attention:

@facontidavide The idea behind this is, before ticking an async child, the BT should halt the other running children (if any). Let me know what do you think about this.

Have you thought about letting the first async node finish execution when ticking the second async node instead of halting the first async node right away? This would mean both would run at the same time for a certain period. That's how I would imagine a reactive sequence to behave and it would allow for some nice use cases.

hlzl avatar May 02 '19 20:05 hlzl

Nice to see someone working on this, thanks! I'm also going to try to have a look next week.

This caught my attention:

@facontidavide The idea behind this is, before ticking an async child, the BT should halt the other running children (if any). Let me know what do you think about this.

Have you thought about letting the first async node finish execution when ticking the second async node instead of halting the first async node right away? This would mean both would run at the same time for a certain period. That's how I would imagine a reactive sequence to behave and it would allow for some nice use cases.

That is possible already (but be careful in doing so). When sending the halt, it calls the halt() function, however the execution of the tick() is not stopped if not handled explicitly. To handle the interruption of the tick() execution you can do something like this:

In the halt() you set a variable https://github.com/BehaviorTree/BehaviorTree.CPP/blob/68b7da74248d068a93970ab38611791282ed2797/sample_nodes/movebase_node.cpp#L36-L39

and you check it in the tick() https://github.com/BehaviorTree/BehaviorTree.CPP/blob/68b7da74248d068a93970ab38611791282ed2797/sample_nodes/movebase_node.cpp#L27-L30

Anyway, If you want to discuss more about this, I think it is better if we move the conversation in another place (i.e. not in a PR).

Cheers MC

miccol avatar May 03 '19 07:05 miccol

I think better solutions have been implemented

miccol avatar Sep 22 '22 08:09 miccol