00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2010, 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 Willow Garage, Inc. 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: Christian Connette 00036 *********************************************************************/ 00037 00038 #ifndef EBAND_LOCAL_PLANNER_ROS_H_ 00039 #define EBAND_LOCAL_PLANNER_ROS_H_ 00040 00041 #include <ros/ros.h> 00042 00043 // abstract class from which our plugin inherits 00044 #include <nav_core/base_local_planner.h> 00045 00046 // dynamic reconfigure 00047 #include <dynamic_reconfigure/server.h> 00048 00049 // classes wich are parts of this pkg 00050 #include <eband_local_planner/eband_local_planner.h> 00051 #include <eband_local_planner/conversions_and_types.h> 00052 #include <eband_local_planner/eband_visualization.h> 00053 #include <eband_local_planner/eband_trajectory_controller.h> 00054 #include <eband_local_planner/EBandPlannerConfig.h> 00055 00056 // local planner specific classes which provide some macros 00057 #include <base_local_planner/goal_functions.h> 00058 00059 // msgs 00060 #include <nav_msgs/Path.h> 00061 #include <nav_msgs/Odometry.h> 00062 #include <geometry_msgs/PoseStamped.h> 00063 #include <visualization_msgs/MarkerArray.h> 00064 #include <visualization_msgs/Marker.h> 00065 00066 // transforms 00067 #include <angles/angles.h> 00068 #include <tf/tf.h> 00069 #include <tf/transform_listener.h> 00070 00071 // costmap & geometry 00072 #include <costmap_2d/costmap_2d_ros.h> 00073 00074 // boost classes 00075 #include <boost/bind.hpp> 00076 #include <boost/shared_ptr.hpp> 00077 00078 00079 namespace eband_local_planner{ 00080 00085 class EBandPlannerROS : public nav_core::BaseLocalPlanner{ 00086 00087 public: 00091 EBandPlannerROS(); 00092 00099 EBandPlannerROS(std::string name, tf::TransformListener* tf, 00100 costmap_2d::Costmap2DROS* costmap_ros); 00101 00105 ~EBandPlannerROS(); 00106 00113 void initialize(std::string name, tf::TransformListener* tf, 00114 costmap_2d::Costmap2DROS* costmap_ros); 00115 00121 bool setPlan(const std::vector<geometry_msgs::PoseStamped>& orig_global_plan); 00122 00128 bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel); 00129 00134 bool isGoalReached(); 00135 00136 private: 00137 00143 void reconfigureCallback(EBandPlannerConfig& config, uint32_t level); 00144 00145 typedef dynamic_reconfigure::Server< 00146 eband_local_planner::EBandPlannerConfig> drs; 00148 boost::shared_ptr<drs> drs_; 00149 00150 // pointer to external objects (do NOT delete object) 00151 costmap_2d::Costmap2DROS* costmap_ros_; 00152 tf::TransformListener* tf_; 00153 00154 // parameters 00155 double yaw_goal_tolerance_, xy_goal_tolerance_; 00156 double rot_stopped_vel_, trans_stopped_vel_; 00157 00158 // Topics & Services 00159 ros::Publisher g_plan_pub_; 00160 ros::Publisher l_plan_pub_; 00161 ros::Subscriber odom_sub_; 00162 00163 // data 00164 nav_msgs::Odometry base_odom_; 00165 std::vector<geometry_msgs::PoseStamped> global_plan_; // plan as handed over from move_base or global planner 00166 std::vector<geometry_msgs::PoseStamped> transformed_plan_; // plan transformed into the map frame we are working in 00167 std::vector<int> plan_start_end_counter_; // stores which number start and end frame of the transformed plan have inside the global plan 00168 00169 // pointer to locally created objects (delete - except for smart-ptrs:) 00170 boost::shared_ptr<EBandPlanner> eband_; 00171 boost::shared_ptr<EBandVisualization> eband_visual_; 00172 boost::shared_ptr<EBandTrajectoryCtrl> eband_trj_ctrl_; 00173 00174 bool goal_reached_; 00175 00176 // flags 00177 bool initialized_; 00178 boost::mutex odom_mutex_; // mutex to lock odometry-callback while data is read from topic 00179 00180 00181 // methods 00182 00187 void odomCallback(const nav_msgs::Odometry::ConstPtr& msg); 00188 00189 }; 00190 }; 00191 #endif 00192 00193