SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
smacc2::client_behaviors::CbWaitTopic Class Reference

#include <cb_wait_topic.hpp>

Inheritance diagram for smacc2::client_behaviors::CbWaitTopic:
Inheritance graph
Collaboration diagram for smacc2::client_behaviors::CbWaitTopic:
Collaboration graph

Public Member Functions

 CbWaitTopic (std::string topicName)
 
virtual ~CbWaitTopic ()
 
void onEntry () override
 
- 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

std::string topicName_
 
rclcpp::Rate rate_
 

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

Definition at line 33 of file cb_wait_topic.hpp.

Constructor & Destructor Documentation

◆ CbWaitTopic()

smacc2::client_behaviors::CbWaitTopic::CbWaitTopic ( std::string  topicName)

Definition at line 27 of file cb_wait_topic.cpp.

◆ ~CbWaitTopic()

smacc2::client_behaviors::CbWaitTopic::~CbWaitTopic ( )
virtual

Definition at line 29 of file cb_wait_topic.cpp.

29{}

Member Function Documentation

◆ onEntry()

void smacc2::client_behaviors::CbWaitTopic::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 31 of file cb_wait_topic.cpp.

32{
33 bool found = false;
34 while (!this->isShutdownRequested() && !found)
35 {
36 RCLCPP_INFO_STREAM_THROTTLE(
37 getLogger(), *(getNode()->get_clock()), 1000,
38 "[" << getName() << "] waiting topic: " << topicName_);
39 std::stringstream ss;
40 auto topicnames = getNode()->get_topic_names_and_types();
41
42 for (auto & t : topicnames)
43 {
44 ss << t.first << std::endl;
45 if (t.first == topicName_)
46 {
47 found = true;
48 }
49 }
50
51 auto totalstr = ss.str();
52 RCLCPP_INFO_STREAM_THROTTLE(
53 getLogger(), *(getNode()->get_clock()), 5000,
54 "[" << getName() << "] still waiting topic " << topicName_ << ", listing topics ("
55 << topicnames.size() << ")" << std::endl
56 << totalstr);
57
58 rate_.sleep();
59 }
60
61 if (found)
62 {
63 this->postSuccessEvent();
64 }
65 else
66 {
67 this->postFailureEvent();
68 }
69}
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), smacc2::ISmaccClientBehavior::getNode(), smacc2::SmaccAsyncClientBehavior::isShutdownRequested(), smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), rate_, and topicName_.

Here is the call graph for this function:

Member Data Documentation

◆ rate_

rclcpp::Rate smacc2::client_behaviors::CbWaitTopic::rate_
protected

Definition at line 45 of file cb_wait_topic.hpp.

Referenced by onEntry().

◆ topicName_

std::string smacc2::client_behaviors::CbWaitTopic::topicName_
protected

Definition at line 43 of file cb_wait_topic.hpp.

Referenced by onEntry().


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