semantic_navigator.cpp
Go to the documentation of this file.
1 /*
2  * semantic_navigator.hpp
3  * LICENSE : BSD - https://raw.github.com/yujinrobot/yujin_ocs/license/LICENSE
4  */
5 
7 
8 namespace yocs_navigator {
9 
11 : nh_(n), basic_move_(n),
12  as_navi_(nh_, SemanticNavigatorDefaultParam::AS_NAVI, false),
13  ac_move_base_(nh_, SemanticNavigatorDefaultParam::AC_MOVE_BASE, true)
14 {
16 }
17 
18 SemanticNavigator::SemanticNavigator(ros::NodeHandle& n, const std::string& as_navigator_topic, const std::string& sub_waypointlist_topic)
19 : nh_(n), basic_move_(n),
20  as_navi_(as_navigator_topic, false),
21  ac_move_base_(SemanticNavigatorDefaultParam::AC_MOVE_BASE, true)
22 {
23  sub_waypointlist_topic_= sub_waypointlist_topic;
24 }
25 
27 {
28 }
29 
31 {
32  ros::NodeHandle pnh("~");
33 
34  pnh.param("global_frame", global_frame_, std::string("map"));
35 
36  distance_to_goal_ = 0.0f;
37  waypoint_received_ = false;
39 
40  loginfo("Wait for move_base");
42 
43  loginfo("Wait for waypoint lists");
45  while(ros::ok() && !waypoint_received_) {
46  ros::spinOnce();
47  ros::Duration(0.5).sleep();
48  }
49 
50  loginfo("Initialized");
53  as_navi_.start();
54 
55  return true;
56 }
57 
58 void SemanticNavigator::processWaypointList(const yocs_msgs::WaypointList::ConstPtr& msg)
59 {
60  waypointlist_ = *msg;
61  waypoint_received_ = true;
62 }
63 
65 {
67  {
69  terminateNavigation(false, "Navigation under progress yet.. Ignoring");
70  return;
71  }
72 
75 }
76 
78 {
79  logwarn("Navigation Preemption Requested");
81 }
82 
84 {
85  ros::Rate r(2);
86 
87  init();
88 
89  while(ros::ok())
90  {
91  ros::spinOnce();
92  r.sleep();
93  }
94 }
95 
96 }
void processNavigation(yocs_msgs::NavigateToGoal::ConstPtr goal)
boost::shared_ptr< const Goal > acceptNewGoal()
yocs_msgs::WaypointList waypointlist_
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool sleep() const
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
bool param(const std::string &param_name, T &param_val, const T &default_val) const
actionlib::SimpleActionClient< move_base_msgs::MoveBaseAction > ac_move_base_
ROSCPP_DECL bool ok()
void registerPreemptCallback(boost::function< void()> cb)
void processWaypointList(const yocs_msgs::WaypointList::ConstPtr &msg)
actionlib::SimpleActionServer< yocs_msgs::NavigateToAction > as_navi_
bool sleep()
void loginfo(const std::string &msg)
Definition: utils.cpp:202
void logwarn(const std::string &msg)
Definition: utils.cpp:207
void registerGoalCallback(boost::function< void()> cb)
ROSCPP_DECL void spinOnce()
void terminateNavigation(bool success, const std::string message)
Definition: utils.cpp:24


yocs_navigator
Author(s): Jihoon Lee, Jorge Simon Santos
autogenerated on Mon Jun 10 2019 15:53:58