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

Make RosTopicSubNode a StatefulActionNode and handle different reliability QoS configurations

Open schornakj opened this issue 5 months ago • 2 comments

There were two things I wanted to improve about the RosTopicSubNode:

  1. The requirement that onTick must strictly either return SUCCESS or FAILURE doesn't match up well with the process of waiting for a message to be received. Practically there are actually three states: the message has not yet been received and we should continue RUNNING while we wait for it, or the message has been received and the user's code determines if the contents of the message mean SUCCESS or FAILURE.
  2. As currently implemented it can't subscribe to publishers that use the BestEffort reliability QoS config, which is often used when publishing sensor data.

Here's what I did to achieve these goals:

  • Make RosTopicSubNode a StatefulActionNode. The user's implementation of onTick can now return RUNNING, which allows explicitly waiting for a new message to be received. This allows the behavior tree to be simpler if the goal is to get a new message before continuing.
  • Always create the subscriber during the first tick. This solves two problems:
    • We can get information about the publishers on the specified topic and dynamically determine the correct QoS settings to use for the subscriber. This lets us handle both Reliable and BestEffort publishers without adding more fields to RosNodeParams and requiring the user to set the QoS themselves. This is a partial fix for #14.
    • Getting the topic name only at runtime requires less handling for special situations than allowing both getting it in the constructor and later getting it at runtime.
  • Add some tests to exercise these different situations.

I've kept this as a draft for now because I have a few design questions (see comments below).

schornakj avatar Sep 20 '24 01:09 schornakj