semantic_navigator.hpp
Go to the documentation of this file.
00001 /*
00002  *  semantic_navigator.hpp
00003  *  LICENSE : BSD - https://raw.github.com/yujinrobot/yujin_ocs/license/LICENSE
00004  */
00005 
00006 #include <ros/ros.h>
00007 #include <actionlib/client/simple_action_client.h>
00008 #include <actionlib/server/simple_action_server.h>
00009 
00010 #include <move_base_msgs/MoveBaseAction.h>
00011 #include <yocs_msgs/NavigateToAction.h>
00012 #include <yocs_msgs/WaypointList.h>
00013 #include <geometry_msgs/PoseStamped.h>
00014 #include <std_srvs/Empty.h>
00015 
00016 #include "yocs_navigator/default_params.h"
00017 #include "yocs_navigator/basic_move_controller.hpp"
00018 
00019 #ifndef _YOCS_SEMANTIC_NAVIGATOR_HPP_
00020 #define _YOCS_SEMANTIC_NAVIGATOR_HPP_
00021 
00022 namespace yocs_navigator {
00023 
00024 class SemanticNavigator {
00025   public:
00026     SemanticNavigator(ros::NodeHandle& n);
00027     SemanticNavigator(ros::NodeHandle& n, const std::string& as_navigator_topic, const std::string& sub_waypointlist_topic);
00028     virtual ~SemanticNavigator();
00029     bool init();
00030     void spin();
00031     void loginfo(const std::string& msg);
00032     void logwarn(const std::string& msg);
00033   protected:
00034     void processWaypointList(const yocs_msgs::WaypointList::ConstPtr& msg);
00035     void processNavigateToGoal();
00036     void processPreemptNavigateTo();
00037 
00038     void processNavigation(yocs_msgs::NavigateToGoal::ConstPtr goal);
00039 
00040     void terminateNavigation(bool success, const std::string message);
00041     void feedbackNavigation(const int status, const double distance, const double remain_time, const std::string message);
00042     bool getGoalLocation(const std::string location, yocs_msgs::Waypoint& waypoint);
00043 
00044     void goOn(const yocs_msgs::Waypoint waypoint, const double in_distance, const int num_retry, const double timeout);
00045       void waitForMoveBase(int& move_base_result, const ros::Time& start_time, const double timeout);
00046       void determineNavigationState(int& navi_result, const int move_base_result, const actionlib::SimpleClientGoalState  move_base_state);
00047       void nextState(bool& retry,bool& final_result,std::string& message, const int navi_result, const ros::Time started_time);
00048     void goNear(const yocs_msgs::Waypoint waypoint, const double in_distance, const int num_retry, const double timeout);
00049 
00050     void processMoveBaseFeedback(const move_base_msgs::MoveBaseFeedback::ConstPtr& feedback, const geometry_msgs::PoseStamped& target);
00051 
00052 
00053     bool cancelMoveBaseGoal();
00054 
00055     bool clearCostmaps();
00056   
00057 
00058   private:
00059     ros::NodeHandle nh_;
00060 
00061     BasicMoveController basic_move_;
00062     ros::Subscriber                                               sub_waypointlist_;
00063     actionlib::SimpleActionServer<yocs_msgs::NavigateToAction>    as_navi_;
00064     actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> ac_move_base_;
00065 
00066     std::string sub_waypointlist_topic_;
00067     std::string global_frame_;
00068 
00069     yocs_msgs::WaypointList waypointlist_;
00070     double distance_to_goal_;
00071     bool waypoint_received_;
00072     bool navigation_in_progress_;
00073     boost::thread order_process_thread_;
00074 
00075     static const int NAVI_IN_PROGRESS =14;
00076     static const int NAVI_SUCCESS     =15;
00077     static const int NAVI_RETRY       =16;
00078     static const int NAVI_FAILED      =17;
00079     static const int NAVI_TIMEOUT     =18;
00080     static const int NAVI_UNKNOWN     =19;
00081 };
00082 }
00083 
00084 #endif


yocs_navigator
Author(s): Jihoon Lee, Jorge Simon Santos
autogenerated on Thu Jun 6 2019 21:47:35