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)
86 "The message was published successfully");
88 if (node ==
nullptr) {
99 throw std::invalid_argument(
"create_message_handler is needed");
113 this->
pub->publish(msg);
123 std::shared_ptr<rclcpp::Publisher<MsgT>>
pub;
std::shared_ptr< Blackboard > SharedPtr
Shared pointer type for Blackboard.
Definition blackboard.hpp:100
Represents a state in a state machine.
Definition state.hpp:49
State(const Outcomes &outcomes)
Shared pointer type for State.
Definition state.cpp:64
void set_outcome_description(const std::string &outcome, const std::string &description)
Sets a human-readable description for an outcome.
Definition state.cpp:164
std::shared_ptr< rclcpp::Publisher< MsgT > > pub
Publisher to the ROS 2 topic.
Definition publisher_state.hpp:123
std::string execute(yasmin::Blackboard::SharedPtr blackboard) override
Execute the publishing operation.
Definition publisher_state.hpp:109
std::string topic_name
Name of the topic to monitor.
Definition publisher_state.hpp:125
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
std::function< MsgT(yasmin::Blackboard::SharedPtr)> CreateMessageHandler
Function type for creating messages for topic.
Definition publisher_state.hpp:46
CreateMessageHandler create_message_handler
Callback handler to create messages.
Definition publisher_state.hpp:127
rclcpp::Node::SharedPtr node_
Shared pointer to the ROS 2 node.
Definition publisher_state.hpp:119
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:175
static YasminNode::SharedPtr get_instance()
Provides access to the singleton instance of YasminNode.
Definition yasmin_node.cpp:58
#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