00001 #ifndef SEARCHPLANNER_H 00002 #define SEARCHPLANNER_H 00003 00004 #include <stdlib.h> /* srand, rand */ 00005 #include <time.h> /* time */ 00006 00007 #include <ros/ros.h> 00008 #include <yaml-cpp/yaml.h> 00009 #include <vector> 00010 #include <string> 00011 #include <geometry_msgs/PoseStamped.h> 00012 #include <geometry_msgs/PoseWithCovarianceStamped.h> 00013 #include <move_base_msgs/MoveBaseAction.h> 00014 #include <actionlib/client/simple_action_client.h> 00015 #include <actionlib/client/terminal_state.h> 00016 00017 #include "bwi_kr_execution/ExecutePlanAction.h" 00018 00019 #define PI (3.1415926) 00020 typedef actionlib::SimpleActionClient<bwi_kr_execution::ExecutePlanAction> KrClient; 00021 00022 class SearchPlannerSimple { 00023 00024 public: 00025 00026 SearchPlannerSimple() {}; 00027 SearchPlannerSimple(ros::NodeHandle *nh); 00028 00029 bool moveToNextDoor(); 00030 00031 bool cancelCurrentGoal(); 00032 00033 bool busy; 00034 00035 protected: 00036 00037 ros::NodeHandle *nh; 00038 KrClient *client; 00039 00040 private: 00041 00042 std::vector<std::string> doors; 00043 int goal_door; 00044 00045 }; 00046 00047 class SearchPlanner : public SearchPlannerSimple { 00048 public: 00049 00050 SearchPlanner() {}; 00051 SearchPlanner(ros::NodeHandle *nh, std::string path_to_yaml, float goal_tolerance); 00052 00053 std::vector<geometry_msgs::PoseStamped> positions; 00054 std::vector<float> belief; 00055 00056 ros::ServiceClient client_make_plan; 00057 ros::Publisher pub_simple_goal; 00058 ros::Subscriber sub_amcl_pose; 00059 00060 // ros::NodeHandle *nh; 00061 00062 geometry_msgs::PoseStamped next_goal; 00063 00064 bool targetDetected; 00065 float tolerance; 00066 00067 void setTargetDetection(bool detected) { 00068 targetDetected = detected; 00069 } 00070 bool getTargetDetection() { return targetDetected; } 00071 00072 geometry_msgs::PoseWithCovarianceStamped getCurrPosition(); 00073 00074 geometry_msgs::PoseStamped selectNextScene(const std::vector<float> &b, int &next_goal_index); 00075 void moveToNextScene(const geometry_msgs::PoseStamped &next_goal); 00076 void analyzeScene(float angle, float angular_vel); 00077 void updateBelief(int ); 00078 00079 }; 00080 00081 #endif