Best practice to use BehaviorTree.CPP along with ROS #803
Unanswered
maker-ATOM
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My ultimate goal is to use BehaviorTree in conjugation with ROS specfically move_base to control a robot move from one point to other.
What I am doing (For testing purpose):
To be more specific I have a StatefulActionNode (work) which get information about current status of goal be it RUNNING, ABORTED or SUCCESS. For time being the BehaviorTree has only a single StatefulActionNode. Functions for condition node are defined inside the
work class.
ROS methods primarily subscription callback are also defined within the work class.
So basically all methods be it related to BehaviorTree or ROS all are defined under single class work which is inherited from StatefulActionNode, the reason to do this is because in case of multiple subscriptions, methods of the same class can access data elements directly.
This is the Tree I am using,
The XML version of the tree, 👆
And the code that I am using currently,
OUPUT:
The while loop ticks the behavior tree and ros once every iteration, the node subscribes to topic
state
and stores the value published on the topic within the class attribute. Moreover work node also does something similar increments another class attribute every time it is ticked.Since both functions are methods of the same class the attributes should accessible which is not the case. BehaviorTree node cannot get the latest value updated by the ROS subscription callback and ROS subscription callback cannot get the latest value updated by the Behavior Tree node.
Meaning in the last block of output behavior tree say value of
state
variable is 0 ([BT] state: 0
) which actually is 94 and subscription callback says value ofwork_done
incremented by BehaviorTree is 0 ([ROS] work_done: 0
) which actually is 2.So what is the best practice to have BehaviorTree Nodes and ROS methods defined in way so that data exchange between them happens?
Beta Was this translation helpful? Give feedback.
All reactions