Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
controller_openrave.h
1 
2 /***************************************************************************
3  * controller_openrave.h - OpenRAVE Controller class for katana arm
4  *
5  * Created: Sat Jan 07 16:10:54 2012
6  * Copyright 2012 Bahram Maleki-Fard, AllemaniACs RoboCup Team
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_CONTROLLER_OPENRAVE_H_
24 #define __PLUGINS_KATANA_CONTROLLER_OPENRAVE_H_
25 
26 #include "controller.h"
27 
28 #include <core/utils/refptr.h>
29 #include <plugins/openrave/aspect/openrave.h>
30 
31 #ifdef HAVE_OPENRAVE
32 #include <openrave/openrave.h>
33 #endif
34 
35 #include <string>
36 #include <memory>
37 #include <vector>
38 
39 
40 namespace fawkes {
41 #if 0 /* just to make Emacs auto-indent happy */
42 }
43 #endif
44 
46 {
47 #ifdef HAVE_OPENRAVE
48  public:
50  virtual ~KatanaControllerOpenrave();
51 
52  // setup
53  virtual void init();
54  virtual void set_max_velocity(unsigned int vel);
55 
56  // status checking
57  virtual bool final();
58  virtual bool joint_angles();
59  virtual bool joint_encoders();
60 
61  // commands
62  virtual void calibrate();
63  virtual void stop();
64  virtual void turn_on();
65  virtual void turn_off();
66  virtual void read_coordinates(bool refresh = false);
67  virtual void read_motor_data();
68  virtual void read_sensor_data();
69  virtual void gripper_open(bool blocking = false);
70  virtual void gripper_close(bool blocking = false);
71  virtual void move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking = false);
72  virtual void move_to(std::vector<int> encoders, bool blocking = false);
73  virtual void move_to(std::vector<float> angles, bool blocking = false);
74  virtual void move_motor_to(unsigned short id, int enc, bool blocking = false);
75  virtual void move_motor_to(unsigned short id, float angle, bool blocking = false);
76  virtual void move_motor_by(unsigned short id, int enc, bool blocking = false);
77  virtual void move_motor_by(unsigned short id, float angle, bool blocking = false);
78 
79  // getters
80  virtual double x();
81  virtual double y();
82  virtual double z();
83  virtual double phi();
84  virtual double theta();
85  virtual double psi();
86  virtual void get_sensors(std::vector<int>& to, bool refresh = false);
87  virtual void get_encoders(std::vector<int>& to, bool refresh = false);
88  virtual void get_angles(std::vector<float>& to, bool refresh = false);
89 
90  private:
91  double __x, __y, __z;
92  double __phi, __theta, __psi;
93 
94  fawkes::OpenRaveConnector* __openrave;
96  fawkes::OpenRaveRobot* __OR_robot;
97  fawkes::OpenRaveManipulator* __OR_manip;
98  OpenRAVE::EnvironmentBasePtr __env;
99  OpenRAVE::RobotBasePtr __robot;
100  OpenRAVE::RobotBase::ManipulatorPtr __manip;
101 
102  bool __initialized;
103 
104  std::vector<short> __active_motors;
105 
106  void update_manipulator();
107  void wait_finished();
108  void check_init();
109 
110  bool motor_oor(unsigned short id);
111 #endif //HAVE_OPENRAVE
112 };
113 
114 
115 } // end of namespace fawkes
116 
117 #endif
Abstract class for a Neuronics Katana controller.
Definition: controller.h:37
OpenRAVE Robot class.
Definition: robot.h:41
OpenRaveEnvironment class.
Definition: environment.h:45
Controller class for a Neuronics Katana, using libkni to interact with the real Katana arm...
Class containing information about all manipulator motors.
Definition: manipulator.h:35
Interface for a OpenRave connection creator.