Go to the documentation of this file.00001 #ifndef _PLANNERCORE_H
00002 #define _PLANNERCORE_H
00003
00004
00005
00006
00007
00008 #include <ros/ros.h>
00009 #include <costmap_2d/costmap_2d.h>
00010 #include <geometry_msgs/PoseStamped.h>
00011 #include <geometry_msgs/Point.h>
00012 #include <nav_msgs/Path.h>
00013 #include <tf/transform_datatypes.h>
00014 #include <vector>
00015 #include <nav_core/base_global_planner.h>
00016 #include <nav_msgs/GetPlan.h>
00017
00018 #include <tuple>
00019 #include <vector>
00020 #include "dynamicvoronoi.h"
00021
00022 #include <voronoi_planner/VoronoiPlannerConfig.h>
00023
00024 namespace voronoi_planner {
00025
00031 class VoronoiPlanner : public nav_core::BaseGlobalPlanner {
00032 public:
00036 VoronoiPlanner();
00037
00044 VoronoiPlanner(std::string name, costmap_2d::Costmap2D* costmap, std::string frame_id);
00045
00049 ~VoronoiPlanner();
00050
00056 void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
00057
00058 void initialize(std::string name, costmap_2d::Costmap2D* costmap, std::string frame_id);
00059
00067 bool makePlan(const geometry_msgs::PoseStamped& start, const geometry_msgs::PoseStamped& goal,
00068 std::vector<geometry_msgs::PoseStamped>& plan);
00069
00078 bool makePlan(const geometry_msgs::PoseStamped& start, const geometry_msgs::PoseStamped& goal, double tolerance,
00079 std::vector<geometry_msgs::PoseStamped>& plan);
00080
00081 bool findPath(std::vector<std::pair<float, float> > *path,
00082 int init_x, int init_y,
00083 int goal_x, int goal_y,
00084 DynamicVoronoi *voronoi,
00085 bool check_is_voronoi_cell,
00086 bool stop_at_voronoi );
00087
00088 void smoothPath(std::vector<std::pair<float, float> > *path);
00089
00090
00094 void publishPlan(const std::vector<geometry_msgs::PoseStamped>& path);
00095
00096 bool makePlanService(nav_msgs::GetPlan::Request& req, nav_msgs::GetPlan::Response& resp);
00097
00098 void publishVoronoiGrid(DynamicVoronoi *voronoi);
00099
00100 protected:
00101
00105 costmap_2d::Costmap2D* costmap_;
00106 std::string frame_id_;
00107 ros::Publisher plan_pub_;
00108 bool initialized_;
00109
00110 bool publish_voronoi_grid_;
00111 ros::Publisher voronoi_grid_pub_;
00112
00113 bool smooth_path_;
00114 float weight_data_;
00115 float weight_smooth_;
00116
00117
00118
00119 private:
00120 void mapToWorld(double mx, double my, double& wx, double& wy);
00121 bool worldToMap(double wx, double wy, double& mx, double& my);
00122 void clearRobotCell(const tf::Stamped<tf::Pose>& global_pose, unsigned int mx, unsigned int my);
00123
00124 double planner_window_x_, planner_window_y_, default_tolerance_;
00125 std::string tf_prefix_;
00126 boost::mutex mutex_;
00127 ros::ServiceServer make_plan_srv_;
00128
00129 DynamicVoronoi voronoi_;
00130
00131 void outlineMap(unsigned char* costarr, int nx, int ny, unsigned char value);
00132 unsigned char* cost_array_;
00133 unsigned int start_x_, start_y_, end_x_, end_y_;
00134
00135
00136 dynamic_reconfigure::Server<voronoi_planner::VoronoiPlannerConfig> *dsrv_;
00137 void reconfigureCB(voronoi_planner::VoronoiPlannerConfig &config, uint32_t level);
00138 void costmapUpdateCallback(const map_msgs::OccupancyGridUpdate::ConstPtr& msg);
00139
00140 };
00141
00142 }
00143
00144 #endif