Fawkes API  Fawkes Development Version
goto_openrave_thread.h
1 
2 /***************************************************************************
3  * goto_openrave_thread.h - Katana goto one-time thread using openrave lib
4  *
5  * Created: Wed Jun 10 11:44:24 2009
6  * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7  * 2010 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_GOTO_OPENRAVE_THREAD_H_
25 #define __PLUGINS_KATANA_GOTO_OPENRAVE_THREAD_H_
26 
27 #include "motion_thread.h"
28 
29 #include <vector>
30 #include <string>
31 
32 #include <plugins/openrave/aspect/openrave.h>
33 
34 #ifdef HAVE_OPENRAVE
35 namespace fawkes {
36  class OpenRaveRobot;
37  class OpenRaveManipulator;
38 }
39 #endif
40 
41 /** class KatanaGotoOpenRaveThread */
43 {
44 #ifdef HAVE_OPENRAVE
45 
46  public:
48  unsigned int poll_interval_ms,
49  std::string robot_file,
50  std::string arm_model,
51  bool autoload_IK,
52  bool use_viewer);
53 
54  virtual void once();
55  virtual void init();
56  virtual void finalize();
57 
58  void set_target(float x, float y, float z, float phi, float theta, float psi);
59  void set_target(float x, float y, float z, float quat_x, float quat_y, float quat_z, float quat_w);
60  void set_target(const std::string& object_name, float rot_x);
61  void set_theta_error(float error);
62  void set_move_straight(bool move_straight);
63  void set_arm_extension(bool arm_extension);
64  void set_plannerparams(std::string& params, bool straight=false);
65  void set_plannerparams(const char* params, bool straight=false);
66 
67  virtual bool plan_target();
68  virtual void update_openrave_data();
69  virtual bool update_motor_data();
70  virtual bool move_katana();
71 
72  static const std::string DEFAULT_PLANNERPARAMS;
73  static const std::string DEFAULT_PLANNERPARAMS_STRAIGHT;
74 
75  private:
76  fawkes::OpenRaveRobot* __OR_robot;
77  fawkes::OpenRaveManipulator* __OR_manip;
78 
79  std::string __target_object;
80  std::vector< std::vector<float> >* __target_traj;
81  std::vector< std::vector<float> >::iterator __it;
82 
83  std::vector< int > __motor_encoders;
84  std::vector< float > __motor_angles;
85 
86  const std::string __cfg_robot_file;
87  const std::string __cfg_arm_model;
88  bool __cfg_autoload_IK;
89  bool __cfg_use_viewer;
90 
91  bool __is_target_object;
92  bool __has_target_quaternion;
93  bool __move_straight;
94  bool __is_arm_extension;
95  std::string __plannerparams;
96  std::string __plannerparams_straight;
97 
98  fawkes::OpenRaveConnector* _openrave;
99 
100  float __x, __y, __z;
101  float __phi, __theta, __psi, __theta_error;
102  float __quat_x, __quat_y, __quat_z, __quat_w;
103  unsigned int __poll_interval_usec;
104 
105 #endif //HAVE_OPENRAVE
106 };
107 
108 #endif
virtual void once()
Execute an action exactly once.
Definition: thread.cpp:1065
Fawkes library namespace.
Katana motion thread base class.
Definition: motion_thread.h:37
OpenRAVE Robot class.
Definition: robot.h:41
virtual void finalize()
Finalize the thread.
Definition: thread.cpp:469
Class containing information about all manipulator motors.
Definition: manipulator.h:35
class KatanaGotoOpenRaveThread
Interface for a OpenRave connection creator.
virtual void init()
Initialize the thread.
Definition: thread.cpp:346
Interface for logging.
Definition: logger.h:34