SMACC2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
smacc2::components::CpTopicPublisher< MessageType > Class Template Reference

#include <cp_topic_publisher.hpp>

Inheritance diagram for smacc2::components::CpTopicPublisher< MessageType >:
Inheritance graph
Collaboration diagram for smacc2::components::CpTopicPublisher< MessageType >:
Collaboration graph

Public Types

typedef MessageType TMessageType
 

Public Member Functions

 CpTopicPublisher (std::string topicname)
 
virtual ~CpTopicPublisher ()
 
void publish (const MessageType &msg)
 
void onInitialize () override
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Public Attributes

std::optional< int > queueSize
 
std::optional< rmw_qos_durability_policy_t > durability
 
std::optional< rmw_qos_reliability_policy_t > reliability
 

Private Attributes

rclcpp::Publisher< MessageType >::SharedPtr pub_
 
bool initialized_
 
std::string topicName_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccComponent
virtual void onInitialize ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage, bool throwExceptionIfNotExist=false)
 
template<typename TComponent >
void requiresComponent (std::string name, TComponent *&requiredComponentStorage, bool throwExceptionIfNotExist=false)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger () const
 
ISmaccStateMachinegetStateMachine ()
 
- Protected Attributes inherited from smacc2::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

template<typename MessageType>
class smacc2::components::CpTopicPublisher< MessageType >

Definition at line 34 of file cp_topic_publisher.hpp.

Member Typedef Documentation

◆ TMessageType

template<typename MessageType >
typedef MessageType smacc2::components::CpTopicPublisher< MessageType >::TMessageType

Definition at line 41 of file cp_topic_publisher.hpp.

Constructor & Destructor Documentation

◆ CpTopicPublisher()

template<typename MessageType >
smacc2::components::CpTopicPublisher< MessageType >::CpTopicPublisher ( std::string  topicname)
inline

◆ ~CpTopicPublisher()

template<typename MessageType >
virtual smacc2::components::CpTopicPublisher< MessageType >::~CpTopicPublisher ( )
inlinevirtual

Definition at line 49 of file cp_topic_publisher.hpp.

49{}

Member Function Documentation

◆ onInitialize()

template<typename T >
void smacc2::components::CpTopicPublisher< T >::onInitialize
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 64 of file cp_topic_publisher.hpp.

65{
66 if (!initialized_)
67 {
68 if (!queueSize) queueSize = 1;
69 if (!durability) durability = RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT;
70 if (!reliability) reliability = RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT;
71 rclcpp::SensorDataQoS qos;
72 qos.keep_last(*queueSize);
73 qos.durability(*durability);
74 qos.reliability(*reliability);
75
76 RCLCPP_INFO_STREAM(
77 getLogger(), "[" << this->getName() << "] Publisher to topic: " << topicName_);
78
79 auto nh = this->getNode();
80 pub_ = nh->template create_publisher<T>(this->topicName_, qos);
81
82 this->initialized_ = true;
83 }
84}
virtual std::string getName() const
rclcpp::Logger getLogger() const
rclcpp::Node::SharedPtr getNode()
std::optional< rmw_qos_reliability_policy_t > reliability
rclcpp::Publisher< MessageType >::SharedPtr pub_
std::optional< rmw_qos_durability_policy_t > durability

◆ publish()

template<typename MessageType >
void smacc2::components::CpTopicPublisher< MessageType >::publish ( const MessageType &  msg)
inline

Definition at line 51 of file cp_topic_publisher.hpp.

51{ pub_->publish(msg); }

References smacc2::components::CpTopicPublisher< MessageType >::pub_.

Member Data Documentation

◆ durability

template<typename MessageType >
std::optional<rmw_qos_durability_policy_t> smacc2::components::CpTopicPublisher< MessageType >::durability

Definition at line 38 of file cp_topic_publisher.hpp.

◆ initialized_

template<typename MessageType >
bool smacc2::components::CpTopicPublisher< MessageType >::initialized_
private

◆ pub_

template<typename MessageType >
rclcpp::Publisher<MessageType>::SharedPtr smacc2::components::CpTopicPublisher< MessageType >::pub_
private

◆ queueSize

template<typename MessageType >
std::optional<int> smacc2::components::CpTopicPublisher< MessageType >::queueSize

Definition at line 37 of file cp_topic_publisher.hpp.

◆ reliability

template<typename MessageType >
std::optional<rmw_qos_reliability_policy_t> smacc2::components::CpTopicPublisher< MessageType >::reliability

Definition at line 39 of file cp_topic_publisher.hpp.

◆ topicName_

template<typename MessageType >
std::string smacc2::components::CpTopicPublisher< MessageType >::topicName_
private

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