Fawkes API Fawkes Development Version

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