00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2014, Austin Hendrix 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: Austin Hendrix 00036 *********************************************************************/ 00037 #ifndef DT_LOCAL_PLANNER_DT_PLANNER_ROS_H_ 00038 #define DT_LOCAL_PLANNER_DT_PLANNER_ROS_H_ 00039 00040 // SHUT UP BOOST SIGNALS 00041 #define BOOST_SIGNALS_NO_DEPRECATION_WARNING 00042 00043 #include <boost/shared_ptr.hpp> 00044 #include <boost/thread.hpp> 00045 00046 #include <tf/transform_listener.h> 00047 00048 #include <dynamic_reconfigure/server.h> 00049 #include <dt_local_planner/DTPlannerConfig.h> 00050 00051 #include <angles/angles.h> 00052 00053 #include <nav_msgs/Odometry.h> 00054 00055 #include <costmap_2d/costmap_2d_ros.h> 00056 #include <nav_core/base_local_planner.h> 00057 #include <base_local_planner/latched_stop_rotate_controller.h> 00058 00059 #include <base_local_planner/odometry_helper_ros.h> 00060 00061 namespace dt_local_planner { 00067 class DTPlannerROS : public nav_core::BaseLocalPlanner { 00068 public: 00072 DTPlannerROS(); 00073 00080 virtual void initialize(std::string name, tf::TransformListener* tf, 00081 costmap_2d::Costmap2DROS* costmap_ros); 00082 00086 virtual ~DTPlannerROS(); 00087 00094 virtual bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel); 00095 00101 virtual bool setPlan(const std::vector<geometry_msgs::PoseStamped>& orig_global_plan); 00102 00107 virtual bool isGoalReached(); 00108 00109 private: 00110 bool isInitialized() { 00111 return initialized_; 00112 } 00113 00117 void reconfigureCB(DTPlannerConfig &config, uint32_t level); 00118 00119 tf::TransformListener* tf_; 00120 00121 // for visualisation, publishers of global and local plan 00122 ros::Publisher g_plan_pub_, l_plan_pub_; 00123 00124 costmap_2d::Costmap2DROS* costmap_ros_; 00125 00126 // TODO(hendrix): shared pointer? 00127 dynamic_reconfigure::Server<DTPlannerConfig> *dsrv_; 00128 00129 bool initialized_; 00130 00131 base_local_planner::OdometryHelperRos odom_helper_; 00132 00133 std::vector<geometry_msgs::PoseStamped> plan_; 00134 double goal_x_ ; 00135 double goal_y_; 00136 00137 std::vector<double> aCoeff_x_; 00138 std::vector<double> aCoeff_y_; 00139 00140 int nPolyGrad_; 00141 int planSize_; 00142 double start_time_; 00143 double lastCall_time_; 00144 double vel_dest0_; 00145 double gamma_dest0_; 00146 00147 //controller params 00148 double K_p_; 00149 double K_d_; 00150 00151 // Limits 00152 double max_vel_; 00153 double max_ang_; 00154 double max_vel_deltaT0_; 00155 int stepCnt_max_vel_; 00156 00157 00158 // configuration 00159 bool move_; 00160 bool firstComputeVelocityCommands_; 00161 00162 // transient data 00163 00164 bool goal_reached_; 00165 }; 00166 00167 // Helper functions that don't need class context 00168 00172 bool isForwards(geometry_msgs::PoseStamped &start, 00173 geometry_msgs::PoseStamped &end); 00174 00178 double dist(geometry_msgs::PoseStamped &start, 00179 geometry_msgs::PoseStamped &end); 00180 00181 }; 00182 #endif