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

#include <backward_global_planner.h>

Inheritance diagram for cl_move_base_z::backward_global_planner::BackwardGlobalPlanner:
Inheritance graph
Collaboration diagram for cl_move_base_z::backward_global_planner::BackwardGlobalPlanner:
Collaboration graph

Public Member Functions

 BackwardGlobalPlanner ()
 
virtual ~BackwardGlobalPlanner ()
 
bool makePlan (const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)
 
bool makePlan (const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan, double &cost)
 
virtual bool createDefaultBackwardPath (const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)
 
virtual void initialize (std::string name, costmap_2d::Costmap2DROS *costmap_ros_) override
 

Private Member Functions

void onForwardTrailMsg (const nav_msgs::Path::ConstPtr &trailMessage)
 
void publishGoalMarker (const geometry_msgs::Pose &pose, double r, double g, double b)
 

Private Attributes

ros::NodeHandle nh_
 
ros::Publisher planPub_
 
ros::Publisher markersPub_
 
costmap_2d::Costmap2DROS * costmap_ros_
 
double skip_straight_motion_distance_
 
double puresSpinningRadStep_
 

Detailed Description

Definition at line 17 of file backward_global_planner.h.

Constructor & Destructor Documentation

◆ BackwardGlobalPlanner()

cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::BackwardGlobalPlanner ( )

◆ ~BackwardGlobalPlanner()

cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::~BackwardGlobalPlanner ( )
virtual

Definition at line 37 of file backward_global_planner.cpp.

38{
39 //clear
40 nav_msgs::Path planMsg;
41 planMsg.header.stamp = ros::Time::now();
42 planPub_.publish(planMsg);
43}

References planPub_.

Member Function Documentation

◆ createDefaultBackwardPath()

bool cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::createDefaultBackwardPath ( const geometry_msgs::PoseStamped &  start,
const geometry_msgs::PoseStamped &  goal,
std::vector< geometry_msgs::PoseStamped > &  plan 
)
virtual

defaultBackwardPath()

Definition at line 105 of file backward_global_planner.cpp.

107{
108 auto q = start.pose.orientation;
109
110 geometry_msgs::PoseStamped pose;
111 pose = start;
112
113 double dx = start.pose.position.x - goal.pose.position.x;
114 double dy = start.pose.position.y - goal.pose.position.y;
115
116 double length = sqrt(dx * dx + dy * dy);
117
118 geometry_msgs::PoseStamped prevState;
120 {
121 // skip initial pure spinning and initial straight motion
122 //ROS_INFO("1 - heading to goal position pure spinning");
123 double heading_direction = atan2(dy, dx);
124 double startyaw = tf::getYaw(q);
125 double offset = angles::shortest_angular_distance(startyaw, heading_direction);
126 heading_direction = startyaw + offset;
127
128 prevState = cl_move_base_z::makePureSpinningSubPlan(start, heading_direction, plan, puresSpinningRadStep_);
129 //ROS_INFO("2 - going forward keep orientation pure straight");
130
131 prevState = cl_move_base_z::makePureStraightSubPlan(prevState, goal.pose.position, length, plan);
132 }
133 else
134 {
135 prevState = start;
136 }
137
138 ROS_WARN_STREAM( "[BackwardGlobalPlanner ] backward global plan size: " <<plan.size());
139 return true;
140}
geometry_msgs::PoseStamped makePureStraightSubPlan(const geometry_msgs::PoseStamped &startOrientedPose, const geometry_msgs::Point &goal, double length, std::vector< geometry_msgs::PoseStamped > &plan)
Definition: path_tools.cpp:61
geometry_msgs::PoseStamped makePureSpinningSubPlan(const geometry_msgs::PoseStamped &start, double dstRads, std::vector< geometry_msgs::PoseStamped > &plan, double puresSpinningRadStep=1000)
Definition: path_tools.cpp:13

References cl_move_base_z::makePureSpinningSubPlan(), cl_move_base_z::makePureStraightSubPlan(), puresSpinningRadStep_, and skip_straight_motion_distance_.

Referenced by makePlan().

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

◆ initialize()

void cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::initialize ( std::string  name,
costmap_2d::Costmap2DROS *  costmap_ros 
)
overridevirtual

initialize()

Definition at line 50 of file backward_global_planner.cpp.

51{
52 //ROS_INFO_NAMED("Backwards", "BackwardGlobalPlanner initialize");
53 costmap_ros_ = costmap_ros;
54 //ROS_WARN_NAMED("Backwards", "initializating global planner, costmap address: %ld", (long)costmap_ros);
55
56 ros::NodeHandle nh;
57 planPub_ = nh.advertise<nav_msgs::Path>("backward_planner/global_plan", 1);
58 markersPub_ = nh.advertise<visualization_msgs::MarkerArray>("backward_planner/markers", 1);
59}

References costmap_ros_, markersPub_, and planPub_.

◆ makePlan() [1/2]

bool cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::makePlan ( const geometry_msgs::PoseStamped &  start,
const geometry_msgs::PoseStamped &  goal,
std::vector< geometry_msgs::PoseStamped > &  plan 
)

makePlan()

Definition at line 147 of file backward_global_planner.cpp.

149{
150 //ROS_WARN_NAMED("Backwards", "Backwards global planner: Generating global plan ");
151 //ROS_WARN_NAMED("Backwards", "Clearing...");
152
153 plan.clear();
154
155 this->createDefaultBackwardPath(start, goal, plan);
156 //this->createPureSpiningAndStragihtLineBackwardPath(start, goal, plan);
157
158 //ROS_INFO_STREAM(" start - " << start);
159 //ROS_INFO_STREAM(" end - " << goal.pose.position);
160
161 //ROS_INFO("3 - heading to goal orientation");
162 //double goalOrientation = angles::normalize_angle(tf::getYaw(goal.pose.orientation));
163 //cl_move_base_z::makePureSpinningSubPlan(prevState,goalOrientation,plan);
164
165 //ROS_WARN_STREAM( "MAKE PLAN INVOKED, plan size:"<< plan.size());
166 publishGoalMarker(goal.pose, 1.0, 0, 1.0);
167
168 nav_msgs::Path planMsg;
169 planMsg.poses = plan;
170 planMsg.header.frame_id = this->costmap_ros_->getGlobalFrameID();
171
172 // check plan rejection
173 bool acceptedGlobalPlan = true;
174
175 // static const unsigned char NO_INFORMATION = 255;
176 // static const unsigned char LETHAL_OBSTACLE = 254;
177 // static const unsigned char INSCRIBED_INFLATED_OBSTACLE = 253;
178 // static const unsigned char FREE_SPACE = 0;
179
180 costmap_2d::Costmap2D *costmap2d = this->costmap_ros_->getCostmap();
181 for (auto &p : plan)
182 {
183 uint32_t mx, my;
184 costmap2d->worldToMap(p.pose.position.x, p.pose.position.y, mx, my);
185 auto cost = costmap2d->getCost(mx, my);
186
187 if (cost >= costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
188 {
189 acceptedGlobalPlan = false;
190 break;
191 }
192 }
193
194 planPub_.publish(planMsg);
195
196 // this was previously set to size() <= 1, but a plan with a single point is also a valid plan (the goal)
197 return true;
198}
virtual bool createDefaultBackwardPath(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)
void publishGoalMarker(const geometry_msgs::Pose &pose, double r, double g, double b)

References costmap_ros_, createDefaultBackwardPath(), planPub_, and publishGoalMarker().

Referenced by makePlan().

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

◆ makePlan() [2/2]

bool cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::makePlan ( const geometry_msgs::PoseStamped &  start,
const geometry_msgs::PoseStamped &  goal,
std::vector< geometry_msgs::PoseStamped > &  plan,
double &  cost 
)

makePlan()

Definition at line 205 of file backward_global_planner.cpp.

208{
209 cost = 0;
210 makePlan(start, goal, plan);
211 return true;
212}
bool makePlan(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)

References makePlan().

Here is the call graph for this function:

◆ onForwardTrailMsg()

void cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::onForwardTrailMsg ( const nav_msgs::Path::ConstPtr &  trailMessage)
private

◆ publishGoalMarker()

void cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::publishGoalMarker ( const geometry_msgs::Pose &  pose,
double  r,
double  g,
double  b 
)
private

publishGoalMarker()

Definition at line 66 of file backward_global_planner.cpp.

67{
68 double phi = tf::getYaw(pose.orientation);
69 visualization_msgs::Marker marker;
70 marker.header.frame_id = this->costmap_ros_->getGlobalFrameID();
71 marker.header.stamp = ros::Time::now();
72 marker.ns = "my_namespace2";
73 marker.id = 0;
74 marker.type = visualization_msgs::Marker::ARROW;
75 marker.action = visualization_msgs::Marker::ADD;
76 marker.scale.x = 0.1;
77 marker.scale.y = 0.3;
78 marker.scale.z = 0.1;
79 marker.color.a = 1.0;
80 marker.color.r = r;
81 marker.color.g = g;
82 marker.color.b = b;
83
84 geometry_msgs::Point start, end;
85 start.x = pose.position.x;
86 start.y = pose.position.y;
87
88 end.x = pose.position.x + 0.5 * cos(phi);
89 end.y = pose.position.y + 0.5 * sin(phi);
90
91 marker.points.push_back(start);
92 marker.points.push_back(end);
93
94 visualization_msgs::MarkerArray ma;
95 ma.markers.push_back(marker);
96
97 markersPub_.publish(ma);
98}

References costmap_ros_, and markersPub_.

Referenced by makePlan().

Here is the caller graph for this function:

Member Data Documentation

◆ costmap_ros_

costmap_2d::Costmap2DROS* cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::costmap_ros_
private

Definition at line 43 of file backward_global_planner.h.

Referenced by initialize(), makePlan(), and publishGoalMarker().

◆ markersPub_

ros::Publisher cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::markersPub_
private

Definition at line 41 of file backward_global_planner.h.

Referenced by initialize(), and publishGoalMarker().

◆ nh_

ros::NodeHandle cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::nh_
private

Definition at line 37 of file backward_global_planner.h.

◆ planPub_

ros::Publisher cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::planPub_
private

Definition at line 39 of file backward_global_planner.h.

Referenced by initialize(), makePlan(), and ~BackwardGlobalPlanner().

◆ puresSpinningRadStep_

double cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::puresSpinningRadStep_
private

Definition at line 51 of file backward_global_planner.h.

Referenced by createDefaultBackwardPath().

◆ skip_straight_motion_distance_

double cl_move_base_z::backward_global_planner::BackwardGlobalPlanner::skip_straight_motion_distance_
private

Definition at line 49 of file backward_global_planner.h.

Referenced by BackwardGlobalPlanner(), and createDefaultBackwardPath().


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