KatanaInterface.h

00001 
00002 /***************************************************************************
00003  *  KatanaInterface.h - Fawkes BlackBoard Interface - KatanaInterface
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_KATANAINTERFACE_H_
00025 #define __INTERFACES_KATANAINTERFACE_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 KatanaInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(KatanaInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040   static const uint32_t SENSOR_IR_RIGHT_INNER_MIDDLE;
00041   static const uint32_t SENSOR_IR_RIGHT_INNER_FRONT;
00042   static const uint32_t SENSOR_RESERVED_2;
00043   static const uint32_t SENSOR_COND_BOTH;
00044   static const uint32_t SENSOR_IR_RIGHT_OUTER_FRONT;
00045   static const uint32_t SENSOR_IR_RIGHT_BOTTOM_FRONT;
00046   static const uint32_t SENSOR_FORCE_RIGHT_REAR;
00047   static const uint32_t SENSOR_FORCE_RIGHT_FRONT;
00048   static const uint32_t SENSOR_IR_LEFT_INNER_MIDDLE;
00049   static const uint32_t SENSOR_IR_LEFT_INNER_FRONT;
00050   static const uint32_t SENSOR_RESERVED_10;
00051   static const uint32_t SENSOR_IR_CENTER_GRIPPER;
00052   static const uint32_t SENSOR_IR_LEFT_OUTER_FRONT;
00053   static const uint32_t SENSOR_IR_LEFT_BOTTOM_FRONT;
00054   static const uint32_t SENSOR_FORCE_LEFT_REAR;
00055   static const uint32_t SENSOR_FORCE_LEFT_FRONT;
00056   static const uint32_t ERROR_NONE;
00057   static const uint32_t ERROR_UNSPECIFIC;
00058   static const uint32_t ERROR_CMD_START_FAILED;
00059   static const uint32_t ERROR_NO_SOLUTION;
00060   static const uint32_t ERROR_COMMUNICATION;
00061   static const uint32_t ERROR_MOTOR_CRASHED;
00062 
00063  private:
00064 #pragma pack(push,4)
00065   /** Internal data storage, do NOT modify! */
00066   typedef struct {
00067     int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00068     int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00069     uint8_t sensor_value[16]; /**< Sensor
00070     values. Use SENSOR_* indexes for accessing the values. */
00071     float x; /**< X-Coordinate for tool position
00072     compared to base coordinate system. */
00073     float y; /**< Y-Coordinate for tool position
00074     compared to base coordinate system. */
00075     float z; /**< Z-Coordinate for tool position
00076     compared to base coordinate system. */
00077     float phi; /**< Euler angle Phi of tool orientation. */
00078     float theta; /**< Euler angle Theta of tool orientation. */
00079     float psi; /**< Euler angle Psi of tool orientation.. */
00080     uint32_t msgid; /**< The ID of the message that is currently being
00081       processed, or 0 if no message is being processed. */
00082     bool final; /**< True, if the last goto command has been finished,
00083       false if it is still running */
00084     uint32_t error_code; /**< Failure code set if
00085     final is true. 0 if no error occured, an error code from ERROR_*
00086     constants otherwise (or a bit-wise combination). */
00087     bool enabled; /**< Are motors enabled? */
00088     bool calibrated; /**< Has arm been calibrated? */
00089     uint8_t max_velocity; /**< Maximum velocity */
00090     uint8_t num_motors; /**< Number of motors */
00091   } KatanaInterface_data_t;
00092 #pragma pack(pop)
00093 
00094   KatanaInterface_data_t *data;
00095 
00096  public:
00097   /* messages */
00098   class StopMessage : public Message
00099   {
00100    private:
00101 #pragma pack(push,4)
00102     /** Internal data storage, do NOT modify! */
00103     typedef struct {
00104       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00105       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00106     } StopMessage_data_t;
00107 #pragma pack(pop)
00108 
00109     StopMessage_data_t *data;
00110 
00111    public:
00112     StopMessage();
00113     ~StopMessage();
00114 
00115     StopMessage(const StopMessage *m);
00116     /* Methods */
00117     virtual Message * clone() const;
00118   };
00119 
00120   class FlushMessage : public Message
00121   {
00122    private:
00123 #pragma pack(push,4)
00124     /** Internal data storage, do NOT modify! */
00125     typedef struct {
00126       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00127       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00128     } FlushMessage_data_t;
00129 #pragma pack(pop)
00130 
00131     FlushMessage_data_t *data;
00132 
00133    public:
00134     FlushMessage();
00135     ~FlushMessage();
00136 
00137     FlushMessage(const FlushMessage *m);
00138     /* Methods */
00139     virtual Message * clone() const;
00140   };
00141 
00142   class ParkMessage : public Message
00143   {
00144    private:
00145 #pragma pack(push,4)
00146     /** Internal data storage, do NOT modify! */
00147     typedef struct {
00148       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00149       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00150     } ParkMessage_data_t;
00151 #pragma pack(pop)
00152 
00153     ParkMessage_data_t *data;
00154 
00155    public:
00156     ParkMessage();
00157     ~ParkMessage();
00158 
00159     ParkMessage(const ParkMessage *m);
00160     /* Methods */
00161     virtual Message * clone() const;
00162   };
00163 
00164   class LinearGotoMessage : public Message
00165   {
00166    private:
00167 #pragma pack(push,4)
00168     /** Internal data storage, do NOT modify! */
00169     typedef struct {
00170       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00171       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00172       float x; /**< X-Coordinate for tool position
00173     compared to base coordinate system. */
00174       float y; /**< Y-Coordinate for tool position
00175     compared to base coordinate system. */
00176       float z; /**< Z-Coordinate for tool position
00177     compared to base coordinate system. */
00178       float phi; /**< Euler angle Phi of tool orientation. */
00179       float theta; /**< Euler angle Theta of tool orientation. */
00180       float psi; /**< Euler angle Psi of tool orientation.. */
00181     } LinearGotoMessage_data_t;
00182 #pragma pack(pop)
00183 
00184     LinearGotoMessage_data_t *data;
00185 
00186    public:
00187     LinearGotoMessage(const float ini_x, const float ini_y, const float ini_z, const float ini_phi, const float ini_theta, const float ini_psi);
00188     LinearGotoMessage();
00189     ~LinearGotoMessage();
00190 
00191     LinearGotoMessage(const LinearGotoMessage *m);
00192     /* Methods */
00193     float x() const;
00194     void set_x(const float new_x);
00195     size_t maxlenof_x() const;
00196     float y() const;
00197     void set_y(const float new_y);
00198     size_t maxlenof_y() const;
00199     float z() const;
00200     void set_z(const float new_z);
00201     size_t maxlenof_z() const;
00202     float phi() const;
00203     void set_phi(const float new_phi);
00204     size_t maxlenof_phi() const;
00205     float theta() const;
00206     void set_theta(const float new_theta);
00207     size_t maxlenof_theta() const;
00208     float psi() const;
00209     void set_psi(const float new_psi);
00210     size_t maxlenof_psi() const;
00211     virtual Message * clone() const;
00212   };
00213 
00214   class CalibrateMessage : public Message
00215   {
00216    private:
00217 #pragma pack(push,4)
00218     /** Internal data storage, do NOT modify! */
00219     typedef struct {
00220       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00221       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00222     } CalibrateMessage_data_t;
00223 #pragma pack(pop)
00224 
00225     CalibrateMessage_data_t *data;
00226 
00227    public:
00228     CalibrateMessage();
00229     ~CalibrateMessage();
00230 
00231     CalibrateMessage(const CalibrateMessage *m);
00232     /* Methods */
00233     virtual Message * clone() const;
00234   };
00235 
00236   class OpenGripperMessage : public Message
00237   {
00238    private:
00239 #pragma pack(push,4)
00240     /** Internal data storage, do NOT modify! */
00241     typedef struct {
00242       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00243       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00244     } OpenGripperMessage_data_t;
00245 #pragma pack(pop)
00246 
00247     OpenGripperMessage_data_t *data;
00248 
00249    public:
00250     OpenGripperMessage();
00251     ~OpenGripperMessage();
00252 
00253     OpenGripperMessage(const OpenGripperMessage *m);
00254     /* Methods */
00255     virtual Message * clone() const;
00256   };
00257 
00258   class CloseGripperMessage : public Message
00259   {
00260    private:
00261 #pragma pack(push,4)
00262     /** Internal data storage, do NOT modify! */
00263     typedef struct {
00264       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00265       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00266     } CloseGripperMessage_data_t;
00267 #pragma pack(pop)
00268 
00269     CloseGripperMessage_data_t *data;
00270 
00271    public:
00272     CloseGripperMessage();
00273     ~CloseGripperMessage();
00274 
00275     CloseGripperMessage(const CloseGripperMessage *m);
00276     /* Methods */
00277     virtual Message * clone() const;
00278   };
00279 
00280   class SetEnabledMessage : public Message
00281   {
00282    private:
00283 #pragma pack(push,4)
00284     /** Internal data storage, do NOT modify! */
00285     typedef struct {
00286       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00287       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00288       bool enabled; /**< Are motors enabled? */
00289     } SetEnabledMessage_data_t;
00290 #pragma pack(pop)
00291 
00292     SetEnabledMessage_data_t *data;
00293 
00294    public:
00295     SetEnabledMessage(const bool ini_enabled);
00296     SetEnabledMessage();
00297     ~SetEnabledMessage();
00298 
00299     SetEnabledMessage(const SetEnabledMessage *m);
00300     /* Methods */
00301     bool is_enabled() const;
00302     void set_enabled(const bool new_enabled);
00303     size_t maxlenof_enabled() const;
00304     virtual Message * clone() const;
00305   };
00306 
00307   class SetMaxVelocityMessage : public Message
00308   {
00309    private:
00310 #pragma pack(push,4)
00311     /** Internal data storage, do NOT modify! */
00312     typedef struct {
00313       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00314       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00315       uint8_t max_velocity; /**< Maximum velocity */
00316     } SetMaxVelocityMessage_data_t;
00317 #pragma pack(pop)
00318 
00319     SetMaxVelocityMessage_data_t *data;
00320 
00321    public:
00322     SetMaxVelocityMessage(const uint8_t ini_max_velocity);
00323     SetMaxVelocityMessage();
00324     ~SetMaxVelocityMessage();
00325 
00326     SetMaxVelocityMessage(const SetMaxVelocityMessage *m);
00327     /* Methods */
00328     uint8_t max_velocity() const;
00329     void set_max_velocity(const uint8_t new_max_velocity);
00330     size_t maxlenof_max_velocity() const;
00331     virtual Message * clone() const;
00332   };
00333 
00334   virtual bool message_valid(const Message *message) const;
00335  private:
00336   KatanaInterface();
00337   ~KatanaInterface();
00338 
00339  public:
00340   /* Methods */
00341   uint8_t * sensor_value() const;
00342   uint8_t sensor_value(unsigned int index) const;
00343   void set_sensor_value(unsigned int index, const uint8_t new_sensor_value);
00344   void set_sensor_value(const uint8_t * new_sensor_value);
00345   size_t maxlenof_sensor_value() const;
00346   float x() const;
00347   void set_x(const float new_x);
00348   size_t maxlenof_x() const;
00349   float y() const;
00350   void set_y(const float new_y);
00351   size_t maxlenof_y() const;
00352   float z() const;
00353   void set_z(const float new_z);
00354   size_t maxlenof_z() const;
00355   float phi() const;
00356   void set_phi(const float new_phi);
00357   size_t maxlenof_phi() const;
00358   float theta() const;
00359   void set_theta(const float new_theta);
00360   size_t maxlenof_theta() const;
00361   float psi() const;
00362   void set_psi(const float new_psi);
00363   size_t maxlenof_psi() const;
00364   uint32_t msgid() const;
00365   void set_msgid(const uint32_t new_msgid);
00366   size_t maxlenof_msgid() const;
00367   bool is_final() const;
00368   void set_final(const bool new_final);
00369   size_t maxlenof_final() const;
00370   uint32_t error_code() const;
00371   void set_error_code(const uint32_t new_error_code);
00372   size_t maxlenof_error_code() const;
00373   bool is_enabled() const;
00374   void set_enabled(const bool new_enabled);
00375   size_t maxlenof_enabled() const;
00376   bool is_calibrated() const;
00377   void set_calibrated(const bool new_calibrated);
00378   size_t maxlenof_calibrated() const;
00379   uint8_t max_velocity() const;
00380   void set_max_velocity(const uint8_t new_max_velocity);
00381   size_t maxlenof_max_velocity() const;
00382   uint8_t num_motors() const;
00383   void set_num_motors(const uint8_t new_num_motors);
00384   size_t maxlenof_num_motors() const;
00385   virtual Message * create_message(const char *type) const;
00386 
00387   virtual void copy_values(const Interface *other);
00388   virtual const char * enum_tostring(const char *enumtype, int val) const;
00389 
00390 };
00391 
00392 } // end namespace fawkes
00393 
00394 #endif

Generated on Tue Feb 22 13:31:24 2011 for Fawkes API by  doxygen 1.4.7