00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2008, Robert Bosch LLC. 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 Robert Bosch 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 *********************************************************************/ 00036 #ifndef NAV_EXPLORE_H_ 00037 #define NAV_EXPLORE_H_ 00038 00039 #include <ros/ros.h> 00040 #include <move_base_msgs/MoveBaseAction.h> 00041 #include <actionlib/client/simple_action_client.h> 00042 #include <geometry_msgs/PoseStamped.h> 00043 #include <nav_msgs/GetMap.h> 00044 #include <costmap_2d/costmap_2d_ros.h> 00045 #include <costmap_2d/costmap_2d.h> 00046 #include <navfn/navfn_ros.h> 00047 #include <explore/explore_frontier.h> 00048 #include <explore/loop_closure.h> 00049 #include <visualization_msgs/MarkerArray.h> 00050 #include <vector> 00051 #include <string> 00052 #include <boost/thread/mutex.hpp> 00053 00054 00055 namespace explore { 00056 00061 class Explore { 00062 public: 00067 Explore(); 00068 00072 virtual ~Explore(); 00073 00080 // virtual robot_actions::ResultStatus execute(const ExploreGoal& goal, ExploreFeedback& feedback); 00081 void execute(); 00082 00083 void spin(); 00084 00085 private: 00089 void makePlan(); 00090 00095 void publishGoal(const geometry_msgs::Pose& goal); 00096 00100 void publishMap(); 00101 00102 void reachedGoal(const actionlib::SimpleClientGoalState& status, const move_base_msgs::MoveBaseResultConstPtr& result, geometry_msgs::PoseStamped frontier_goal); 00103 00107 // void resetCostmaps(double size_x, double size_y); 00108 00109 bool mapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res); 00110 00111 bool goalOnBlacklist(const geometry_msgs::PoseStamped& goal); 00112 00113 ros::NodeHandle node_; 00114 tf::TransformListener tf_; 00115 costmap_2d::Costmap2DROS* explore_costmap_ros_; 00116 00117 actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> move_base_client_; 00118 00119 navfn::NavfnROS* planner_; 00120 std::string robot_base_frame_; 00121 bool done_exploring_; 00122 00123 ros::Publisher marker_publisher_; 00124 ros::Publisher marker_array_publisher_; 00125 ros::Publisher map_publisher_; 00126 ros::ServiceServer map_server_; 00127 00128 ExploreFrontier* explorer_; 00129 00130 tf::Stamped<tf::Pose> global_pose_; 00131 double planner_frequency_; 00132 int visualize_; 00133 LoopClosure* loop_closure_; 00134 std::vector<geometry_msgs::PoseStamped> frontier_blacklist_; 00135 geometry_msgs::PoseStamped prev_goal_; 00136 unsigned int prev_plan_size_; 00137 double time_since_progress_, progress_timeout_; 00138 double potential_scale_, orientation_scale_, gain_scale_; 00139 boost::mutex client_mutex_; 00140 bool close_loops_; 00141 }; 00142 00143 } 00144 00145 #endif 00146