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  * 2011-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_GOTO_OPENRAVE_THREAD_H_
25 #define __PLUGINS_KATANA_GOTO_OPENRAVE_THREAD_H_
26 
27 #include "motion_thread.h"
28 
29 #ifdef HAVE_OPENRAVE
30  #include <plugins/openrave/types.h>
31 #endif
32 
33 #include <vector>
34 #include <string>
35 
36 namespace fawkes {
37  class OpenRaveConnector;
38 }
39 
40 /** class KatanaGotoOpenRaveThread */
42 {
43 #ifdef HAVE_OPENRAVE
44 
45  public:
47  unsigned int poll_interval_ms,
48  std::string robot_file,
49  std::string arm_model,
50  bool autoload_IK,
51  bool use_viewer);
52 
53  virtual void once();
54  virtual void init();
55  virtual void finalize();
56 
57  void set_target(float x, float y, float z, float phi, float theta, float psi);
58  void set_target(float x, float y, float z, float quat_x, float quat_y, float quat_z, float quat_w);
59  void set_target(const std::string& object_name, float rot_x);
60  void set_theta_error(float error);
61  void set_move_straight(bool move_straight);
62  void set_arm_extension(bool arm_extension);
63  void set_plannerparams(std::string& params, bool straight=false);
64  void set_plannerparams(const char* params, bool straight=false);
65 
66  virtual bool plan_target();
67  virtual void update_openrave_data();
68  virtual bool update_motor_data();
69  virtual bool move_katana();
70 
71  static const std::string DEFAULT_PLANNERPARAMS;
72  static const std::string DEFAULT_PLANNERPARAMS_STRAIGHT;
73 
74  private:
75  fawkes::OpenRaveRobotPtr __OR_robot;
77 
78  std::string __target_object;
79  std::vector< std::vector<float> >* __target_traj;
80  std::vector< std::vector<float> >::iterator __it;
81 
82  std::vector< int > __motor_encoders;
83  std::vector< float > __motor_angles;
84 
85  const std::string __cfg_robot_file;
86  const std::string __cfg_arm_model;
87  bool __cfg_autoload_IK;
88  bool __cfg_use_viewer;
89 
90  bool __is_target_object;
91  bool __has_target_quaternion;
92  bool __move_straight;
93  bool __is_arm_extension;
94  std::string __plannerparams;
95  std::string __plannerparams_straight;
96 
97  fawkes::OpenRaveConnector* _openrave;
98 
99  float __x, __y, __z;
100  float __phi, __theta, __psi, __theta_error;
101  float __quat_x, __quat_y, __quat_z, __quat_w;
102  unsigned int __poll_interval_usec;
103 
104 #endif //HAVE_OPENRAVE
105 };
106 
107 #endif
Fawkes library namespace.
Katana motion thread base class.
Definition: motion_thread.h:35
class KatanaGotoOpenRaveThread
Interface for a OpenRave connection creator.
Interface for logging.
Definition: logger.h:34