![]() |
AutoAPMS
Streamlining behaviors in ROS 2
|
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:
topic, use that.It is possible to customize which data 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::topic 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::topic as (input:my_port)/bar and providing the string "foo" to the port with name my_port.
Additionally, the following characteristics depend on NodeRegistrationOptions:
true, a warning is logged. Otherwise, an exception is raised.| MessageT | Type of the ROS 2 message. |
Definition at line 63 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 150 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 94 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 105 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 271 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 171 of file ros_publisher_node.hpp.
|
inline |
Get the name of the topic name this node publishes to.
Definition at line 277 of file ros_publisher_node.hpp.