$search
00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2008, Willow Garage, Inc. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the Willow Garage nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 * Author: Mike Phillips, Sachin Chitta 00036 *********************************************************************/ 00037 00038 #ifndef SBPL_CART_PLANNER_H 00039 #define SBPL_CART_PLANNER_H 00040 00041 #include <iostream> 00042 #include <vector> 00043 00044 using namespace std; 00045 00047 #include <ros/ros.h> 00048 00049 // Costmap used for the map representation 00050 #include <costmap_2d/costmap_2d_ros.h> 00051 00052 // sbpl headers 00053 #include <sbpl/headers.h> 00054 00055 //global representation 00056 #include <nav_core/base_global_planner.h> 00057 00058 #include <sbpl_cart_planner/environment_cart_planner.h> 00059 #include <visualization_msgs/MarkerArray.h> 00060 00061 class SBPLPlannerException : public std::runtime_error 00062 { 00063 public: 00064 SBPLPlannerException(const std::string &error_desc) : std::runtime_error(error_desc) { ; }; 00065 }; 00066 00067 class SBPLCartPlanner : public nav_core::BaseGlobalPlanner{ 00068 public: 00069 00073 SBPLCartPlanner(); 00074 00075 00081 SBPLCartPlanner(std::string name, costmap_2d::Costmap2DROS* costmap_ros); 00082 00083 00089 virtual void initialize(std::string name, 00090 costmap_2d::Costmap2DROS* costmap_ros); 00091 00099 virtual bool makePlan(const geometry_msgs::PoseStamped& start, 00100 const geometry_msgs::PoseStamped& goal, 00101 std::vector<geometry_msgs::PoseStamped>& plan); 00102 00103 virtual ~SBPLCartPlanner(){}; 00104 00105 private: 00106 bool initialized_; 00107 00108 SBPLPlanner* planner_; 00109 EnvironmentNAVXYTHETACARTLAT* env_; 00110 00111 std::string planner_type_; 00113 double allocated_time_; 00114 double initial_epsilon_; 00116 std::string environment_type_; 00117 std::string cost_map_topic_; 00119 bool forward_search_; 00120 std::string primitive_filename_; 00121 int force_scratch_limit_; 00124 costmap_2d::Costmap2DROS* costmap_ros_; 00125 costmap_2d::Costmap2D cost_map_; 00127 ros::Publisher plan_pub_,sbpl_plan_pub_,sbpl_plan_footprint_pub_,sbpl_robot_cart_plan_pub_, stats_publisher_; 00128 00129 std::vector<geometry_msgs::Point> footprint_; 00130 std::vector<geometry_msgs::Point> loadRobotFootprint(ros::NodeHandle node); 00131 00132 double sign(double x); 00133 sbpl_2Dpt_t cart_offset_, cart_cp_offset_; 00134 00135 void convertPathToMarkerArray(const std::vector<EnvNAVXYTHETACARTLAT3Dpt_t> &sbpl_path, 00136 const std::string &path_frame_id, 00137 visualization_msgs::MarkerArray &ma); 00138 00139 std::vector<geometry_msgs::Point> cart_footprint_,robot_footprint_; 00140 00141 void transformFootprintToEdges(const geometry_msgs::Pose &robot_pose, 00142 const std::vector<geometry_msgs::Point> &footprint, 00143 std::vector<geometry_msgs::Point> &out_footprint); 00144 00145 void getFootprintList(const std::vector<EnvNAVXYTHETACARTLAT3Dpt_t> &sbpl_path, 00146 const std::string &path_frame_id, 00147 visualization_msgs::MarkerArray &ma); 00148 geometry_msgs::Pose getGlobalCartPose(const EnvNAVXYTHETACARTLAT3Dpt_t& sbpl_pose); 00149 geometry_msgs::Pose getLocalCartPose(const EnvNAVXYTHETACARTLAT3Dpt_t& sbpl_pose); 00150 geometry_msgs::Pose getLocalCartControlFramePose(const EnvNAVXYTHETACARTLAT3Dpt_t& sbpl_pose); 00151 00152 bool clearFootprint(const geometry_msgs::Pose &robot_pose, 00153 const std::vector<geometry_msgs::Point> &footprint); 00154 00155 void getOrientedFootprint(const geometry_msgs::Pose &robot_pose, 00156 const std::vector<geometry_msgs::Point> &footprint, 00157 std::vector<geometry_msgs::Point> &oriented_footprint); 00158 00159 geometry_msgs::Pose getGlobalCartPose(const geometry_msgs::Pose &robot_pose, const double &cart_angle); 00160 00161 unsigned char costMapCostToSBPLCost(unsigned char newcost); 00162 00163 unsigned char sbpl_cost_multiplier_; 00164 unsigned char lethal_obstacle_; 00165 unsigned char inscribed_inflated_obstacle_; 00166 unsigned int num_sbpl_markers_; 00167 int visualizer_skip_poses_; 00168 }; 00169 00170 #endif 00171