SMACC2
Loading...
Searching...
No Matches
cl_nav2z::CbWaitPose Class Reference

#include <cb_wait_pose.hpp>

Inheritance diagram for cl_nav2z::CbWaitPose:
Inheritance graph
Collaboration diagram for cl_nav2z::CbWaitPose:
Collaboration graph

Public Member Functions

 CbWaitPose ()
 
 ~CbWaitPose () override
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
void onEntry () 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 onExit ()
 

Protected Attributes

cl_nav2z::ClNav2Z * nav2zClient_ = nullptr
 

Additional Inherited Members

- 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
 

Detailed Description

Definition at line 29 of file cb_wait_pose.hpp.

Constructor & Destructor Documentation

◆ CbWaitPose()

cl_nav2z::CbWaitPose::CbWaitPose ( )

Definition at line 31 of file cb_wait_pose.cpp.

31{}

◆ ~CbWaitPose()

cl_nav2z::CbWaitPose::~CbWaitPose ( )
override

Definition at line 33 of file cb_wait_pose.cpp.

33{}

Member Function Documentation

◆ onEntry()

void cl_nav2z::CbWaitPose::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 35 of file cb_wait_pose.cpp.

36{
37 cl_nav2z::CpPose * pose = nullptr;
38 this->requiresComponent(pose, ComponentRequirement::SOFT);
39 if (pose == nullptr)
40 {
41 RCLCPP_ERROR(getLogger(), "[CbWaitPose] no CpPose component in the state machine");
42 this->postFailureEvent();
43 return;
44 }
45 try
46 {
47 // leaves without an event when the state is exited first; the wait used to block that exit
48 if (!pose->waitTransformUpdate(
49 rclcpp::Rate(20), [this] { return this->isShutdownRequested(); }))
50 {
51 return;
52 }
53 auto posemsg = pose->toPoseMsg();
54 RCLCPP_INFO_STREAM(getLogger(), "[CbWaitPose] pose arrived: " << '\n' << posemsg);
55 }
56 catch (std::exception & ex)
57 {
58 RCLCPP_INFO(getLogger(), "[CbWaitPose] error getting the robot pose");
59 this->postFailureEvent();
60 return;
61 }
62
63 RCLCPP_INFO(getLogger(), "[CbWaitPose] pose received");
64 this->postSuccessEvent();
65}
geometry_msgs::msg::Pose toPoseMsg()
Definition cp_pose.hpp:60
bool waitTransformUpdate(rclcpp::Rate r=rclcpp::Rate(20), const std::function< bool()> &cancelled={})
Definition cp_pose.cpp:81
virtual rclcpp::Logger getLogger() const
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), smacc2::ISmaccClientBehavior::requiresComponent(), cl_nav2z::CpPose::toPoseMsg(), and cl_nav2z::CpPose::waitTransformUpdate().

Here is the call graph for this function:

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_nav2z::CbWaitPose::onStateOrthogonalAllocation ( )
inline

Member Data Documentation

◆ nav2zClient_

cl_nav2z::ClNav2Z* cl_nav2z::CbWaitPose::nav2zClient_ = nullptr
protected

Definition at line 47 of file cb_wait_pose.hpp.

Referenced by onStateOrthogonalAllocation().


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