C++ YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
yasmin_ros::PublisherState< MsgT > Class Template Reference

Template class to publish ROS 2 messages. More...

#include <publisher_state.hpp>

Inheritance diagram for yasmin_ros::PublisherState< MsgT >:
Collaboration diagram for yasmin_ros::PublisherState< MsgT >:

Public Member Functions

 PublisherState (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.
 
 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.
 
std::string execute (std::shared_ptr< yasmin::blackboard::Blackboard > blackboard) override
 Execute the publishing operation.
 
- Public Member Functions inherited from yasmin::State
 State (const std::set< std::string > &outcomes)
 Constructs a State with a set of possible outcomes.
 
StateStatus get_status () const
 Gets the current status of the state.
 
bool is_idle () const
 Checks if the state is idle.
 
bool is_running () const
 Checks if the state is currently running.
 
bool is_canceled () const
 Checks if the state has been canceled.
 
bool is_completed () const
 Checks if the state has completed execution.
 
std::string operator() (std::shared_ptr< blackboard::Blackboard > blackboard)
 Executes the state and returns the outcome.
 
virtual void cancel_state ()
 Cancels the current state execution.
 
std::set< std::string > const & get_outcomes ()
 Gets the set of possible outcomes for this state.
 
virtual std::string to_string ()
 Converts the state to a string representation.
 

Protected Attributes

rclcpp::Node::SharedPtr node_
 Shared pointer to the ROS 2 node.
 
- Protected Attributes inherited from yasmin::State
std::set< std::string > outcomes
 The possible outcomes of this state.
 

Private Types

using CreateMessageHandler
 Function type for creating messages for topic.
 

Private Attributes

std::shared_ptr< rclcpp::Publisher< MsgT > > pub
 
std::string topic_name
 
CreateMessageHandler create_message_handler
 

Detailed Description

template<typename MsgT>
class yasmin_ros::PublisherState< MsgT >

Template class to publish ROS 2 messages.

This class provides functionality to publish to a ROS 2 topic of type MsgT and create a custom messages.

Template Parameters
MsgTThe message type of the topic to publish to.

Member Typedef Documentation

◆ CreateMessageHandler

template<typename MsgT>
using yasmin_ros::PublisherState< MsgT >::CreateMessageHandler
private
Initial value:
std::function<MsgT(std::shared_ptr<yasmin::blackboard::Blackboard>)>

Function type for creating messages for topic.

Constructor & Destructor Documentation

◆ PublisherState() [1/2]

template<typename MsgT>
yasmin_ros::PublisherState< MsgT >::PublisherState ( const std::string & topic_name,
CreateMessageHandler create_message_handler,
rclcpp::QoS qos = 10,
rclcpp::CallbackGroup::SharedPtr callback_group = nullptr )
inline

Construct a new PublisherState with ROS 2 node and specific QoS.

Parameters
topic_nameThe name of the topic to monitor.
create_message_handlerA callback handler to create messages.
qosQuality of Service settings for the topic.

◆ PublisherState() [2/2]

template<typename MsgT>
yasmin_ros::PublisherState< MsgT >::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 )
inline

Construct a new PublisherState with ROS 2 node and specific QoS.

Parameters
nodeThe ROS 2 node.
topic_nameThe name of the topic to monitor.
create_message_handlerA callback handler to create messages.
qosQuality of Service settings for the topic.

Member Function Documentation

◆ execute()

template<typename MsgT>
std::string yasmin_ros::PublisherState< MsgT >::execute ( std::shared_ptr< yasmin::blackboard::Blackboard > blackboard)
inlineoverridevirtual

Execute the publishing operation.

Parameters
blackboardA shared pointer to the blackboard for data storage.
Returns
A string outcome indicating the result of the monitoring operation.

Reimplemented from yasmin::State.

Member Data Documentation

◆ create_message_handler

template<typename MsgT>
CreateMessageHandler yasmin_ros::PublisherState< MsgT >::create_message_handler
private

Callback handler to create messages.

◆ node_

template<typename MsgT>
rclcpp::Node::SharedPtr yasmin_ros::PublisherState< MsgT >::node_
protected

Shared pointer to the ROS 2 node.

◆ pub

template<typename MsgT>
std::shared_ptr<rclcpp::Publisher<MsgT> > yasmin_ros::PublisherState< MsgT >::pub
private

Publisher to the ROS 2 topic.

◆ topic_name

template<typename MsgT>
std::string yasmin_ros::PublisherState< MsgT >::topic_name
private

Name of the topic to monitor.


The documentation for this class was generated from the following file: