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