sea-bass / turtlebot3_behavior_demos

Example repository for autonomous behaviors using TurtleBot3, as well as Docker workflows in ROS based projects.
MIT License
270 stars 53 forks source link

Doubts about LookForObject::onHalted() #32

Closed ZhipengZhang-flexiv closed 1 year ago

ZhipengZhang-flexiv commented 1 year ago

I am confused about when and how this onHalted() method will be called. In BT source code the comment said that "callback to execute if the action was aborted by another node." But how can I implement that?I mean how can I abort a running statefulActionNode using another custom node? Thanks!

sea-bass commented 1 year ago

Well, say for example you're running this under a "Parallel" or "Reactive Sequence" control node. If something else fails and causes the stateful action node to terminate early (i.e., while it's still RUNNING), then the onHalted() method will kick in to do any cleanup.

I would point you to the BehaviorTree.CPP documentation : https://www.behaviortree.dev/docs/tutorial-basics/tutorial_04_sequence

ZhipengZhang-flexiv commented 1 year ago

I rewrote the example of t04 according to your prompt, and it did work. Thank you