AutoAPMS
Resilient Robot Mission Management
|
Generic behavior tree node wrapper for a ROS 2 publisher. More...
#include <auto_apms_behavior_tree_core/node/ros_publisher_node.hpp>
Public Member Functions | |
RosPublisherNode (const std::string &instance_name, const Config &config, Context context, const rclcpp::QoS &qos={10}) | |
Constructor. | |
virtual bool | setMessage (MessageT &msg) |
Callback invoked when ticked to define the message to be published. | |
bool | createPublisher (const std::string &topic_name) |
Create the ROS 2 publisher. | |
std::string | getTopicName () const |
Get the name of the topic name this node publishes to. | |
Static Public Member Functions | |
static BT::PortsList | providedBasicPorts (BT::PortsList addition) |
Derived nodes implementing the static method RosPublisherNode::providedPorts may call this method to also include the default port for ROS 2 behavior tree nodes. | |
static BT::PortsList | providedPorts () |
If a behavior tree requires input/output data ports, the developer must define this method accordingly. | |
Generic behavior tree node wrapper for a ROS 2 publisher.
When ticked, this node publishes a single message to a topic. Inheriting classes must reimplement the virtual methods as described below.
By default, the name of the topic will be determined as follows:
port
, use that.It is possible to customize which port is used to determine the topic name and also extend the input's value with a prefix or suffix. This is achieved by including the special pattern (input:<port_name>)
in NodeRegistrationOptions::port and replacing <port_name>
with the desired input port name.
Example: Given the user implements an input port BT::InputPort<std::string>("my_port")
, one may create a client for the topic "foo/bar" by defining NodeRegistrationOptions::port as (input:my_port)/bar
and providing the string "foo" to the port with name my_port
.
Additionally, the following characteristics depend on NodeRegistrationOptions:
MessageT | Type of the ROS 2 message. |
Definition at line 57 of file ros_publisher_node.hpp.
|
inlineexplicit |
Constructor.
Derived nodes are automatically created by TreeBuilder::instantiate when included inside a node manifest associated with the behavior tree resource.
instance_name | Name given to this specific node instance. |
config | Structure of internal data determined at runtime by BT::BehaviorTreeFactory. |
context | Additional parameters specific to ROS 2 determined at runtime by TreeBuilder. |
qos | Quality of service settings forwarded to the publisher. |
Definition at line 144 of file ros_publisher_node.hpp.
|
inlinestatic |
Derived nodes implementing the static method RosPublisherNode::providedPorts may call this method to also include the default port for ROS 2 behavior tree nodes.
addition | Additional ports to add to the ports list. |
Definition at line 88 of file ros_publisher_node.hpp.
|
inlinestatic |
If a behavior tree requires input/output data ports, the developer must define this method accordingly.
Definition at line 99 of file ros_publisher_node.hpp.
|
inlinevirtual |
Callback invoked when ticked to define the message to be published.
The node may deny to publish a message by returning false
. Otherwise, this method should return true
.
By default, this callback simply returns true
and sends an empty message.
msg | Reference to the message. |
false
if no message should be published. In that case, the return status of this node will be BT::NodeStatus::FAILURE. Otherwise, the message will be published and the node returns BT::NodeStatus::SUCCESS. Definition at line 232 of file ros_publisher_node.hpp.
|
inline |
Create the ROS 2 publisher.
topic_name | Name of the topic. |
true
if the publisher was created successfully, false
otherwise. Definition at line 162 of file ros_publisher_node.hpp.
|
inline |
Get the name of the topic name this node publishes to.
Definition at line 238 of file ros_publisher_node.hpp.