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 <aspect/blackboard.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <core/threading/thread.h>
30 #ifdef HAVE_OPENRAVE
31 # include <plugins/openrave/aspect/openrave.h>
32 #endif
33 
34 #include "types.h"
35 
36 #include <core/utils/refptr.h>
37 
38 #include <list>
39 #include <string>
40 #include <vector>
41 
42 namespace fawkes {
43 class Mutex;
44 
45 #ifdef HAVE_OPENRAVE
46 typedef struct
47 {
49  OpenRaveRobotPtr robot;
51 } jaco_openrave_set_t;
52 #endif
53 } // namespace fawkes
54 
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
86  run()
87  {
88  Thread::run();
89  }
90 
91  /** Use this in inheriting classes for additiona initializations. */
92  virtual void
94  {
95  }
96 
97  /** Use this in inheriting classes to load the OpenRaveRobot */
98  virtual void
100  {
101  }
102 
103  /** Use this in inheriting classes for post_init stuff, e.g. env-cloning */
104  virtual void
106  {
107  }
108 
109  fawkes::Mutex *planning_mutex_; /**< mutex, used to lock when planning. */
110 
111 #ifdef HAVE_OPENRAVE
112  fawkes::jaco_openrave_set_t viewer_env_;
113 
114  bool cfg_OR_use_viewer_;
115  std::string cfg_OR_robot_file_;
116  bool cfg_OR_auto_load_ik_;
117  float cfg_OR_sampling_;
118  bool cfg_OR_plot_traj_manip_;
119  bool cfg_OR_plot_traj_joints_;
120  bool cfg_OR_plot_cur_manip_;
121  bool cfg_OR_plot_cur_joints_;
122 
123  std::string plannerparams_;
124  bool plot_current_;
125 #endif
126 };
127 
128 #endif
virtual ~JacoOpenraveBaseThread()
Destructor.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:33
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:45
virtual void update_openrave()=0
Update the openrave environment to represent the current situation.
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: openrave.h:34
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.
const char * name() const
Get name of thread.
Definition: thread.h:100
Thread aspect to log output.
Definition: logging.h:32
virtual void plot_first()=0
Plot the first target of the target_queue, if it is a trajectory.
Thread aspect to access configuration data.
Definition: configurable.h:32
virtual void finalize()
Finalize the thread.
virtual void set_plannerparams(const std::string &params)
Set planner parameters.
fawkes::Mutex * planning_mutex_
mutex, used to lock when planning.
JacoOpenraveBaseThread(const char *name)
Constructor.
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.
virtual void plot_current(bool enable)
Enable/Disable plotting of the current arm position.
Base Jaco Arm thread, integrating OpenRAVE.