NavigatorInterface.h
00001 00002 /*************************************************************************** 00003 * NavigatorInterface.h - Fawkes BlackBoard Interface - NavigatorInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2007-2009 Martin Liebenberg, Daniel Beck, 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_NAVIGATORINTERFACE_H_ 00025 #define __INTERFACES_NAVIGATORINTERFACE_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 NavigatorInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(NavigatorInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 static const unsigned int ERROR_NONE; 00041 static const unsigned int ERROR_MOTOR; 00042 static const unsigned int ERROR_OBSTRUCTION; 00043 static const unsigned int ERROR_UNKNOWN_PLACE; 00044 static const unsigned int FLAG_NONE; 00045 static const unsigned int FLAG_CART_GOTO; 00046 static const unsigned int FLAG_POLAR_GOTO; 00047 static const unsigned int FLAG_PLACE_GOTO; 00048 static const unsigned int FLAG_UPDATES_DEST_DIST; 00049 static const unsigned int FLAG_SECURITY_DISTANCE; 00050 static const unsigned int FLAG_ESCAPING; 00051 00052 private: 00053 /** Internal data storage, do NOT modify! */ 00054 typedef struct { 00055 unsigned int flags; /**< Bit-wise combination of 00056 FLAG_* constants denoting navigator component features. */ 00057 unsigned int msgid; /**< The ID of the message that is currently being 00058 processed, or 0 if no message is being processed. */ 00059 unsigned int error_code; /**< Failure code set if 00060 final is true. 0 if no error occured, an error code from ERROR_* 00061 constants otherwise (or a bit-wise combination). */ 00062 float x; /**< Current X-coordinate in the navigator coordinate system. */ 00063 float y; /**< Current Y-coordinate in the navigator coordinate system. */ 00064 float dest_x; /**< X-coordinate of the current destination, or 0.0 if no target has been set. */ 00065 float dest_y; /**< Y-coordinate of the current destination, or 0.0 if no target has been set. */ 00066 float dest_ori; /**< Orientation of the current destination, or 0.0 if no target has been set. */ 00067 float dest_dist; /**< Distance to destination in m. */ 00068 float max_velocity; /**< Maximum velocity */ 00069 float security_distance; /**< Security distance to 00070 keep to obstacles */ 00071 bool final; /**< True, if the last goto command has been finished, 00072 false if it is still running */ 00073 bool escaping_enabled; /**< This is used for 00074 navigation components with integrated collision avoidance, to 00075 check whether the navigator should stop when an obstacle 00076 obstructs the path, or if it should escape. */ 00077 } NavigatorInterface_data_t; 00078 00079 NavigatorInterface_data_t *data; 00080 00081 public: 00082 /* messages */ 00083 class StopMessage : public Message 00084 { 00085 public: 00086 StopMessage(); 00087 ~StopMessage(); 00088 00089 StopMessage(const StopMessage *m); 00090 /* Methods */ 00091 virtual Message * clone() const; 00092 }; 00093 00094 class TurnMessage : public Message 00095 { 00096 private: 00097 /** Internal data storage, do NOT modify! */ 00098 typedef struct { 00099 float angle; /**< Angle of the turn. */ 00100 float velocity; /**< The desired turning velocity in rad/s, 00101 set to zero to use default value. */ 00102 } TurnMessage_data_t; 00103 00104 TurnMessage_data_t *data; 00105 00106 public: 00107 TurnMessage(const float ini_angle, const float ini_velocity); 00108 TurnMessage(); 00109 ~TurnMessage(); 00110 00111 TurnMessage(const TurnMessage *m); 00112 /* Methods */ 00113 float angle() const; 00114 void set_angle(const float new_angle); 00115 size_t maxlenof_angle() const; 00116 float velocity() const; 00117 void set_velocity(const float new_velocity); 00118 size_t maxlenof_velocity() const; 00119 virtual Message * clone() const; 00120 }; 00121 00122 class CartesianGotoMessage : public Message 00123 { 00124 private: 00125 /** Internal data storage, do NOT modify! */ 00126 typedef struct { 00127 float x; /**< X-coordinate of the target, in the robot's coordinate system. */ 00128 float y; /**< Y-coordinate of the target, in the robot's coordinate system. */ 00129 float orientation; /**< The orientation of the robot at the target. */ 00130 } CartesianGotoMessage_data_t; 00131 00132 CartesianGotoMessage_data_t *data; 00133 00134 public: 00135 CartesianGotoMessage(const float ini_x, const float ini_y, const float ini_orientation); 00136 CartesianGotoMessage(); 00137 ~CartesianGotoMessage(); 00138 00139 CartesianGotoMessage(const CartesianGotoMessage *m); 00140 /* Methods */ 00141 float x() const; 00142 void set_x(const float new_x); 00143 size_t maxlenof_x() const; 00144 float y() const; 00145 void set_y(const float new_y); 00146 size_t maxlenof_y() const; 00147 float orientation() const; 00148 void set_orientation(const float new_orientation); 00149 size_t maxlenof_orientation() const; 00150 virtual Message * clone() const; 00151 }; 00152 00153 class PolarGotoMessage : public Message 00154 { 00155 private: 00156 /** Internal data storage, do NOT modify! */ 00157 typedef struct { 00158 float phi; /**< Angle between the robot's front and the target. */ 00159 float dist; /**< Distance to the target. */ 00160 float orientation; /**< The orientation of the robot at the target. */ 00161 } PolarGotoMessage_data_t; 00162 00163 PolarGotoMessage_data_t *data; 00164 00165 public: 00166 PolarGotoMessage(const float ini_phi, const float ini_dist, const float ini_orientation); 00167 PolarGotoMessage(); 00168 ~PolarGotoMessage(); 00169 00170 PolarGotoMessage(const PolarGotoMessage *m); 00171 /* Methods */ 00172 float phi() const; 00173 void set_phi(const float new_phi); 00174 size_t maxlenof_phi() const; 00175 float dist() const; 00176 void set_dist(const float new_dist); 00177 size_t maxlenof_dist() const; 00178 float orientation() const; 00179 void set_orientation(const float new_orientation); 00180 size_t maxlenof_orientation() const; 00181 virtual Message * clone() const; 00182 }; 00183 00184 class PlaceGotoMessage : public Message 00185 { 00186 private: 00187 /** Internal data storage, do NOT modify! */ 00188 typedef struct { 00189 char place[64]; /**< Place to go to. */ 00190 } PlaceGotoMessage_data_t; 00191 00192 PlaceGotoMessage_data_t *data; 00193 00194 public: 00195 PlaceGotoMessage(const char * ini_place); 00196 PlaceGotoMessage(); 00197 ~PlaceGotoMessage(); 00198 00199 PlaceGotoMessage(const PlaceGotoMessage *m); 00200 /* Methods */ 00201 char * place() const; 00202 void set_place(const char * new_place); 00203 size_t maxlenof_place() const; 00204 virtual Message * clone() const; 00205 }; 00206 00207 class ObstacleMessage : public Message 00208 { 00209 private: 00210 /** Internal data storage, do NOT modify! */ 00211 typedef struct { 00212 float x; /**< X-coordinate of the obstacle. */ 00213 float y; /**< Y-coordinate of the obstacle. */ 00214 float width; /**< Width of the obstacle. */ 00215 } ObstacleMessage_data_t; 00216 00217 ObstacleMessage_data_t *data; 00218 00219 public: 00220 ObstacleMessage(const float ini_x, const float ini_y, const float ini_width); 00221 ObstacleMessage(); 00222 ~ObstacleMessage(); 00223 00224 ObstacleMessage(const ObstacleMessage *m); 00225 /* Methods */ 00226 float x() const; 00227 void set_x(const float new_x); 00228 size_t maxlenof_x() const; 00229 float y() const; 00230 void set_y(const float new_y); 00231 size_t maxlenof_y() const; 00232 float width() const; 00233 void set_width(const float new_width); 00234 size_t maxlenof_width() const; 00235 virtual Message * clone() const; 00236 }; 00237 00238 class ResetOdometryMessage : public Message 00239 { 00240 public: 00241 ResetOdometryMessage(); 00242 ~ResetOdometryMessage(); 00243 00244 ResetOdometryMessage(const ResetOdometryMessage *m); 00245 /* Methods */ 00246 virtual Message * clone() const; 00247 }; 00248 00249 class SetMaxVelocityMessage : public Message 00250 { 00251 private: 00252 /** Internal data storage, do NOT modify! */ 00253 typedef struct { 00254 float max_velocity; /**< Maximum velocity */ 00255 } SetMaxVelocityMessage_data_t; 00256 00257 SetMaxVelocityMessage_data_t *data; 00258 00259 public: 00260 SetMaxVelocityMessage(const float ini_max_velocity); 00261 SetMaxVelocityMessage(); 00262 ~SetMaxVelocityMessage(); 00263 00264 SetMaxVelocityMessage(const SetMaxVelocityMessage *m); 00265 /* Methods */ 00266 float max_velocity() const; 00267 void set_max_velocity(const float new_max_velocity); 00268 size_t maxlenof_max_velocity() const; 00269 virtual Message * clone() const; 00270 }; 00271 00272 class SetEscapingMessage : public Message 00273 { 00274 private: 00275 /** Internal data storage, do NOT modify! */ 00276 typedef struct { 00277 bool escaping_enabled; /**< This is used for 00278 navigation components with integrated collision avoidance, to 00279 check whether the navigator should stop when an obstacle 00280 obstructs the path, or if it should escape. */ 00281 } SetEscapingMessage_data_t; 00282 00283 SetEscapingMessage_data_t *data; 00284 00285 public: 00286 SetEscapingMessage(const bool ini_escaping_enabled); 00287 SetEscapingMessage(); 00288 ~SetEscapingMessage(); 00289 00290 SetEscapingMessage(const SetEscapingMessage *m); 00291 /* Methods */ 00292 bool is_escaping_enabled() const; 00293 void set_escaping_enabled(const bool new_escaping_enabled); 00294 size_t maxlenof_escaping_enabled() const; 00295 virtual Message * clone() const; 00296 }; 00297 00298 class SetSecurityDistanceMessage : public Message 00299 { 00300 private: 00301 /** Internal data storage, do NOT modify! */ 00302 typedef struct { 00303 float security_distance; /**< Security distance to 00304 keep to obstacles */ 00305 } SetSecurityDistanceMessage_data_t; 00306 00307 SetSecurityDistanceMessage_data_t *data; 00308 00309 public: 00310 SetSecurityDistanceMessage(const float ini_security_distance); 00311 SetSecurityDistanceMessage(); 00312 ~SetSecurityDistanceMessage(); 00313 00314 SetSecurityDistanceMessage(const SetSecurityDistanceMessage *m); 00315 /* Methods */ 00316 float security_distance() const; 00317 void set_security_distance(const float new_security_distance); 00318 size_t maxlenof_security_distance() const; 00319 virtual Message * clone() const; 00320 }; 00321 00322 virtual bool message_valid(const Message *message) const; 00323 private: 00324 NavigatorInterface(); 00325 ~NavigatorInterface(); 00326 00327 public: 00328 /* Methods */ 00329 unsigned int flags() const; 00330 void set_flags(const unsigned int new_flags); 00331 size_t maxlenof_flags() const; 00332 float x() const; 00333 void set_x(const float new_x); 00334 size_t maxlenof_x() const; 00335 float y() const; 00336 void set_y(const float new_y); 00337 size_t maxlenof_y() const; 00338 float dest_x() const; 00339 void set_dest_x(const float new_dest_x); 00340 size_t maxlenof_dest_x() const; 00341 float dest_y() const; 00342 void set_dest_y(const float new_dest_y); 00343 size_t maxlenof_dest_y() const; 00344 float dest_ori() const; 00345 void set_dest_ori(const float new_dest_ori); 00346 size_t maxlenof_dest_ori() const; 00347 float dest_dist() const; 00348 void set_dest_dist(const float new_dest_dist); 00349 size_t maxlenof_dest_dist() const; 00350 unsigned int msgid() const; 00351 void set_msgid(const unsigned int new_msgid); 00352 size_t maxlenof_msgid() const; 00353 bool is_final() const; 00354 void set_final(const bool new_final); 00355 size_t maxlenof_final() const; 00356 unsigned int error_code() const; 00357 void set_error_code(const unsigned int new_error_code); 00358 size_t maxlenof_error_code() const; 00359 float max_velocity() const; 00360 void set_max_velocity(const float new_max_velocity); 00361 size_t maxlenof_max_velocity() const; 00362 float security_distance() const; 00363 void set_security_distance(const float new_security_distance); 00364 size_t maxlenof_security_distance() const; 00365 bool is_escaping_enabled() const; 00366 void set_escaping_enabled(const bool new_escaping_enabled); 00367 size_t maxlenof_escaping_enabled() const; 00368 virtual Message * create_message(const char *type) const; 00369 00370 virtual void copy_values(const Interface *other); 00371 00372 }; 00373 00374 } // end namespace fawkes 00375 00376 #endif

