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