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 <openrave/openrave.h>
32 # include <plugins/openrave/types.h>
33 #endif
34 
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
39 namespace fawkes {
40 
41 class OpenRaveConnector;
42 
43 class KatanaControllerOpenrave : public KatanaController
44 {
45 #ifdef HAVE_OPENRAVE
46 public:
47  KatanaControllerOpenrave(fawkes::OpenRaveConnector *openrave);
48  virtual ~KatanaControllerOpenrave();
49 
50  // setup
51  virtual void init();
52  virtual void set_max_velocity(unsigned int vel);
53 
54  // status checking
55  virtual bool final();
56  virtual bool joint_angles();
57  virtual bool joint_encoders();
58 
59  // commands
60  virtual void calibrate();
61  virtual void stop();
62  virtual void turn_on();
63  virtual void turn_off();
64  virtual void read_coordinates(bool refresh = false);
65  virtual void read_motor_data();
66  virtual void read_sensor_data();
67  virtual void gripper_open(bool blocking = false);
68  virtual void gripper_close(bool blocking = false);
69  virtual void
70  move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking = false);
71  virtual void move_to(std::vector<int> encoders, bool blocking = false);
72  virtual void move_to(std::vector<float> angles, bool blocking = false);
73  virtual void move_motor_to(unsigned short id, int enc, bool blocking = false);
74  virtual void move_motor_to(unsigned short id, float angle, bool blocking = false);
75  virtual void move_motor_by(unsigned short id, int enc, bool blocking = false);
76  virtual void move_motor_by(unsigned short id, float angle, bool blocking = false);
77 
78  // getters
79  virtual double x();
80  virtual double y();
81  virtual double z();
82  virtual double phi();
83  virtual double theta();
84  virtual double psi();
85  virtual void get_sensors(std::vector<int> &to, bool refresh = false);
86  virtual void get_encoders(std::vector<int> &to, bool refresh = false);
87  virtual void get_angles(std::vector<float> &to, bool refresh = false);
88 
89 private:
90  double x_, y_, z_;
91  double phi_, theta_, psi_;
92 
93  fawkes::OpenRaveConnector * openrave_;
95  fawkes::OpenRaveRobotPtr OR_robot_;
97  OpenRAVE::EnvironmentBasePtr env_;
98  OpenRAVE::RobotBasePtr robot_;
99  OpenRAVE::RobotBase::ManipulatorPtr manip_;
100 
101  bool initialized_;
102 
103  std::vector<short> active_motors_;
104 
105  void update_manipulator();
106  void wait_finished();
107  void check_init();
108 
109  bool motor_oor(unsigned short id);
110 #endif //HAVE_OPENRAVE
111 };
112 
113 } // end of namespace fawkes
114 
115 #endif
fawkes::KatanaController::y
virtual double y()=0
Get y-coordinate of latest endeffector position.
fawkes::KatanaController::gripper_close
virtual void gripper_close(bool blocking=false)=0
Close Gripper.
fawkes::KatanaController::read_coordinates
virtual void read_coordinates(bool refresh=false)=0
Store current coordinates of endeeffctor.
fawkes::KatanaController::get_sensors
virtual void get_sensors(std::vector< int > &to, bool refresh=false)=0
Get sensor values.
fawkes::KatanaController::psi
virtual double psi()=0
Get psi-rotation of latest endeffector orientation.
fawkes::KatanaController::init
virtual void init()=0
Initialize controller.
fawkes::KatanaController::stop
virtual void stop()=0
Stop movement immediately.
fawkes::KatanaController::move_motor_by
virtual void move_motor_by(unsigned short id, int enc, bool blocking=false)=0
Move single joint/motor by encoder value (i.e.
fawkes::RefPtr
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:57
fawkes::KatanaController::turn_off
virtual void turn_off()=0
Turn off arm/motors.
fawkes::KatanaController::move_to
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.
fawkes::KatanaController::calibrate
virtual void calibrate()=0
Calibrate the arm.
fawkes::KatanaController::gripper_open
virtual void gripper_open(bool blocking=false)=0
Open Gripper.
fawkes::KatanaController::theta
virtual double theta()=0
Get theta-rotation of latest endeffector orientation.
fawkes::KatanaController::joint_angles
virtual bool joint_angles()=0
Check if controller provides joint angle values.
fawkes::KatanaController::z
virtual double z()=0
Get z-coordinate of latest endeffector position.
fawkes::KatanaController::get_encoders
virtual void get_encoders(std::vector< int > &to, bool refresh=false)=0
Get encoder values of joints/motors.
fawkes
fawkes::OpenRaveConnector
Definition: openrave_connector.h:54
fawkes::KatanaController::move_motor_to
virtual void move_motor_to(unsigned short id, int enc, bool blocking=false)=0
Move single joint/motor to encoder value.
fawkes::KatanaController::phi
virtual double phi()=0
Get x-coordinate of latest endeffector position.
fawkes::KatanaController::x
virtual double x()=0
Get x-coordinate of latest endeffector position.
fawkes::KatanaController::joint_encoders
virtual bool joint_encoders()=0
Check if controller provides joint encoder values.
fawkes::KatanaController::read_motor_data
virtual void read_motor_data()=0
Read motor data of currently active joints from device into controller libray.
fawkes::KatanaController::turn_on
virtual void turn_on()=0
Turn on arm/motors.
fawkes::KatanaController::set_max_velocity
virtual void set_max_velocity(unsigned int vel)=0
Set maximum velocity.
fawkes::KatanaController::read_sensor_data
virtual void read_sensor_data()=0
Read all sensor data from device into controller libray.
fawkes::KatanaController::get_angles
virtual void get_angles(std::vector< float > &to, bool refresh=false)=0
Get angle values of joints/motors.