Fawkes API  Fawkes Development Version
move_base_thread.h
1 
2 /***************************************************************************
3  * move_base_thread.h - Emulate ROS move_base
4  *
5  * Created: Wed May 07 13:48:59 2014
6  * Copyright 2014 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __ROS_MOVE_BASE_THREAD_H_
23 #define __ROS_MOVE_BASE_THREAD_H_
24 
25 #include <core/threading/thread.h>
26 #include <aspect/blocked_timing.h>
27 #include <aspect/logging.h>
28 #include <aspect/blackboard.h>
29 #include <aspect/configurable.h>
30 #include <aspect/tf.h>
31 #include <plugins/ros/aspect/ros.h>
32 
33 #include <interfaces/NavigatorInterface.h>
34 
35 #include <tf/types.h>
36 #include <cmath>
37 #include <ros/ros.h>
38 #include <move_base_msgs/MoveBaseAction.h>
39 #include <move_base_msgs/MoveBaseGoal.h>
40 #include <move_base_msgs/MoveBaseActionGoal.h>
41 #include <actionlib/server/simple_action_server.h>
42 
43 namespace fawkes {
44  class NavigatorInterface;
45 }
46 
48 : public fawkes::Thread,
50  public fawkes::LoggingAspect,
54  public fawkes::ROSAspect
55 {
56  public:
58 
59  /* thread */
60  virtual void init();
61  virtual void finalize();
62  virtual void once();
63  virtual void loop();
64 
65  private:
66  typedef enum {
67  NAVGRAPH,
68  COLLI
69  } ExecType;
70 
71  typedef actionlib::ActionServer<move_base_msgs::MoveBaseAction> MoveBaseServer;
72 
73  void action_goal_cb(MoveBaseServer::GoalHandle goal, ExecType ext);
74  void action_cancel_cb(MoveBaseServer::GoalHandle goal);
75  void message_cb(geometry_msgs::PoseStampedConstPtr goal_pose, ExecType ext);
76 
77  void stop();
78  move_base_msgs::MoveBaseResult create_result();
79  move_base_msgs::MoveBaseFeedback create_feedback();
80 
81 
82  private:
83  fawkes::NavigatorInterface *nav_navgraph_if_;
84  fawkes::NavigatorInterface *nav_colli_if_;
86 
87  MoveBaseServer *as_colli_;
88  MoveBaseServer *as_navgraph_;
89  ros::Subscriber sub_colli_;
90  ros::Subscriber sub_navgraph_;
91 
92  MoveBaseServer::GoalHandle as_goal_;
93  geometry_msgs::PoseStamped goal_pose_;
94 
95  std::string cfg_base_frame_;
96  std::string cfg_fixed_frame_;
97 
98  bool exec_as_;
99  bool exec_request_;
100  bool exec_running_;
101  ExecType exec_type_;
102  unsigned int exec_msgid_;
103 };
104 
105 #endif /* __ROS_NAVIGATOR_THREAD_H_ */
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Accept locomotion commands from ROS (emulate move_base).
Thread aspect to access the transform system.
Definition: tf.h:42
Thread aspect to use blocked timing.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
NavigatorInterface Fawkes BlackBoard Interface.