Fawkes API  Fawkes Development Version
openrave_base_thread.h
1 
2 /***************************************************************************
3  * openrave_thread.h - Kinova Jaco plugin OpenRAVE base thread
4  *
5  * Created: Tue Jun 04 13:13:20 2013
6  * Copyright 2013 Bahram Maleki-Fard
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_JACO_OPENRAVE_BASE_THREAD_H_
24 #define __PLUGINS_JACO_OPENRAVE_BASE_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/logging.h>
28 #include <aspect/configurable.h>
29 #include <aspect/blackboard.h>
30 #ifdef HAVE_OPENRAVE
31  #include <plugins/openrave/aspect/openrave.h>
32 #endif
33 
34 #include <core/utils/refptr.h>
35 
36 #include "types.h"
37 
38 #include <string>
39 #include <list>
40 #include <vector>
41 
42 namespace fawkes {
43  class Mutex;
44 
45 #ifdef HAVE_OPENRAVE
46  typedef struct {
48  OpenRaveRobotPtr robot;
50  } jaco_openrave_set_t;
51 #endif
52 }
53 
55 : public fawkes::Thread,
56  public fawkes::LoggingAspect,
58 #ifdef HAVE_OPENRAVE
60 #endif
62 {
63  public:
64  JacoOpenraveBaseThread(const char *name);
65  virtual ~JacoOpenraveBaseThread();
66 
67  void init();
68  virtual void finalize();
69 
70  virtual void set_plannerparams(const std::string &params);
71  virtual void set_plannerparams(const char* params);
72 
73  /** Update the openrave environment to represent the current situation.
74  * This includes updating the model and plotting current positions.
75  */
76  virtual void update_openrave() = 0;
77 
78  /** Plot the first target of the target_queue, if it is a trajectory. */
79  virtual void plot_first() = 0;
80 
81  virtual void plot_current(bool enable);
82 
83  protected:
84  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
85  virtual void run() { Thread::run(); }
86 
87  /** Use this in inheriting classes for additiona initializations. */
88  virtual void _init() {}
89 
90  /** Use this in inheriting classes to load the OpenRaveRobot */
91  virtual void _load_robot() {}
92 
93  /** Use this in inheriting classes for post_init stuff, e.g. env-cloning */
94  virtual void _post_init() {}
95 
96  fawkes::Mutex *__planning_mutex; /**< mutex, used to lock when planning. */
97 
98 #ifdef HAVE_OPENRAVE
99  fawkes::jaco_openrave_set_t __viewer_env;
100 
101  bool __cfg_OR_use_viewer;
102  std::string __cfg_OR_robot_file;
103  bool __cfg_OR_auto_load_ik;
104  float __cfg_OR_sampling;
105  bool __cfg_OR_plot_traj_manip;
106  bool __cfg_OR_plot_traj_joints;
107  bool __cfg_OR_plot_cur_manip;
108  bool __cfg_OR_plot_cur_joints;
109 
110  std::string __plannerparams;
111  bool __plot_current;
112 #endif
113 };
114 
115 
116 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
fawkes::Mutex * __planning_mutex
mutex, used to lock when planning.
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: openrave.h:35
RefPtr< OpenRaveEnvironment > OpenRaveEnvironmentPtr
RefPtr to OpenRaveEnvironment.
virtual void _post_init()
Use this in inheriting classes for post_init stuff, e.g.
virtual void _load_robot()
Use this in inheriting classes to load the OpenRaveRobot.
RefPtr< OpenRaveManipulator > OpenRaveManipulatorPtr
RefPtr to OpenRaveManipulator.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Mutex mutual exclusion lock.
Definition: mutex.h:32
RefPtr< OpenRaveRobot > OpenRaveRobotPtr
RefPtr to OpenRaveRobot.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void _init()
Use this in inheriting classes for additiona initializations.
Base Jaco Arm thread, integrating OpenRAVE.