SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
smacc2::client_behaviors::CbWaitTopicMessage< TMessage > Class Template Reference

#include <cb_wait_topic_message.hpp>

Inheritance diagram for smacc2::client_behaviors::CbWaitTopicMessage< TMessage >:
Inheritance graph
Collaboration diagram for smacc2::client_behaviors::CbWaitTopicMessage< TMessage >:
Collaboration graph

Public Member Functions

 CbWaitTopicMessage (const char *topicname, std::function< bool(const TMessage &)> guardFunction=nullptr)
 
virtual ~CbWaitTopicMessage ()
 
void onEntry () override
 
void onMessageReceived (const typename TMessage::SharedPtr msg)
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
boost::signals2::connection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onFailure (TCallbackMethod callback, T *object)
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, bool throwExceptionIfNotExist=false)
 
virtual void onExit ()
 

Protected Attributes

bool success = false
 
rclcpp::Subscription< TMessage >::SharedPtr sub_
 
std::function< bool(const TMessage &)> guardFn_
 
std::string topicname_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
bool isShutdownRequested ()
 onEntry is executed in a new thread. However the current state cannot be left until the onEntry thread finishes. This flag can be checked from the onEntry thread to force finishing the thread.
 
- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Detailed Description

template<typename TMessage>
class smacc2::client_behaviors::CbWaitTopicMessage< TMessage >

Definition at line 36 of file cb_wait_topic_message.hpp.

Constructor & Destructor Documentation

◆ CbWaitTopicMessage()

template<typename TMessage >
smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::CbWaitTopicMessage ( const char topicname,
std::function< bool(const TMessage &)>  guardFunction = nullptr 
)
inline

◆ ~CbWaitTopicMessage()

Definition at line 46 of file cb_wait_topic_message.hpp.

46{}

Member Function Documentation

◆ onEntry()

template<typename TMessage >
void smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::onEntry ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 48 of file cb_wait_topic_message.hpp.

49 {
50 rclcpp::SensorDataQoS qos;
51 // qos.reliable();
52 // rclcpp::SubscriptionOptions sub_option;
53 RCLCPP_INFO_STREAM(
54 getLogger(), "[CbWaitTopicMessage] waiting message from topic: "
55 << topicname_ << "[" << demangledTypeName<TMessage>() << "]");
56
57 // sub_ = getNode()->create_subscription<TMessage>(
58 // topicname_, qos,
59 // std::bind(&CbWaitTopicMessage<TMessage>::onMessageReceived, this, std::placeholders::_1),
60 // sub_option);
61
62 std::function<void(typename TMessage::SharedPtr)> fn = [this](auto msg)
63 { this->onMessageReceived(msg); };
64
65 auto nh = getNode();
66 sub_ = nh->create_subscription<TMessage>(topicname_, qos, fn);
67 }
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
void onMessageReceived(const typename TMessage::SharedPtr msg)
rclcpp::Subscription< TMessage >::SharedPtr sub_

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getNode(), smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::onMessageReceived(), smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::sub_, and smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::topicname_.

Here is the call graph for this function:

◆ onMessageReceived()

template<typename TMessage >
void smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::onMessageReceived ( const typename TMessage::SharedPtr  msg)
inline

Member Data Documentation

◆ guardFn_

template<typename TMessage >
std::function<bool(const TMessage &)> smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::guardFn_
protected

◆ sub_

template<typename TMessage >
rclcpp::Subscription<TMessage>::SharedPtr smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::sub_
protected

◆ success

◆ topicname_

template<typename TMessage >
std::string smacc2::client_behaviors::CbWaitTopicMessage< TMessage >::topicname_
protected

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