00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2008, Robert Bosch LLC. 00006 * Copyright (c) 2015-2016, Jiri Horner. 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of the Jiri Horner nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 *********************************************************************/ 00037 #ifndef NAV_EXPLORE_H_ 00038 #define NAV_EXPLORE_H_ 00039 00040 #include <vector> 00041 #include <string> 00042 #include <memory> 00043 #include <mutex> 00044 00045 #include <ros/ros.h> 00046 #include <move_base_msgs/MoveBaseAction.h> 00047 #include <actionlib/client/simple_action_client.h> 00048 #include <geometry_msgs/PoseStamped.h> 00049 #include <visualization_msgs/MarkerArray.h> 00050 00051 #include <explore/explore_frontier.h> 00052 #include <explore/costmap_client.h> 00053 00054 /* I have been using modified version of navfn for a long time here. 00055 Unfornutely my changes are affecting ABI of the component, so the can't be 00056 accepted for ROS Jade or below. I expect them be accepted for ROS Karmic. Then 00057 this should be moved back to using standard ROS navfn `<navfn/navfn_ros.h>`. 00058 For the meanwhile, to allow seamless building, I will be using internal 00059 version included from ROS. */ 00060 00061 #include <explore/navfn_ros.h> 00062 00063 namespace explore { 00064 00069 class Explore { 00070 public: 00071 Explore(); 00072 00073 void execute(); 00074 00075 void spin(); 00076 00077 private: 00081 void makePlan(); 00082 00086 void publishFrontiers(); 00087 00088 void reachedGoal( 00089 const actionlib::SimpleClientGoalState& status, 00090 const move_base_msgs::MoveBaseResultConstPtr& result, 00091 const geometry_msgs::PoseStamped& frontier_goal); 00092 00093 bool goalOnBlacklist(const geometry_msgs::PoseStamped& goal); 00094 00095 ros::NodeHandle private_nh_; 00096 ros::NodeHandle relative_nh_; 00097 ros::Publisher marker_array_publisher_; 00098 tf::TransformListener tf_listener_; 00099 00100 Costmap2DClient costmap_client_; 00101 navfn::NavfnROS planner_; 00102 actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> move_base_client_; 00103 ExploreFrontier explorer_; 00104 std::mutex planning_mutex_; 00105 00106 tf::Stamped<tf::Pose> global_pose_; 00107 double planner_frequency_; 00108 std::vector<geometry_msgs::PoseStamped> frontier_blacklist_; 00109 geometry_msgs::PoseStamped prev_goal_; 00110 size_t prev_plan_size_; 00111 double time_since_progress_, progress_timeout_; 00112 double potential_scale_, orientation_scale_, gain_scale_; 00113 bool done_exploring_; 00114 bool visualize_; 00115 }; 00116 00117 } 00118 00119 #endif 00120