SMACC2
Loading...
Searching...
No Matches
smacc2::client_behaviors::CbWaitActionServer2< ActionT > Class Template Reference

#include <cb_wait_action_server_2.hpp>

Inheritance diagram for smacc2::client_behaviors::CbWaitActionServer2< ActionT >:
Inheritance graph
Collaboration diagram for smacc2::client_behaviors::CbWaitActionServer2< ActionT >:
Collaboration graph

Public Member Functions

template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
 CbWaitActionServer2 (std::chrono::milliseconds timeout)
 
virtual ~CbWaitActionServer2 ()
 
void onEntry ()
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
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)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void onExit ()
 

Private Attributes

CpActionClient< ActionT > * cp_action_client_
 
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

template<typename ActionT>
class smacc2::client_behaviors::CbWaitActionServer2< ActionT >

Definition at line 36 of file cb_wait_action_server_2.hpp.

Constructor & Destructor Documentation

◆ CbWaitActionServer2()

template<typename ActionT >
smacc2::client_behaviors::CbWaitActionServer2< ActionT >::CbWaitActionServer2 ( std::chrono::milliseconds timeout)
inline

Definition at line 47 of file cb_wait_action_server_2.hpp.

47: timeout_(timeout) {}

◆ ~CbWaitActionServer2()

template<typename ActionT >
virtual smacc2::client_behaviors::CbWaitActionServer2< ActionT >::~CbWaitActionServer2 ( )
inlinevirtual

Definition at line 49 of file cb_wait_action_server_2.hpp.

49{}

Member Function Documentation

◆ onEntry()

template<typename ActionT >
void smacc2::client_behaviors::CbWaitActionServer2< ActionT >::onEntry ( )
inlinevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 51 of file cb_wait_action_server_2.hpp.

52 {
53 if (cp_action_client_ != nullptr)
54 {
55 RCLCPP_INFO(
56 getLogger(), "[CbWaitActionServer] waiting for action server (using CpActionClient)...");
57 bool found = false;
58 auto starttime = getNode()->now();
59 while (!this->isShutdownRequested() && !found && (getNode()->now() - starttime) < timeout_)
60 {
61 auto client_base = cp_action_client_->getActionClient();
62 found = client_base->wait_for_action_server(std::chrono::milliseconds(1000));
63 }
64
65 if (found)
66 {
67 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] action server already available");
68 this->postSuccessEvent();
69 }
70 else
71 {
72 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] action server not found, timeout");
73 this->postFailureEvent();
74 }
75 }
76 else
77 {
78 RCLCPP_INFO(getLogger(), "[CbWaitActionServer] there is no action client in this orthogonal");
79 this->postFailureEvent();
80 }
81 }
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...
std::shared_ptr< ActionClient > getActionClient() const

References smacc2::client_behaviors::CbWaitActionServer2< ActionT >::cp_action_client_, smacc2::client_core_components::CpActionClient< ActionType >::getActionClient(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getNode(), smacc2::SmaccAsyncClientBehavior::isShutdownRequested(), smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), and smacc2::client_behaviors::CbWaitActionServer2< ActionT >::timeout_.

Here is the call graph for this function:

◆ onStateOrthogonalAllocation()

Member Data Documentation

◆ cp_action_client_

◆ timeout_

template<typename ActionT >
std::chrono::milliseconds smacc2::client_behaviors::CbWaitActionServer2< ActionT >::timeout_
private

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