SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cl_nav2z::CbNav2ZClientBehaviorBase Class Reference

#include <cb_nav2z_client_behavior_base.hpp>

Inheritance diagram for cl_nav2z::CbNav2ZClientBehaviorBase:
Inheritance graph
Collaboration diagram for cl_nav2z::CbNav2ZClientBehaviorBase:
Collaboration graph

Public Member Functions

virtual ~CbNav2ZClientBehaviorBase ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
- 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 onEntry ()
 
virtual void onExit ()
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 

Protected Member Functions

void sendGoal (ClNav2Z::Goal &goal)
 
void cancelGoal ()
 
bool isOwnActionResponse (const ClNav2Z::WrappedResult &)
 
virtual void onNavigationResult (const ClNav2Z::WrappedResult &)
 
virtual void onNavigationActionSuccess (const ClNav2Z::WrappedResult &)
 
virtual void onNavigationActionAbort (const ClNav2Z::WrappedResult &)
 
- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
bool isShutdownRequested ()
 
- 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 void dispose ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Protected Attributes

cl_nav2z::ClNav2Znav2zClient_
 
cl_nav2z::ClNav2Z::SmaccNavigateResultSignal::SharedPtr navigationCallback_
 
rclcpp_action::ResultCode navigationResult_
 
std::shared_future< std::shared_ptr< rclcpp_action::ClientGoalHandle< nav2_msgs::action::NavigateToPose > > > goalHandleFuture_
 

Detailed Description

Definition at line 28 of file cb_nav2z_client_behavior_base.hpp.

Constructor & Destructor Documentation

◆ ~CbNav2ZClientBehaviorBase()

cl_nav2z::CbNav2ZClientBehaviorBase::~CbNav2ZClientBehaviorBase ( )
virtual

Definition at line 24 of file cb_nav2z_client_behavior_base.cpp.

24{}

Member Function Documentation

◆ cancelGoal()

void cl_nav2z::CbNav2ZClientBehaviorBase::cancelGoal ( )
protected

◆ isOwnActionResponse()

bool cl_nav2z::CbNav2ZClientBehaviorBase::isOwnActionResponse ( const ClNav2Z::WrappedResult r)
protected

Definition at line 45 of file cb_nav2z_client_behavior_base.cpp.

46{
47 auto name = getName();
49 {
50 RCLCPP_ERROR(
51 getLogger(), "[%s] Propagating action client signal skipped. the behavior is shutting down",
52 name.c_str());
53 return false;
54 }
55
56 if (!goalHandleFuture_.valid())
57 {
58 RCLCPP_ERROR(
59 this->getLogger(), "[%s]Propagating action client signal, our goal handle is not valid",
60 name.c_str());
61 return false;
62 }
63
64 auto goalHandle = goalHandleFuture_.get();
65 auto goal_uuid_ = goalHandle->get_goal_id();
66
67 if (r.goal_id != goal_uuid_)
68 {
69 RCLCPP_ERROR(
70 getLogger(),
71 "[%s] Received a failure event from an action server with a different goal_uuid: %s, "
72 "expected: %s",
73 smacc2::demangleType(typeid(*this)).c_str(), rclcpp_action::to_string(r.goal_id).c_str(),
74 rclcpp_action::to_string(goal_uuid_).c_str());
75 return false;
76 }
77
78 return true;
79}
std::shared_future< std::shared_ptr< rclcpp_action::ClientGoalHandle< nav2_msgs::action::NavigateToPose > > > goalHandleFuture_
virtual rclcpp::Logger getLogger() const
std::string demangleType(const std::type_info *tinfo)

References smacc2::introspection::demangleType(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), goalHandleFuture_, and smacc2::SmaccAsyncClientBehavior::isShutdownRequested().

Here is the call graph for this function:

◆ onNavigationActionAbort()

void cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationActionAbort ( const ClNav2Z::WrappedResult r)
protectedvirtual

Definition at line 109 of file cb_nav2z_client_behavior_base.cpp.

110{
111 // if (!isOwnActionResponse(r))
112 // {
113 // RCLCPP_WARN(
114 // getLogger(), "[%s] Propagating success event skipped. Action response is not ours.",
115 // getName().c_str());
116 // return;
117 // }
118
119 navigationResult_ = r.code;
120 auto name = getName();
121 RCLCPP_INFO(getLogger(), "[%s] Propagating failure event from action server", name.c_str());
122 this->postFailureEvent();
123}

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), navigationResult_, and smacc2::SmaccAsyncClientBehavior::postFailureEvent().

Referenced by onNavigationResult().

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

◆ onNavigationActionSuccess()

void cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationActionSuccess ( const ClNav2Z::WrappedResult r)
protectedvirtual

Reimplemented in cl_nav2z::CbNavigateNextWaypointUntilReached.

Definition at line 93 of file cb_nav2z_client_behavior_base.cpp.

94{
95 // if (!isOwnActionResponse(r))
96 // {
97 // RCLCPP_WARN(
98 // getLogger(), "[%s] Propagating success event skipped. Action response is not ours.",
99 // getName().c_str());
100 // return;
101 // }
102
103 navigationResult_ = r.code;
104
105 RCLCPP_INFO(getLogger(), "[%s] Propagating success event from action server", getName().c_str());
106 this->postSuccessEvent();
107}

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), navigationResult_, and smacc2::SmaccAsyncClientBehavior::postSuccessEvent().

Referenced by onNavigationResult().

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

◆ onNavigationResult()

void cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationResult ( const ClNav2Z::WrappedResult r)
protectedvirtual

Definition at line 81 of file cb_nav2z_client_behavior_base.cpp.

82{
83 if (r.code == rclcpp_action::ResultCode::SUCCEEDED)
84 {
86 }
87 else
88 {
90 }
91}
virtual void onNavigationActionSuccess(const ClNav2Z::WrappedResult &)
virtual void onNavigationActionAbort(const ClNav2Z::WrappedResult &)

References onNavigationActionAbort(), and onNavigationActionSuccess().

Referenced by cl_nav2z::CbNavigateNextWaypoint::onEntry(), and sendGoal().

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

◆ onOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_nav2z::CbNav2ZClientBehaviorBase::onOrthogonalAllocation ( )
inline

Definition at line 34 of file cb_nav2z_client_behavior_base.hpp.

35 {
37 smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
38 }
void requiresClient(SmaccClientType *&storage)

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

Here is the call graph for this function:

◆ sendGoal()

void cl_nav2z::CbNav2ZClientBehaviorBase::sendGoal ( ClNav2Z::Goal goal)
protected

Definition at line 26 of file cb_nav2z_client_behavior_base.cpp.

27{
28 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] Creating sending goal callback signal.");
29
30 this->navigationCallback_ = std::make_shared<cl_nav2z::ClNav2Z::SmaccNavigateResultSignal>();
31
34
35 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] Sending goal");
37 RCLCPP_INFO_STREAM(
38 getLogger(), "[" << getName() << "] Goal set, future valid: " << goalHandleFuture_.valid());
39
40 // this->goal_uuid_ = gh.get_goal_id () ;
41}
virtual void onNavigationResult(const ClNav2Z::WrappedResult &)
cl_nav2z::ClNav2Z::SmaccNavigateResultSignal::SharedPtr navigationCallback_
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
std::shared_future< typename GoalHandle::SharedPtr > sendGoal(Goal &goal, typename SmaccActionResultSignal::WeakPtr resultCallback=typename SmaccActionResultSignal::WeakPtr())

References smacc2::ISmaccStateMachine::createSignalConnection(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), smacc2::ISmaccClientBehavior::getStateMachine(), goalHandleFuture_, nav2zClient_, navigationCallback_, onNavigationResult(), and smacc2::client_bases::SmaccActionClientBase< ActionType >::sendGoal().

Referenced by cl_nav2z::CbNavigateGlobalPosition::execute(), cl_nav2z::CbAbsoluteRotate::onEntry(), cl_nav2z::CbNavigateBackwards::onEntry(), cl_nav2z::CbNavigateForward::onEntry(), cl_nav2z::CbRotate::onEntry(), and cl_nav2z::CbUndoPathBackwards::onEntry().

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

Member Data Documentation

◆ goalHandleFuture_

std::shared_future< std::shared_ptr<rclcpp_action::ClientGoalHandle<nav2_msgs::action::NavigateToPose> > > cl_nav2z::CbNav2ZClientBehaviorBase::goalHandleFuture_
protected

Definition at line 58 of file cb_nav2z_client_behavior_base.hpp.

Referenced by isOwnActionResponse(), and sendGoal().

◆ nav2zClient_

cl_nav2z::ClNav2Z* cl_nav2z::CbNav2ZClientBehaviorBase::nav2zClient_
protected

◆ navigationCallback_

cl_nav2z::ClNav2Z::SmaccNavigateResultSignal::SharedPtr cl_nav2z::CbNav2ZClientBehaviorBase::navigationCallback_
protected

Definition at line 52 of file cb_nav2z_client_behavior_base.hpp.

Referenced by sendGoal().

◆ navigationResult_

rclcpp_action::ResultCode cl_nav2z::CbNav2ZClientBehaviorBase::navigationResult_
protected

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