Integrating ROS 2 and BTs
In this second example, we will create a more complex BT, using the blackboard to share a ROS 2 node variable, to use ROS 2 publishers, and the input port of a node to get information about which message to publish. We will create two nodes: a CheckNumber
node, which generates a random number and tests whether it is lower than a given value. If it is lower, the node returns SUCCESS
, or FAILURE
otherwise. This is repeated three times, considering a higher value for the number checking. The generated number is then sent to the PublishResult
node, which uses the ROS 2 node object to publish the generated value. To create such a testing structure, we will use the fallback control node while, to create the tree, we will use Groot 2, as discussed in the next section. Apart from the implementation discussed in this chapter, some wrappers for ROS 2 nodes shaped as BT nodes can be found at this link [2]. This wrapper can be used to speed up the implementation of the...