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

#include <cb_wait_for_frame.hpp>

Inheritance diagram for cl_rgb::CbWaitForFrame:
Inheritance graph
Collaboration diagram for cl_rgb::CbWaitForFrame:
Collaboration graph

Public Member Functions

 CbWaitForFrame (const WaitForFrameParams &params=WaitForFrameParams())
 
void onEntry () override
 
void onExit () override
 
- Public Member Functions inherited from cl_rgb::CbRgbClientBehaviorBase
 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)
 
- 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

void wireCompletionSignals () override
 
- Protected Member Functions inherited from cl_rgb::CbRgbClientBehaviorBase
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

Private Member Functions

void onFrame (const FramePtr &frame)
 

Private Attributes

WaitForFrameParams params_
 
std::atomic< uint64_t > startSequence_ {0}
 

Additional Inherited Members

- Protected Attributes inherited from cl_rgb::CbRgbClientBehaviorBase
std::string cameraName_
 
CpCamera * camera_ = nullptr
 
CpTablePlane * table_ = nullptr
 
CpTableSegmenter * segmenter_ = nullptr
 
CpSceneSurvey * survey_ = nullptr
 

Detailed Description

Definition at line 34 of file cb_wait_for_frame.hpp.

Constructor & Destructor Documentation

◆ CbWaitForFrame()

cl_rgb::CbWaitForFrame::CbWaitForFrame ( const WaitForFrameParams & params = WaitForFrameParams())
explicit

Definition at line 20 of file cb_wait_for_frame.cpp.

21: CbRgbClientBehaviorBase(params.camera), params_(params)
22{
23}
CbRgbClientBehaviorBase(const std::string &cameraName)
WaitForFrameParams params_

Member Function Documentation

◆ onEntry()

void cl_rgb::CbWaitForFrame::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 37 of file cb_wait_for_frame.cpp.

38{
39 if (camera_ == nullptr)
40 {
41 RCLCPP_ERROR(getLogger(), "CbWaitForFrame: no camera named '%s'", params_.camera.c_str());
42 this->postRgbFailure();
43 return;
44 }
45 RCLCPP_INFO(
46 getLogger(), "CbWaitForFrame: waiting for %u new image(s) of '%s'", params_.frames,
47 params_.camera.c_str());
48}
virtual rclcpp::Logger getLogger() const

References cl_rgb::WaitForFrameParams::camera, cl_rgb::CbRgbClientBehaviorBase::camera_, cl_rgb::WaitForFrameParams::frames, smacc2::ISmaccClientBehavior::getLogger(), params_, and cl_rgb::CbRgbClientBehaviorBase::postRgbFailure().

Here is the call graph for this function:

◆ onExit()

void cl_rgb::CbWaitForFrame::onExit ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 40 of file cb_wait_for_frame.hpp.

40{}

◆ onFrame()

void cl_rgb::CbWaitForFrame::onFrame ( const FramePtr & frame)
private

Definition at line 50 of file cb_wait_for_frame.cpp.

51{
52 if (frame->sequence >= startSequence_.load() + params_.frames)
53 {
54 this->postRgbSuccess();
55 }
56}
std::atomic< uint64_t > startSequence_

References cl_rgb::WaitForFrameParams::frames, params_, cl_rgb::CbRgbClientBehaviorBase::postRgbSuccess(), and startSequence_.

Referenced by wireCompletionSignals().

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

◆ wireCompletionSignals()

void cl_rgb::CbWaitForFrame::wireCompletionSignals ( )
overrideprotectedvirtual

Reimplemented from cl_rgb::CbRgbClientBehaviorBase.

Definition at line 25 of file cb_wait_for_frame.cpp.

26{
27 if (camera_ == nullptr)
28 {
29 return;
30 }
31 const FramePtr latest = camera_->latestFrame();
32 startSequence_ = latest ? latest->sequence : 0;
35}
void onFrame(const FramePtr &frame)
FramePtr latestFrame() const
Definition cp_camera.cpp:87
smacc2::SmaccSignal< void(const FramePtr &)> onFrame_
Definition cp_camera.hpp:62
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
std::shared_ptr< const Frame > FramePtr
Definition types.hpp:39

References cl_rgb::CbRgbClientBehaviorBase::camera_, smacc2::ISmaccStateMachine::createSignalConnection(), smacc2::ISmaccClientBehavior::getStateMachine(), cl_rgb::CpCamera::latestFrame(), onFrame(), cl_rgb::CpCamera::onFrame_, and startSequence_.

Here is the call graph for this function:

Member Data Documentation

◆ params_

WaitForFrameParams cl_rgb::CbWaitForFrame::params_
private

Definition at line 48 of file cb_wait_for_frame.hpp.

Referenced by onEntry(), and onFrame().

◆ startSequence_

std::atomic<uint64_t> cl_rgb::CbWaitForFrame::startSequence_ {0}
private

Definition at line 49 of file cb_wait_for_frame.hpp.

49{0};

Referenced by onFrame(), and wireCompletionSignals().


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