SMACC
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cl_move_base_z::CbNavigateBackwards Class Reference

#include <cb_navigate_backwards.h>

Inheritance diagram for cl_move_base_z::CbNavigateBackwards:
Inheritance graph
Collaboration diagram for cl_move_base_z::CbNavigateBackwards:
Collaboration graph

Public Member Functions

 CbNavigateBackwards (float backwardDistance)
 
 CbNavigateBackwards ()
 
virtual void onEntry () override
 
virtual void onExit () override
 
- Public Member Functions inherited from cl_move_base_z::CbMoveBaseClientBehaviorBase
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
- Public Member Functions inherited from smacc::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 smacc::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage)
 
ros::NodeHandle getNode ()
 

Public Attributes

boost::optional< float > backwardDistance
 
boost::optional< float > backwardSpeed
 
tf::TransformListener listener
 
cl_move_base_z::odom_tracker::OdomTrackerodomTracker_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc::SmaccAsyncClientBehavior
virtual void executeOnEntry () override
 
virtual void executeOnExit () override
 
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
- Protected Member Functions inherited from smacc::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 executeOnEntry ()
 
virtual void executeOnExit ()
 
virtual void dispose ()
 
- Protected Attributes inherited from cl_move_base_z::CbMoveBaseClientBehaviorBase
ClMoveBaseZmoveBaseClient_
 
ros::Publisher visualizationMarkersPub_
 

Detailed Description

Definition at line 15 of file cb_navigate_backwards.h.

Constructor & Destructor Documentation

◆ CbNavigateBackwards() [1/2]

cl_move_base_z::CbNavigateBackwards::CbNavigateBackwards ( float  backwardDistance)

Definition at line 10 of file cb_navigate_backward.cpp.

11{
12 if (backwardDistance < 0)
13 {
14 ROS_ERROR("cb backward: distance must be greater or equal than 0");
15 this->backwardDistance = 0;
16 }
18}
boost::optional< float > backwardDistance

References backwardDistance.

◆ CbNavigateBackwards() [2/2]

cl_move_base_z::CbNavigateBackwards::CbNavigateBackwards ( )

Definition at line 20 of file cb_navigate_backward.cpp.

21{
22}

Member Function Documentation

◆ onEntry()

void cl_move_base_z::CbNavigateBackwards::onEntry ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 24 of file cb_navigate_backward.cpp.

25{
26 // straight motion distance
27 double dist;
28
30 {
31 this->getCurrentState()->param("straight_motion_distance", dist, 3.5);
32 }
33 else
34 {
35 dist = *backwardDistance;
36 }
37
38 ROS_INFO_STREAM("[CbNavigateBackwards] Straight backwards motion distance: " << dist);
39
41 auto referenceFrame = p->getReferenceFrame();
42 auto currentPoseMsg = p->toPoseMsg();
43
44 tf::Transform currentPose;
45 tf::poseMsgToTF(currentPoseMsg, currentPose);
46 tf::Transform forwardDeltaTransform;
47 forwardDeltaTransform.setIdentity();
48 forwardDeltaTransform.setOrigin(tf::Vector3(-dist, 0, 0));
49 tf::Transform targetPose = currentPose * forwardDeltaTransform;
50 ClMoveBaseZ::Goal goal;
51 goal.target_pose.header.frame_id = referenceFrame;
52 goal.target_pose.header.stamp = ros::Time::now();
53 tf::poseTFToMsg(targetPose, goal.target_pose.pose);
54 ROS_INFO_STREAM("[CbNavigateBackwards] TARGET POSE BACKWARDS: " << goal.target_pose);
55
57 if (odomTracker_ != nullptr)
58 {
59 this->odomTracker_->clearPath();
60 this->odomTracker_->setStartPoint(currentPoseMsg);
61 this->odomTracker_->setWorkingMode(WorkingMode::RECORD_PATH);
62 }
63
64 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
65 plannerSwitcher->setBackwardPlanner();
66 // this wait might be needed to let the backward planner receive the last forward message from the odom tracker
67 ros::Duration(0.5).sleep();
68
70}
cl_move_base_z::odom_tracker::OdomTracker * odomTracker_
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39
void setStartPoint(const geometry_msgs::PoseStamped &pose)
void setWorkingMode(WorkingMode workingMode)
TComponent * getComponent()
bool param(std::string param_name, T &param_val, const T &default_val) const

References backwardDistance, cl_move_base_z::odom_tracker::OdomTracker::clearPath(), smacc::ISmaccClient::getComponent(), smacc::ISmaccClientBehavior::getCurrentState(), cl_move_base_z::Pose::getReferenceFrame(), cl_move_base_z::CbMoveBaseClientBehaviorBase::moveBaseClient_, odomTracker_, smacc::ISmaccState::param(), smacc::client_bases::SmaccActionClientBase< ActionType >::sendGoal(), cl_move_base_z::PlannerSwitcher::setBackwardPlanner(), cl_move_base_z::odom_tracker::OdomTracker::setStartPoint(), and cl_move_base_z::odom_tracker::OdomTracker::setWorkingMode().

Here is the call graph for this function:

◆ onExit()

void cl_move_base_z::CbNavigateBackwards::onExit ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 72 of file cb_navigate_backward.cpp.

73{
74 if (odomTracker_)
75 {
76 this->odomTracker_->setWorkingMode(WorkingMode::IDLE);
77 }
78}

References odomTracker_, and cl_move_base_z::odom_tracker::OdomTracker::setWorkingMode().

Here is the call graph for this function:

Member Data Documentation

◆ backwardDistance

boost::optional<float> cl_move_base_z::CbNavigateBackwards::backwardDistance

Definition at line 18 of file cb_navigate_backwards.h.

Referenced by CbNavigateBackwards(), and onEntry().

◆ backwardSpeed

boost::optional<float> cl_move_base_z::CbNavigateBackwards::backwardSpeed

Definition at line 21 of file cb_navigate_backwards.h.

◆ listener

tf::TransformListener cl_move_base_z::CbNavigateBackwards::listener

Definition at line 23 of file cb_navigate_backwards.h.

◆ odomTracker_

cl_move_base_z::odom_tracker::OdomTracker* cl_move_base_z::CbNavigateBackwards::odomTracker_

Definition at line 25 of file cb_navigate_backwards.h.

Referenced by onEntry(), and onExit().


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