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

#include <cb_undo_path_backwards2.h>

Inheritance diagram for cl_move_base_z::CbUndoPathBackwards2:
Inheritance graph
Collaboration diagram for cl_move_base_z::CbUndoPathBackwards2:
Collaboration graph

Public Member Functions

 CbUndoPathBackwards2 ()
 
virtual void onEntry () override
 
virtual void onExit () override
 
virtual void update () override
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
- 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 Member Functions inherited from smacc::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (ros::Duration duration)
 
void executeUpdate ()
 
void setUpdatePeriod (ros::Duration duration)
 

Private Member Functions

void publishMarkers ()
 
float evalPlaneSide (const geometry_msgs::Pose &pose)
 

Private Attributes

ClMoveBaseZ::Goal goal_
 
odom_tracker::OdomTrackerodomTracker_
 
tf::TransformListener listener
 
cl_move_base_z::PoserobotPose_
 
std::atomic< boolgoalLinePassed_
 
float initial_plane_side_
 
float triggerThreshold_
 
std::function< void()> postVirtualLinePassed_
 

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 ()
 
virtual void update ()=0
 
- Protected Attributes inherited from cl_move_base_z::CbMoveBaseClientBehaviorBase
ClMoveBaseZmoveBaseClient_
 
ros::Publisher visualizationMarkersPub_
 

Detailed Description

Definition at line 21 of file cb_undo_path_backwards2.h.

Constructor & Destructor Documentation

◆ CbUndoPathBackwards2()

cl_move_base_z::CbUndoPathBackwards2::CbUndoPathBackwards2 ( )

Definition at line 15 of file cb_undo_path_backwards2.cpp.

References triggerThreshold_.

Member Function Documentation

◆ evalPlaneSide()

float cl_move_base_z::CbUndoPathBackwards2::evalPlaneSide ( const geometry_msgs::Pose &  pose)
private

Definition at line 48 of file cb_undo_path_backwards2.cpp.

49{
50 // check the line was passed
51 // y = mx x + y0
52 // y = (sin(alpha)/cos(alpha)) (x -x0) + y0
53 // cos(alpha)(y - y0) - sin(alpha) (x -x0)= 0 // if greater one side if lower , the other
54 auto y = pose.position.y;
55 auto x = pose.position.x;
56 auto alpha = tf::getYaw(goal_.target_pose.pose.orientation);
57 auto y0 = goal_.target_pose.pose.position.y;
58 auto x0 = goal_.target_pose.pose.position.x;
59
60 auto evalimplicit = cos(alpha) * (y - y0) - sin (alpha) * (x - x0);
61 return evalimplicit;
62}

References goal_.

Referenced by onEntry(), and update().

Here is the caller graph for this function:

◆ onEntry()

void cl_move_base_z::CbUndoPathBackwards2::onEntry ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 20 of file cb_undo_path_backwards2.cpp.

21{
23
24 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
26
27 nav_msgs::Path forwardpath = odomTracker_->getPath();
28 // ROS_INFO_STREAM("[UndoPathBackward] Current path backwards: " << forwardpath);
29
30 odomTracker_->setWorkingMode(WorkingMode::CLEAR_PATH);
31
32 // this line is used to flush/reset backward planner in the case it were already there
33 // plannerSwitcher->setDefaultPlanners();
34 if (forwardpath.poses.size() > 0)
35 {
36 goal_.target_pose = forwardpath.poses.front();
38 plannerSwitcher->setUndoPathBackwardsPlannerConfiguration();
40 }
41}
odom_tracker::OdomTracker * odomTracker_
float evalPlaneSide(const geometry_msgs::Pose &pose)
geometry_msgs::Pose toPoseMsg()
Definition: cp_pose.h:27
void setWorkingMode(WorkingMode workingMode)
TComponent * getComponent()

References evalPlaneSide(), smacc::ISmaccClient::getComponent(), cl_move_base_z::odom_tracker::OdomTracker::getPath(), goal_, initial_plane_side_, cl_move_base_z::CbMoveBaseClientBehaviorBase::moveBaseClient_, odomTracker_, robotPose_, smacc::client_bases::SmaccActionClientBase< ActionType >::sendGoal(), cl_move_base_z::odom_tracker::OdomTracker::setWorkingMode(), and cl_move_base_z::Pose::toPoseMsg().

Here is the call graph for this function:

◆ onExit()

void cl_move_base_z::CbUndoPathBackwards2::onExit ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 127 of file cb_undo_path_backwards2.cpp.

128{
129 auto* odomTracker = moveBaseClient_->getComponent<OdomTracker>();
130 odomTracker->popPath();
131}

References smacc::ISmaccClient::getComponent(), and cl_move_base_z::CbMoveBaseClientBehaviorBase::moveBaseClient_.

Here is the call graph for this function:

◆ onOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_move_base_z::CbUndoPathBackwards2::onOrthogonalAllocation ( )
inline

Definition at line 32 of file cb_undo_path_backwards2.h.

33 {
34 CbMoveBaseClientBehaviorBase::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
35
36 postVirtualLinePassed_ = [=] { this->postEvent<EvGoalVirtualLinePassed<TSourceObject, TOrthogonal>>(); };
37 }

References postVirtualLinePassed_.

◆ publishMarkers()

void cl_move_base_z::CbUndoPathBackwards2::publishMarkers ( )
private

Definition at line 90 of file cb_undo_path_backwards2.cpp.

91{
92 double phi = tf::getYaw(goal_.target_pose.pose.orientation);
93 visualization_msgs::Marker marker;
94 marker.header.frame_id = robotPose_->getReferenceFrame();
95
96 marker.header.stamp = ros::Time::now();
97 marker.ns = "my_namespace2";
98 marker.id = 0;
99 marker.type = visualization_msgs::Marker::SPHERE;
100 marker.action = visualization_msgs::Marker::ADD;
101 marker.scale.x = 3;
102 marker.scale.y = 3;
103 marker.scale.z = 3;
104 marker.color.a = 1.0;
105 marker.color.r = 1.0;
106 marker.color.g = 0.0;
107 marker.color.b = 0.0;
108
109 marker.pose = goal_.target_pose.pose;
110
111 // geometry_msgs::Point start, end;
112 // start.x = pose.position.x;
113 // start.y = pose.position.y;
114
115 // end.x = pose.position.x + 0.5 * cos(phi);
116 // end.y = pose.position.y + 0.5 * sin(phi);
117
118 // marker.points.push_back(start);
119 // marker.points.push_back(end);
120
121 visualization_msgs::MarkerArray ma;
122 ma.markers.push_back(marker);
123
124 this->visualizationMarkersPub_.publish(ma);
125}
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39

References cl_move_base_z::Pose::getReferenceFrame(), goal_, robotPose_, and cl_move_base_z::CbMoveBaseClientBehaviorBase::visualizationMarkersPub_.

Here is the call graph for this function:

◆ update()

void cl_move_base_z::CbUndoPathBackwards2::update ( )
overridevirtual

Implements smacc::ISmaccUpdatable.

Definition at line 64 of file cb_undo_path_backwards2.cpp.

65{
66 auto pose = robotPose_->toPoseMsg();
67
68 float evalimplicit = evalPlaneSide(pose);
69 if (sgn(evalimplicit) != sgn(initial_plane_side_))
70 {
71 ROS_WARN_STREAM("[CbUndoPathBackwards2] goal_ line passed: "
72 << evalimplicit << "/" << this->initial_plane_side_);
73
74 if (fabs(evalimplicit) > triggerThreshold_ /*meters*/)
75 {
76 ROS_WARN_STREAM("[CbUndoPathBackwards2] virtual goal line passed, stopping behavior and success: "
77 << evalimplicit << "/" << this->initial_plane_side_);
79 // this->postSuccessEvent();
81 }
82 }
83 else
84 {
85 ROS_INFO_STREAM_THROTTLE(1.0, "[CbUndoPathBackwards2] goal_ line not passed yet: " << evalimplicit << "/"
86 << this->initial_plane_side_);
87 }
88}

References smacc::client_bases::SmaccActionClientBase< ActionType >::cancelGoal(), evalPlaneSide(), initial_plane_side_, cl_move_base_z::CbMoveBaseClientBehaviorBase::moveBaseClient_, postVirtualLinePassed_, robotPose_, cl_move_base_z::sgn(), cl_move_base_z::Pose::toPoseMsg(), and triggerThreshold_.

Here is the call graph for this function:

Member Data Documentation

◆ goal_

ClMoveBaseZ::Goal cl_move_base_z::CbUndoPathBackwards2::goal_
private

Definition at line 43 of file cb_undo_path_backwards2.h.

Referenced by evalPlaneSide(), onEntry(), and publishMarkers().

◆ goalLinePassed_

std::atomic<bool> cl_move_base_z::CbUndoPathBackwards2::goalLinePassed_
private

Definition at line 48 of file cb_undo_path_backwards2.h.

◆ initial_plane_side_

float cl_move_base_z::CbUndoPathBackwards2::initial_plane_side_
private

Definition at line 49 of file cb_undo_path_backwards2.h.

Referenced by onEntry(), and update().

◆ listener

tf::TransformListener cl_move_base_z::CbUndoPathBackwards2::listener
private

Definition at line 46 of file cb_undo_path_backwards2.h.

◆ odomTracker_

odom_tracker::OdomTracker* cl_move_base_z::CbUndoPathBackwards2::odomTracker_
private

Definition at line 44 of file cb_undo_path_backwards2.h.

Referenced by onEntry().

◆ postVirtualLinePassed_

std::function<void()> cl_move_base_z::CbUndoPathBackwards2::postVirtualLinePassed_
private

Definition at line 51 of file cb_undo_path_backwards2.h.

Referenced by onOrthogonalAllocation(), and update().

◆ robotPose_

cl_move_base_z::Pose* cl_move_base_z::CbUndoPathBackwards2::robotPose_
private

Definition at line 47 of file cb_undo_path_backwards2.h.

Referenced by onEntry(), publishMarkers(), and update().

◆ triggerThreshold_

float cl_move_base_z::CbUndoPathBackwards2::triggerThreshold_
private

Definition at line 50 of file cb_undo_path_backwards2.h.

Referenced by CbUndoPathBackwards2(), and update().


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