Fawkes API  Fawkes Development Version
act_thread.h
1 
2 /***************************************************************************
3  * act_thread.h - Katana plugin act thread
4  *
5  * Created: Mon Jun 08 17:59:57 2009
6  * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7  * 2010-2014 Bahram Maleki-Fard
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #ifndef __PLUGINS_KATANA_ACT_THREAD_H_
25 #define __PLUGINS_KATANA_ACT_THREAD_H_
26 
27 #include <core/threading/thread.h>
28 #include <aspect/clock.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <aspect/blackboard.h>
33 #include <aspect/tf.h>
34 #ifdef HAVE_OPENRAVE
35 # include <plugins/openrave/aspect/openrave.h>
36 #endif
37 #include <blackboard/interface_listener.h>
38 #include <core/utils/refptr.h>
39 #ifdef USE_TIMETRACKER
40 # include <utils/time/tracker.h>
41 #endif
42 #include <string>
43 #include <memory>
44 #include <vector>
45 
46 namespace fawkes {
47  class KatanaInterface;
48  class JointInterface;
49  class Time;
50  class KatanaController;
51 }
52 
54 class KatanaMotionThread;
56 class KatanaGotoThread;
60 
62 : public fawkes::Thread,
63  public fawkes::ClockAspect,
65  public fawkes::LoggingAspect,
69 #ifdef HAVE_OPENRAVE
71 #endif
73 {
74  public:
76  ~KatanaActThread();
77 
78  virtual void init();
79  virtual void finalize();
80  virtual void once();
81  virtual void loop();
82 
83  // For BlackBoardInterfaceListener
84  virtual bool bb_interface_message_received(fawkes::Interface *interface,
85  fawkes::Message *message) throw();
86 
87  void update_sensor_values();
88 
89  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
90  protected: virtual void run() { Thread::run(); }
91 
92  private:
93  void stop_motion();
94  void update_position(bool refresh);
95  void update_sensors(bool refresh);
96  void update_motors(bool refresh);
97  void start_motion(fawkes::RefPtr<KatanaMotionThread> motion_thread,
98  unsigned int msgid, const char *logmsg, ...);
99 
100  private:
101  fawkes::KatanaInterface *__katana_if;
102  std::vector<fawkes::JointInterface*> *__joint_ifs;
103 
104  std::string __cfg_controller;
105  std::string __cfg_device;
106  std::string __cfg_kni_conffile;
107  bool __cfg_auto_calibrate;
108  unsigned int __cfg_defmax_speed;
109  unsigned int __cfg_read_timeout;
110  unsigned int __cfg_write_timeout;
111  unsigned int __cfg_gripper_pollint;
112  unsigned int __cfg_goto_pollint;
113  float __cfg_park_x;
114  float __cfg_park_y;
115  float __cfg_park_z;
116  float __cfg_park_phi;
117  float __cfg_park_theta;
118  float __cfg_park_psi;
119 
120  float __cfg_distance_scale;
121 
122  float __cfg_update_interval;
123 
124  std::string __cfg_frame_kni;
125  std::string __cfg_frame_gripper;
126  std::string __cfg_frame_openrave;
127 
128  bool __cfg_OR_enabled;
129 #ifdef HAVE_OPENRAVE
130  bool __cfg_OR_use_viewer;
131  bool __cfg_OR_auto_load_ik;
132  std::string __cfg_OR_robot_file;
133  std::string __cfg_OR_arm_model;
134 #endif
135 
137  fawkes::RefPtr<KatanaMotionThread> __actmot_thread;
139  fawkes::RefPtr<KatanaGotoThread> __goto_thread;
140  fawkes::RefPtr<KatanaGripperThread> __gripper_thread;
141  fawkes::RefPtr<KatanaMotorControlThread> __motor_control_thread;
142 #ifdef HAVE_OPENRAVE
143  fawkes::RefPtr<KatanaGotoOpenRaveThread> __goto_openrave_thread;
144 #endif
145 
147 
148  fawkes::Time *__last_update;
149 
150 #ifdef USE_TIMETRACKER
152  unsigned int __tt_count;
153  unsigned int __ttc_read_sensor;
154 #endif
155 };
156 
157 
158 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Fawkes library namespace.
Katana motor control thread.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: act_thread.h:90
A class for handling time.
Definition: time.h:91
Katana motion thread base class.
Definition: motion_thread.h:35
Thread class encapsulation of pthreads.
Definition: thread.h:42
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: openrave.h:35
Thread aspect to access the transform system.
Definition: tf.h:42
Thread aspect to use blocked timing.
Katana act thread.
Definition: act_thread.h:61
KatanaInterface Fawkes BlackBoard Interface.
Katana gripper thread.
Thread aspect to log output.
Definition: logging.h:35
Katana sensor acquisition thread.
class KatanaGotoOpenRaveThread
Thread aspect to access configuration data.
Definition: configurable.h:35
Katana linear goto thread.
Definition: goto_thread.h:30
Katana calibration thread.
Definition: calib_thread.h:28
BlackBoard interface listener.