Fawkes API  Fawkes Development Version
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-2014 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_KATANA_CONTROLLER_OPENRAVE_H_
24 #define __PLUGINS_KATANA_CONTROLLER_OPENRAVE_H_
25 
26 #include "controller.h"
27 
28 #include <core/utils/refptr.h>
29 
30 #ifdef HAVE_OPENRAVE
31 #include <plugins/openrave/types.h>
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 
45 class OpenRaveConnector;
46 
48 {
49 #ifdef HAVE_OPENRAVE
50  public:
52  virtual ~KatanaControllerOpenrave();
53 
54  // setup
55  virtual void init();
56  virtual void set_max_velocity(unsigned int vel);
57 
58  // status checking
59  virtual bool final();
60  virtual bool joint_angles();
61  virtual bool joint_encoders();
62 
63  // commands
64  virtual void calibrate();
65  virtual void stop();
66  virtual void turn_on();
67  virtual void turn_off();
68  virtual void read_coordinates(bool refresh = false);
69  virtual void read_motor_data();
70  virtual void read_sensor_data();
71  virtual void gripper_open(bool blocking = false);
72  virtual void gripper_close(bool blocking = false);
73  virtual void move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking = false);
74  virtual void move_to(std::vector<int> encoders, bool blocking = false);
75  virtual void move_to(std::vector<float> angles, bool blocking = false);
76  virtual void move_motor_to(unsigned short id, int enc, bool blocking = false);
77  virtual void move_motor_to(unsigned short id, float angle, bool blocking = false);
78  virtual void move_motor_by(unsigned short id, int enc, bool blocking = false);
79  virtual void move_motor_by(unsigned short id, float angle, bool blocking = false);
80 
81  // getters
82  virtual double x();
83  virtual double y();
84  virtual double z();
85  virtual double phi();
86  virtual double theta();
87  virtual double psi();
88  virtual void get_sensors(std::vector<int>& to, bool refresh = false);
89  virtual void get_encoders(std::vector<int>& to, bool refresh = false);
90  virtual void get_angles(std::vector<float>& to, bool refresh = false);
91 
92  private:
93  double __x, __y, __z;
94  double __phi, __theta, __psi;
95 
96  fawkes::OpenRaveConnector* __openrave;
98  fawkes::OpenRaveRobotPtr __OR_robot;
100  OpenRAVE::EnvironmentBasePtr __env;
101  OpenRAVE::RobotBasePtr __robot;
102  OpenRAVE::RobotBase::ManipulatorPtr __manip;
103 
104  bool __initialized;
105 
106  std::vector<short> __active_motors;
107 
108  void update_manipulator();
109  void wait_finished();
110  void check_init();
111 
112  bool motor_oor(unsigned short id);
113 #endif //HAVE_OPENRAVE
114 };
115 
116 
117 } // end of namespace fawkes
118 
119 #endif
virtual void init()=0
Initialize controller.
virtual void read_motor_data()=0
Read motor data of currently active joints from device into controller libray.
virtual double y()=0
Get y-coordinate of latest endeffector position.
virtual void move_motor_to(unsigned short id, int enc, bool blocking=false)=0
Move single joint/motor to encoder value.
virtual void gripper_close(bool blocking=false)=0
Close Gripper.
virtual void get_angles(std::vector< float > &to, bool refresh=false)=0
Get angle values of joints/motors.
Fawkes library namespace.
virtual double theta()=0
Get theta-rotation of latest endeffector orientation.
virtual void read_sensor_data()=0
Read all sensor data from device into controller libray.
virtual double z()=0
Get z-coordinate of latest endeffector position.
Abstract class for a Neuronics Katana controller.
Definition: controller.h:37
virtual void read_coordinates(bool refresh=false)=0
Store current coordinates of endeeffctor.
virtual void turn_on()=0
Turn on arm/motors.
virtual bool joint_angles()=0
Check if controller provides joint angle values.
Controller class for a Neuronics Katana, using libkni to interact with the real Katana arm...
virtual void move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking=false)=0
Move endeffctor to given coordinates.
virtual double x()=0
Get x-coordinate of latest endeffector position.
virtual void get_sensors(std::vector< int > &to, bool refresh=false)=0
Get sensor values.
virtual void calibrate()=0
Calibrate the arm.
virtual void turn_off()=0
Turn off arm/motors.
virtual void move_motor_by(unsigned short id, int enc, bool blocking=false)=0
Move single joint/motor by encoder value (i.e.
Interface for a OpenRave connection creator.
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:49
virtual double psi()=0
Get psi-rotation of latest endeffector orientation.
virtual bool joint_encoders()=0
Check if controller provides joint encoder values.
virtual void set_max_velocity(unsigned int vel)=0
Set maximum velocity.
virtual double phi()=0
Get x-coordinate of latest endeffector position.
virtual void gripper_open(bool blocking=false)=0
Open Gripper.
virtual void stop()=0
Stop movement immediately.
virtual void get_encoders(std::vector< int > &to, bool refresh=false)=0
Get encoder values of joints/motors.