SMACC2
Public Member Functions | Public Attributes | Private Attributes | List of all members
cl_nav2z::CbUndoPathBackwards Class Reference

#include <cb_undo_path_backwards.hpp>

Inheritance diagram for cl_nav2z::CbUndoPathBackwards:
Inheritance graph
Collaboration diagram for cl_nav2z::CbUndoPathBackwards:
Collaboration graph

Public Member Functions

void onEntry () override
 
void onExit () override
 
- Public Member Functions inherited from cl_nav2z::CbNav2ZClientBehaviorBase
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)
 
- 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)
 

Public Attributes

std::optional< std::string > goalChecker_
 

Private Attributes

std::shared_ptr< tf2_ros::Buffer > listener
 

Additional Inherited Members

- 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 ()
 
virtual void onEntry ()
 
virtual void onExit ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void dispose ()
 
virtual rclcpp::Node::SharedPtr getNode ()
 
virtual rclcpp::Logger getLogger ()
 
- Protected Attributes inherited from cl_nav2z::CbNav2ZClientBehaviorBase
cl_nav2z::ClNav2ZmoveBaseClient_
 
rclcpp_action::ResultCode navigationResult_
 

Detailed Description

Definition at line 28 of file cb_undo_path_backwards.hpp.

Member Function Documentation

◆ onEntry()

void cl_nav2z::CbUndoPathBackwards::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 34 of file cb_undo_path_backwards.cpp.

35{
36 listener = std::make_shared<tf2_ros::Buffer>(this->getNode()->get_clock());
37 auto * odomTracker = moveBaseClient_->getComponent<OdomTracker>();
38
39 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
40
41 nav_msgs::msg::Path forwardpath = odomTracker->getPath();
42 // RCLCPP_INFO_STREAM(getLogger(),"[UndoPathBackward] Current path backwards: " << forwardpath);
43
44 odomTracker->setWorkingMode(WorkingMode::CLEAR_PATH);
45
46 ClNav2Z::Goal goal;
47
48 auto goalCheckerSwitcher = moveBaseClient_->getComponent<GoalCheckerSwitcher>();
49 goalCheckerSwitcher->setGoalCheckerId("undo_path_backwards_goal_checker");
50
51 // WARNING: There might be some race condition with the remote undo global planner were the global path was not received yet
52 rclcpp::sleep_for(1s);
53
54 // this line is used to flush/reset backward planner in the case it were already there
55 // plannerSwitcher->setDefaultPlanners();
56 if (forwardpath.poses.size() > 0)
57 {
58 goal.pose = forwardpath.poses.front();
59 goal.pose.header.stamp = getNode()->now();
60 plannerSwitcher->setUndoPathBackwardPlanner();
62 }
63}
std::shared_ptr< tf2_ros::Buffer > listener
virtual rclcpp::Node::SharedPtr getNode()
TComponent * getComponent()
std::shared_future< typename GoalHandle::SharedPtr > sendGoal(Goal &goal)

References smacc2::ISmaccClient::getComponent(), smacc2::ISmaccClientBehavior::getNode(), listener, cl_nav2z::CbNav2ZClientBehaviorBase::moveBaseClient_, service_node_3::s, smacc2::client_bases::SmaccActionClientBase< ActionType >::sendGoal(), and cl_nav2z::GoalCheckerSwitcher::setGoalCheckerId().

Here is the call graph for this function:

◆ onExit()

void cl_nav2z::CbUndoPathBackwards::onExit ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 65 of file cb_undo_path_backwards.cpp.

66{
67 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] Exiting: undo navigation ");
68
69 if (this->navigationResult_ == rclcpp_action::ResultCode::SUCCEEDED)
70 {
71 RCLCPP_INFO_STREAM(
72 getLogger(),
73 getName() << " - Exiting: undo navigation successful, popping odom tracker path");
74 auto * odomTracker = moveBaseClient_->getComponent<OdomTracker>();
75 odomTracker->popPath();
76 }
77 else
78 {
79 // navigation interrupted or aborted. The path may be not totally undone.
80 // We keep the odom tracker in its current state, probably in the middle of the undoing process.
81 // Could you try to repeat the behavior?
82 }
83}

References smacc2::ISmaccClient::getComponent(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), cl_nav2z::CbNav2ZClientBehaviorBase::moveBaseClient_, cl_nav2z::CbNav2ZClientBehaviorBase::navigationResult_, and cl_nav2z::odom_tracker::OdomTracker::popPath().

Here is the call graph for this function:

Member Data Documentation

◆ goalChecker_

std::optional<std::string> cl_nav2z::CbUndoPathBackwards::goalChecker_

Definition at line 31 of file cb_undo_path_backwards.hpp.

◆ listener

std::shared_ptr<tf2_ros::Buffer> cl_nav2z::CbUndoPathBackwards::listener
private

Definition at line 38 of file cb_undo_path_backwards.hpp.

Referenced by onEntry().


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