Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_KATANA_ACT_THREAD_H_
24 #define __PLUGINS_KATANA_ACT_THREAD_H_
25 
26 #include "motion_thread.h"
27 #include "calib_thread.h"
28 #include "goto_thread.h"
29 #include "goto_openrave_thread.h"
30 #include "gripper_thread.h"
31 #include "sensacq_thread.h"
32 #include "motor_control_thread.h"
33 
34 #include <core/threading/thread.h>
35 #include <aspect/clock.h>
36 #include <aspect/blocked_timing.h>
37 #include <aspect/logging.h>
38 #include <aspect/configurable.h>
39 #include <aspect/blackboard.h>
40 #include <aspect/tf.h>
41 #ifdef HAVE_OPENRAVE
42 # include <plugins/openrave/aspect/openrave.h>
43 #endif
44 #include <blackboard/interface_listener.h>
45 #include <core/utils/refptr.h>
46 #ifdef USE_TIMETRACKER
47 # include <utils/time/tracker.h>
48 #endif
49 #include <string>
50 #include <memory>
51 
52 namespace fawkes {
53  class KatanaInterface;
54  class Time;
55  class KatanaController;
56 }
57 
59 : public fawkes::Thread,
60  public fawkes::ClockAspect,
62  public fawkes::LoggingAspect,
66 #ifdef HAVE_OPENRAVE
68 #endif
70 {
71  public:
74 
75  virtual void init();
76  virtual void finalize();
77  virtual void once();
78  virtual void loop();
79 
80  // For BlackBoardInterfaceListener
81  virtual bool bb_interface_message_received(fawkes::Interface *interface,
82  fawkes::Message *message) throw();
83 
84  void update_sensor_values();
85 
86  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
87  protected: virtual void run() { Thread::run(); }
88 
89  private:
90  void stop_motion();
91  void update_position(bool refresh);
92  void update_sensors(bool refresh);
93  void update_motors(bool refresh);
94  void start_motion(fawkes::RefPtr<KatanaMotionThread> motion_thread,
95  unsigned int msgid, const char *logmsg, ...);
96 
97  private:
98  fawkes::KatanaInterface *__katana_if;
99 
100  std::string __cfg_controller;
101  std::string __cfg_device;
102  std::string __cfg_kni_conffile;
103  bool __cfg_auto_calibrate;
104  unsigned int __cfg_defmax_speed;
105  unsigned int __cfg_read_timeout;
106  unsigned int __cfg_write_timeout;
107  unsigned int __cfg_gripper_pollint;
108  unsigned int __cfg_goto_pollint;
109  float __cfg_park_x;
110  float __cfg_park_y;
111  float __cfg_park_z;
112  float __cfg_park_phi;
113  float __cfg_park_theta;
114  float __cfg_park_psi;
115 
116  float __cfg_distance_scale;
117 
118  float __cfg_update_interval;
119 
120  std::string __cfg_frame_kni;
121  std::string __cfg_frame_openrave;
122 
123  bool __cfg_OR_enabled;
124  bool __cfg_OR_use_viewer;
125  bool __cfg_OR_auto_load_ik;
126  std::string __cfg_OR_robot_file;
127  std::string __cfg_OR_arm_model;
128 
129 
130  std::auto_ptr<KatanaSensorAcquisitionThread> __sensacq_thread;
131  fawkes::RefPtr<KatanaMotionThread> __actmot_thread;
133  fawkes::RefPtr<KatanaGotoThread> __goto_thread;
134  fawkes::RefPtr<KatanaGripperThread> __gripper_thread;
135  fawkes::RefPtr<KatanaMotorControlThread> __motor_control_thread;
136 #ifdef HAVE_OPENRAVE
137  fawkes::RefPtr<KatanaGotoOpenRaveThread> __goto_openrave_thread;
138 #endif
139 
141 
142  fawkes::Time *__last_update;
143 
144 #ifdef USE_TIMETRACKER
145  std::auto_ptr<fawkes::TimeTracker> __tt;
146  unsigned int __tt_count;
147  unsigned int __ttc_read_sensor;
148 #endif
149 };
150 
151 
152 #endif