PanTiltInterface.cpp

00001 
00002 /***************************************************************************
00003  *  PanTiltInterface.cpp - Fawkes BlackBoard Interface - PanTiltInterface
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/PanTiltInterface.h>
00025 
00026 #include <core/exceptions/software.h>
00027 
00028 #include <cstring>
00029 #include <cstdlib>
00030 
00031 namespace fawkes {
00032 
00033 /** @class PanTiltInterface <interfaces/PanTiltInterface.h>
00034  * PanTiltInterface Fawkes BlackBoard Interface.
00035  * 
00036       Interface to access pan/tilt units.
00037     
00038  * @ingroup FawkesInterfaces
00039  */
00040 
00041 
00042 /** FLAG_SUPPORTS_PAN constant */
00043 const uint32_t PanTiltInterface::FLAG_SUPPORTS_PAN = 1u;
00044 /** FLAG_SUPPORTS_TILT constant */
00045 const uint32_t PanTiltInterface::FLAG_SUPPORTS_TILT = 2u;
00046 /** ERROR_NONE constant */
00047 const uint32_t PanTiltInterface::ERROR_NONE = 0u;
00048 /** ERROR_UNSPECIFIC constant */
00049 const uint32_t PanTiltInterface::ERROR_UNSPECIFIC = 1u;
00050 /** ERROR_COMMUNICATION constant */
00051 const uint32_t PanTiltInterface::ERROR_COMMUNICATION = 2u;
00052 /** ERROR_PAN_OUTOFRANGE constant */
00053 const uint32_t PanTiltInterface::ERROR_PAN_OUTOFRANGE = 4u;
00054 /** ERROR_TILT_OUTOFRANGE constant */
00055 const uint32_t PanTiltInterface::ERROR_TILT_OUTOFRANGE = 8u;
00056 
00057 /** Constructor */
00058 PanTiltInterface::PanTiltInterface() : Interface()
00059 {
00060   data_size = sizeof(PanTiltInterface_data_t);
00061   data_ptr  = malloc(data_size);
00062   data      = (PanTiltInterface_data_t *)data_ptr;
00063   data_ts   = (interface_data_ts_t *)data_ptr;
00064   memset(data_ptr, 0, data_size);
00065   add_fieldinfo(IFT_UINT32, "flags", 1, &data->flags);
00066   add_fieldinfo(IFT_FLOAT, "pan", 1, &data->pan);
00067   add_fieldinfo(IFT_FLOAT, "tilt", 1, &data->tilt);
00068   add_fieldinfo(IFT_UINT32, "msgid", 1, &data->msgid);
00069   add_fieldinfo(IFT_BOOL, "final", 1, &data->final);
00070   add_fieldinfo(IFT_UINT32, "error_code", 1, &data->error_code);
00071   add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
00072   add_fieldinfo(IFT_BOOL, "calibrated", 1, &data->calibrated);
00073   add_fieldinfo(IFT_FLOAT, "min_pan", 1, &data->min_pan);
00074   add_fieldinfo(IFT_FLOAT, "max_pan", 1, &data->max_pan);
00075   add_fieldinfo(IFT_FLOAT, "min_tilt", 1, &data->min_tilt);
00076   add_fieldinfo(IFT_FLOAT, "max_tilt", 1, &data->max_tilt);
00077   add_fieldinfo(IFT_FLOAT, "max_pan_velocity", 1, &data->max_pan_velocity);
00078   add_fieldinfo(IFT_FLOAT, "max_tilt_velocity", 1, &data->max_tilt_velocity);
00079   add_fieldinfo(IFT_FLOAT, "pan_velocity", 1, &data->pan_velocity);
00080   add_fieldinfo(IFT_FLOAT, "tilt_velocity", 1, &data->tilt_velocity);
00081   add_fieldinfo(IFT_FLOAT, "pan_margin", 1, &data->pan_margin);
00082   add_fieldinfo(IFT_FLOAT, "tilt_margin", 1, &data->tilt_margin);
00083   add_messageinfo("StopMessage");
00084   add_messageinfo("FlushMessage");
00085   add_messageinfo("CalibrateMessage");
00086   add_messageinfo("ParkMessage");
00087   add_messageinfo("GotoMessage");
00088   add_messageinfo("TimedGotoMessage");
00089   add_messageinfo("SetEnabledMessage");
00090   add_messageinfo("SetVelocityMessage");
00091   add_messageinfo("SetMarginMessage");
00092   unsigned char tmp_hash[] = {0x3, 0xd7, 0x3b, 0xa8, 0x9f, 0x6d, 00, 0xb9, 0xf5, 0xf2, 0x2f, 0x92, 0x25, 0x1b, 0x87, 0x8e};
00093   set_hash(tmp_hash);
00094 }
00095 
00096 /** Destructor */
00097 PanTiltInterface::~PanTiltInterface()
00098 {
00099   free(data_ptr);
00100 }
00101 /* Methods */
00102 /** Get flags value.
00103  * Flags.
00104  * @return flags value
00105  */
00106 uint32_t
00107 PanTiltInterface::flags() const
00108 {
00109   return data->flags;
00110 }
00111 
00112 /** Get maximum length of flags value.
00113  * @return length of flags value, can be length of the array or number of 
00114  * maximum number of characters for a string
00115  */
00116 size_t
00117 PanTiltInterface::maxlenof_flags() const
00118 {
00119   return 1;
00120 }
00121 
00122 /** Set flags value.
00123  * Flags.
00124  * @param new_flags new flags value
00125  */
00126 void
00127 PanTiltInterface::set_flags(const uint32_t new_flags)
00128 {
00129   data->flags = new_flags;
00130   data_changed = true;
00131 }
00132 
00133 /** Get pan value.
00134  * Current pan.
00135  * @return pan value
00136  */
00137 float
00138 PanTiltInterface::pan() const
00139 {
00140   return data->pan;
00141 }
00142 
00143 /** Get maximum length of pan value.
00144  * @return length of pan value, can be length of the array or number of 
00145  * maximum number of characters for a string
00146  */
00147 size_t
00148 PanTiltInterface::maxlenof_pan() const
00149 {
00150   return 1;
00151 }
00152 
00153 /** Set pan value.
00154  * Current pan.
00155  * @param new_pan new pan value
00156  */
00157 void
00158 PanTiltInterface::set_pan(const float new_pan)
00159 {
00160   data->pan = new_pan;
00161   data_changed = true;
00162 }
00163 
00164 /** Get tilt value.
00165  * Current tilt.
00166  * @return tilt value
00167  */
00168 float
00169 PanTiltInterface::tilt() const
00170 {
00171   return data->tilt;
00172 }
00173 
00174 /** Get maximum length of tilt value.
00175  * @return length of tilt value, can be length of the array or number of 
00176  * maximum number of characters for a string
00177  */
00178 size_t
00179 PanTiltInterface::maxlenof_tilt() const
00180 {
00181   return 1;
00182 }
00183 
00184 /** Set tilt value.
00185  * Current tilt.
00186  * @param new_tilt new tilt value
00187  */
00188 void
00189 PanTiltInterface::set_tilt(const float new_tilt)
00190 {
00191   data->tilt = new_tilt;
00192   data_changed = true;
00193 }
00194 
00195 /** Get msgid value.
00196  * The ID of the message that is currently being
00197       processed, or 0 if no message is being processed.
00198  * @return msgid value
00199  */
00200 uint32_t
00201 PanTiltInterface::msgid() const
00202 {
00203   return data->msgid;
00204 }
00205 
00206 /** Get maximum length of msgid value.
00207  * @return length of msgid value, can be length of the array or number of 
00208  * maximum number of characters for a string
00209  */
00210 size_t
00211 PanTiltInterface::maxlenof_msgid() const
00212 {
00213   return 1;
00214 }
00215 
00216 /** Set msgid value.
00217  * The ID of the message that is currently being
00218       processed, or 0 if no message is being processed.
00219  * @param new_msgid new msgid value
00220  */
00221 void
00222 PanTiltInterface::set_msgid(const uint32_t new_msgid)
00223 {
00224   data->msgid = new_msgid;
00225   data_changed = true;
00226 }
00227 
00228 /** Get final value.
00229  * True, if the last goto command has been finished,
00230       false if it is still running
00231  * @return final value
00232  */
00233 bool
00234 PanTiltInterface::is_final() const
00235 {
00236   return data->final;
00237 }
00238 
00239 /** Get maximum length of final value.
00240  * @return length of final value, can be length of the array or number of 
00241  * maximum number of characters for a string
00242  */
00243 size_t
00244 PanTiltInterface::maxlenof_final() const
00245 {
00246   return 1;
00247 }
00248 
00249 /** Set final value.
00250  * True, if the last goto command has been finished,
00251       false if it is still running
00252  * @param new_final new final value
00253  */
00254 void
00255 PanTiltInterface::set_final(const bool new_final)
00256 {
00257   data->final = new_final;
00258   data_changed = true;
00259 }
00260 
00261 /** Get error_code value.
00262  * Failure code set if
00263     final is true. 0 if no error occured, an error code from ERROR_*
00264     constants otherwise (or a bit-wise combination).
00265  * @return error_code value
00266  */
00267 uint32_t
00268 PanTiltInterface::error_code() const
00269 {
00270   return data->error_code;
00271 }
00272 
00273 /** Get maximum length of error_code value.
00274  * @return length of error_code value, can be length of the array or number of 
00275  * maximum number of characters for a string
00276  */
00277 size_t
00278 PanTiltInterface::maxlenof_error_code() const
00279 {
00280   return 1;
00281 }
00282 
00283 /** Set error_code value.
00284  * Failure code set if
00285     final is true. 0 if no error occured, an error code from ERROR_*
00286     constants otherwise (or a bit-wise combination).
00287  * @param new_error_code new error_code value
00288  */
00289 void
00290 PanTiltInterface::set_error_code(const uint32_t new_error_code)
00291 {
00292   data->error_code = new_error_code;
00293   data_changed = true;
00294 }
00295 
00296 /** Get enabled value.
00297  * Is the pan/tilt unit enabled?
00298  * @return enabled value
00299  */
00300 bool
00301 PanTiltInterface::is_enabled() const
00302 {
00303   return data->enabled;
00304 }
00305 
00306 /** Get maximum length of enabled value.
00307  * @return length of enabled value, can be length of the array or number of 
00308  * maximum number of characters for a string
00309  */
00310 size_t
00311 PanTiltInterface::maxlenof_enabled() const
00312 {
00313   return 1;
00314 }
00315 
00316 /** Set enabled value.
00317  * Is the pan/tilt unit enabled?
00318  * @param new_enabled new enabled value
00319  */
00320 void
00321 PanTiltInterface::set_enabled(const bool new_enabled)
00322 {
00323   data->enabled = new_enabled;
00324   data_changed = true;
00325 }
00326 
00327 /** Get calibrated value.
00328  * Is the pan/tilt unit calibrated?
00329  * @return calibrated value
00330  */
00331 bool
00332 PanTiltInterface::is_calibrated() const
00333 {
00334   return data->calibrated;
00335 }
00336 
00337 /** Get maximum length of calibrated value.
00338  * @return length of calibrated value, can be length of the array or number of 
00339  * maximum number of characters for a string
00340  */
00341 size_t
00342 PanTiltInterface::maxlenof_calibrated() const
00343 {
00344   return 1;
00345 }
00346 
00347 /** Set calibrated value.
00348  * Is the pan/tilt unit calibrated?
00349  * @param new_calibrated new calibrated value
00350  */
00351 void
00352 PanTiltInterface::set_calibrated(const bool new_calibrated)
00353 {
00354   data->calibrated = new_calibrated;
00355   data_changed = true;
00356 }
00357 
00358 /** Get min_pan value.
00359  * Minimum pan possible.
00360  * @return min_pan value
00361  */
00362 float
00363 PanTiltInterface::min_pan() const
00364 {
00365   return data->min_pan;
00366 }
00367 
00368 /** Get maximum length of min_pan value.
00369  * @return length of min_pan value, can be length of the array or number of 
00370  * maximum number of characters for a string
00371  */
00372 size_t
00373 PanTiltInterface::maxlenof_min_pan() const
00374 {
00375   return 1;
00376 }
00377 
00378 /** Set min_pan value.
00379  * Minimum pan possible.
00380  * @param new_min_pan new min_pan value
00381  */
00382 void
00383 PanTiltInterface::set_min_pan(const float new_min_pan)
00384 {
00385   data->min_pan = new_min_pan;
00386   data_changed = true;
00387 }
00388 
00389 /** Get max_pan value.
00390  * Maximum pan possible.
00391  * @return max_pan value
00392  */
00393 float
00394 PanTiltInterface::max_pan() const
00395 {
00396   return data->max_pan;
00397 }
00398 
00399 /** Get maximum length of max_pan value.
00400  * @return length of max_pan value, can be length of the array or number of 
00401  * maximum number of characters for a string
00402  */
00403 size_t
00404 PanTiltInterface::maxlenof_max_pan() const
00405 {
00406   return 1;
00407 }
00408 
00409 /** Set max_pan value.
00410  * Maximum pan possible.
00411  * @param new_max_pan new max_pan value
00412  */
00413 void
00414 PanTiltInterface::set_max_pan(const float new_max_pan)
00415 {
00416   data->max_pan = new_max_pan;
00417   data_changed = true;
00418 }
00419 
00420 /** Get min_tilt value.
00421  * Minimum tilt possible.
00422  * @return min_tilt value
00423  */
00424 float
00425 PanTiltInterface::min_tilt() const
00426 {
00427   return data->min_tilt;
00428 }
00429 
00430 /** Get maximum length of min_tilt value.
00431  * @return length of min_tilt value, can be length of the array or number of 
00432  * maximum number of characters for a string
00433  */
00434 size_t
00435 PanTiltInterface::maxlenof_min_tilt() const
00436 {
00437   return 1;
00438 }
00439 
00440 /** Set min_tilt value.
00441  * Minimum tilt possible.
00442  * @param new_min_tilt new min_tilt value
00443  */
00444 void
00445 PanTiltInterface::set_min_tilt(const float new_min_tilt)
00446 {
00447   data->min_tilt = new_min_tilt;
00448   data_changed = true;
00449 }
00450 
00451 /** Get max_tilt value.
00452  * Maximum tilt possible.
00453  * @return max_tilt value
00454  */
00455 float
00456 PanTiltInterface::max_tilt() const
00457 {
00458   return data->max_tilt;
00459 }
00460 
00461 /** Get maximum length of max_tilt value.
00462  * @return length of max_tilt value, can be length of the array or number of 
00463  * maximum number of characters for a string
00464  */
00465 size_t
00466 PanTiltInterface::maxlenof_max_tilt() const
00467 {
00468   return 1;
00469 }
00470 
00471 /** Set max_tilt value.
00472  * Maximum tilt possible.
00473  * @param new_max_tilt new max_tilt value
00474  */
00475 void
00476 PanTiltInterface::set_max_tilt(const float new_max_tilt)
00477 {
00478   data->max_tilt = new_max_tilt;
00479   data_changed = true;
00480 }
00481 
00482 /** Get max_pan_velocity value.
00483  * Maximum supported pan velocity.
00484  * @return max_pan_velocity value
00485  */
00486 float
00487 PanTiltInterface::max_pan_velocity() const
00488 {
00489   return data->max_pan_velocity;
00490 }
00491 
00492 /** Get maximum length of max_pan_velocity value.
00493  * @return length of max_pan_velocity value, can be length of the array or number of 
00494  * maximum number of characters for a string
00495  */
00496 size_t
00497 PanTiltInterface::maxlenof_max_pan_velocity() const
00498 {
00499   return 1;
00500 }
00501 
00502 /** Set max_pan_velocity value.
00503  * Maximum supported pan velocity.
00504  * @param new_max_pan_velocity new max_pan_velocity value
00505  */
00506 void
00507 PanTiltInterface::set_max_pan_velocity(const float new_max_pan_velocity)
00508 {
00509   data->max_pan_velocity = new_max_pan_velocity;
00510   data_changed = true;
00511 }
00512 
00513 /** Get max_tilt_velocity value.
00514  * Maximum supported tilt velocity.
00515  * @return max_tilt_velocity value
00516  */
00517 float
00518 PanTiltInterface::max_tilt_velocity() const
00519 {
00520   return data->max_tilt_velocity;
00521 }
00522 
00523 /** Get maximum length of max_tilt_velocity value.
00524  * @return length of max_tilt_velocity value, can be length of the array or number of 
00525  * maximum number of characters for a string
00526  */
00527 size_t
00528 PanTiltInterface::maxlenof_max_tilt_velocity() const
00529 {
00530   return 1;
00531 }
00532 
00533 /** Set max_tilt_velocity value.
00534  * Maximum supported tilt velocity.
00535  * @param new_max_tilt_velocity new max_tilt_velocity value
00536  */
00537 void
00538 PanTiltInterface::set_max_tilt_velocity(const float new_max_tilt_velocity)
00539 {
00540   data->max_tilt_velocity = new_max_tilt_velocity;
00541   data_changed = true;
00542 }
00543 
00544 /** Get pan_velocity value.
00545  * Maximum pan velocity currently reached.
00546  * @return pan_velocity value
00547  */
00548 float
00549 PanTiltInterface::pan_velocity() const
00550 {
00551   return data->pan_velocity;
00552 }
00553 
00554 /** Get maximum length of pan_velocity value.
00555  * @return length of pan_velocity value, can be length of the array or number of 
00556  * maximum number of characters for a string
00557  */
00558 size_t
00559 PanTiltInterface::maxlenof_pan_velocity() const
00560 {
00561   return 1;
00562 }
00563 
00564 /** Set pan_velocity value.
00565  * Maximum pan velocity currently reached.
00566  * @param new_pan_velocity new pan_velocity value
00567  */
00568 void
00569 PanTiltInterface::set_pan_velocity(const float new_pan_velocity)
00570 {
00571   data->pan_velocity = new_pan_velocity;
00572   data_changed = true;
00573 }
00574 
00575 /** Get tilt_velocity value.
00576  * Maximum tilt velocity currently reached.
00577  * @return tilt_velocity value
00578  */
00579 float
00580 PanTiltInterface::tilt_velocity() const
00581 {
00582   return data->tilt_velocity;
00583 }
00584 
00585 /** Get maximum length of tilt_velocity value.
00586  * @return length of tilt_velocity value, can be length of the array or number of 
00587  * maximum number of characters for a string
00588  */
00589 size_t
00590 PanTiltInterface::maxlenof_tilt_velocity() const
00591 {
00592   return 1;
00593 }
00594 
00595 /** Set tilt_velocity value.
00596  * Maximum tilt velocity currently reached.
00597  * @param new_tilt_velocity new tilt_velocity value
00598  */
00599 void
00600 PanTiltInterface::set_tilt_velocity(const float new_tilt_velocity)
00601 {
00602   data->tilt_velocity = new_tilt_velocity;
00603   data_changed = true;
00604 }
00605 
00606 /** Get pan_margin value.
00607  * Margin in radians around a
00608     target pan value to consider the motion as final.
00609  * @return pan_margin value
00610  */
00611 float
00612 PanTiltInterface::pan_margin() const
00613 {
00614   return data->pan_margin;
00615 }
00616 
00617 /** Get maximum length of pan_margin value.
00618  * @return length of pan_margin value, can be length of the array or number of 
00619  * maximum number of characters for a string
00620  */
00621 size_t
00622 PanTiltInterface::maxlenof_pan_margin() const
00623 {
00624   return 1;
00625 }
00626 
00627 /** Set pan_margin value.
00628  * Margin in radians around a
00629     target pan value to consider the motion as final.
00630  * @param new_pan_margin new pan_margin value
00631  */
00632 void
00633 PanTiltInterface::set_pan_margin(const float new_pan_margin)
00634 {
00635   data->pan_margin = new_pan_margin;
00636   data_changed = true;
00637 }
00638 
00639 /** Get tilt_margin value.
00640  * Margin in radians around a
00641     target tilt value to consider the motion as final.
00642  * @return tilt_margin value
00643  */
00644 float
00645 PanTiltInterface::tilt_margin() const
00646 {
00647   return data->tilt_margin;
00648 }
00649 
00650 /** Get maximum length of tilt_margin value.
00651  * @return length of tilt_margin value, can be length of the array or number of 
00652  * maximum number of characters for a string
00653  */
00654 size_t
00655 PanTiltInterface::maxlenof_tilt_margin() const
00656 {
00657   return 1;
00658 }
00659 
00660 /** Set tilt_margin value.
00661  * Margin in radians around a
00662     target tilt value to consider the motion as final.
00663  * @param new_tilt_margin new tilt_margin value
00664  */
00665 void
00666 PanTiltInterface::set_tilt_margin(const float new_tilt_margin)
00667 {
00668   data->tilt_margin = new_tilt_margin;
00669   data_changed = true;
00670 }
00671 
00672 /* =========== message create =========== */
00673 Message *
00674 PanTiltInterface::create_message(const char *type) const
00675 {
00676   if ( strncmp("StopMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00677     return new StopMessage();
00678   } else if ( strncmp("FlushMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00679     return new FlushMessage();
00680   } else if ( strncmp("CalibrateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00681     return new CalibrateMessage();
00682   } else if ( strncmp("ParkMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00683     return new ParkMessage();
00684   } else if ( strncmp("GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00685     return new GotoMessage();
00686   } else if ( strncmp("TimedGotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00687     return new TimedGotoMessage();
00688   } else if ( strncmp("SetEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00689     return new SetEnabledMessage();
00690   } else if ( strncmp("SetVelocityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00691     return new SetVelocityMessage();
00692   } else if ( strncmp("SetMarginMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00693     return new SetMarginMessage();
00694   } else {
00695     throw UnknownTypeException("The given type '%s' does not match any known "
00696                                "message type for this interface type.", type);
00697   }
00698 }
00699 
00700 
00701 /** Copy values from other interface.
00702  * @param other other interface to copy values from
00703  */
00704 void
00705 PanTiltInterface::copy_values(const Interface *other)
00706 {
00707   const PanTiltInterface *oi = dynamic_cast<const PanTiltInterface *>(other);
00708   if (oi == NULL) {
00709     throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00710                                 type(), other->type());
00711   }
00712   memcpy(data, oi->data, sizeof(PanTiltInterface_data_t));
00713 }
00714 
00715 const char *
00716 PanTiltInterface::enum_tostring(const char *enumtype, int val) const
00717 {
00718   throw UnknownTypeException("Unknown enum type %s", enumtype);
00719 }
00720 
00721 /* =========== messages =========== */
00722 /** @class PanTiltInterface::StopMessage <interfaces/PanTiltInterface.h>
00723  * StopMessage Fawkes BlackBoard Interface Message.
00724  * 
00725     
00726  */
00727 
00728 
00729 /** Constructor */
00730 PanTiltInterface::StopMessage::StopMessage() : Message("StopMessage")
00731 {
00732   data_size = sizeof(StopMessage_data_t);
00733   data_ptr  = malloc(data_size);
00734   memset(data_ptr, 0, data_size);
00735   data      = (StopMessage_data_t *)data_ptr;
00736   data_ts   = (message_data_ts_t *)data_ptr;
00737 }
00738 
00739 /** Destructor */
00740 PanTiltInterface::StopMessage::~StopMessage()
00741 {
00742   free(data_ptr);
00743 }
00744 
00745 /** Copy constructor.
00746  * @param m message to copy from
00747  */
00748 PanTiltInterface::StopMessage::StopMessage(const StopMessage *m) : Message("StopMessage")
00749 {
00750   data_size = m->data_size;
00751   data_ptr  = malloc(data_size);
00752   memcpy(data_ptr, m->data_ptr, data_size);
00753   data      = (StopMessage_data_t *)data_ptr;
00754   data_ts   = (message_data_ts_t *)data_ptr;
00755 }
00756 
00757 /* Methods */
00758 /** Clone this message.
00759  * Produces a message of the same type as this message and copies the
00760  * data to the new message.
00761  * @return clone of this message
00762  */
00763 Message *
00764 PanTiltInterface::StopMessage::clone() const
00765 {
00766   return new PanTiltInterface::StopMessage(this);
00767 }
00768 /** @class PanTiltInterface::FlushMessage <interfaces/PanTiltInterface.h>
00769  * FlushMessage Fawkes BlackBoard Interface Message.
00770  * 
00771     
00772  */
00773 
00774 
00775 /** Constructor */
00776 PanTiltInterface::FlushMessage::FlushMessage() : Message("FlushMessage")
00777 {
00778   data_size = sizeof(FlushMessage_data_t);
00779   data_ptr  = malloc(data_size);
00780   memset(data_ptr, 0, data_size);
00781   data      = (FlushMessage_data_t *)data_ptr;
00782   data_ts   = (message_data_ts_t *)data_ptr;
00783 }
00784 
00785 /** Destructor */
00786 PanTiltInterface::FlushMessage::~FlushMessage()
00787 {
00788   free(data_ptr);
00789 }
00790 
00791 /** Copy constructor.
00792  * @param m message to copy from
00793  */
00794 PanTiltInterface::FlushMessage::FlushMessage(const FlushMessage *m) : Message("FlushMessage")
00795 {
00796   data_size = m->data_size;
00797   data_ptr  = malloc(data_size);
00798   memcpy(data_ptr, m->data_ptr, data_size);
00799   data      = (FlushMessage_data_t *)data_ptr;
00800   data_ts   = (message_data_ts_t *)data_ptr;
00801 }
00802 
00803 /* Methods */
00804 /** Clone this message.
00805  * Produces a message of the same type as this message and copies the
00806  * data to the new message.
00807  * @return clone of this message
00808  */
00809 Message *
00810 PanTiltInterface::FlushMessage::clone() const
00811 {
00812   return new PanTiltInterface::FlushMessage(this);
00813 }
00814 /** @class PanTiltInterface::CalibrateMessage <interfaces/PanTiltInterface.h>
00815  * CalibrateMessage Fawkes BlackBoard Interface Message.
00816  * 
00817     
00818  */
00819 
00820 
00821 /** Constructor */
00822 PanTiltInterface::CalibrateMessage::CalibrateMessage() : Message("CalibrateMessage")
00823 {
00824   data_size = sizeof(CalibrateMessage_data_t);
00825   data_ptr  = malloc(data_size);
00826   memset(data_ptr, 0, data_size);
00827   data      = (CalibrateMessage_data_t *)data_ptr;
00828   data_ts   = (message_data_ts_t *)data_ptr;
00829 }
00830 
00831 /** Destructor */
00832 PanTiltInterface::CalibrateMessage::~CalibrateMessage()
00833 {
00834   free(data_ptr);
00835 }
00836 
00837 /** Copy constructor.
00838  * @param m message to copy from
00839  */
00840 PanTiltInterface::CalibrateMessage::CalibrateMessage(const CalibrateMessage *m) : Message("CalibrateMessage")
00841 {
00842   data_size = m->data_size;
00843   data_ptr  = malloc(data_size);
00844   memcpy(data_ptr, m->data_ptr, data_size);
00845   data      = (CalibrateMessage_data_t *)data_ptr;
00846   data_ts   = (message_data_ts_t *)data_ptr;
00847 }
00848 
00849 /* Methods */
00850 /** Clone this message.
00851  * Produces a message of the same type as this message and copies the
00852  * data to the new message.
00853  * @return clone of this message
00854  */
00855 Message *
00856 PanTiltInterface::CalibrateMessage::clone() const
00857 {
00858   return new PanTiltInterface::CalibrateMessage(this);
00859 }
00860 /** @class PanTiltInterface::ParkMessage <interfaces/PanTiltInterface.h>
00861  * ParkMessage Fawkes BlackBoard Interface Message.
00862  * 
00863     
00864  */
00865 
00866 
00867 /** Constructor */
00868 PanTiltInterface::ParkMessage::ParkMessage() : Message("ParkMessage")
00869 {
00870   data_size = sizeof(ParkMessage_data_t);
00871   data_ptr  = malloc(data_size);
00872   memset(data_ptr, 0, data_size);
00873   data      = (ParkMessage_data_t *)data_ptr;
00874   data_ts   = (message_data_ts_t *)data_ptr;
00875 }
00876 
00877 /** Destructor */
00878 PanTiltInterface::ParkMessage::~ParkMessage()
00879 {
00880   free(data_ptr);
00881 }
00882 
00883 /** Copy constructor.
00884  * @param m message to copy from
00885  */
00886 PanTiltInterface::ParkMessage::ParkMessage(const ParkMessage *m) : Message("ParkMessage")
00887 {
00888   data_size = m->data_size;
00889   data_ptr  = malloc(data_size);
00890   memcpy(data_ptr, m->data_ptr, data_size);
00891   data      = (ParkMessage_data_t *)data_ptr;
00892   data_ts   = (message_data_ts_t *)data_ptr;
00893 }
00894 
00895 /* Methods */
00896 /** Clone this message.
00897  * Produces a message of the same type as this message and copies the
00898  * data to the new message.
00899  * @return clone of this message
00900  */
00901 Message *
00902 PanTiltInterface::ParkMessage::clone() const
00903 {
00904   return new PanTiltInterface::ParkMessage(this);
00905 }
00906 /** @class PanTiltInterface::GotoMessage <interfaces/PanTiltInterface.h>
00907  * GotoMessage Fawkes BlackBoard Interface Message.
00908  * 
00909     
00910  */
00911 
00912 
00913 /** Constructor with initial values.
00914  * @param ini_pan initial value for pan
00915  * @param ini_tilt initial value for tilt
00916  */
00917 PanTiltInterface::GotoMessage::GotoMessage(const float ini_pan, const float ini_tilt) : Message("GotoMessage")
00918 {
00919   data_size = sizeof(GotoMessage_data_t);
00920   data_ptr  = malloc(data_size);
00921   memset(data_ptr, 0, data_size);
00922   data      = (GotoMessage_data_t *)data_ptr;
00923   data_ts   = (message_data_ts_t *)data_ptr;
00924   data->pan = ini_pan;
00925   data->tilt = ini_tilt;
00926   add_fieldinfo(IFT_FLOAT, "pan", 1, &data->pan);
00927   add_fieldinfo(IFT_FLOAT, "tilt", 1, &data->tilt);
00928 }
00929 /** Constructor */
00930 PanTiltInterface::GotoMessage::GotoMessage() : Message("GotoMessage")
00931 {
00932   data_size = sizeof(GotoMessage_data_t);
00933   data_ptr  = malloc(data_size);
00934   memset(data_ptr, 0, data_size);
00935   data      = (GotoMessage_data_t *)data_ptr;
00936   data_ts   = (message_data_ts_t *)data_ptr;
00937   add_fieldinfo(IFT_FLOAT, "pan", 1, &data->pan);
00938   add_fieldinfo(IFT_FLOAT, "tilt", 1, &data->tilt);
00939 }
00940 
00941 /** Destructor */
00942 PanTiltInterface::GotoMessage::~GotoMessage()
00943 {
00944   free(data_ptr);
00945 }
00946 
00947 /** Copy constructor.
00948  * @param m message to copy from
00949  */
00950 PanTiltInterface::GotoMessage::GotoMessage(const GotoMessage *m) : Message("GotoMessage")
00951 {
00952   data_size = m->data_size;
00953   data_ptr  = malloc(data_size);
00954   memcpy(data_ptr, m->data_ptr, data_size);
00955   data      = (GotoMessage_data_t *)data_ptr;
00956   data_ts   = (message_data_ts_t *)data_ptr;
00957 }
00958 
00959 /* Methods */
00960 /** Get pan value.
00961  * Current pan.
00962  * @return pan value
00963  */
00964 float
00965 PanTiltInterface::GotoMessage::pan() const
00966 {
00967   return data->pan;
00968 }
00969 
00970 /** Get maximum length of pan value.
00971  * @return length of pan value, can be length of the array or number of 
00972  * maximum number of characters for a string
00973  */
00974 size_t
00975 PanTiltInterface::GotoMessage::maxlenof_pan() const
00976 {
00977   return 1;
00978 }
00979 
00980 /** Set pan value.
00981  * Current pan.
00982  * @param new_pan new pan value
00983  */
00984 void
00985 PanTiltInterface::GotoMessage::set_pan(const float new_pan)
00986 {
00987   data->pan = new_pan;
00988 }
00989 
00990 /** Get tilt value.
00991  * Current tilt.
00992  * @return tilt value
00993  */
00994 float
00995 PanTiltInterface::GotoMessage::tilt() const
00996 {
00997   return data->tilt;
00998 }
00999 
01000 /** Get maximum length of tilt value.
01001  * @return length of tilt value, can be length of the array or number of 
01002  * maximum number of characters for a string
01003  */
01004 size_t
01005 PanTiltInterface::GotoMessage::maxlenof_tilt() const
01006 {
01007   return 1;
01008 }
01009 
01010 /** Set tilt value.
01011  * Current tilt.
01012  * @param new_tilt new tilt value
01013  */
01014 void
01015 PanTiltInterface::GotoMessage::set_tilt(const float new_tilt)
01016 {
01017   data->tilt = new_tilt;
01018 }
01019 
01020 /** Clone this message.
01021  * Produces a message of the same type as this message and copies the
01022  * data to the new message.
01023  * @return clone of this message
01024  */
01025 Message *
01026 PanTiltInterface::GotoMessage::clone() const
01027 {
01028   return new PanTiltInterface::GotoMessage(this);
01029 }
01030 /** @class PanTiltInterface::TimedGotoMessage <interfaces/PanTiltInterface.h>
01031  * TimedGotoMessage Fawkes BlackBoard Interface Message.
01032  * 
01033     
01034  */
01035 
01036 
01037 /** Constructor with initial values.
01038  * @param ini_time_sec initial value for time_sec
01039  * @param ini_pan initial value for pan
01040  * @param ini_tilt initial value for tilt
01041  */
01042 PanTiltInterface::TimedGotoMessage::TimedGotoMessage(const float ini_time_sec, const float ini_pan, const float ini_tilt) : Message("TimedGotoMessage")
01043 {
01044   data_size = sizeof(TimedGotoMessage_data_t);
01045   data_ptr  = malloc(data_size);
01046   memset(data_ptr, 0, data_size);
01047   data      = (TimedGotoMessage_data_t *)data_ptr;
01048   data_ts   = (message_data_ts_t *)data_ptr;
01049   data->time_sec = ini_time_sec;
01050   data->pan = ini_pan;
01051   data->tilt = ini_tilt;
01052   add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
01053   add_fieldinfo(IFT_FLOAT, "pan", 1, &data->pan);
01054   add_fieldinfo(IFT_FLOAT, "tilt", 1, &data->tilt);
01055 }
01056 /** Constructor */
01057 PanTiltInterface::TimedGotoMessage::TimedGotoMessage() : Message("TimedGotoMessage")
01058 {
01059   data_size = sizeof(TimedGotoMessage_data_t);
01060   data_ptr  = malloc(data_size);
01061   memset(data_ptr, 0, data_size);
01062   data      = (TimedGotoMessage_data_t *)data_ptr;
01063   data_ts   = (message_data_ts_t *)data_ptr;
01064   add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
01065   add_fieldinfo(IFT_FLOAT, "pan", 1, &data->pan);
01066   add_fieldinfo(IFT_FLOAT, "tilt", 1, &data->tilt);
01067 }
01068 
01069 /** Destructor */
01070 PanTiltInterface::TimedGotoMessage::~TimedGotoMessage()
01071 {
01072   free(data_ptr);
01073 }
01074 
01075 /** Copy constructor.
01076  * @param m message to copy from
01077  */
01078 PanTiltInterface::TimedGotoMessage::TimedGotoMessage(const TimedGotoMessage *m) : Message("TimedGotoMessage")
01079 {
01080   data_size = m->data_size;
01081   data_ptr  = malloc(data_size);
01082   memcpy(data_ptr, m->data_ptr, data_size);
01083   data      = (TimedGotoMessage_data_t *)data_ptr;
01084   data_ts   = (message_data_ts_t *)data_ptr;
01085 }
01086 
01087 /* Methods */
01088 /** Get time_sec value.
01089  * Time in seconds when to reach
01090     the final position.
01091  * @return time_sec value
01092  */
01093 float
01094 PanTiltInterface::TimedGotoMessage::time_sec() const
01095 {
01096   return data->time_sec;
01097 }
01098 
01099 /** Get maximum length of time_sec value.
01100  * @return length of time_sec value, can be length of the array or number of 
01101  * maximum number of characters for a string
01102  */
01103 size_t
01104 PanTiltInterface::TimedGotoMessage::maxlenof_time_sec() const
01105 {
01106   return 1;
01107 }
01108 
01109 /** Set time_sec value.
01110  * Time in seconds when to reach
01111     the final position.
01112  * @param new_time_sec new time_sec value
01113  */
01114 void
01115 PanTiltInterface::TimedGotoMessage::set_time_sec(const float new_time_sec)
01116 {
01117   data->time_sec = new_time_sec;
01118 }
01119 
01120 /** Get pan value.
01121  * Current pan.
01122  * @return pan value
01123  */
01124 float
01125 PanTiltInterface::TimedGotoMessage::pan() const
01126 {
01127   return data->pan;
01128 }
01129 
01130 /** Get maximum length of pan value.
01131  * @return length of pan value, can be length of the array or number of 
01132  * maximum number of characters for a string
01133  */
01134 size_t
01135 PanTiltInterface::TimedGotoMessage::maxlenof_pan() const
01136 {
01137   return 1;
01138 }
01139 
01140 /** Set pan value.
01141  * Current pan.
01142  * @param new_pan new pan value
01143  */
01144 void
01145 PanTiltInterface::TimedGotoMessage::set_pan(const float new_pan)
01146 {
01147   data->pan = new_pan;
01148 }
01149 
01150 /** Get tilt value.
01151  * Current tilt.
01152  * @return tilt value
01153  */
01154 float
01155 PanTiltInterface::TimedGotoMessage::tilt() const
01156 {
01157   return data->tilt;
01158 }
01159 
01160 /** Get maximum length of tilt value.
01161  * @return length of tilt value, can be length of the array or number of 
01162  * maximum number of characters for a string
01163  */
01164 size_t
01165 PanTiltInterface::TimedGotoMessage::maxlenof_tilt() const
01166 {
01167   return 1;
01168 }
01169 
01170 /** Set tilt value.
01171  * Current tilt.
01172  * @param new_tilt new tilt value
01173  */
01174 void
01175 PanTiltInterface::TimedGotoMessage::set_tilt(const float new_tilt)
01176 {
01177   data->tilt = new_tilt;
01178 }
01179 
01180 /** Clone this message.
01181  * Produces a message of the same type as this message and copies the
01182  * data to the new message.
01183  * @return clone of this message
01184  */
01185 Message *
01186 PanTiltInterface::TimedGotoMessage::clone() const
01187 {
01188   return new PanTiltInterface::TimedGotoMessage(this);
01189 }
01190 /** @class PanTiltInterface::SetEnabledMessage <interfaces/PanTiltInterface.h>
01191  * SetEnabledMessage Fawkes BlackBoard Interface Message.
01192  * 
01193     
01194  */
01195 
01196 
01197 /** Constructor with initial values.
01198  * @param ini_enabled initial value for enabled
01199  */
01200 PanTiltInterface::SetEnabledMessage::SetEnabledMessage(const bool ini_enabled) : Message("SetEnabledMessage")
01201 {
01202   data_size = sizeof(SetEnabledMessage_data_t);
01203   data_ptr  = malloc(data_size);
01204   memset(data_ptr, 0, data_size);
01205   data      = (SetEnabledMessage_data_t *)data_ptr;
01206   data_ts   = (message_data_ts_t *)data_ptr;
01207   data->enabled = ini_enabled;
01208   add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
01209 }
01210 /** Constructor */
01211 PanTiltInterface::SetEnabledMessage::SetEnabledMessage() : Message("SetEnabledMessage")
01212 {
01213   data_size = sizeof(SetEnabledMessage_data_t);
01214   data_ptr  = malloc(data_size);
01215   memset(data_ptr, 0, data_size);
01216   data      = (SetEnabledMessage_data_t *)data_ptr;
01217   data_ts   = (message_data_ts_t *)data_ptr;
01218   add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
01219 }
01220 
01221 /** Destructor */
01222 PanTiltInterface::SetEnabledMessage::~SetEnabledMessage()
01223 {
01224   free(data_ptr);
01225 }
01226 
01227 /** Copy constructor.
01228  * @param m message to copy from
01229  */
01230 PanTiltInterface::SetEnabledMessage::SetEnabledMessage(const SetEnabledMessage *m) : Message("SetEnabledMessage")
01231 {
01232   data_size = m->data_size;
01233   data_ptr  = malloc(data_size);
01234   memcpy(data_ptr, m->data_ptr, data_size);
01235   data      = (SetEnabledMessage_data_t *)data_ptr;
01236   data_ts   = (message_data_ts_t *)data_ptr;
01237 }
01238 
01239 /* Methods */
01240 /** Get enabled value.
01241  * Is the pan/tilt unit enabled?
01242  * @return enabled value
01243  */
01244 bool
01245 PanTiltInterface::SetEnabledMessage::is_enabled() const
01246 {
01247   return data->enabled;
01248 }
01249 
01250 /** Get maximum length of enabled value.
01251  * @return length of enabled value, can be length of the array or number of 
01252  * maximum number of characters for a string
01253  */
01254 size_t
01255 PanTiltInterface::SetEnabledMessage::maxlenof_enabled() const
01256 {
01257   return 1;
01258 }
01259 
01260 /** Set enabled value.
01261  * Is the pan/tilt unit enabled?
01262  * @param new_enabled new enabled value
01263  */
01264 void
01265 PanTiltInterface::SetEnabledMessage::set_enabled(const bool new_enabled)
01266 {
01267   data->enabled = new_enabled;
01268 }
01269 
01270 /** Clone this message.
01271  * Produces a message of the same type as this message and copies the
01272  * data to the new message.
01273  * @return clone of this message
01274  */
01275 Message *
01276 PanTiltInterface::SetEnabledMessage::clone() const
01277 {
01278   return new PanTiltInterface::SetEnabledMessage(this);
01279 }
01280 /** @class PanTiltInterface::SetVelocityMessage <interfaces/PanTiltInterface.h>
01281  * SetVelocityMessage Fawkes BlackBoard Interface Message.
01282  * 
01283     
01284  */
01285 
01286 
01287 /** Constructor with initial values.
01288  * @param ini_pan_velocity initial value for pan_velocity
01289  * @param ini_tilt_velocity initial value for tilt_velocity
01290  */
01291 PanTiltInterface::SetVelocityMessage::SetVelocityMessage(const float ini_pan_velocity, const float ini_tilt_velocity) : Message("SetVelocityMessage")
01292 {
01293   data_size = sizeof(SetVelocityMessage_data_t);
01294   data_ptr  = malloc(data_size);
01295   memset(data_ptr, 0, data_size);
01296   data      = (SetVelocityMessage_data_t *)data_ptr;
01297   data_ts   = (message_data_ts_t *)data_ptr;
01298   data->pan_velocity = ini_pan_velocity;
01299   data->tilt_velocity = ini_tilt_velocity;
01300   add_fieldinfo(IFT_FLOAT, "pan_velocity", 1, &data->pan_velocity);
01301   add_fieldinfo(IFT_FLOAT, "tilt_velocity", 1, &data->tilt_velocity);
01302 }
01303 /** Constructor */
01304 PanTiltInterface::SetVelocityMessage::SetVelocityMessage() : Message("SetVelocityMessage")
01305 {
01306   data_size = sizeof(SetVelocityMessage_data_t);
01307   data_ptr  = malloc(data_size);
01308   memset(data_ptr, 0, data_size);
01309   data      = (SetVelocityMessage_data_t *)data_ptr;
01310   data_ts   = (message_data_ts_t *)data_ptr;
01311   add_fieldinfo(IFT_FLOAT, "pan_velocity", 1, &data->pan_velocity);
01312   add_fieldinfo(IFT_FLOAT, "tilt_velocity", 1, &data->tilt_velocity);
01313 }
01314 
01315 /** Destructor */
01316 PanTiltInterface::SetVelocityMessage::~SetVelocityMessage()
01317 {
01318   free(data_ptr);
01319 }
01320 
01321 /** Copy constructor.
01322  * @param m message to copy from
01323  */
01324 PanTiltInterface::SetVelocityMessage::SetVelocityMessage(const SetVelocityMessage *m) : Message("SetVelocityMessage")
01325 {
01326   data_size = m->data_size;
01327   data_ptr  = malloc(data_size);
01328   memcpy(data_ptr, m->data_ptr, data_size);
01329   data      = (SetVelocityMessage_data_t *)data_ptr;
01330   data_ts   = (message_data_ts_t *)data_ptr;
01331 }
01332 
01333 /* Methods */
01334 /** Get pan_velocity value.
01335  * Maximum pan velocity currently reached.
01336  * @return pan_velocity value
01337  */
01338 float
01339 PanTiltInterface::SetVelocityMessage::pan_velocity() const
01340 {
01341   return data->pan_velocity;
01342 }
01343 
01344 /** Get maximum length of pan_velocity value.
01345  * @return length of pan_velocity value, can be length of the array or number of 
01346  * maximum number of characters for a string
01347  */
01348 size_t
01349 PanTiltInterface::SetVelocityMessage::maxlenof_pan_velocity() const
01350 {
01351   return 1;
01352 }
01353 
01354 /** Set pan_velocity value.
01355  * Maximum pan velocity currently reached.
01356  * @param new_pan_velocity new pan_velocity value
01357  */
01358 void
01359 PanTiltInterface::SetVelocityMessage::set_pan_velocity(const float new_pan_velocity)
01360 {
01361   data->pan_velocity = new_pan_velocity;
01362 }
01363 
01364 /** Get tilt_velocity value.
01365  * Maximum tilt velocity currently reached.
01366  * @return tilt_velocity value
01367  */
01368 float
01369 PanTiltInterface::SetVelocityMessage::tilt_velocity() const
01370 {
01371   return data->tilt_velocity;
01372 }
01373 
01374 /** Get maximum length of tilt_velocity value.
01375  * @return length of tilt_velocity value, can be length of the array or number of 
01376  * maximum number of characters for a string
01377  */
01378 size_t
01379 PanTiltInterface::SetVelocityMessage::maxlenof_tilt_velocity() const
01380 {
01381   return 1;
01382 }
01383 
01384 /** Set tilt_velocity value.
01385  * Maximum tilt velocity currently reached.
01386  * @param new_tilt_velocity new tilt_velocity value
01387  */
01388 void
01389 PanTiltInterface::SetVelocityMessage::set_tilt_velocity(const float new_tilt_velocity)
01390 {
01391   data->tilt_velocity = new_tilt_velocity;
01392 }
01393 
01394 /** Clone this message.
01395  * Produces a message of the same type as this message and copies the
01396  * data to the new message.
01397  * @return clone of this message
01398  */
01399 Message *
01400 PanTiltInterface::SetVelocityMessage::clone() const
01401 {
01402   return new PanTiltInterface::SetVelocityMessage(this);
01403 }
01404 /** @class PanTiltInterface::SetMarginMessage <interfaces/PanTiltInterface.h>
01405  * SetMarginMessage Fawkes BlackBoard Interface Message.
01406  * 
01407     
01408  */
01409 
01410 
01411 /** Constructor with initial values.
01412  * @param ini_pan_margin initial value for pan_margin
01413  * @param ini_tilt_margin initial value for tilt_margin
01414  */
01415 PanTiltInterface::SetMarginMessage::SetMarginMessage(const float ini_pan_margin, const float ini_tilt_margin) : Message("SetMarginMessage")
01416 {
01417   data_size = sizeof(SetMarginMessage_data_t);
01418   data_ptr  = malloc(data_size);
01419   memset(data_ptr, 0, data_size);
01420   data      = (SetMarginMessage_data_t *)data_ptr;
01421   data_ts   = (message_data_ts_t *)data_ptr;
01422   data->pan_margin = ini_pan_margin;
01423   data->tilt_margin = ini_tilt_margin;
01424   add_fieldinfo(IFT_FLOAT, "pan_margin", 1, &data->pan_margin);
01425   add_fieldinfo(IFT_FLOAT, "tilt_margin", 1, &data->tilt_margin);
01426 }
01427 /** Constructor */
01428 PanTiltInterface::SetMarginMessage::SetMarginMessage() : Message("SetMarginMessage")
01429 {
01430   data_size = sizeof(SetMarginMessage_data_t);
01431   data_ptr  = malloc(data_size);
01432   memset(data_ptr, 0, data_size);
01433   data      = (SetMarginMessage_data_t *)data_ptr;
01434   data_ts   = (message_data_ts_t *)data_ptr;
01435   add_fieldinfo(IFT_FLOAT, "pan_margin", 1, &data->pan_margin);
01436   add_fieldinfo(IFT_FLOAT, "tilt_margin", 1, &data->tilt_margin);
01437 }
01438 
01439 /** Destructor */
01440 PanTiltInterface::SetMarginMessage::~SetMarginMessage()
01441 {
01442   free(data_ptr);
01443 }
01444 
01445 /** Copy constructor.
01446  * @param m message to copy from
01447  */
01448 PanTiltInterface::SetMarginMessage::SetMarginMessage(const SetMarginMessage *m) : Message("SetMarginMessage")
01449 {
01450   data_size = m->data_size;
01451   data_ptr  = malloc(data_size);
01452   memcpy(data_ptr, m->data_ptr, data_size);
01453   data      = (SetMarginMessage_data_t *)data_ptr;
01454   data_ts   = (message_data_ts_t *)data_ptr;
01455 }
01456 
01457 /* Methods */
01458 /** Get pan_margin value.
01459  * Margin in radians around a
01460     target pan value to consider the motion as final.
01461  * @return pan_margin value
01462  */
01463 float
01464 PanTiltInterface::SetMarginMessage::pan_margin() const
01465 {
01466   return data->pan_margin;
01467 }
01468 
01469 /** Get maximum length of pan_margin value.
01470  * @return length of pan_margin value, can be length of the array or number of 
01471  * maximum number of characters for a string
01472  */
01473 size_t
01474 PanTiltInterface::SetMarginMessage::maxlenof_pan_margin() const
01475 {
01476   return 1;
01477 }
01478 
01479 /** Set pan_margin value.
01480  * Margin in radians around a
01481     target pan value to consider the motion as final.
01482  * @param new_pan_margin new pan_margin value
01483  */
01484 void
01485 PanTiltInterface::SetMarginMessage::set_pan_margin(const float new_pan_margin)
01486 {
01487   data->pan_margin = new_pan_margin;
01488 }
01489 
01490 /** Get tilt_margin value.
01491  * Margin in radians around a
01492     target tilt value to consider the motion as final.
01493  * @return tilt_margin value
01494  */
01495 float
01496 PanTiltInterface::SetMarginMessage::tilt_margin() const
01497 {
01498   return data->tilt_margin;
01499 }
01500 
01501 /** Get maximum length of tilt_margin value.
01502  * @return length of tilt_margin value, can be length of the array or number of 
01503  * maximum number of characters for a string
01504  */
01505 size_t
01506 PanTiltInterface::SetMarginMessage::maxlenof_tilt_margin() const
01507 {
01508   return 1;
01509 }
01510 
01511 /** Set tilt_margin value.
01512  * Margin in radians around a
01513     target tilt value to consider the motion as final.
01514  * @param new_tilt_margin new tilt_margin value
01515  */
01516 void
01517 PanTiltInterface::SetMarginMessage::set_tilt_margin(const float new_tilt_margin)
01518 {
01519   data->tilt_margin = new_tilt_margin;
01520 }
01521 
01522 /** Clone this message.
01523  * Produces a message of the same type as this message and copies the
01524  * data to the new message.
01525  * @return clone of this message
01526  */
01527 Message *
01528 PanTiltInterface::SetMarginMessage::clone() const
01529 {
01530   return new PanTiltInterface::SetMarginMessage(this);
01531 }
01532 /** Check if message is valid and can be enqueued.
01533  * @param message Message to check
01534  * @return true if the message is valid, false otherwise.
01535  */
01536 bool
01537 PanTiltInterface::message_valid(const Message *message) const
01538 {
01539   const StopMessage *m0 = dynamic_cast<const StopMessage *>(message);
01540   if ( m0 != NULL ) {
01541     return true;
01542   }
01543   const FlushMessage *m1 = dynamic_cast<const FlushMessage *>(message);
01544   if ( m1 != NULL ) {
01545     return true;
01546   }
01547   const CalibrateMessage *m2 = dynamic_cast<const CalibrateMessage *>(message);
01548   if ( m2 != NULL ) {
01549     return true;
01550   }
01551   const ParkMessage *m3 = dynamic_cast<const ParkMessage *>(message);
01552   if ( m3 != NULL ) {
01553     return true;
01554   }
01555   const GotoMessage *m4 = dynamic_cast<const GotoMessage *>(message);
01556   if ( m4 != NULL ) {
01557     return true;
01558   }
01559   const TimedGotoMessage *m5 = dynamic_cast<const TimedGotoMessage *>(message);
01560   if ( m5 != NULL ) {
01561     return true;
01562   }
01563   const SetEnabledMessage *m6 = dynamic_cast<const SetEnabledMessage *>(message);
01564   if ( m6 != NULL ) {
01565     return true;
01566   }
01567   const SetVelocityMessage *m7 = dynamic_cast<const SetVelocityMessage *>(message);
01568   if ( m7 != NULL ) {
01569     return true;
01570   }
01571   const SetMarginMessage *m8 = dynamic_cast<const SetMarginMessage *>(message);
01572   if ( m8 != NULL ) {
01573     return true;
01574   }
01575   return false;
01576 }
01577 
01578 /// @cond INTERNALS
01579 EXPORT_INTERFACE(PanTiltInterface)
01580 /// @endcond
01581 
01582 
01583 } // end namespace fawkes