6#include <boost/assign.hpp>
7#include <boost/range/adaptor/reversed.hpp>
8#include <boost/range/algorithm/copy.hpp>
9#include <pluginlib/class_list_macros.h>
14#include <nav_msgs/Path.h>
15#include <angles/angles.h>
17#include <tf/transform_datatypes.h>
21namespace forward_global_planner
24 : nh_(
"~/ForwardGlobalPlanner")
32 ROS_INFO(
"[Forward Global Planner] initializing");
33 planPub_ =
nh_.advertise<nav_msgs::Path>(
"global_plan", 1);
40 const geometry_msgs::PoseStamped &goal, std::vector<geometry_msgs::PoseStamped> &plan,
43 ROS_INFO(
"[Forward Global Planner] planning");
49 const geometry_msgs::PoseStamped &goal, std::vector<geometry_msgs::PoseStamped> &plan)
58 double dx = goal.pose.position.x - start.pose.position.x;
59 double dy = goal.pose.position.y - start.pose.position.y;
61 double length = sqrt(dx * dx + dy * dy);
63 geometry_msgs::PoseStamped prevState;
68 double heading_direction = atan2(dy, dx);
79 double goalOrientation = angles::normalize_angle(tf::getYaw(goal.pose.orientation));
82 nav_msgs::Path planMsg;
84 planMsg.header.stamp = ros::Time::now();
86 planMsg.header.frame_id = this->
costmap_ros_->getGlobalFrameID();
89 bool acceptedGlobalPlan =
true;
96 costmap_2d::Costmap2D *costmap2d = this->
costmap_ros_->getCostmap();
100 costmap2d->worldToMap(p.pose.position.x, p.pose.position.y, mx, my);
101 auto cost = costmap2d->getCost(mx, my);
103 if (cost >= costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
105 acceptedGlobalPlan =
false;
110 if (acceptedGlobalPlan)
void initialize(std::string name, costmap_2d::Costmap2DROS *costmap_ros_)
double puresSpinningRadStep_
costmap_2d::Costmap2DROS * costmap_ros_
stored but almost not used
bool makePlan(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)
double skip_straight_motion_distance_
PLUGINLIB_EXPORT_CLASS(cl_move_base_z::forward_global_planner::ForwardGlobalPlanner, nav_core::BaseGlobalPlanner)
geometry_msgs::PoseStamped makePureStraightSubPlan(const geometry_msgs::PoseStamped &startOrientedPose, const geometry_msgs::Point &goal, double length, std::vector< geometry_msgs::PoseStamped > &plan)
geometry_msgs::PoseStamped makePureSpinningSubPlan(const geometry_msgs::PoseStamped &start, double dstRads, std::vector< geometry_msgs::PoseStamped > &plan, double puresSpinningRadStep=1000)