KatanaInterface.h
00001 00002 /*************************************************************************** 00003 * KatanaInterface.h - Fawkes BlackBoard Interface - KatanaInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2009 Tim Niemueller 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __INTERFACES_KATANAINTERFACE_H_ 00025 #define __INTERFACES_KATANAINTERFACE_H_ 00026 00027 #include <interface/interface.h> 00028 #include <interface/message.h> 00029 #include <interface/field_iterator.h> 00030 00031 namespace fawkes { 00032 00033 class KatanaInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(KatanaInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 static const unsigned int SENSOR_IR_RIGHT_INNER_MIDDLE; 00041 static const unsigned int SENSOR_IR_RIGHT_INNER_FRONT; 00042 static const unsigned int SENSOR_RESERVED_2; 00043 static const unsigned int SENSOR_COND_BOTH; 00044 static const unsigned int SENSOR_IR_RIGHT_OUTER_FRONT; 00045 static const unsigned int SENSOR_IR_RIGHT_BOTTOM_FRONT; 00046 static const unsigned int SENSOR_FORCE_RIGHT_REAR; 00047 static const unsigned int SENSOR_FORCE_RIGHT_FRONT; 00048 static const unsigned int SENSOR_IR_LEFT_INNER_MIDDLE; 00049 static const unsigned int SENSOR_IR_LEFT_INNER_FRONT; 00050 static const unsigned int SENSOR_RESERVED_10; 00051 static const unsigned int SENSOR_IR_CENTER_GRIPPER; 00052 static const unsigned int SENSOR_IR_LEFT_OUTER_FRONT; 00053 static const unsigned int SENSOR_IR_LEFT_BOTTOM_FRONT; 00054 static const unsigned int SENSOR_FORCE_LEFT_REAR; 00055 static const unsigned int SENSOR_FORCE_LEFT_FRONT; 00056 static const unsigned int ERROR_NONE; 00057 static const unsigned int ERROR_UNSPECIFIC; 00058 static const unsigned int ERROR_CMD_START_FAILED; 00059 static const unsigned int ERROR_NO_SOLUTION; 00060 static const unsigned int ERROR_COMMUNICATION; 00061 static const unsigned int ERROR_MOTOR_CRASHED; 00062 00063 private: 00064 /** Internal data storage, do NOT modify! */ 00065 typedef struct { 00066 unsigned int msgid; /**< The ID of the message that is currently being 00067 processed, or 0 if no message is being processed. */ 00068 unsigned int error_code; /**< Failure code set if 00069 final is true. 0 if no error occured, an error code from ERROR_* 00070 constants otherwise (or a bit-wise combination). */ 00071 float x; /**< X-Coordinate for tool position 00072 compared to base coordinate system. */ 00073 float y; /**< Y-Coordinate for tool position 00074 compared to base coordinate system. */ 00075 float z; /**< Z-Coordinate for tool position 00076 compared to base coordinate system. */ 00077 float phi; /**< Euler angle Phi of tool orientation. */ 00078 float theta; /**< Euler angle Theta of tool orientation. */ 00079 float psi; /**< Euler angle Psi of tool orientation.. */ 00080 bool final; /**< True, if the last goto command has been finished, 00081 false if it is still running */ 00082 bool enabled; /**< Are motors enabled? */ 00083 bool calibrated; /**< Has arm been calibrated? */ 00084 unsigned char sensor_value[16]; /**< Sensor 00085 values. Use SENSOR_* indexes for accessing the values. */ 00086 unsigned char max_velocity; /**< Maximum velocity */ 00087 unsigned char num_motors; /**< Number of motors */ 00088 } KatanaInterface_data_t; 00089 00090 KatanaInterface_data_t *data; 00091 00092 public: 00093 /* messages */ 00094 class StopMessage : public Message 00095 { 00096 public: 00097 StopMessage(); 00098 ~StopMessage(); 00099 00100 StopMessage(const StopMessage *m); 00101 /* Methods */ 00102 virtual Message * clone() const; 00103 }; 00104 00105 class FlushMessage : public Message 00106 { 00107 public: 00108 FlushMessage(); 00109 ~FlushMessage(); 00110 00111 FlushMessage(const FlushMessage *m); 00112 /* Methods */ 00113 virtual Message * clone() const; 00114 }; 00115 00116 class ParkMessage : public Message 00117 { 00118 public: 00119 ParkMessage(); 00120 ~ParkMessage(); 00121 00122 ParkMessage(const ParkMessage *m); 00123 /* Methods */ 00124 virtual Message * clone() const; 00125 }; 00126 00127 class LinearGotoMessage : public Message 00128 { 00129 private: 00130 /** Internal data storage, do NOT modify! */ 00131 typedef struct { 00132 float x; /**< X-Coordinate for tool position 00133 compared to base coordinate system. */ 00134 float y; /**< Y-Coordinate for tool position 00135 compared to base coordinate system. */ 00136 float z; /**< Z-Coordinate for tool position 00137 compared to base coordinate system. */ 00138 float phi; /**< Euler angle Phi of tool orientation. */ 00139 float theta; /**< Euler angle Theta of tool orientation. */ 00140 float psi; /**< Euler angle Psi of tool orientation.. */ 00141 } LinearGotoMessage_data_t; 00142 00143 LinearGotoMessage_data_t *data; 00144 00145 public: 00146 LinearGotoMessage(const float ini_x, const float ini_y, const float ini_z, const float ini_phi, const float ini_theta, const float ini_psi); 00147 LinearGotoMessage(); 00148 ~LinearGotoMessage(); 00149 00150 LinearGotoMessage(const LinearGotoMessage *m); 00151 /* Methods */ 00152 float x() const; 00153 void set_x(const float new_x); 00154 size_t maxlenof_x() const; 00155 float y() const; 00156 void set_y(const float new_y); 00157 size_t maxlenof_y() const; 00158 float z() const; 00159 void set_z(const float new_z); 00160 size_t maxlenof_z() const; 00161 float phi() const; 00162 void set_phi(const float new_phi); 00163 size_t maxlenof_phi() const; 00164 float theta() const; 00165 void set_theta(const float new_theta); 00166 size_t maxlenof_theta() const; 00167 float psi() const; 00168 void set_psi(const float new_psi); 00169 size_t maxlenof_psi() const; 00170 virtual Message * clone() const; 00171 }; 00172 00173 class CalibrateMessage : public Message 00174 { 00175 public: 00176 CalibrateMessage(); 00177 ~CalibrateMessage(); 00178 00179 CalibrateMessage(const CalibrateMessage *m); 00180 /* Methods */ 00181 virtual Message * clone() const; 00182 }; 00183 00184 class OpenGripperMessage : public Message 00185 { 00186 public: 00187 OpenGripperMessage(); 00188 ~OpenGripperMessage(); 00189 00190 OpenGripperMessage(const OpenGripperMessage *m); 00191 /* Methods */ 00192 virtual Message * clone() const; 00193 }; 00194 00195 class CloseGripperMessage : public Message 00196 { 00197 public: 00198 CloseGripperMessage(); 00199 ~CloseGripperMessage(); 00200 00201 CloseGripperMessage(const CloseGripperMessage *m); 00202 /* Methods */ 00203 virtual Message * clone() const; 00204 }; 00205 00206 class SetEnabledMessage : public Message 00207 { 00208 private: 00209 /** Internal data storage, do NOT modify! */ 00210 typedef struct { 00211 bool enabled; /**< Are motors enabled? */ 00212 } SetEnabledMessage_data_t; 00213 00214 SetEnabledMessage_data_t *data; 00215 00216 public: 00217 SetEnabledMessage(const bool ini_enabled); 00218 SetEnabledMessage(); 00219 ~SetEnabledMessage(); 00220 00221 SetEnabledMessage(const SetEnabledMessage *m); 00222 /* Methods */ 00223 bool is_enabled() const; 00224 void set_enabled(const bool new_enabled); 00225 size_t maxlenof_enabled() const; 00226 virtual Message * clone() const; 00227 }; 00228 00229 class SetMaxVelocityMessage : public Message 00230 { 00231 private: 00232 /** Internal data storage, do NOT modify! */ 00233 typedef struct { 00234 unsigned char max_velocity; /**< Maximum velocity */ 00235 } SetMaxVelocityMessage_data_t; 00236 00237 SetMaxVelocityMessage_data_t *data; 00238 00239 public: 00240 SetMaxVelocityMessage(const unsigned char ini_max_velocity); 00241 SetMaxVelocityMessage(); 00242 ~SetMaxVelocityMessage(); 00243 00244 SetMaxVelocityMessage(const SetMaxVelocityMessage *m); 00245 /* Methods */ 00246 unsigned char max_velocity() const; 00247 void set_max_velocity(const unsigned char new_max_velocity); 00248 size_t maxlenof_max_velocity() const; 00249 virtual Message * clone() const; 00250 }; 00251 00252 virtual bool message_valid(const Message *message) const; 00253 private: 00254 KatanaInterface(); 00255 ~KatanaInterface(); 00256 00257 public: 00258 /* Methods */ 00259 unsigned char * sensor_value() const; 00260 unsigned char sensor_value(unsigned int index) const; 00261 void set_sensor_value(unsigned int index, const unsigned char new_sensor_value); 00262 void set_sensor_value(const unsigned char * new_sensor_value); 00263 size_t maxlenof_sensor_value() const; 00264 float x() const; 00265 void set_x(const float new_x); 00266 size_t maxlenof_x() const; 00267 float y() const; 00268 void set_y(const float new_y); 00269 size_t maxlenof_y() const; 00270 float z() const; 00271 void set_z(const float new_z); 00272 size_t maxlenof_z() const; 00273 float phi() const; 00274 void set_phi(const float new_phi); 00275 size_t maxlenof_phi() const; 00276 float theta() const; 00277 void set_theta(const float new_theta); 00278 size_t maxlenof_theta() const; 00279 float psi() const; 00280 void set_psi(const float new_psi); 00281 size_t maxlenof_psi() const; 00282 unsigned int msgid() const; 00283 void set_msgid(const unsigned int new_msgid); 00284 size_t maxlenof_msgid() const; 00285 bool is_final() const; 00286 void set_final(const bool new_final); 00287 size_t maxlenof_final() const; 00288 unsigned int error_code() const; 00289 void set_error_code(const unsigned int new_error_code); 00290 size_t maxlenof_error_code() const; 00291 bool is_enabled() const; 00292 void set_enabled(const bool new_enabled); 00293 size_t maxlenof_enabled() const; 00294 bool is_calibrated() const; 00295 void set_calibrated(const bool new_calibrated); 00296 size_t maxlenof_calibrated() const; 00297 unsigned char max_velocity() const; 00298 void set_max_velocity(const unsigned char new_max_velocity); 00299 size_t maxlenof_max_velocity() const; 00300 unsigned char num_motors() const; 00301 void set_num_motors(const unsigned char new_num_motors); 00302 size_t maxlenof_num_motors() const; 00303 virtual Message * create_message(const char *type) const; 00304 00305 virtual void copy_values(const Interface *other); 00306 00307 }; 00308 00309 } // end namespace fawkes 00310 00311 #endif

