Fawkes API  Fawkes Development Version
controller.h
1 
2 /***************************************************************************
3  * controller.h - Controller class for katana arm
4  *
5  * Created: Tue Jan 03 11:40:31 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_H_
24 #define __PLUGINS_KATANA_CONTROLLER_H_
25 
26 #include <vector>
27 
28 namespace fawkes {
29 #if 0 /* just to make Emacs auto-indent happy */
30 }
31 #endif
32 
33 /** @class KatanaController <plugins/katana/controller.h>
34  * Abstract class for a Neuronics Katana controller.
35  * @author Bahram Maleki-Fard
36  */
38 {
39  public:
40  /** Virtual empty destructor. */
41  virtual ~KatanaController() {}
42 
43  // setup
44  /** Initialize controller */
45  virtual void init() = 0;
46 
47  /** Set maximum velocity.
48  * @param vel velocity
49  */
50  virtual void set_max_velocity(unsigned int vel) = 0;
51 
52 
53 
54  // status checking
55  /** Check if movement is final.
56  * @return movement is final
57  */
58  virtual bool final() = 0;
59 
60  /** Check if controller provides joint angle values.
61  * @return can get angle values
62  */
63  virtual bool joint_angles() = 0;
64 
65  /** Check if controller provides joint encoder values.
66  * @return can get encoder values
67  */
68  virtual bool joint_encoders() = 0;
69 
70 
71 
72  // commands
73  /** Calibrate the arm. */
74  virtual void calibrate() = 0;
75 
76  /** Turn on arm/motors. */
77  virtual void turn_on() = 0;
78 
79  /** Turn off arm/motors. */
80  virtual void turn_off() = 0;
81 
82  /** Stop movement immediately. */
83  virtual void stop() = 0;
84 
85  /** Store current coordinates of endeeffctor.
86  * @param refresh fetch new joint data from device (update data in controller library).
87  * No need to set to 'true' if 'read_motor_data()' is being called regularly.
88  */
89  virtual void read_coordinates(bool refresh = false) = 0;
90 
91  /** Read motor data of currently active joints from device into controller libray. */
92  virtual void read_motor_data() = 0;
93 
94  /** Read all sensor data from device into controller libray. */
95  virtual void read_sensor_data() = 0;
96 
97  /** Open Gripper.
98  * @param blocking Is this a blocking call?
99  */
100  virtual void gripper_open(bool blocking = false) = 0;
101 
102  /** Close Gripper.
103  * @param blocking Is this a blocking call?
104  */
105  virtual void gripper_close(bool blocking = false) = 0;
106 
107  /** Move endeffctor to given coordinates.
108  * @param x translation on x-axis.
109  * @param y translation on y-axis.
110  * @param z translation on z-axis.
111  * @param phi 1st rotation of euler-ZXZ-rotation
112  * @param theta 2nd rotation of euler-ZXZ-rotation
113  * @param psi 3rd rotation of euler-ZXZ-rotation
114  * @param blocking Is this a blocking call?
115  */
116  virtual void move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking = false) = 0;
117 
118  /** Move joints to encoder values.
119  * @param encoders vector containing encoder values for all joints.
120  * @param blocking Is this a blocking call?
121  */
122  virtual void move_to(std::vector<int> encoders, bool blocking = false) = 0;
123 
124  /** Move joints to angle values.
125  * @param angles vector containing angle values for all joints.
126  * @param blocking Is this a blocking call?
127  */
128  virtual void move_to(std::vector<float> angles, bool blocking = false) = 0;
129 
130  /** Move single joint/motor to encoder value.
131  * @param id id of the joint/motor.
132  * @param enc target encoder value.
133  * @param blocking Is this a blocking call?
134  */
135  virtual void move_motor_to(unsigned short id, int enc, bool blocking = false) = 0;
136 
137  /** Move single joint/motor to angle value.
138  * @param id id of the joint/motor.
139  * @param angle target angle value.
140  * @param blocking Is this a blocking call?
141  */
142  virtual void move_motor_to(unsigned short id, float angle, bool blocking = false) = 0;
143 
144  /** Move single joint/motor by encoder value (i.e. increase/decrease).
145  * @param id id of the joint/motor.
146  * @param enc increase/decrease by encoder value.
147  * @param blocking Is this a blocking call?
148  */
149  virtual void move_motor_by(unsigned short id, int enc, bool blocking = false) = 0;
150 
151  /** Move single joint/motor by angle value (i.e. increase/decrease).
152  * @param id id of the joint/motor.
153  * @param angle increase/decrease by angle value.
154  * @param blocking Is this a blocking call?
155  */
156  virtual void move_motor_by(unsigned short id, float angle, bool blocking = false) = 0;
157 
158 
159 
160 
161  // getters
162  /** Get x-coordinate of latest endeffector position.
163  * Call 'read_coordinates()' to read latest position.
164  * @return x-coordinate
165  */
166  virtual double x() = 0;
167 
168  /** Get y-coordinate of latest endeffector position.
169  * Call 'read_coordinates()' to read latest position.
170  * @return y-coordinate
171  */
172  virtual double y() = 0;
173 
174  /** Get z-coordinate of latest endeffector position.
175  * Call 'read_coordinates()' to read latest position.
176  * @return z-coordinate
177  */
178  virtual double z() = 0;
179 
180  /** Get x-coordinate of latest endeffector position.
181  * Call 'read_coordinates()' to read latest position.
182  * @return x-coordinate
183  */
184 
185  /** Get phi-rotation of latest endeffector orientation.
186  * Call 'read_coordinates()' to read latest orientation.
187  * @return phi-rotation (1st rotation of euler-ZXZ-rotation)
188  */
189  virtual double phi() = 0;
190 
191  /** Get theta-rotation of latest endeffector orientation.
192  * Call 'read_coordinates()' to read latest orientation.
193  * @return theta-rotation (2nd rotation of euler-ZXZ-rotation)
194  */
195  virtual double theta() = 0;
196 
197  /** Get psi-rotation of latest endeffector orientation.
198  * Call 'read_coordinates()' to read latest orientation.
199  * @return psi-rotation (3rd rotation of euler-ZXZ-rotation)
200  */
201  virtual double psi() = 0;
202 
203  /** Get sensor values.
204  * @param to vector to be filled with all available sensor values.
205  * @param refresh refresh sensor data (call 'read_sensor_data')?
206  */
207  virtual void get_sensors(std::vector<int>& to, bool refresh = false) = 0;
208 
209  /** Get encoder values of joints/motors.
210  * @param to vector to be filled with encoder values for active joints.
211  * @param refresh refresh joints/motors data (call 'read_motor_data')?
212  */
213  virtual void get_encoders(std::vector<int>& to, bool refresh = false) = 0;
214 
215  /** Get angle values of joints/motors.
216  * @param to vector to be filled with angle values for active joints.
217  * @param refresh refresh joints/motors data (call 'read_motor_data')?
218  */
219  virtual void get_angles(std::vector<float>& to, bool refresh = false) = 0;
220 
221 
222 };
223 
224 
225 } // end of namespace fawkes
226 
227 #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.
virtual ~KatanaController()
Virtual empty destructor.
Definition: controller.h:41
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.
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.
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.