SMACC2
Loading...
Searching...
No Matches
cl_rgb::CbRgbClientBehaviorBase Class Reference

#include <cb_rgb_client_behavior_base.hpp>

Inheritance diagram for cl_rgb::CbRgbClientBehaviorBase:
Inheritance graph
Collaboration diagram for cl_rgb::CbRgbClientBehaviorBase:
Collaboration graph

Public Member Functions

 CbRgbClientBehaviorBase (const std::string &cameraName)
 
 ~CbRgbClientBehaviorBase () override
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
void setTimeout (std::chrono::milliseconds timeout)
 
void update () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
 SmaccAsyncClientBehavior ()=default
 
 ~SmaccAsyncClientBehavior () override
 
 SmaccAsyncClientBehavior (const SmaccAsyncClientBehavior &)=delete
 
SmaccAsyncClientBehavior & operator= (const SmaccAsyncClientBehavior &)=delete
 
 SmaccAsyncClientBehavior (SmaccAsyncClientBehavior &&)=delete
 
SmaccAsyncClientBehavior & operator= (SmaccAsyncClientBehavior &&)=delete
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFailure (TCallbackMethod callback, T *object)
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
 ISmaccClientBehavior (const ISmaccClientBehavior &)=delete
 
ISmaccClientBehavior & operator= (const ISmaccClientBehavior &)=delete
 
 ISmaccClientBehavior (ISmaccClientBehavior &&)=delete
 
ISmaccClientBehavior & operator= (ISmaccClientBehavior &&)=delete
 
ISmaccStateMachine * getStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename SmaccComponentType >
void requiresComponent (const std::string &name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void onEntry ()
 
virtual void onExit ()
 
- Public Member Functions inherited from smacc2::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
virtual ~ISmaccUpdatable ()=default
 
 ISmaccUpdatable (const ISmaccUpdatable &)=delete
 
ISmaccUpdatable & operator= (const ISmaccUpdatable &)=delete
 
 ISmaccUpdatable (ISmaccUpdatable &&)=delete
 
ISmaccUpdatable & operator= (ISmaccUpdatable &&)=delete
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Protected Member Functions

virtual void wireCompletionSignals ()
 
void postRgbSuccess ()
 
void postRgbFailure ()
 
bool completed () const
 
- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
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 ()
 
ISmaccState * getCurrentState ()
 
void postInitializationFailureEvent (const std::string &what)
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
std::string getTraceStateName () const
 
std::string getTraceOrthogonalName () const
 
- Protected Member Functions inherited from smacc2::ISmaccUpdatable

Protected Attributes

std::string cameraName_
 
CpCamera * camera_ = nullptr
 
CpTablePlane * table_ = nullptr
 
CpTableSegmenter * segmenter_ = nullptr
 
CpSceneSurvey * survey_ = nullptr
 

Private Attributes

std::atomic< bool > completed_ {false}
 
std::atomic< int64_t > timeoutMs_ {0}
 
std::optional< std::chrono::steady_clock::time_point > watchdogStart_
 

Detailed Description

Definition at line 40 of file cb_rgb_client_behavior_base.hpp.

Constructor & Destructor Documentation

◆ CbRgbClientBehaviorBase()

cl_rgb::CbRgbClientBehaviorBase::CbRgbClientBehaviorBase ( const std::string & cameraName)
inlineexplicit

Definition at line 44 of file cb_rgb_client_behavior_base.hpp.

◆ ~CbRgbClientBehaviorBase()

cl_rgb::CbRgbClientBehaviorBase::~CbRgbClientBehaviorBase ( )
inlineoverride

Definition at line 46 of file cb_rgb_client_behavior_base.hpp.

46{}

Member Function Documentation

◆ completed()

bool cl_rgb::CbRgbClientBehaviorBase::completed ( ) const
inlineprotected

Definition at line 105 of file cb_rgb_client_behavior_base.hpp.

105{ return completed_; }

References completed_.

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_rgb::CbRgbClientBehaviorBase::onStateOrthogonalAllocation ( )
inline

Definition at line 49 of file cb_rgb_client_behavior_base.hpp.

References camera_, cameraName_, smacc2::SmaccAsyncClientBehavior::onStateOrthogonalAllocation(), smacc2::ISmaccClientBehavior::requiresComponent(), segmenter_, smacc2::SOFT, survey_, table_, and wireCompletionSignals().

Here is the call graph for this function:

◆ postRgbFailure()

void cl_rgb::CbRgbClientBehaviorBase::postRgbFailure ( )
inlineprotected

Definition at line 97 of file cb_rgb_client_behavior_base.hpp.

98 {
99 if (!completed_.exchange(true))
100 {
101 this->postFailureEvent();
102 }
103 }

References completed_, and smacc2::SmaccAsyncClientBehavior::postFailureEvent().

Referenced by cl_rgb::CbSurveyTable::onEntry(), cl_rgb::CbWaitForFrame::onEntry(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postRgbSuccess()

void cl_rgb::CbRgbClientBehaviorBase::postRgbSuccess ( )
inlineprotected

Definition at line 89 of file cb_rgb_client_behavior_base.hpp.

90 {
91 if (!completed_.exchange(true))
92 {
93 this->postSuccessEvent();
94 }
95 }

References completed_, and smacc2::SmaccAsyncClientBehavior::postSuccessEvent().

Referenced by cl_rgb::CbSurveyTable::onEntry(), and cl_rgb::CbWaitForFrame::onFrame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTimeout()

void cl_rgb::CbRgbClientBehaviorBase::setTimeout ( std::chrono::milliseconds timeout)
inline

Definition at line 62 of file cb_rgb_client_behavior_base.hpp.

62{ timeoutMs_ = timeout.count(); }

References timeoutMs_.

◆ update()

void cl_rgb::CbRgbClientBehaviorBase::update ( )
inlineoverridevirtual

Implements smacc2::ISmaccUpdatable.

Definition at line 64 of file cb_rgb_client_behavior_base.hpp.

65 {
66 const int64_t timeoutMs = timeoutMs_.load();
67 if (timeoutMs <= 0 || completed_)
68 {
69 return;
70 }
71 const auto now = std::chrono::steady_clock::now();
72 if (!watchdogStart_)
73 {
74 watchdogStart_ = now;
75 return;
76 }
77 if (now - *watchdogStart_ > std::chrono::milliseconds(timeoutMs))
78 {
79 RCLCPP_ERROR(
80 getLogger(), "[%s] Timed out after %ld ms without completing - posting failure",
81 getName().c_str(), static_cast<long>(timeoutMs));
82 this->postRgbFailure();
83 }
84 }
std::optional< std::chrono::steady_clock::time_point > watchdogStart_
virtual rclcpp::Logger getLogger() const

References completed_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), postRgbFailure(), timeoutMs_, and watchdogStart_.

Here is the call graph for this function:

◆ wireCompletionSignals()

virtual void cl_rgb::CbRgbClientBehaviorBase::wireCompletionSignals ( )
inlineprotectedvirtual

Reimplemented in cl_rgb::CbWaitForFrame.

Definition at line 87 of file cb_rgb_client_behavior_base.hpp.

87{}

Referenced by onStateOrthogonalAllocation().

Here is the caller graph for this function:

Member Data Documentation

◆ camera_

◆ cameraName_

std::string cl_rgb::CbRgbClientBehaviorBase::cameraName_
protected

Definition at line 107 of file cb_rgb_client_behavior_base.hpp.

Referenced by onStateOrthogonalAllocation().

◆ completed_

std::atomic<bool> cl_rgb::CbRgbClientBehaviorBase::completed_ {false}
private

Definition at line 114 of file cb_rgb_client_behavior_base.hpp.

114{false};

Referenced by completed(), postRgbFailure(), postRgbSuccess(), and update().

◆ segmenter_

CpTableSegmenter* cl_rgb::CbRgbClientBehaviorBase::segmenter_ = nullptr
protected

◆ survey_

CpSceneSurvey* cl_rgb::CbRgbClientBehaviorBase::survey_ = nullptr
protected

◆ table_

CpTablePlane* cl_rgb::CbRgbClientBehaviorBase::table_ = nullptr
protected

◆ timeoutMs_

std::atomic<int64_t> cl_rgb::CbRgbClientBehaviorBase::timeoutMs_ {0}
private

Definition at line 115 of file cb_rgb_client_behavior_base.hpp.

115{0}; // 0 = watchdog disabled

Referenced by setTimeout(), and update().

◆ watchdogStart_

std::optional<std::chrono::steady_clock::time_point> cl_rgb::CbRgbClientBehaviorBase::watchdogStart_
private

Definition at line 116 of file cb_rgb_client_behavior_base.hpp.

Referenced by update().


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