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

#include <forward_global_planner.h>

Inheritance diagram for cl_move_base_z::forward_global_planner::ForwardGlobalPlanner:
Inheritance graph
Collaboration diagram for cl_move_base_z::forward_global_planner::ForwardGlobalPlanner:
Collaboration graph

Public Member Functions

 ForwardGlobalPlanner ()
 
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)
 
void initialize (std::string name, costmap_2d::Costmap2DROS *costmap_ros_)
 

Private Attributes

ros::NodeHandle nh_
 
ros::Publisher planPub_
 
costmap_2d::Costmap2DROS * costmap_ros_
 stored but almost not used More...
 
double skip_straight_motion_distance_
 
double puresSpinningRadStep_
 

Detailed Description

Definition at line 16 of file forward_global_planner.h.

Constructor & Destructor Documentation

◆ ForwardGlobalPlanner()

cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::ForwardGlobalPlanner ( )

Member Function Documentation

◆ initialize()

void cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::initialize ( std::string  name,
costmap_2d::Costmap2DROS *  costmap_ros_ 
)

Definition at line 30 of file forward_global_planner.cpp.

31{
32 ROS_INFO("[Forward Global Planner] initializing");
33 planPub_ = nh_.advertise<nav_msgs::Path>("global_plan", 1);
34 skip_straight_motion_distance_ = 0.2; //meters
35 puresSpinningRadStep_ = 1000; // rads
36 this->costmap_ros_ = costmap_ros;
37}
costmap_2d::Costmap2DROS * costmap_ros_
stored but almost not used

References costmap_ros_, nh_, planPub_, puresSpinningRadStep_, and skip_straight_motion_distance_.

◆ makePlan() [1/2]

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

Definition at line 48 of file forward_global_planner.cpp.

50{
51 //ROS_WARN_STREAM("Forward global plan goal: " << goal);
52
53 //three stages: 1 - heading to goal position, 2 - going forward keep orientation, 3 - heading to goal orientation
54
55 // 1 - heading to goal position
56 // orientation direction
57
58 double dx = goal.pose.position.x - start.pose.position.x;
59 double dy = goal.pose.position.y - start.pose.position.y;
60
61 double length = sqrt(dx * dx + dy * dy);
62
63 geometry_msgs::PoseStamped prevState;
65 {
66 // skip initial pure spinning and initial straight motion
67 //ROS_INFO("1 - heading to goal position pure spinning");
68 double heading_direction = atan2(dy, dx);
69 prevState = cl_move_base_z::makePureSpinningSubPlan(start, heading_direction, plan, puresSpinningRadStep_);
70 //ROS_INFO("2 - going forward keep orientation pure straight");
71 prevState = cl_move_base_z::makePureStraightSubPlan(prevState, goal.pose.position, length, plan);
72 }
73 else
74 {
75 prevState = start;
76 }
77
78 //ROS_INFO("3 - heading to goal orientation");
79 double goalOrientation = angles::normalize_angle(tf::getYaw(goal.pose.orientation));
80 cl_move_base_z::makePureSpinningSubPlan(prevState, goalOrientation, plan, puresSpinningRadStep_);
81
82 nav_msgs::Path planMsg;
83 planMsg.poses = plan;
84 planMsg.header.stamp = ros::Time::now();
85
86 planMsg.header.frame_id = this->costmap_ros_->getGlobalFrameID();
87
88 // check plan rejection
89 bool acceptedGlobalPlan = true;
90
91 // static const unsigned char NO_INFORMATION = 255;
92 // static const unsigned char LETHAL_OBSTACLE = 254;
93 // static const unsigned char INSCRIBED_INFLATED_OBSTACLE = 253;
94 // static const unsigned char FREE_SPACE = 0;
95
96 costmap_2d::Costmap2D *costmap2d = this->costmap_ros_->getCostmap();
97 for (auto &p : plan)
98 {
99 uint32_t mx, my;
100 costmap2d->worldToMap(p.pose.position.x, p.pose.position.y, mx, my);
101 auto cost = costmap2d->getCost(mx, my);
102
103 if (cost >= costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
104 {
105 acceptedGlobalPlan = false;
106 break;
107 }
108 }
109
110 if (acceptedGlobalPlan)
111 {
112 planPub_.publish(planMsg);
113 //ROS_INFO_STREAM("global forward plan: " << planMsg);
114 return true;
115 }
116 else
117 {
118 return false;
119 }
120}
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 costmap_ros_, cl_move_base_z::makePureSpinningSubPlan(), cl_move_base_z::makePureStraightSubPlan(), planPub_, 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:

◆ makePlan() [2/2]

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

Definition at line 39 of file forward_global_planner.cpp.

42{
43 ROS_INFO("[Forward Global Planner] planning");
44 cost = 0;
45 return makePlan(start, goal, plan);
46}
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:

Member Data Documentation

◆ costmap_ros_

costmap_2d::Costmap2DROS* cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::costmap_ros_
private

stored but almost not used

Definition at line 36 of file forward_global_planner.h.

Referenced by initialize(), and makePlan().

◆ nh_

ros::NodeHandle cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::nh_
private

Definition at line 31 of file forward_global_planner.h.

Referenced by initialize().

◆ planPub_

ros::Publisher cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::planPub_
private

Definition at line 33 of file forward_global_planner.h.

Referenced by initialize(), and makePlan().

◆ puresSpinningRadStep_

double cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::puresSpinningRadStep_
private

Definition at line 40 of file forward_global_planner.h.

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

◆ skip_straight_motion_distance_

double cl_move_base_z::forward_global_planner::ForwardGlobalPlanner::skip_straight_motion_distance_
private

Definition at line 38 of file forward_global_planner.h.

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


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