PanTiltInterface.h
00001 00002 /*************************************************************************** 00003 * PanTiltInterface.h - 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 #ifndef __INTERFACES_PANTILTINTERFACE_H_ 00025 #define __INTERFACES_PANTILTINTERFACE_H_ 00026 00027 #include <interface/interface.h> 00028 #include <interface/message.h> 00029 #include <interface/field_iterator.h> 00030 00031 namespace fawkes { 00032 00033 class PanTiltInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(PanTiltInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 static const unsigned int FLAG_SUPPORTS_PAN; 00041 static const unsigned int FLAG_SUPPORTS_TILT; 00042 static const unsigned int ERROR_NONE; 00043 static const unsigned int ERROR_UNSPECIFIC; 00044 static const unsigned int ERROR_COMMUNICATION; 00045 static const unsigned int ERROR_PAN_OUTOFRANGE; 00046 static const unsigned int ERROR_TILT_OUTOFRANGE; 00047 00048 private: 00049 /** Internal data storage, do NOT modify! */ 00050 typedef struct { 00051 unsigned int flags; /**< Flags. */ 00052 unsigned int msgid; /**< The ID of the message that is currently being 00053 processed, or 0 if no message is being processed. */ 00054 unsigned int error_code; /**< Failure code set if 00055 final is true. 0 if no error occured, an error code from ERROR_* 00056 constants otherwise (or a bit-wise combination). */ 00057 float pan; /**< Current pan. */ 00058 float tilt; /**< Current tilt. */ 00059 float min_pan; /**< Minimum pan possible. */ 00060 float max_pan; /**< Maximum pan possible. */ 00061 float min_tilt; /**< Minimum tilt possible. */ 00062 float max_tilt; /**< Maximum tilt possible. */ 00063 float max_pan_velocity; /**< Maximum supported pan velocity. */ 00064 float max_tilt_velocity; /**< Maximum supported tilt velocity. */ 00065 float pan_velocity; /**< Maximum pan velocity currently reached. */ 00066 float tilt_velocity; /**< Maximum tilt velocity currently reached. */ 00067 float pan_margin; /**< Margin in radians around a 00068 target pan value to consider the motion as final. */ 00069 float tilt_margin; /**< Margin in radians around a 00070 target tilt value to consider the motion as final. */ 00071 bool final; /**< True, if the last goto command has been finished, 00072 false if it is still running */ 00073 bool enabled; /**< Is the pan/tilt unit enabled? */ 00074 bool calibrated; /**< Is the pan/tilt unit calibrated? */ 00075 } PanTiltInterface_data_t; 00076 00077 PanTiltInterface_data_t *data; 00078 00079 public: 00080 /* messages */ 00081 class StopMessage : public Message 00082 { 00083 public: 00084 StopMessage(); 00085 ~StopMessage(); 00086 00087 StopMessage(const StopMessage *m); 00088 /* Methods */ 00089 virtual Message * clone() const; 00090 }; 00091 00092 class FlushMessage : public Message 00093 { 00094 public: 00095 FlushMessage(); 00096 ~FlushMessage(); 00097 00098 FlushMessage(const FlushMessage *m); 00099 /* Methods */ 00100 virtual Message * clone() const; 00101 }; 00102 00103 class CalibrateMessage : public Message 00104 { 00105 public: 00106 CalibrateMessage(); 00107 ~CalibrateMessage(); 00108 00109 CalibrateMessage(const CalibrateMessage *m); 00110 /* Methods */ 00111 virtual Message * clone() const; 00112 }; 00113 00114 class ParkMessage : public Message 00115 { 00116 public: 00117 ParkMessage(); 00118 ~ParkMessage(); 00119 00120 ParkMessage(const ParkMessage *m); 00121 /* Methods */ 00122 virtual Message * clone() const; 00123 }; 00124 00125 class GotoMessage : public Message 00126 { 00127 private: 00128 /** Internal data storage, do NOT modify! */ 00129 typedef struct { 00130 float pan; /**< Current pan. */ 00131 float tilt; /**< Current tilt. */ 00132 } GotoMessage_data_t; 00133 00134 GotoMessage_data_t *data; 00135 00136 public: 00137 GotoMessage(const float ini_pan, const float ini_tilt); 00138 GotoMessage(); 00139 ~GotoMessage(); 00140 00141 GotoMessage(const GotoMessage *m); 00142 /* Methods */ 00143 float pan() const; 00144 void set_pan(const float new_pan); 00145 size_t maxlenof_pan() const; 00146 float tilt() const; 00147 void set_tilt(const float new_tilt); 00148 size_t maxlenof_tilt() const; 00149 virtual Message * clone() const; 00150 }; 00151 00152 class TimedGotoMessage : public Message 00153 { 00154 private: 00155 /** Internal data storage, do NOT modify! */ 00156 typedef struct { 00157 float time_sec; /**< Time in seconds when to reach 00158 the final position. */ 00159 float pan; /**< Current pan. */ 00160 float tilt; /**< Current tilt. */ 00161 } TimedGotoMessage_data_t; 00162 00163 TimedGotoMessage_data_t *data; 00164 00165 public: 00166 TimedGotoMessage(const float ini_time_sec, const float ini_pan, const float ini_tilt); 00167 TimedGotoMessage(); 00168 ~TimedGotoMessage(); 00169 00170 TimedGotoMessage(const TimedGotoMessage *m); 00171 /* Methods */ 00172 float time_sec() const; 00173 void set_time_sec(const float new_time_sec); 00174 size_t maxlenof_time_sec() const; 00175 float pan() const; 00176 void set_pan(const float new_pan); 00177 size_t maxlenof_pan() const; 00178 float tilt() const; 00179 void set_tilt(const float new_tilt); 00180 size_t maxlenof_tilt() const; 00181 virtual Message * clone() const; 00182 }; 00183 00184 class SetEnabledMessage : public Message 00185 { 00186 private: 00187 /** Internal data storage, do NOT modify! */ 00188 typedef struct { 00189 bool enabled; /**< Is the pan/tilt unit enabled? */ 00190 } SetEnabledMessage_data_t; 00191 00192 SetEnabledMessage_data_t *data; 00193 00194 public: 00195 SetEnabledMessage(const bool ini_enabled); 00196 SetEnabledMessage(); 00197 ~SetEnabledMessage(); 00198 00199 SetEnabledMessage(const SetEnabledMessage *m); 00200 /* Methods */ 00201 bool is_enabled() const; 00202 void set_enabled(const bool new_enabled); 00203 size_t maxlenof_enabled() const; 00204 virtual Message * clone() const; 00205 }; 00206 00207 class SetVelocityMessage : public Message 00208 { 00209 private: 00210 /** Internal data storage, do NOT modify! */ 00211 typedef struct { 00212 float pan_velocity; /**< Maximum pan velocity currently reached. */ 00213 float tilt_velocity; /**< Maximum tilt velocity currently reached. */ 00214 } SetVelocityMessage_data_t; 00215 00216 SetVelocityMessage_data_t *data; 00217 00218 public: 00219 SetVelocityMessage(const float ini_pan_velocity, const float ini_tilt_velocity); 00220 SetVelocityMessage(); 00221 ~SetVelocityMessage(); 00222 00223 SetVelocityMessage(const SetVelocityMessage *m); 00224 /* Methods */ 00225 float pan_velocity() const; 00226 void set_pan_velocity(const float new_pan_velocity); 00227 size_t maxlenof_pan_velocity() const; 00228 float tilt_velocity() const; 00229 void set_tilt_velocity(const float new_tilt_velocity); 00230 size_t maxlenof_tilt_velocity() const; 00231 virtual Message * clone() const; 00232 }; 00233 00234 class SetMarginMessage : public Message 00235 { 00236 private: 00237 /** Internal data storage, do NOT modify! */ 00238 typedef struct { 00239 float pan_margin; /**< Margin in radians around a 00240 target pan value to consider the motion as final. */ 00241 float tilt_margin; /**< Margin in radians around a 00242 target tilt value to consider the motion as final. */ 00243 } SetMarginMessage_data_t; 00244 00245 SetMarginMessage_data_t *data; 00246 00247 public: 00248 SetMarginMessage(const float ini_pan_margin, const float ini_tilt_margin); 00249 SetMarginMessage(); 00250 ~SetMarginMessage(); 00251 00252 SetMarginMessage(const SetMarginMessage *m); 00253 /* Methods */ 00254 float pan_margin() const; 00255 void set_pan_margin(const float new_pan_margin); 00256 size_t maxlenof_pan_margin() const; 00257 float tilt_margin() const; 00258 void set_tilt_margin(const float new_tilt_margin); 00259 size_t maxlenof_tilt_margin() const; 00260 virtual Message * clone() const; 00261 }; 00262 00263 virtual bool message_valid(const Message *message) const; 00264 private: 00265 PanTiltInterface(); 00266 ~PanTiltInterface(); 00267 00268 public: 00269 /* Methods */ 00270 unsigned int flags() const; 00271 void set_flags(const unsigned int new_flags); 00272 size_t maxlenof_flags() const; 00273 float pan() const; 00274 void set_pan(const float new_pan); 00275 size_t maxlenof_pan() const; 00276 float tilt() const; 00277 void set_tilt(const float new_tilt); 00278 size_t maxlenof_tilt() const; 00279 unsigned int msgid() const; 00280 void set_msgid(const unsigned int new_msgid); 00281 size_t maxlenof_msgid() const; 00282 bool is_final() const; 00283 void set_final(const bool new_final); 00284 size_t maxlenof_final() const; 00285 unsigned int error_code() const; 00286 void set_error_code(const unsigned int new_error_code); 00287 size_t maxlenof_error_code() const; 00288 bool is_enabled() const; 00289 void set_enabled(const bool new_enabled); 00290 size_t maxlenof_enabled() const; 00291 bool is_calibrated() const; 00292 void set_calibrated(const bool new_calibrated); 00293 size_t maxlenof_calibrated() const; 00294 float min_pan() const; 00295 void set_min_pan(const float new_min_pan); 00296 size_t maxlenof_min_pan() const; 00297 float max_pan() const; 00298 void set_max_pan(const float new_max_pan); 00299 size_t maxlenof_max_pan() const; 00300 float min_tilt() const; 00301 void set_min_tilt(const float new_min_tilt); 00302 size_t maxlenof_min_tilt() const; 00303 float max_tilt() const; 00304 void set_max_tilt(const float new_max_tilt); 00305 size_t maxlenof_max_tilt() const; 00306 float max_pan_velocity() const; 00307 void set_max_pan_velocity(const float new_max_pan_velocity); 00308 size_t maxlenof_max_pan_velocity() const; 00309 float max_tilt_velocity() const; 00310 void set_max_tilt_velocity(const float new_max_tilt_velocity); 00311 size_t maxlenof_max_tilt_velocity() const; 00312 float pan_velocity() const; 00313 void set_pan_velocity(const float new_pan_velocity); 00314 size_t maxlenof_pan_velocity() const; 00315 float tilt_velocity() const; 00316 void set_tilt_velocity(const float new_tilt_velocity); 00317 size_t maxlenof_tilt_velocity() const; 00318 float pan_margin() const; 00319 void set_pan_margin(const float new_pan_margin); 00320 size_t maxlenof_pan_margin() const; 00321 float tilt_margin() const; 00322 void set_tilt_margin(const float new_tilt_margin); 00323 size_t maxlenof_tilt_margin() const; 00324 virtual Message * create_message(const char *type) const; 00325 00326 virtual void copy_values(const Interface *other); 00327 00328 }; 00329 00330 } // end namespace fawkes 00331 00332 #endif

