KatanaInterface.cpp

00001
00002 /***************************************************************************
00003  *  KatanaInterface.cpp - 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 #include <interfaces/KatanaInterface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032 
00033 /** @class KatanaInterface <interfaces/KatanaInterface.h>
00034  * KatanaInterface Fawkes BlackBoard Interface.
00035  * 
00036       Interface to access component providing access to a Neuronics
00037       Katana arm.
00038     
00039  * @ingroup FawkesInterfaces
00040  */
00041
00042 
00043 /** SENSOR_IR_RIGHT_INNER_MIDDLE constant */
00044 const unsigned int KatanaInterface::SENSOR_IR_RIGHT_INNER_MIDDLE = 0;
00045 /** SENSOR_IR_RIGHT_INNER_FRONT constant */
00046 const unsigned int KatanaInterface::SENSOR_IR_RIGHT_INNER_FRONT = 1;
00047 /** SENSOR_RESERVED_2 constant */
00048 const unsigned int KatanaInterface::SENSOR_RESERVED_2 = 2;
00049 /** SENSOR_COND_BOTH constant */
00050 const unsigned int KatanaInterface::SENSOR_COND_BOTH = 3;
00051 /** SENSOR_IR_RIGHT_OUTER_FRONT constant */
00052 const unsigned int KatanaInterface::SENSOR_IR_RIGHT_OUTER_FRONT = 4;
00053 /** SENSOR_IR_RIGHT_BOTTOM_FRONT constant */
00054 const unsigned int KatanaInterface::SENSOR_IR_RIGHT_BOTTOM_FRONT = 5;
00055 /** SENSOR_FORCE_RIGHT_REAR constant */
00056 const unsigned int KatanaInterface::SENSOR_FORCE_RIGHT_REAR = 6;
00057 /** SENSOR_FORCE_RIGHT_FRONT constant */
00058 const unsigned int KatanaInterface::SENSOR_FORCE_RIGHT_FRONT = 7;
00059 /** SENSOR_IR_LEFT_INNER_MIDDLE constant */
00060 const unsigned int KatanaInterface::SENSOR_IR_LEFT_INNER_MIDDLE = 8;
00061 /** SENSOR_IR_LEFT_INNER_FRONT constant */
00062 const unsigned int KatanaInterface::SENSOR_IR_LEFT_INNER_FRONT = 9;
00063 /** SENSOR_RESERVED_10 constant */
00064 const unsigned int KatanaInterface::SENSOR_RESERVED_10 = 10;
00065 /** SENSOR_IR_CENTER_GRIPPER constant */
00066 const unsigned int KatanaInterface::SENSOR_IR_CENTER_GRIPPER = 11;
00067 /** SENSOR_IR_LEFT_OUTER_FRONT constant */
00068 const unsigned int KatanaInterface::SENSOR_IR_LEFT_OUTER_FRONT = 12;
00069 /** SENSOR_IR_LEFT_BOTTOM_FRONT constant */
00070 const unsigned int KatanaInterface::SENSOR_IR_LEFT_BOTTOM_FRONT = 13;
00071 /** SENSOR_FORCE_LEFT_REAR constant */
00072 const unsigned int KatanaInterface::SENSOR_FORCE_LEFT_REAR = 14;
00073 /** SENSOR_FORCE_LEFT_FRONT constant */
00074 const unsigned int KatanaInterface::SENSOR_FORCE_LEFT_FRONT = 15;
00075 /** ERROR_NONE constant */
00076 const unsigned int KatanaInterface::ERROR_NONE = 0;
00077 /** ERROR_UNSPECIFIC constant */
00078 const unsigned int KatanaInterface::ERROR_UNSPECIFIC = 1;
00079 /** ERROR_CMD_START_FAILED constant */
00080 const unsigned int KatanaInterface::ERROR_CMD_START_FAILED = 2;
00081 /** ERROR_NO_SOLUTION constant */
00082 const unsigned int KatanaInterface::ERROR_NO_SOLUTION = 4;
00083 /** ERROR_COMMUNICATION constant */
00084 const unsigned int KatanaInterface::ERROR_COMMUNICATION = 8;
00085 /** ERROR_MOTOR_CRASHED constant */
00086 const unsigned int KatanaInterface::ERROR_MOTOR_CRASHED = 16;
00087 
00088 /** Constructor */
00089 KatanaInterface::KatanaInterface() : Interface()
00090 {
00091   data_size = sizeof(KatanaInterface_data_t);
00092   data_ptr  = malloc(data_size);
00093   data      = (KatanaInterface_data_t *)data_ptr;
00094   memset(data_ptr, 0, data_size);
00095   add_fieldinfo(IFT_BYTE, "sensor_value", 16, &data->sensor_value);
00096   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00097   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00098   add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
00099   add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
00100   add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
00101   add_fieldinfo(IFT_FLOAT, "psi", 1, &data->psi);
00102   add_fieldinfo(IFT_UINT, "msgid", 1, &data->msgid);
00103   add_fieldinfo(IFT_BOOL, "final", 1, &data->final);
00104   add_fieldinfo(IFT_UINT, "error_code", 1, &data->error_code);
00105   add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
00106   add_fieldinfo(IFT_BOOL, "calibrated", 1, &data->calibrated);
00107   add_fieldinfo(IFT_BYTE, "max_velocity", 1, &data->max_velocity);
00108   add_fieldinfo(IFT_BYTE, "num_motors", 1, &data->num_motors);
00109   add_messageinfo("StopMessage");
00110   add_messageinfo("FlushMessage");
00111   add_messageinfo("ParkMessage");
00112   add_messageinfo("LinearGotoMessage");
00113   add_messageinfo("CalibrateMessage");
00114   add_messageinfo("OpenGripperMessage");
00115   add_messageinfo("CloseGripperMessage");
00116   add_messageinfo("SetEnabledMessage");
00117   add_messageinfo("SetMaxVelocityMessage");
00118   unsigned char tmp_hash[] = {0x67, 0x9b, 0x57, 0x4e, 0xb3, 0x7c, 0x64, 0x5f, 0x23, 0xd4, 0x1e, 0x8a, 0x19, 0x52, 0x5b, 0x84};
00119   set_hash(tmp_hash);
00120 }
00121 
00122 /** Destructor */
00123 KatanaInterface::~KatanaInterface()
00124 {
00125   free(data_ptr);
00126 }
00127 /* Methods */
00128 /** Get sensor_value value.
00129  * Sensor
00130     values. Use SENSOR_* indexes for accessing the values.
00131  * @return sensor_value value
00132  */
00133 unsigned char *
00134 KatanaInterface::sensor_value() const
00135 {
00136   return data->sensor_value;
00137 }
00138 
00139 /** Get sensor_value value at given index.
00140  * Sensor
00141     values. Use SENSOR_* indexes for accessing the values.
00142  * @param index index of value
00143  * @return sensor_value value
00144  * @exception Exception thrown if index is out of bounds
00145  */
00146 unsigned char
00147 KatanaInterface::sensor_value(unsigned int index) const
00148 {
00149   if (index > 16) {
00150     throw Exception("Index value %u out of bounds (0..16)", index);
00151   }
00152   return data->sensor_value[index];
00153 }
00154 
00155 /** Get maximum length of sensor_value value.
00156  * @return length of sensor_value value, can be length of the array or number of 
00157  * maximum number of characters for a string
00158  */
00159 size_t
00160 KatanaInterface::maxlenof_sensor_value() const
00161 {
00162   return 16;
00163 }
00164 
00165 /** Set sensor_value value.
00166  * Sensor
00167     values. Use SENSOR_* indexes for accessing the values.
00168  * @param new_sensor_value new sensor_value value
00169  */
00170 void
00171 KatanaInterface::set_sensor_value(const unsigned char * new_sensor_value)
00172 {
00173   memcpy(data->sensor_value, new_sensor_value, sizeof(unsigned char) * 16);
00174 }
00175 
00176 /** Set sensor_value value at given index.
00177  * Sensor
00178     values. Use SENSOR_* indexes for accessing the values.
00179  * @param new_sensor_value new sensor_value value
00180  * @param index index for of the value
00181  */
00182 void
00183 KatanaInterface::set_sensor_value(unsigned int index, const unsigned char new_sensor_value)
00184 {
00185   if (index > 16) {
00186     throw Exception("Index value %u out of bounds (0..16)", index);
00187   }
00188   data->sensor_value[index] = new_sensor_value;
00189 }
00190 /** Get x value.
00191  * X-Coordinate for tool position
00192     compared to base coordinate system.
00193  * @return x value
00194  */
00195 float
00196 KatanaInterface::x() const
00197 {
00198   return data->x;
00199 }
00200 
00201 /** Get maximum length of x value.
00202  * @return length of x value, can be length of the array or number of 
00203  * maximum number of characters for a string
00204  */
00205 size_t
00206 KatanaInterface::maxlenof_x() const
00207 {
00208   return 1;
00209 }
00210 
00211 /** Set x value.
00212  * X-Coordinate for tool position
00213     compared to base coordinate system.
00214  * @param new_x new x value
00215  */
00216 void
00217 KatanaInterface::set_x(const float new_x)
00218 {
00219   data->x = new_x;
00220 }
00221 
00222 /** Get y value.
00223  * Y-Coordinate for tool position
00224     compared to base coordinate system.
00225  * @return y value
00226  */
00227 float
00228 KatanaInterface::y() const
00229 {
00230   return data->y;
00231 }
00232 
00233 /** Get maximum length of y value.
00234  * @return length of y value, can be length of the array or number of 
00235  * maximum number of characters for a string
00236  */
00237 size_t
00238 KatanaInterface::maxlenof_y() const
00239 {
00240   return 1;
00241 }
00242 
00243 /** Set y value.
00244  * Y-Coordinate for tool position
00245     compared to base coordinate system.
00246  * @param new_y new y value
00247  */
00248 void
00249 KatanaInterface::set_y(const float new_y)
00250 {
00251   data->y = new_y;
00252 }
00253 
00254 /** Get z value.
00255  * Z-Coordinate for tool position
00256     compared to base coordinate system.
00257  * @return z value
00258  */
00259 float
00260 KatanaInterface::z() const
00261 {
00262   return data->z;
00263 }
00264 
00265 /** Get maximum length of z value.
00266  * @return length of z value, can be length of the array or number of 
00267  * maximum number of characters for a string
00268  */
00269 size_t
00270 KatanaInterface::maxlenof_z() const
00271 {
00272   return 1;
00273 }
00274 
00275 /** Set z value.
00276  * Z-Coordinate for tool position
00277     compared to base coordinate system.
00278  * @param new_z new z value
00279  */
00280 void
00281 KatanaInterface::set_z(const float new_z)
00282 {
00283   data->z = new_z;
00284 }
00285 
00286 /** Get phi value.
00287  * Euler angle Phi of tool orientation.
00288  * @return phi value
00289  */
00290 float
00291 KatanaInterface::phi() const
00292 {
00293   return data->phi;
00294 }
00295 
00296 /** Get maximum length of phi value.
00297  * @return length of phi value, can be length of the array or number of 
00298  * maximum number of characters for a string
00299  */
00300 size_t
00301 KatanaInterface::maxlenof_phi() const
00302 {
00303   return 1;
00304 }
00305 
00306 /** Set phi value.
00307  * Euler angle Phi of tool orientation.
00308  * @param new_phi new phi value
00309  */
00310 void
00311 KatanaInterface::set_phi(const float new_phi)
00312 {
00313   data->phi = new_phi;
00314 }
00315 
00316 /** Get theta value.
00317  * Euler angle Theta of tool orientation.
00318  * @return theta value
00319  */
00320 float
00321 KatanaInterface::theta() const
00322 {
00323   return data->theta;
00324 }
00325 
00326 /** Get maximum length of theta value.
00327  * @return length of theta value, can be length of the array or number of 
00328  * maximum number of characters for a string
00329  */
00330 size_t
00331 KatanaInterface::maxlenof_theta() const
00332 {
00333   return 1;
00334 }
00335 
00336 /** Set theta value.
00337  * Euler angle Theta of tool orientation.
00338  * @param new_theta new theta value
00339  */
00340 void
00341 KatanaInterface::set_theta(const float new_theta)
00342 {
00343   data->theta = new_theta;
00344 }
00345 
00346 /** Get psi value.
00347  * Euler angle Psi of tool orientation..
00348  * @return psi value
00349  */
00350 float
00351 KatanaInterface::psi() const
00352 {
00353   return data->psi;
00354 }
00355 
00356 /** Get maximum length of psi value.
00357  * @return length of psi value, can be length of the array or number of 
00358  * maximum number of characters for a string
00359  */
00360 size_t
00361 KatanaInterface::maxlenof_psi() const
00362 {
00363   return 1;
00364 }
00365 
00366 /** Set psi value.
00367  * Euler angle Psi of tool orientation..
00368  * @param new_psi new psi value
00369  */
00370 void
00371 KatanaInterface::set_psi(const float new_psi)
00372 {
00373   data->psi = new_psi;
00374 }
00375 
00376 /** Get msgid value.
00377  * The ID of the message that is currently being
00378       processed, or 0 if no message is being processed.
00379  * @return msgid value
00380  */
00381 unsigned int
00382 KatanaInterface::msgid() const
00383 {
00384   return data->msgid;
00385 }
00386 
00387 /** Get maximum length of msgid value.
00388  * @return length of msgid value, can be length of the array or number of 
00389  * maximum number of characters for a string
00390  */
00391 size_t
00392 KatanaInterface::maxlenof_msgid() const
00393 {
00394   return 1;
00395 }
00396 
00397 /** Set msgid value.
00398  * The ID of the message that is currently being
00399       processed, or 0 if no message is being processed.
00400  * @param new_msgid new msgid value
00401  */
00402 void
00403 KatanaInterface::set_msgid(const unsigned int new_msgid)
00404 {
00405   data->msgid = new_msgid;
00406 }
00407 
00408 /** Get final value.
00409  * True, if the last goto command has been finished,
00410       false if it is still running
00411  * @return final value
00412  */
00413 bool
00414 KatanaInterface::is_final() const
00415 {
00416   return data->final;
00417 }
00418 
00419 /** Get maximum length of final value.
00420  * @return length of final value, can be length of the array or number of 
00421  * maximum number of characters for a string
00422  */
00423 size_t
00424 KatanaInterface::maxlenof_final() const
00425 {
00426   return 1;
00427 }
00428 
00429 /** Set final value.
00430  * True, if the last goto command has been finished,
00431       false if it is still running
00432  * @param new_final new final value
00433  */
00434 void
00435 KatanaInterface::set_final(const bool new_final)
00436 {
00437   data->final = new_final;
00438 }
00439 
00440 /** Get error_code value.
00441  * Failure code set if
00442     final is true. 0 if no error occured, an error code from ERROR_*
00443     constants otherwise (or a bit-wise combination).
00444  * @return error_code value
00445  */
00446 unsigned int
00447 KatanaInterface::error_code() const
00448 {
00449   return data->error_code;
00450 }
00451 
00452 /** Get maximum length of error_code value.
00453  * @return length of error_code value, can be length of the array or number of 
00454  * maximum number of characters for a string
00455  */
00456 size_t
00457 KatanaInterface::maxlenof_error_code() const
00458 {
00459   return 1;
00460 }
00461 
00462 /** Set error_code value.
00463  * Failure code set if
00464     final is true. 0 if no error occured, an error code from ERROR_*
00465     constants otherwise (or a bit-wise combination).
00466  * @param new_error_code new error_code value
00467  */
00468 void
00469 KatanaInterface::set_error_code(const unsigned int new_error_code)
00470 {
00471   data->error_code = new_error_code;
00472 }
00473 
00474 /** Get enabled value.
00475  * Are motors enabled?
00476  * @return enabled value
00477  */
00478 bool
00479 KatanaInterface::is_enabled() const
00480 {
00481   return data->enabled;
00482 }
00483 
00484 /** Get maximum length of enabled value.
00485  * @return length of enabled value, can be length of the array or number of 
00486  * maximum number of characters for a string
00487  */
00488 size_t
00489 KatanaInterface::maxlenof_enabled() const
00490 {
00491   return 1;
00492 }
00493 
00494 /** Set enabled value.
00495  * Are motors enabled?
00496  * @param new_enabled new enabled value
00497  */
00498 void
00499 KatanaInterface::set_enabled(const bool new_enabled)
00500 {
00501   data->enabled = new_enabled;
00502 }
00503 
00504 /** Get calibrated value.
00505  * Has arm been calibrated?
00506  * @return calibrated value
00507  */
00508 bool
00509 KatanaInterface::is_calibrated() const
00510 {
00511   return data->calibrated;
00512 }
00513 
00514 /** Get maximum length of calibrated value.
00515  * @return length of calibrated value, can be length of the array or number of 
00516  * maximum number of characters for a string
00517  */
00518 size_t
00519 KatanaInterface::maxlenof_calibrated() const
00520 {
00521   return 1;
00522 }
00523 
00524 /** Set calibrated value.
00525  * Has arm been calibrated?
00526  * @param new_calibrated new calibrated value
00527  */
00528 void
00529 KatanaInterface::set_calibrated(const bool new_calibrated)
00530 {
00531   data->calibrated = new_calibrated;
00532 }
00533 
00534 /** Get max_velocity value.
00535  * Maximum velocity
00536  * @return max_velocity value
00537  */
00538 unsigned char
00539 KatanaInterface::max_velocity() const
00540 {
00541   return data->max_velocity;
00542 }
00543 
00544 /** Get maximum length of max_velocity value.
00545  * @return length of max_velocity value, can be length of the array or number of 
00546  * maximum number of characters for a string
00547  */
00548 size_t
00549 KatanaInterface::maxlenof_max_velocity() const
00550 {
00551   return 1;
00552 }
00553 
00554 /** Set max_velocity value.
00555  * Maximum velocity
00556  * @param new_max_velocity new max_velocity value
00557  */
00558 void
00559 KatanaInterface::set_max_velocity(const unsigned char new_max_velocity)
00560 {
00561   data->max_velocity = new_max_velocity;
00562 }
00563 
00564 /** Get num_motors value.
00565  * Number of motors
00566  * @return num_motors value
00567  */
00568 unsigned char
00569 KatanaInterface::num_motors() const
00570 {
00571   return data->num_motors;
00572 }
00573 
00574 /** Get maximum length of num_motors value.
00575  * @return length of num_motors value, can be length of the array or number of 
00576  * maximum number of characters for a string
00577  */
00578 size_t
00579 KatanaInterface::maxlenof_num_motors() const
00580 {
00581   return 1;
00582 }
00583 
00584 /** Set num_motors value.
00585  * Number of motors
00586  * @param new_num_motors new num_motors value
00587  */
00588 void
00589 KatanaInterface::set_num_motors(const unsigned char new_num_motors)
00590 {
00591   data->num_motors = new_num_motors;
00592 }
00593
00594 /* =========== message create =========== */
00595 Message *
00596 KatanaInterface::create_message(const char *type) const
00597 {
00598   if ( strncmp("StopMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00599     return new StopMessage();
00600   } else if ( strncmp("FlushMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00601     return new FlushMessage();
00602   } else if ( strncmp("ParkMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00603     return new ParkMessage();
00604   } else if ( strncmp("LinearGotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00605     return new LinearGotoMessage();
00606   } else if ( strncmp("CalibrateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00607     return new CalibrateMessage();
00608   } else if ( strncmp("OpenGripperMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00609     return new OpenGripperMessage();
00610   } else if ( strncmp("CloseGripperMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00611     return new CloseGripperMessage();
00612   } else if ( strncmp("SetEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00613     return new SetEnabledMessage();
00614   } else if ( strncmp("SetMaxVelocityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00615     return new SetMaxVelocityMessage();
00616   } else {
00617     throw UnknownTypeException("The given type '%s' does not match any known "
00618                                "message type for this interface type.", type);
00619   }
00620 }
00621
00622 
00623 /** Copy values from other interface.
00624  * @param other other interface to copy values from
00625  */
00626 void
00627 KatanaInterface::copy_values(const Interface *other)
00628 {
00629   const KatanaInterface *oi = dynamic_cast<const KatanaInterface *>(other);
00630   if (oi == NULL) {
00631     throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00632                                 type(), other->type());
00633   }
00634   memcpy(data, oi->data, sizeof(KatanaInterface_data_t));
00635 }
00636
00637 /* =========== messages =========== */
00638 /** @class KatanaInterface::StopMessage <interfaces/KatanaInterface.h>
00639  * StopMessage Fawkes BlackBoard Interface Message.
00640  * 
00641     
00642  */
00643
00644 
00645 /** Constructor */
00646 KatanaInterface::StopMessage::StopMessage() : Message("StopMessage")
00647 {
00648   data_size = 0;
00649   data_ptr  = NULL;
00650 }
00651 
00652 /** Destructor */
00653 KatanaInterface::StopMessage::~StopMessage()
00654 {
00655 }
00656 
00657 /** Copy constructor.
00658  * @param m message to copy from
00659  */
00660 KatanaInterface::StopMessage::StopMessage(const StopMessage *m) : Message("StopMessage")
00661 {
00662   data_size = 0;
00663   data_ptr  = NULL;
00664 }
00665
00666 /* Methods */
00667 /** Clone this message.
00668  * Produces a message of the same type as this message and copies the
00669  * data to the new message.
00670  * @return clone of this message
00671  */
00672 Message *
00673 KatanaInterface::StopMessage::clone() const
00674 {
00675   return new KatanaInterface::StopMessage(this);
00676 }
00677 /** @class KatanaInterface::FlushMessage <interfaces/KatanaInterface.h>
00678  * FlushMessage Fawkes BlackBoard Interface Message.
00679  * 
00680     
00681  */
00682
00683 
00684 /** Constructor */
00685 KatanaInterface::FlushMessage::FlushMessage() : Message("FlushMessage")
00686 {
00687   data_size = 0;
00688   data_ptr  = NULL;
00689 }
00690 
00691 /** Destructor */
00692 KatanaInterface::FlushMessage::~FlushMessage()
00693 {
00694 }
00695 
00696 /** Copy constructor.
00697  * @param m message to copy from
00698  */
00699 KatanaInterface::FlushMessage::FlushMessage(const FlushMessage *m) : Message("FlushMessage")
00700 {
00701   data_size = 0;
00702   data_ptr  = NULL;
00703 }
00704
00705 /* Methods */
00706 /** Clone this message.
00707  * Produces a message of the same type as this message and copies the
00708  * data to the new message.
00709  * @return clone of this message
00710  */
00711 Message *
00712 KatanaInterface::FlushMessage::clone() const
00713 {
00714   return new KatanaInterface::FlushMessage(this);
00715 }
00716 /** @class KatanaInterface::ParkMessage <interfaces/KatanaInterface.h>
00717  * ParkMessage Fawkes BlackBoard Interface Message.
00718  * 
00719     
00720  */
00721
00722 
00723 /** Constructor */
00724 KatanaInterface::ParkMessage::ParkMessage() : Message("ParkMessage")
00725 {
00726   data_size = 0;
00727   data_ptr  = NULL;
00728 }
00729 
00730 /** Destructor */
00731 KatanaInterface::ParkMessage::~ParkMessage()
00732 {
00733 }
00734 
00735 /** Copy constructor.
00736  * @param m message to copy from
00737  */
00738 KatanaInterface::ParkMessage::ParkMessage(const ParkMessage *m) : Message("ParkMessage")
00739 {
00740   data_size = 0;
00741   data_ptr  = NULL;
00742 }
00743
00744 /* Methods */
00745 /** Clone this message.
00746  * Produces a message of the same type as this message and copies the
00747  * data to the new message.
00748  * @return clone of this message
00749  */
00750 Message *
00751 KatanaInterface::ParkMessage::clone() const
00752 {
00753   return new KatanaInterface::ParkMessage(this);
00754 }
00755 /** @class KatanaInterface::LinearGotoMessage <interfaces/KatanaInterface.h>
00756  * LinearGotoMessage Fawkes BlackBoard Interface Message.
00757  * 
00758     
00759  */
00760
00761 
00762 /** Constructor with initial values.
00763  * @param ini_x initial value for x
00764  * @param ini_y initial value for y
00765  * @param ini_z initial value for z
00766  * @param ini_phi initial value for phi
00767  * @param ini_theta initial value for theta
00768  * @param ini_psi initial value for psi
00769  */
00770 KatanaInterface::LinearGotoMessage::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) : Message("LinearGotoMessage")
00771 {
00772   data_size = sizeof(LinearGotoMessage_data_t);
00773   data_ptr  = malloc(data_size);
00774   memset(data_ptr, 0, data_size);
00775   data      = (LinearGotoMessage_data_t *)data_ptr;
00776   data->x = ini_x;
00777   data->y = ini_y;
00778   data->z = ini_z;
00779   data->phi = ini_phi;
00780   data->theta = ini_theta;
00781   data->psi = ini_psi;
00782   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00783   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00784   add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
00785   add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
00786   add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
00787   add_fieldinfo(IFT_FLOAT, "psi", 1, &data->psi);
00788 }
00789 /** Constructor */
00790 KatanaInterface::LinearGotoMessage::LinearGotoMessage() : Message("LinearGotoMessage")
00791 {
00792   data_size = sizeof(LinearGotoMessage_data_t);
00793   data_ptr  = malloc(data_size);
00794   memset(data_ptr, 0, data_size);
00795   data      = (LinearGotoMessage_data_t *)data_ptr;
00796   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00797   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00798   add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
00799   add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
00800   add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
00801   add_fieldinfo(IFT_FLOAT, "psi", 1, &data->psi);
00802 }
00803 
00804 /** Destructor */
00805 KatanaInterface::LinearGotoMessage::~LinearGotoMessage()
00806 {
00807   free(data_ptr);
00808 }
00809 
00810 /** Copy constructor.
00811  * @param m message to copy from
00812  */
00813 KatanaInterface::LinearGotoMessage::LinearGotoMessage(const LinearGotoMessage *m) : Message("LinearGotoMessage")
00814 {
00815   data_size = m->data_size;
00816   data_ptr  = malloc(data_size);
00817   memcpy(data_ptr, m->data_ptr, data_size);
00818   data      = (LinearGotoMessage_data_t *)data_ptr;
00819 }
00820
00821 /* Methods */
00822 /** Get x value.
00823  * X-Coordinate for tool position
00824     compared to base coordinate system.
00825  * @return x value
00826  */
00827 float
00828 KatanaInterface::LinearGotoMessage::x() const
00829 {
00830   return data->x;
00831 }
00832 
00833 /** Get maximum length of x value.
00834  * @return length of x value, can be length of the array or number of 
00835  * maximum number of characters for a string
00836  */
00837 size_t
00838 KatanaInterface::LinearGotoMessage::maxlenof_x() const
00839 {
00840   return 1;
00841 }
00842 
00843 /** Set x value.
00844  * X-Coordinate for tool position
00845     compared to base coordinate system.
00846  * @param new_x new x value
00847  */
00848 void
00849 KatanaInterface::LinearGotoMessage::set_x(const float new_x)
00850 {
00851   data->x = new_x;
00852 }
00853 
00854 /** Get y value.
00855  * Y-Coordinate for tool position
00856     compared to base coordinate system.
00857  * @return y value
00858  */
00859 float
00860 KatanaInterface::LinearGotoMessage::y() const
00861 {
00862   return data->y;
00863 }
00864 
00865 /** Get maximum length of y value.
00866  * @return length of y value, can be length of the array or number of 
00867  * maximum number of characters for a string
00868  */
00869 size_t
00870 KatanaInterface::LinearGotoMessage::maxlenof_y() const
00871 {
00872   return 1;
00873 }
00874 
00875 /** Set y value.
00876  * Y-Coordinate for tool position
00877     compared to base coordinate system.
00878  * @param new_y new y value
00879  */
00880 void
00881 KatanaInterface::LinearGotoMessage::set_y(const float new_y)
00882 {
00883   data->y = new_y;
00884 }
00885 
00886 /** Get z value.
00887  * Z-Coordinate for tool position
00888     compared to base coordinate system.
00889  * @return z value
00890  */
00891 float
00892 KatanaInterface::LinearGotoMessage::z() const
00893 {
00894   return data->z;
00895 }
00896 
00897 /** Get maximum length of z value.
00898  * @return length of z value, can be length of the array or number of 
00899  * maximum number of characters for a string
00900  */
00901 size_t
00902 KatanaInterface::LinearGotoMessage::maxlenof_z() const
00903 {
00904   return 1;
00905 }
00906 
00907 /** Set z value.
00908  * Z-Coordinate for tool position
00909     compared to base coordinate system.
00910  * @param new_z new z value
00911  */
00912 void
00913 KatanaInterface::LinearGotoMessage::set_z(const float new_z)
00914 {
00915   data->z = new_z;
00916 }
00917 
00918 /** Get phi value.
00919  * Euler angle Phi of tool orientation.
00920  * @return phi value
00921  */
00922 float
00923 KatanaInterface::LinearGotoMessage::phi() const
00924 {
00925   return data->phi;
00926 }
00927 
00928 /** Get maximum length of phi value.
00929  * @return length of phi value, can be length of the array or number of 
00930  * maximum number of characters for a string
00931  */
00932 size_t
00933 KatanaInterface::LinearGotoMessage::maxlenof_phi() const
00934 {
00935   return 1;
00936 }
00937 
00938 /** Set phi value.
00939  * Euler angle Phi of tool orientation.
00940  * @param new_phi new phi value
00941  */
00942 void
00943 KatanaInterface::LinearGotoMessage::set_phi(const float new_phi)
00944 {
00945   data->phi = new_phi;
00946 }
00947 
00948 /** Get theta value.
00949  * Euler angle Theta of tool orientation.
00950  * @return theta value
00951  */
00952 float
00953 KatanaInterface::LinearGotoMessage::theta() const
00954 {
00955   return data->theta;
00956 }
00957 
00958 /** Get maximum length of theta value.
00959  * @return length of theta value, can be length of the array or number of 
00960  * maximum number of characters for a string
00961  */
00962 size_t
00963 KatanaInterface::LinearGotoMessage::maxlenof_theta() const
00964 {
00965   return 1;
00966 }
00967 
00968 /** Set theta value.
00969  * Euler angle Theta of tool orientation.
00970  * @param new_theta new theta value
00971  */
00972 void
00973 KatanaInterface::LinearGotoMessage::set_theta(const float new_theta)
00974 {
00975   data->theta = new_theta;
00976 }
00977 
00978 /** Get psi value.
00979  * Euler angle Psi of tool orientation..
00980  * @return psi value
00981  */
00982 float
00983 KatanaInterface::LinearGotoMessage::psi() const
00984 {
00985   return data->psi;
00986 }
00987 
00988 /** Get maximum length of psi value.
00989  * @return length of psi value, can be length of the array or number of 
00990  * maximum number of characters for a string
00991  */
00992 size_t
00993 KatanaInterface::LinearGotoMessage::maxlenof_psi() const
00994 {
00995   return 1;
00996 }
00997 
00998 /** Set psi value.
00999  * Euler angle Psi of tool orientation..
01000  * @param new_psi new psi value
01001  */
01002 void
01003 KatanaInterface::LinearGotoMessage::set_psi(const float new_psi)
01004 {
01005   data->psi = new_psi;
01006 }
01007 
01008 /** Clone this message.
01009  * Produces a message of the same type as this message and copies the
01010  * data to the new message.
01011  * @return clone of this message
01012  */
01013 Message *
01014 KatanaInterface::LinearGotoMessage::clone() const
01015 {
01016   return new KatanaInterface::LinearGotoMessage(this);
01017 }
01018 /** @class KatanaInterface::CalibrateMessage <interfaces/KatanaInterface.h>
01019  * CalibrateMessage Fawkes BlackBoard Interface Message.
01020  * 
01021     
01022  */
01023
01024 
01025 /** Constructor */
01026 KatanaInterface::CalibrateMessage::CalibrateMessage() : Message("CalibrateMessage")
01027 {
01028   data_size = 0;
01029   data_ptr  = NULL;
01030 }
01031 
01032 /** Destructor */
01033 KatanaInterface::CalibrateMessage::~CalibrateMessage()
01034 {
01035 }
01036 
01037 /** Copy constructor.
01038  * @param m message to copy from
01039  */
01040 KatanaInterface::CalibrateMessage::CalibrateMessage(const CalibrateMessage *m) : Message("CalibrateMessage")
01041 {
01042   data_size = 0;
01043   data_ptr  = NULL;
01044 }
01045
01046 /* Methods */
01047 /** Clone this message.
01048  * Produces a message of the same type as this message and copies the
01049  * data to the new message.
01050  * @return clone of this message
01051  */
01052 Message *
01053 KatanaInterface::CalibrateMessage::clone() const
01054 {
01055   return new KatanaInterface::CalibrateMessage(this);
01056 }
01057 /** @class KatanaInterface::OpenGripperMessage <interfaces/KatanaInterface.h>
01058  * OpenGripperMessage Fawkes BlackBoard Interface Message.
01059  * 
01060     
01061  */
01062
01063 
01064 /** Constructor */
01065 KatanaInterface::OpenGripperMessage::OpenGripperMessage() : Message("OpenGripperMessage")
01066 {
01067   data_size = 0;
01068   data_ptr  = NULL;
01069 }
01070 
01071 /** Destructor */
01072 KatanaInterface::OpenGripperMessage::~OpenGripperMessage()
01073 {
01074 }
01075 
01076 /** Copy constructor.
01077  * @param m message to copy from
01078  */
01079 KatanaInterface::OpenGripperMessage::OpenGripperMessage(const OpenGripperMessage *m) : Message("OpenGripperMessage")
01080 {
01081   data_size = 0;
01082   data_ptr  = NULL;
01083 }
01084
01085 /* Methods */
01086 /** Clone this message.
01087  * Produces a message of the same type as this message and copies the
01088  * data to the new message.
01089  * @return clone of this message
01090  */
01091 Message *
01092 KatanaInterface::OpenGripperMessage::clone() const
01093 {
01094   return new KatanaInterface::OpenGripperMessage(this);
01095 }
01096 /** @class KatanaInterface::CloseGripperMessage <interfaces/KatanaInterface.h>
01097  * CloseGripperMessage Fawkes BlackBoard Interface Message.
01098  * 
01099     
01100  */
01101
01102 
01103 /** Constructor */
01104 KatanaInterface::CloseGripperMessage::CloseGripperMessage() : Message("CloseGripperMessage")
01105 {
01106   data_size = 0;
01107   data_ptr  = NULL;
01108 }
01109 
01110 /** Destructor */
01111 KatanaInterface::CloseGripperMessage::~CloseGripperMessage()
01112 {
01113 }
01114 
01115 /** Copy constructor.
01116  * @param m message to copy from
01117  */
01118 KatanaInterface::CloseGripperMessage::CloseGripperMessage(const CloseGripperMessage *m) : Message("CloseGripperMessage")
01119 {
01120   data_size = 0;
01121   data_ptr  = NULL;
01122 }
01123
01124 /* Methods */
01125 /** Clone this message.
01126  * Produces a message of the same type as this message and copies the
01127  * data to the new message.
01128  * @return clone of this message
01129  */
01130 Message *
01131 KatanaInterface::CloseGripperMessage::clone() const
01132 {
01133   return new KatanaInterface::CloseGripperMessage(this);
01134 }
01135 /** @class KatanaInterface::SetEnabledMessage <interfaces/KatanaInterface.h>
01136  * SetEnabledMessage Fawkes BlackBoard Interface Message.
01137  * 
01138     
01139  */
01140
01141 
01142 /** Constructor with initial values.
01143  * @param ini_enabled initial value for enabled
01144  */
01145 KatanaInterface::SetEnabledMessage::SetEnabledMessage(const bool ini_enabled) : Message("SetEnabledMessage")
01146 {
01147   data_size = sizeof(SetEnabledMessage_data_t);
01148   data_ptr  = malloc(data_size);
01149   memset(data_ptr, 0, data_size);
01150   data      = (SetEnabledMessage_data_t *)data_ptr;
01151   data->enabled = ini_enabled;
01152   add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
01153 }
01154 /** Constructor */
01155 KatanaInterface::SetEnabledMessage::SetEnabledMessage() : Message("SetEnabledMessage")
01156 {
01157   data_size = sizeof(SetEnabledMessage_data_t);
01158   data_ptr  = malloc(data_size);
01159   memset(data_ptr, 0, data_size);
01160   data      = (SetEnabledMessage_data_t *)data_ptr;
01161   add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
01162 }
01163 
01164 /** Destructor */
01165 KatanaInterface::SetEnabledMessage::~SetEnabledMessage()
01166 {
01167   free(data_ptr);
01168 }
01169 
01170 /** Copy constructor.
01171  * @param m message to copy from
01172  */
01173 KatanaInterface::SetEnabledMessage::SetEnabledMessage(const SetEnabledMessage *m) : Message("SetEnabledMessage")
01174 {
01175   data_size = m->data_size;
01176   data_ptr  = malloc(data_size);
01177   memcpy(data_ptr, m->data_ptr, data_size);
01178   data      = (SetEnabledMessage_data_t *)data_ptr;
01179 }
01180
01181 /* Methods */
01182 /** Get enabled value.
01183  * Are motors enabled?
01184  * @return enabled value
01185  */
01186 bool
01187 KatanaInterface::SetEnabledMessage::is_enabled() const
01188 {
01189   return data->enabled;
01190 }
01191 
01192 /** Get maximum length of enabled value.
01193  * @return length of enabled value, can be length of the array or number of 
01194  * maximum number of characters for a string
01195  */
01196 size_t
01197 KatanaInterface::SetEnabledMessage::maxlenof_enabled() const
01198 {
01199   return 1;
01200 }
01201 
01202 /** Set enabled value.
01203  * Are motors enabled?
01204  * @param new_enabled new enabled value
01205  */
01206 void
01207 KatanaInterface::SetEnabledMessage::set_enabled(const bool new_enabled)
01208 {
01209   data->enabled = new_enabled;
01210 }
01211 
01212 /** Clone this message.
01213  * Produces a message of the same type as this message and copies the
01214  * data to the new message.
01215  * @return clone of this message
01216  */
01217 Message *
01218 KatanaInterface::SetEnabledMessage::clone() const
01219 {
01220   return new KatanaInterface::SetEnabledMessage(this);
01221 }
01222 /** @class KatanaInterface::SetMaxVelocityMessage <interfaces/KatanaInterface.h>
01223  * SetMaxVelocityMessage Fawkes BlackBoard Interface Message.
01224  * 
01225     
01226  */
01227
01228 
01229 /** Constructor with initial values.
01230  * @param ini_max_velocity initial value for max_velocity
01231  */
01232 KatanaInterface::SetMaxVelocityMessage::SetMaxVelocityMessage(const unsigned char ini_max_velocity) : Message("SetMaxVelocityMessage")
01233 {
01234   data_size = sizeof(SetMaxVelocityMessage_data_t);
01235   data_ptr  = malloc(data_size);
01236   memset(data_ptr, 0, data_size);
01237   data      = (SetMaxVelocityMessage_data_t *)data_ptr;
01238   data->max_velocity = ini_max_velocity;
01239   add_fieldinfo(IFT_BYTE, "max_velocity", 1, &data->max_velocity);
01240 }
01241 /** Constructor */
01242 KatanaInterface::SetMaxVelocityMessage::SetMaxVelocityMessage() : Message("SetMaxVelocityMessage")
01243 {
01244   data_size = sizeof(SetMaxVelocityMessage_data_t);
01245   data_ptr  = malloc(data_size);
01246   memset(data_ptr, 0, data_size);
01247   data      = (SetMaxVelocityMessage_data_t *)data_ptr;
01248   add_fieldinfo(IFT_BYTE, "max_velocity", 1, &data->max_velocity);
01249 }
01250 
01251 /** Destructor */
01252 KatanaInterface::SetMaxVelocityMessage::~SetMaxVelocityMessage()
01253 {
01254   free(data_ptr);
01255 }
01256 
01257 /** Copy constructor.
01258  * @param m message to copy from
01259  */
01260 KatanaInterface::SetMaxVelocityMessage::SetMaxVelocityMessage(const SetMaxVelocityMessage *m) : Message("SetMaxVelocityMessage")
01261 {
01262   data_size = m->data_size;
01263   data_ptr  = malloc(data_size);
01264   memcpy(data_ptr, m->data_ptr, data_size);
01265   data      = (SetMaxVelocityMessage_data_t *)data_ptr;
01266 }
01267
01268 /* Methods */
01269 /** Get max_velocity value.
01270  * Maximum velocity
01271  * @return max_velocity value
01272  */
01273 unsigned char
01274 KatanaInterface::SetMaxVelocityMessage::max_velocity() const
01275 {
01276   return data->max_velocity;
01277 }
01278 
01279 /** Get maximum length of max_velocity value.
01280  * @return length of max_velocity value, can be length of the array or number of 
01281  * maximum number of characters for a string
01282  */
01283 size_t
01284 KatanaInterface::SetMaxVelocityMessage::maxlenof_max_velocity() const
01285 {
01286   return 1;
01287 }
01288 
01289 /** Set max_velocity value.
01290  * Maximum velocity
01291  * @param new_max_velocity new max_velocity value
01292  */
01293 void
01294 KatanaInterface::SetMaxVelocityMessage::set_max_velocity(const unsigned char new_max_velocity)
01295 {
01296   data->max_velocity = new_max_velocity;
01297 }
01298 
01299 /** Clone this message.
01300  * Produces a message of the same type as this message and copies the
01301  * data to the new message.
01302  * @return clone of this message
01303  */
01304 Message *
01305 KatanaInterface::SetMaxVelocityMessage::clone() const
01306 {
01307   return new KatanaInterface::SetMaxVelocityMessage(this);
01308 }
01309 /** Check if message is valid and can be enqueued.
01310  * @param message Message to check
01311  */
01312 bool
01313 KatanaInterface::message_valid(const Message *message) const
01314 {
01315   const StopMessage *m0 = dynamic_cast<const StopMessage *>(message);
01316   if ( m0 != NULL ) {
01317     return true;
01318   }
01319   const FlushMessage *m1 = dynamic_cast<const FlushMessage *>(message);
01320   if ( m1 != NULL ) {
01321     return true;
01322   }
01323   const ParkMessage *m2 = dynamic_cast<const ParkMessage *>(message);
01324   if ( m2 != NULL ) {
01325     return true;
01326   }
01327   const LinearGotoMessage *m3 = dynamic_cast<const LinearGotoMessage *>(message);
01328   if ( m3 != NULL ) {
01329     return true;
01330   }
01331   const CalibrateMessage *m4 = dynamic_cast<const CalibrateMessage *>(message);
01332   if ( m4 != NULL ) {
01333     return true;
01334   }
01335   const OpenGripperMessage *m5 = dynamic_cast<const OpenGripperMessage *>(message);
01336   if ( m5 != NULL ) {
01337     return true;
01338   }
01339   const CloseGripperMessage *m6 = dynamic_cast<const CloseGripperMessage *>(message);
01340   if ( m6 != NULL ) {
01341     return true;
01342   }
01343   const SetEnabledMessage *m7 = dynamic_cast<const SetEnabledMessage *>(message);
01344   if ( m7 != NULL ) {
01345     return true;
01346   }
01347   const SetMaxVelocityMessage *m8 = dynamic_cast<const SetMaxVelocityMessage *>(message);
01348   if ( m8 != NULL ) {
01349     return true;
01350   }
01351   return false;
01352 }
01353 
01354 /// @cond INTERNALS
01355 EXPORT_INTERFACE(KatanaInterface)
01356 /// @endcond
01357 
01358
01359 } // end namespace fawkes