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

#include <cb_navigate_next_waypoint.hpp>

Inheritance diagram for cl_nav2z::CbNavigateNextWaypoint:
Inheritance graph
Collaboration diagram for cl_nav2z::CbNavigateNextWaypoint:
Collaboration graph

Public Member Functions

 CbNavigateNextWaypoint (const std::optional< NavigateNextWaypointOptions > &options=std::nullopt)
 
 ~CbNavigateNextWaypoint () override
 
void onEntry () override
 
void onExit () override
 
- Public Member Functions inherited from cl_nav2z::CbNav2ZClientBehaviorBase
 ~CbNav2ZClientBehaviorBase () override
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
- Public Member Functions inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
void onStateOrthogonalAllocation ()
 
virtual ~CbActionClientBehaviorBase ()
 
- 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)
 

Protected Attributes

CpWaypointNavigator * waypointsNavigator_ = nullptr
 
NavigateNextWaypointOptions options_
 
- Protected Attributes inherited from cl_nav2z::CbNav2ZClientBehaviorBase
components::CpNav2ActionInterface * nav2ActionInterface_ = nullptr
 
rclcpp_action::ResultCode navigationResult_ = rclcpp_action::ResultCode::UNKNOWN
 
- Protected Attributes inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
ActionClientComponent * actionClient_
 
std::string actionClientName_
 
rclcpp_action::ResultCode actionResult_
 
std::chrono::milliseconds goalResponseTimeout_
 

Additional Inherited Members

- Public Types inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
using Goal
 
using GoalHandle
 
using WrappedResult
 
using Feedback
 
using ActionClientComponent
 
- Protected Member Functions inherited from cl_nav2z::CbNav2ZClientBehaviorBase
virtual void onNavigationActionSuccess (const components::CpNav2ActionInterface::WrappedResult &)
 
virtual void onNavigationActionAbort (const components::CpNav2ActionInterface::WrappedResult &)
 
void onActionSuccess (const WrappedResult &result) override
 
void onActionAbort (const WrappedResult &result) override
 
- Protected Member Functions inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
bool sendGoal (Goal &goal)
 
bool trackGoal (std::shared_future< typename GoalHandle::SharedPtr > goalHandleFuture)
 
void cancelGoal ()
 
virtual void onActionSuccess (const WrappedResult &result)
 
virtual void onActionAbort (const WrappedResult &result)
 
virtual void onActionFeedback (const Feedback &)
 
void setActionClientName (std::string name)
 
- 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_navigate_next_waypoint.hpp.

Constructor & Destructor Documentation

◆ CbNavigateNextWaypoint()

cl_nav2z::CbNavigateNextWaypoint::CbNavigateNextWaypoint ( const std::optional< NavigateNextWaypointOptions > & options = std::nullopt)

Definition at line 27 of file cb_navigate_next_waypoint.cpp.

29{
30 if (options) options_ = *options;
31}

References options_.

◆ ~CbNavigateNextWaypoint()

cl_nav2z::CbNavigateNextWaypoint::~CbNavigateNextWaypoint ( )
override

Definition at line 33 of file cb_navigate_next_waypoint.cpp.

33{}

Member Function Documentation

◆ onEntry()

void cl_nav2z::CbNavigateNextWaypoint::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Reimplemented in cl_nav2z::CbNavigateNextWaypointUntilReached.

Definition at line 35 of file cb_navigate_next_waypoint.cpp.

36{
37 this->requiresComponent(waypointsNavigator_, ComponentRequirement::HARD);
38
39 auto goalHandleFuture = waypointsNavigator_->sendNextGoal(options_);
40 if (!goalHandleFuture)
41 {
42 RCLCPP_ERROR(getLogger(), "[CbNavigateNextWaypoint] no waypoint left to navigate to");
43 this->postFailureEvent();
44 return;
45 }
46
47 auto waypointname = waypointsNavigator_->getCurrentWaypointName();
48
49 if (waypointname)
50 {
51 RCLCPP_INFO(
52 getLogger(), "[CbNavigateNextWaypoint] current iteration waypoints i: %ld with name '%s'",
53 waypointsNavigator_->getCurrentWaypointIndex(), waypointname->c_str());
54 }
55 else
56 {
57 RCLCPP_INFO(
58 getLogger(), "[CbNavigateNextWaypoint] current iteration waypoints i: %ld",
60 }
61
62 // the component sent the goal: without this the base ignores its result and a rejection is never seen
63 this->trackGoal(*goalHandleFuture);
64}
std::optional< std::string > getCurrentWaypointName() const
std::optional< std::shared_future< std::shared_ptr< rclcpp_action::ClientGoalHandle< nav2_msgs::action::NavigateToPose > > > > sendNextGoal(std::optional< NavigateNextWaypointOptions > options=std::nullopt)
virtual rclcpp::Logger getLogger() const
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
bool trackGoal(std::shared_future< typename GoalHandle::SharedPtr > goalHandleFuture)

References cl_nav2z::CpWaypointNavigatorBase::getCurrentWaypointIndex(), cl_nav2z::CpWaypointNavigatorBase::getCurrentWaypointName(), smacc2::ISmaccClientBehavior::getLogger(), options_, smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::ISmaccClientBehavior::requiresComponent(), cl_nav2z::CpWaypointNavigator::sendNextGoal(), smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >::trackGoal(), and waypointsNavigator_.

Referenced by cl_nav2z::CbNavigateNamedWaypoint::onEntry(), and cl_nav2z::CbNavigateNextWaypointUntilReached::onEntry().

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

◆ onExit()

void cl_nav2z::CbNavigateNextWaypoint::onExit ( )
overridevirtual

Member Data Documentation

◆ options_

NavigateNextWaypointOptions cl_nav2z::CbNavigateNextWaypoint::options_
protected

Definition at line 43 of file cb_navigate_next_waypoint.hpp.

Referenced by CbNavigateNextWaypoint(), and onEntry().

◆ waypointsNavigator_

CpWaypointNavigator* cl_nav2z::CbNavigateNextWaypoint::waypointsNavigator_ = nullptr
protected

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