SMACC2
Loading...
Searching...
No Matches
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 onStateOrthogonalAllocation ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual ~CbNav2ZClientBehaviorBase ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
- 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 onEntry ()
 
virtual void onExit ()
 

Protected Member Functions

void sendGoal (nav2_msgs::action::NavigateToPose::Goal &goal)
 
void cancelGoal ()
 
template<typename T >
boost::signals2::connection onNavigationSucceeded (void(T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T *object)
 
template<typename T >
boost::signals2::connection onNavigationAborted (void(T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T *object)
 
template<typename T >
boost::signals2::connection onNavigationCancelled (void(T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T *object)
 
virtual void onNavigationResult (const components::CpNav2ActionInterface::WrappedResult &)
 
virtual void onNavigationActionSuccess (const components::CpNav2ActionInterface::WrappedResult &)
 
virtual void onNavigationActionAbort (const components::CpNav2ActionInterface::WrappedResult &)
 
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 ()
 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
 

Protected Attributes

components::CpNav2ActionInterfacenav2ActionInterface_ = nullptr
 
smacc2::client_core_components::CpActionClient< nav2_msgs::action::NavigateToPose > * actionClient_ = nullptr
 
rclcpp_action::ResultCode navigationResult_
 
cl_nav2z::ClNav2Znav2zClient_
 
cl_nav2z::ClNav2Z::SmaccNavigateResultSignal::SharedPtr navigationCallback_
 
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() [1/2]

cl_nav2z::CbNav2ZClientBehaviorBase::~CbNav2ZClientBehaviorBase ( )
virtual

Definition at line 25 of file cb_nav2z_client_behavior_base.cpp.

25{}

◆ ~CbNav2ZClientBehaviorBase() [2/2]

virtual cl_nav2z::CbNav2ZClientBehaviorBase::~CbNav2ZClientBehaviorBase ( )
virtual

Member Function Documentation

◆ cancelGoal() [1/2]

void cl_nav2z::CbNav2ZClientBehaviorBase::cancelGoal ( )
inlineprotected

◆ cancelGoal() [2/2]

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
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...
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:

◆ onNavigationAborted()

template<typename T >
boost::signals2::connection cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationAborted ( void(T::* callback )(const components::CpNav2ActionInterface::WrappedResult &),
T * object )
inlineprotected

Definition at line 87 of file cb_nav2z_client_behavior_base.hpp.

89 {
91 {
92 return nav2ActionInterface_->onNavigationAborted(callback, object);
93 }
94 return boost::signals2::connection();
95 }
boost::signals2::connection onNavigationAborted(void(T::*callback)(const WrappedResult &), T *object)

References nav2ActionInterface_, and cl_nav2z::components::CpNav2ActionInterface::onNavigationAborted().

Here is the call graph for this function:

◆ onNavigationActionAbort() [1/2]

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

Definition at line 112 of file cb_nav2z_client_behavior_base.cpp.

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

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

Here is the call graph for this function:

◆ onNavigationActionAbort() [2/2]

virtual void cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationActionAbort ( const components::CpNav2ActionInterface::WrappedResult & )
inlineprotectedvirtual

Definition at line 127 of file cb_nav2z_client_behavior_base.hpp.

127{}

Referenced by onNavigationResult().

Here is the caller graph for this function:

◆ onNavigationActionSuccess() [1/2]

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

Definition at line 96 of file cb_nav2z_client_behavior_base.cpp.

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

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

Here is the call graph for this function:

◆ onNavigationActionSuccess() [2/2]

virtual void cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationActionSuccess ( const components::CpNav2ActionInterface::WrappedResult & )
inlineprotectedvirtual

Reimplemented in cl_nav2z::CbNavigateNextWaypointUntilReached, and cl_nav2z::CbNavigateNextWaypointUntilReached.

Definition at line 124 of file cb_nav2z_client_behavior_base.hpp.

125 {
126 }

Referenced by onNavigationResult().

Here is the caller graph for this function:

◆ onNavigationCancelled()

template<typename T >
boost::signals2::connection cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationCancelled ( void(T::* callback )(const components::CpNav2ActionInterface::WrappedResult &),
T * object )
inlineprotected

Definition at line 98 of file cb_nav2z_client_behavior_base.hpp.

100 {
102 {
103 return nav2ActionInterface_->onNavigationCancelled(callback, object);
104 }
105 return boost::signals2::connection();
106 }
boost::signals2::connection onNavigationCancelled(void(T::*callback)(const WrappedResult &), T *object)

References nav2ActionInterface_, and cl_nav2z::components::CpNav2ActionInterface::onNavigationCancelled().

Here is the call graph for this function:

◆ onNavigationResult() [1/2]

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

Definition at line 81 of file cb_nav2z_client_behavior_base.cpp.

82{
83 RCLCPP_DEBUG(
84 getLogger(), "[%s] Received result event from action server, result code", getName().c_str());
85
86 if (r.code == rclcpp_action::ResultCode::SUCCEEDED)
87 {
89 }
90 else
91 {
93 }
94}
virtual void onNavigationActionSuccess(const components::CpNav2ActionInterface::WrappedResult &)
virtual void onNavigationActionAbort(const components::CpNav2ActionInterface::WrappedResult &)

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), onNavigationActionAbort(), and onNavigationActionSuccess().

Here is the call graph for this function:

◆ onNavigationResult() [2/2]

virtual void cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationResult ( const components::CpNav2ActionInterface::WrappedResult & )
inlineprotectedvirtual

Definition at line 123 of file cb_nav2z_client_behavior_base.hpp.

123{}

Referenced by sendGoal().

Here is the caller graph for this function:

◆ onNavigationSucceeded()

template<typename T >
boost::signals2::connection cl_nav2z::CbNav2ZClientBehaviorBase::onNavigationSucceeded ( void(T::* callback )(const components::CpNav2ActionInterface::WrappedResult &),
T * object )
inlineprotected

Definition at line 76 of file cb_nav2z_client_behavior_base.hpp.

78 {
80 {
81 return nav2ActionInterface_->onNavigationSucceeded(callback, object);
82 }
83 return boost::signals2::connection();
84 }
boost::signals2::connection onNavigationSucceeded(void(T::*callback)(const WrappedResult &), T *object)

References nav2ActionInterface_, and cl_nav2z::components::CpNav2ActionInterface::onNavigationSucceeded().

Here is the call graph for this function:

◆ onOrthogonalAllocation() [1/2]

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

Definition at line 51 of file cb_nav2z_client_behavior_base.hpp.

References onStateOrthogonalAllocation().

Here is the call graph for this function:

◆ onOrthogonalAllocation() [2/2]

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

Definition at line 40 of file cb_nav2z_client_behavior_base.hpp.

41 {
42 // Call the new method to maintain functionality for third-party inheritors
44 }

References onStateOrthogonalAllocation().

Here is the call graph for this function:

◆ onStateOrthogonalAllocation() [1/2]

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

Definition at line 37 of file cb_nav2z_client_behavior_base.hpp.

38 {
39 // NEW: Pure component-based approach - no client dependencies
40 this->requiresComponent(nav2ActionInterface_, ComponentRequirement::HARD);
41 this->requiresComponent(actionClient_, ComponentRequirement::HARD);
42
44 }
smacc2::client_core_components::CpActionClient< nav2_msgs::action::NavigateToPose > * actionClient_
void requiresComponent(SmaccComponentType *&storage, bool throwExceptionIfNotExist)

References actionClient_, nav2ActionInterface_, smacc2::SmaccAsyncClientBehavior::onStateOrthogonalAllocation(), and smacc2::ISmaccClientBehavior::requiresComponent().

Referenced by onOrthogonalAllocation().

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

◆ onStateOrthogonalAllocation() [2/2]

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

◆ sendGoal() [1/2]

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}
cl_nav2z::ClNav2Z::SmaccNavigateResultSignal::SharedPtr navigationCallback_
virtual void onNavigationResult(const components::CpNav2ActionInterface::WrappedResult &)
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().

Here is the call graph for this function:

◆ sendGoal() [2/2]

void cl_nav2z::CbNav2ZClientBehaviorBase::sendGoal ( nav2_msgs::action::NavigateToPose::Goal & goal)
inlineprotected

Member Data Documentation

◆ actionClient_

smacc2::client_core_components::CpActionClient<nav2_msgs::action::NavigateToPose>* cl_nav2z::CbNav2ZClientBehaviorBase::actionClient_ = nullptr
protected

Definition at line 111 of file cb_nav2z_client_behavior_base.hpp.

Referenced by onStateOrthogonalAllocation().

◆ goalHandleFuture_

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

Definition at line 71 of file cb_nav2z_client_behavior_base.hpp.

Referenced by isOwnActionResponse(), and sendGoal().

◆ nav2ActionInterface_

components::CpNav2ActionInterface* cl_nav2z::CbNav2ZClientBehaviorBase::nav2ActionInterface_ = nullptr
protected

◆ nav2zClient_

◆ navigationCallback_

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

Definition at line 65 of file cb_nav2z_client_behavior_base.hpp.

Referenced by sendGoal().

◆ navigationResult_


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