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 // classes wich are parts of this pkg 00047 #include <eband_local_planner/eband_local_planner.h> 00048 #include <eband_local_planner/conversions_and_types.h> 00049 #include <eband_local_planner/eband_visualization.h> 00050 #include <eband_local_planner/eband_trajectory_controller.h> 00051 00052 // local planner specific classes which provide some macros 00053 #include <base_local_planner/goal_functions.h> 00054 00055 // msgs 00056 #include <nav_msgs/Path.h> 00057 #include <nav_msgs/Odometry.h> 00058 #include <geometry_msgs/PoseStamped.h> 00059 #include <visualization_msgs/MarkerArray.h> 00060 #include <visualization_msgs/Marker.h> 00061 00062 // transforms 00063 #include <angles/angles.h> 00064 #include <tf/tf.h> 00065 #include <tf/transform_listener.h> 00066 00067 // costmap & geometry 00068 #include <costmap_2d/costmap_2d_ros.h> 00069 00070 // boost classes 00071 #include <boost/bind.hpp> 00072 #include <boost/shared_ptr.hpp> 00073 00074 00075 namespace eband_local_planner{ 00076 00081 class EBandPlannerROS : public nav_core::BaseLocalPlanner{ 00082 00083 public: 00087 EBandPlannerROS(); 00088 00095 EBandPlannerROS(std::string name, tf::TransformListener* tf, 00096 costmap_2d::Costmap2DROS* costmap_ros); 00097 00101 ~EBandPlannerROS(); 00102 00109 void initialize(std::string name, tf::TransformListener* tf, 00110 costmap_2d::Costmap2DROS* costmap_ros); 00111 00117 bool setPlan(const std::vector<geometry_msgs::PoseStamped>& orig_global_plan); 00118 00124 bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel); 00125 00130 bool isGoalReached(); 00131 00132 private: 00133 00134 // pointer to external objects (do NOT delete object) 00135 costmap_2d::Costmap2DROS* costmap_ros_; 00136 tf::TransformListener* tf_; 00137 00138 // parameters 00139 double yaw_goal_tolerance_, xy_goal_tolerance_; 00140 double rot_stopped_vel_, trans_stopped_vel_; 00141 00142 // Topics & Services 00143 ros::Publisher g_plan_pub_; 00144 ros::Publisher l_plan_pub_; 00145 ros::Subscriber odom_sub_; 00146 00147 // data 00148 nav_msgs::Odometry base_odom_; 00149 std::vector<geometry_msgs::PoseStamped> global_plan_; // plan as handed over from move_base or global planner 00150 std::vector<geometry_msgs::PoseStamped> transformed_plan_; // plan transformed into the map frame we are working in 00151 std::vector<int> plan_start_end_counter_; // stores which number start and end frame of the transformed plan have inside the global plan 00152 00153 // pointer to locally created objects (delete - except for smart-ptrs:) 00154 boost::shared_ptr<EBandPlanner> eband_; 00155 boost::shared_ptr<EBandVisualization> eband_visual_; 00156 boost::shared_ptr<EBandTrajectoryCtrl> eband_trj_ctrl_; 00157 00158 // flags 00159 bool initialized_; 00160 boost::mutex odom_mutex_; // mutex to lock odometry-callback while data is read from topic 00161 00162 00163 // methods 00164 00169 void odomCallback(const nav_msgs::Odometry::ConstPtr& msg); 00170 00171 }; 00172 }; 00173 #endif 00174 00175