16#ifndef YASMIN_ROS__PUBLISHER_STATE_HPP_
17#define YASMIN_ROS__PUBLISHER_STATE_HPP_
23#include "rclcpp/rclcpp.hpp"
65 rclcpp::CallbackGroup::SharedPtr callback_group =
nullptr)
81 rclcpp::CallbackGroup::SharedPtr callback_group =
nullptr)
85 if (node ==
nullptr) {
96 throw std::invalid_argument(
"create_message_handler is needed");
110 this->
pub->publish(msg);
120 std::shared_ptr<rclcpp::Publisher<MsgT>>
pub;
std::shared_ptr< Blackboard > SharedPtr
Shared pointer type for Blackboard.
Definition blackboard.hpp:85
Represents a state in a state machine.
Definition state.hpp:46
State(const Outcomes &outcomes)
Shared pointer type for State.
Definition state.cpp:32
std::shared_ptr< rclcpp::Publisher< MsgT > > pub
Publisher to the ROS 2 topic.
Definition publisher_state.hpp:120
std::string execute(yasmin::Blackboard::SharedPtr blackboard) override
Execute the publishing operation.
Definition publisher_state.hpp:106
std::string topic_name
Name of the topic to monitor.
Definition publisher_state.hpp:122
PublisherState(const std::string &topic_name, CreateMessageHandler create_message_handler, rclcpp::QoS qos=10, rclcpp::CallbackGroup::SharedPtr callback_group=nullptr)
Shared pointer type for PublisherState.
Definition publisher_state.hpp:62
CreateMessageHandler create_message_handler
Callback handler to create messages.
Definition publisher_state.hpp:124
rclcpp::Node::SharedPtr node_
Shared pointer to the ROS 2 node.
Definition publisher_state.hpp:116
std::function< MsgT(yasmin::Blackboard::SharedPtr)> CreateMessageHandler
Function type for creating messages for topic.
Definition publisher_state.hpp:46
PublisherState(const rclcpp::Node::SharedPtr &node, const std::string &topic_name, CreateMessageHandler create_message_handler, rclcpp::QoS qos=10, rclcpp::CallbackGroup::SharedPtr callback_group=nullptr)
Construct a new PublisherState with ROS 2 node and specific QoS.
Definition publisher_state.hpp:77
static rclcpp::Publisher< MsgT >::SharedPtr get_or_create_publisher(rclcpp::Node::SharedPtr node, const std::string &topic_name, const rclcpp::QoS &qos_profile=rclcpp::QoS(10), rclcpp::CallbackGroup::SharedPtr callback_group=nullptr)
Get an existing publisher from the cache or create a new one.
Definition ros_clients_cache.hpp:174
static YasminNode::SharedPtr get_instance()
Provides access to the singleton instance of YasminNode.
Definition yasmin_node.hpp:74
#define YASMIN_LOG_DEBUG(text,...)
Definition logs.hpp:174
constexpr char SUCCEED[]
Constant representing a successful action outcome.
Definition basic_outcomes.hpp:39
Definition action_state.hpp:37
#define YASMIN_PTR_ALIASES(ClassName)
Macro to define all pointer aliases for a class.
Definition types.hpp:52