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 <actionlib/server/simple_action_server.h>
26 #include <aspect/blackboard.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/configurable.h>
29 #include <aspect/logging.h>
30 #include <core/threading/thread.h>
31 #include <fawkes_msgs/ExecSkillAction.h>
32 #include <fawkes_msgs/ExecSkillActionGoal.h>
33 #include <fawkes_msgs/ExecSkillGoal.h>
34 #include <interfaces/SkillerInterface.h>
35 #include <plugins/ros/aspect/ros.h>
36 #include <ros/ros.h>
37 #include <std_msgs/String.h>
38 
39 #include <string>
40 
41 namespace fawkes {
42 class SkillerInterface;
43 }
44 
47  public fawkes::LoggingAspect,
50  public fawkes::ROSAspect
51 {
52 public:
54 
55  /* thread */
56  virtual void init();
57  virtual void finalize();
58  virtual void once();
59  virtual void loop();
60 
61 private:
62  typedef actionlib::ActionServer<fawkes_msgs::ExecSkillAction> SkillerServer;
63 
64  void action_goal_cb(SkillerServer::GoalHandle goal);
65  void action_cancel_cb(SkillerServer::GoalHandle goal);
66  void message_cb(const std_msgs::String::ConstPtr &goal);
67 
68  void stop();
69  fawkes_msgs::ExecSkillResult create_result(const std::string &errmsg);
70  fawkes_msgs::ExecSkillFeedback create_feedback();
71 
72  bool assure_control();
73  void release_control();
74 
75 private:
76  fawkes::SkillerInterface *skiller_if_;
77 
78  SkillerServer * server_;
79  ros::Subscriber sub_cmd_;
80  ros::Publisher pub_status_;
81 
82  SkillerServer::GoalHandle as_goal_;
83  std::string goal_;
84 
85  bool exec_as_;
86  bool exec_request_;
87  bool exec_running_;
88  unsigned int exec_msgid_;
89  std::string exec_skill_string_;
90  unsigned int loops_waited_;
91 };
92 
93 #endif /* ROS_SKILLER_THREAD_H__ */
RosSkillerThread::once
virtual void once()
Execute an action exactly once.
Definition: skiller_thread.cpp:82
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:56
RosSkillerThread::finalize
virtual void finalize()
Finalize the thread.
Definition: skiller_thread.cpp:71
RosSkillerThread::init
virtual void init()
Initialize the thread.
Definition: skiller_thread.cpp:43
RosSkillerThread
Definition: skiller_thread.h:45
RosSkillerThread::RosSkillerThread
RosSkillerThread()
Contructor.
Definition: skiller_thread.cpp:36
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
fawkes::ROSAspect
Definition: ros.h:38
fawkes::SkillerInterface
Definition: SkillerInterface.h:39
RosSkillerThread::loop
virtual void loop()
Code to execute in the thread.
Definition: skiller_thread.cpp:155
fawkes::Thread
Definition: thread.h:45
fawkes::ConfigurableAspect
Definition: configurable.h:38