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

#include <cb_wait_action_server.hpp>

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

Public Member Functions

 CbWaitActionServer (std::chrono::milliseconds timeout)
 
virtual ~CbWaitActionServer ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
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 ()
 

Private Attributes

ISmaccActionClientclient_
 
std::chrono::milliseconds timeout_
 

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_action_server.hpp.

Constructor & Destructor Documentation

◆ CbWaitActionServer()

smacc2::client_behaviors::CbWaitActionServer::CbWaitActionServer ( std::chrono::milliseconds  timeout)

Definition at line 27 of file cb_wait_action_server.cpp.

27: timeout_(timeout) {}

◆ ~CbWaitActionServer()

smacc2::client_behaviors::CbWaitActionServer::~CbWaitActionServer ( )
virtual

Definition at line 29 of file cb_wait_action_server.cpp.

29{}

Member Function Documentation

◆ onEntry()

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

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 31 of file cb_wait_action_server.cpp.

32{
33 if (client_ != nullptr)
34 {
35 bool found = false;
36 auto starttime = getNode()->now();
37 while (!this->isShutdownRequested() && !found && (getNode()->now() - starttime) < timeout_)
38 {
39 std::shared_ptr<rclcpp_action::ClientBase> client_base = client_->getClientBase();
40 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] waiting action server..");
41 found = client_base->wait_for_action_server(std::chrono::milliseconds(1000));
42 }
43
44 if (found)
45 {
46 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] action server already available");
47 this->postSuccessEvent();
48 }
49 else
50 {
51 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] action server not found, timeout");
52 this->postFailureEvent();
53 }
54 }
55 else
56 {
57 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] there is no action client in this orthogonal");
58 this->postFailureEvent();
59 }
60}
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...
virtual std::shared_ptr< rclcpp_action::ClientBase > getClientBase()=0

References client_, smacc2::client_bases::ISmaccActionClient::getClientBase(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getNode(), smacc2::SmaccAsyncClientBehavior::isShutdownRequested(), smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), and timeout_.

Here is the call graph for this function:

◆ onOrthogonalAllocation()

void smacc2::client_behaviors::CbWaitActionServer::onOrthogonalAllocation ( )
inline

Definition at line 40 of file cb_wait_action_server.hpp.

41 {
42 SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
44 }
void requiresClient(SmaccClientType *&storage)

References client_, and smacc2::ISmaccClientBehavior::requiresClient().

Here is the call graph for this function:

Member Data Documentation

◆ client_

ISmaccActionClient* smacc2::client_behaviors::CbWaitActionServer::client_
private

Definition at line 49 of file cb_wait_action_server.hpp.

Referenced by onEntry(), and onOrthogonalAllocation().

◆ timeout_

std::chrono::milliseconds smacc2::client_behaviors::CbWaitActionServer::timeout_
private

Definition at line 50 of file cb_wait_action_server.hpp.

Referenced by onEntry().


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