SMACC2
Public Member Functions | Public Attributes | Private Attributes | List of all members
smacc2::client_bases::SmaccPublisherClient Class Reference

#include <smacc_publisher_client.hpp>

Inheritance diagram for smacc2::client_bases::SmaccPublisherClient:
Inheritance graph
Collaboration diagram for smacc2::client_bases::SmaccPublisherClient:
Collaboration graph

Public Member Functions

 SmaccPublisherClient ()
 
virtual ~SmaccPublisherClient ()
 
template<typename MessageType >
void configure (std::string topicName)
 
template<typename MessageType >
void publish (const MessageType &msg)
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void onInitialize ()
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachinegetStateMachine ()
 
template<typename TSmaccSignal , typename T >
void connectSignal (TSmaccSignal &signal, void(T::*callback)(), T *object)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
void getComponents (std::vector< std::shared_ptr< ISmaccComponent > > &components)
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

Public Attributes

std::optional< std::string > topicName
 
std::optional< int > queueSize
 
std::optional< rmw_qos_durability_policy_t > durability
 
std::optional< rmw_qos_reliability_policy_t > reliability
 
rclcpp::PublisherBase::SharedPtr pub_
 

Private Attributes

bool initialized_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClient
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

Definition at line 30 of file smacc_publisher_client.hpp.

Constructor & Destructor Documentation

◆ SmaccPublisherClient()

smacc2::client_bases::SmaccPublisherClient::SmaccPublisherClient ( )

◆ ~SmaccPublisherClient()

smacc2::client_bases::SmaccPublisherClient::~SmaccPublisherClient ( )
virtual

Definition at line 29 of file smacc_publisher_client.cpp.

29{}

Member Function Documentation

◆ configure()

template<typename MessageType >
void smacc2::client_bases::SmaccPublisherClient::configure ( std::string  topicName)
inline

Definition at line 42 of file smacc_publisher_client.hpp.

43 {
44 this->topicName = topicName;
45 if (!initialized_)
46 {
47 if (!this->topicName)
48 {
49 RCLCPP_ERROR(getLogger(), "topic publisher with no topic name set. Skipping advertising.");
50 return;
51 }
52
53 if (!queueSize) queueSize = 1;
54 if (!durability) durability = RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT;
55 if (!reliability) reliability = RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT;
56 rclcpp::SensorDataQoS qos;
57 qos.keep_last(*queueSize);
58 qos.durability(*durability);
59 qos.reliability(*reliability);
60
61 RCLCPP_INFO_STREAM(
62 getLogger(), "[" << this->getName() << "] Client Publisher to topic: " << topicName);
63 pub_ = getNode()->create_publisher<MessageType>(*(this->topicName), qos);
64
65 this->initialized_ = true;
66 }
67 }
rclcpp::Node::SharedPtr getNode()
Definition: client.cpp:60
virtual std::string getName() const
Definition: client.cpp:42
rclcpp::Logger getLogger()
std::optional< rmw_qos_reliability_policy_t > reliability
std::optional< rmw_qos_durability_policy_t > durability

References durability, smacc2::ISmaccClient::getLogger(), smacc2::ISmaccClient::getName(), smacc2::ISmaccClient::getNode(), initialized_, pub_, queueSize, reliability, and topicName.

Here is the call graph for this function:

◆ publish()

template<typename MessageType >
void smacc2::client_bases::SmaccPublisherClient::publish ( const MessageType &  msg)
inline

Member Data Documentation

◆ durability

std::optional<rmw_qos_durability_policy_t> smacc2::client_bases::SmaccPublisherClient::durability

Definition at line 35 of file smacc_publisher_client.hpp.

Referenced by configure().

◆ initialized_

bool smacc2::client_bases::SmaccPublisherClient::initialized_
private

Definition at line 79 of file smacc_publisher_client.hpp.

Referenced by configure(), and SmaccPublisherClient().

◆ pub_

rclcpp::PublisherBase::SharedPtr smacc2::client_bases::SmaccPublisherClient::pub_

Definition at line 76 of file smacc_publisher_client.hpp.

Referenced by configure(), and publish().

◆ queueSize

std::optional<int> smacc2::client_bases::SmaccPublisherClient::queueSize

Definition at line 34 of file smacc_publisher_client.hpp.

Referenced by configure().

◆ reliability

std::optional<rmw_qos_reliability_policy_t> smacc2::client_bases::SmaccPublisherClient::reliability

Definition at line 36 of file smacc_publisher_client.hpp.

Referenced by configure().

◆ topicName

std::optional<std::string> smacc2::client_bases::SmaccPublisherClient::topicName

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