Fawkes API  Fawkes Development Version
skiller_thread.h
1 
2 /***************************************************************************
3  * skiller_thread.h - ROS Action Server to receive skiller commands from ROS
4  *
5  * Created: Fri Jun 27 12:02:42 2014
6  * Copyright 2014 Till Hofmann
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_SKILLER_THREAD_H_
23 #define __ROS_SKILLER_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 <plugins/ros/aspect/ros.h>
31 
32 #include <interfaces/SkillerInterface.h>
33 
34 
35 #include <ros/ros.h>
36 
37 #include <std_msgs/String.h>
38 #include <fawkes_msgs/ExecSkillAction.h>
39 #include <fawkes_msgs/ExecSkillGoal.h>
40 #include <fawkes_msgs/ExecSkillActionGoal.h>
41 
42 #include <actionlib/server/simple_action_server.h>
43 
44 #include <string>
45 
46 namespace fawkes {
47  class SkillerInterface;
48 }
49 
51 : public fawkes::Thread,
53  public fawkes::LoggingAspect,
56  public fawkes::ROSAspect
57 {
58  public:
60 
61  /* thread */
62  virtual void init();
63  virtual void finalize();
64  virtual void once();
65  virtual void loop();
66 
67  private:
68 
69  typedef actionlib::ActionServer<fawkes_msgs::ExecSkillAction> SkillerServer;
70 
71  void action_goal_cb(SkillerServer::GoalHandle goal);
72  void action_cancel_cb(SkillerServer::GoalHandle goal);
73  void message_cb(const std_msgs::String::ConstPtr & goal);
74 
75  void stop();
76  fawkes_msgs::ExecSkillResult create_result(std::string errmsg);
77  fawkes_msgs::ExecSkillFeedback create_feedback();
78 
79  bool assure_control();
80  void release_control();
81 
82 
83  private:
84 
85  fawkes::SkillerInterface *skiller_if_;
86 
87  SkillerServer *server_;
88  ros::Subscriber sub_cmd_;
89  ros::Publisher pub_status_;
90 
91  SkillerServer::GoalHandle as_goal_;
92  std::string goal_;
93 
94  bool exec_as_;
95  bool exec_request_;
96  bool exec_running_;
97  unsigned int exec_msgid_;
98  std::string exec_skill_string_;
99  unsigned int loops_waited_;
100 };
101 
102 #endif /* __ROS_SKILLER_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
Thread aspect to use blocked timing.
Accept skiller commands from ROS.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
SkillerInterface Fawkes BlackBoard Interface.