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

#include <cb_navigate_forward.h>

Inheritance diagram for cl_move_base_z::CbNavigateForward:
Inheritance graph
Collaboration diagram for cl_move_base_z::CbNavigateForward:
Collaboration graph

Public Member Functions

 CbNavigateForward (float forwardDistance)
 
 CbNavigateForward ()
 
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 > forwardDistance
 
boost::optional< float > forwardSpeed
 
boost::optional< geometry_msgs::Quaternion > forceInitialOrientation
 
tf::TransformListener listener
 
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 14 of file cb_navigate_forward.h.

Constructor & Destructor Documentation

◆ CbNavigateForward() [1/2]

cl_move_base_z::CbNavigateForward::CbNavigateForward ( float  forwardDistance)

Definition at line 8 of file cb_navigate_forward.cpp.

9{
11}
boost::optional< float > forwardDistance

References forwardDistance.

◆ CbNavigateForward() [2/2]

cl_move_base_z::CbNavigateForward::CbNavigateForward ( )

Definition at line 13 of file cb_navigate_forward.cpp.

14{
15}

Member Function Documentation

◆ onEntry()

void cl_move_base_z::CbNavigateForward::onEntry ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 17 of file cb_navigate_forward.cpp.

18{
19 // straight motion distance
20 double dist;
21
22 if (!forwardDistance)
23 {
24 this->getCurrentState()->param("straight_motion_distance", dist, 3.5);
25 }
26 else
27 {
28 dist = *forwardDistance;
29 }
30
31 ROS_INFO_STREAM("[CbNavigateForward] Straight motion distance: " << dist);
32
34 auto referenceFrame = p->getReferenceFrame();
35 auto currentPoseMsg = p->toPoseMsg();
36
38 {
39 currentPoseMsg.orientation = *forceInitialOrientation;
40 ROS_WARN_STREAM("[CbNavigateForward] Forcing initial straight motion orientation: " << currentPoseMsg.orientation);
41 }
42
43 tf::Transform currentPose;
44 tf::poseMsgToTF(currentPoseMsg, currentPose);
45
46 tf::Transform forwardDeltaTransform;
47 forwardDeltaTransform.setIdentity();
48 forwardDeltaTransform.setOrigin(tf::Vector3(dist, 0, 0));
49
50 tf::Transform targetPose = currentPose * forwardDeltaTransform;
51
52 ClMoveBaseZ::Goal goal;
53 goal.target_pose.header.frame_id = referenceFrame;
54 goal.target_pose.header.stamp = ros::Time::now();
55 tf::poseTFToMsg(targetPose, goal.target_pose.pose);
56
57 ROS_INFO_STREAM("TARGET POSE FORWARD: " << goal.target_pose.pose);
58
59 geometry_msgs::PoseStamped currentStampedPoseMsg;
60 currentStampedPoseMsg.header.frame_id = referenceFrame;
61 currentStampedPoseMsg.header.stamp = ros::Time::now();
62 tf::poseTFToMsg(currentPose, currentStampedPoseMsg.pose);
63
65 odomTracker_->pushPath("StraightNavigationForwards");
66
67 odomTracker_->setStartPoint(currentStampedPoseMsg);
68 odomTracker_->setWorkingMode(WorkingMode::RECORD_PATH);
69
70 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
71 plannerSwitcher->setForwardPlanner();
72
74}
odom_tracker::OdomTracker * odomTracker_
boost::optional< geometry_msgs::Quaternion > forceInitialOrientation
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39
void setStartPoint(const geometry_msgs::PoseStamped &pose)
void pushPath(std::string newPathTagName="")
void setWorkingMode(WorkingMode workingMode)
TComponent * getComponent()
bool param(std::string param_name, T &param_val, const T &default_val) const

References forceInitialOrientation, forwardDistance, smacc::ISmaccClient::getComponent(), smacc::ISmaccClientBehavior::getCurrentState(), cl_move_base_z::Pose::getReferenceFrame(), cl_move_base_z::CbMoveBaseClientBehaviorBase::moveBaseClient_, odomTracker_, smacc::ISmaccState::param(), cl_move_base_z::odom_tracker::OdomTracker::pushPath(), smacc::client_bases::SmaccActionClientBase< ActionType >::sendGoal(), cl_move_base_z::PlannerSwitcher::setForwardPlanner(), 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::CbNavigateForward::onExit ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 76 of file cb_navigate_forward.cpp.

77{
78 this->odomTracker_->setWorkingMode(WorkingMode::IDLE);
79}

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

Here is the call graph for this function:

Member Data Documentation

◆ forceInitialOrientation

boost::optional<geometry_msgs::Quaternion> cl_move_base_z::CbNavigateForward::forceInitialOrientation

Definition at line 26 of file cb_navigate_forward.h.

Referenced by onEntry().

◆ forwardDistance

boost::optional<float> cl_move_base_z::CbNavigateForward::forwardDistance

Definition at line 17 of file cb_navigate_forward.h.

Referenced by CbNavigateForward(), and onEntry().

◆ forwardSpeed

boost::optional<float> cl_move_base_z::CbNavigateForward::forwardSpeed

Definition at line 20 of file cb_navigate_forward.h.

◆ listener

tf::TransformListener cl_move_base_z::CbNavigateForward::listener

Definition at line 28 of file cb_navigate_forward.h.

◆ odomTracker_

odom_tracker::OdomTracker* cl_move_base_z::CbNavigateForward::odomTracker_

Definition at line 30 of file cb_navigate_forward.h.

Referenced by onEntry(), and onExit().


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