Fawkes API  Fawkes Development Version
NaoSensorInterface.h
00001 
00002 /***************************************************************************
00003  *  NaoSensorInterface.h - Fawkes BlackBoard Interface - NaoSensorInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2008  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_NAOSENSORINTERFACE_H_
00025 #define __INTERFACES_NAOSENSORINTERFACE_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 NaoSensorInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(NaoSensorInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040 
00041   /** 
00042         This determines the chosen sender/receiver.
00043        */
00044   typedef enum {
00045     USD_NONE /**< No transmission received, yet. */,
00046     USD_LEFT_LEFT /**< Left emitter and left receiver. */,
00047     USD_LEFT_RIGHT /**< Left emitter and right receiver. */,
00048     USD_RIGHT_RIGHT /**< Right emitter and right receiver. */,
00049     USD_RIGHT_LEFT /**< Right emitter and left receiver. */,
00050     USD_BOTH_BOTH /**< Both emitters and both receivers. */
00051   } UltrasonicDirection;
00052   const char * tostring_UltrasonicDirection(UltrasonicDirection value) const;
00053 
00054  private:
00055 #pragma pack(push,4)
00056   /** Internal data storage, do NOT modify! */
00057   typedef struct {
00058     int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00059     int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00060     float accel_x; /**< Accelerometer x */
00061     float accel_y; /**< Accelerometer y */
00062     float accel_z; /**< Accelerometer z */
00063     float gyro_x; /**< Gyrometer x */
00064     float gyro_y; /**< Gyrometer y */
00065     float gyro_ref; /**< Gyrometer reference */
00066     float angle_x; /**< Angle x */
00067     float angle_y; /**< Angle y */
00068     float l_fsr_fl; /**< Left FSR front left */
00069     float l_fsr_fr; /**< Left FSR front right */
00070     float l_fsr_rl; /**< Left FSR rear left */
00071     float l_fsr_rr; /**< Left FSR rear right */
00072     float r_fsr_fl; /**< Right FSR front left */
00073     float r_fsr_fr; /**< Right FSR front right */
00074     float r_fsr_rl; /**< Right FSR rear left */
00075     float r_fsr_rr; /**< Right FSR rear right */
00076     float l_total_weight; /**< Total weight on left foot */
00077     float r_total_weight; /**< Total weight on right foot */
00078     float l_cop_x; /**< Center of pressure X for left foot. */
00079     float l_cop_y; /**< Center of pressure Y for left foot. */
00080     float r_cop_x; /**< Center of pressure X for right foot. */
00081     float r_cop_y; /**< Center of pressure Y for right foot. */
00082     float ultrasonic_distance_left[4]; /**< 
00083       First four ultrasonic sensor readings from left receiver. Distance
00084       to detected object is in meters.
00085      */
00086     float ultrasonic_distance_right[4]; /**< 
00087       First four ultrasonic sensor readings from right receiver. Distance
00088       to detected object is in meters.
00089      */
00090     int32_t ultrasonic_direction; /**< 
00091       Direction that was used to gather the ultrasonic readings.
00092      */
00093     uint8_t l_foot_bumper_l; /**< Left foot bumper left side */
00094     uint8_t l_foot_bumper_r; /**< Left foot bumper right side */
00095     uint8_t r_foot_bumper_l; /**< Right foot bumper left side */
00096     uint8_t r_foot_bumper_r; /**< Right foot bumper right side */
00097     uint8_t head_touch_front; /**< Front part of head touch sensor (only Academics robot) */
00098     uint8_t head_touch_middle; /**< Middle part of head touch sensor (only Academics robot) */
00099     uint8_t head_touch_rear; /**< Rear part of head touch sensor (only Academics robot) */
00100     uint8_t chest_button; /**< Chest button state */
00101     float battery_charge; /**< Battery charge */
00102   } NaoSensorInterface_data_t;
00103 #pragma pack(pop)
00104 
00105   NaoSensorInterface_data_t *data;
00106 
00107  public:
00108   /* messages */
00109   class EmitUltrasonicWaveMessage : 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       int32_t ultrasonic_direction; /**< 
00118       Direction that was used to gather the ultrasonic readings.
00119      */
00120     } EmitUltrasonicWaveMessage_data_t;
00121 #pragma pack(pop)
00122 
00123     EmitUltrasonicWaveMessage_data_t *data;
00124 
00125    public:
00126     EmitUltrasonicWaveMessage(const UltrasonicDirection ini_ultrasonic_direction);
00127     EmitUltrasonicWaveMessage();
00128     ~EmitUltrasonicWaveMessage();
00129 
00130     EmitUltrasonicWaveMessage(const EmitUltrasonicWaveMessage *m);
00131     /* Methods */
00132     UltrasonicDirection ultrasonic_direction() const;
00133     void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction);
00134     size_t maxlenof_ultrasonic_direction() const;
00135     virtual Message * clone() const;
00136   };
00137 
00138   class StartUltrasonicMessage : public Message
00139   {
00140    private:
00141 #pragma pack(push,4)
00142     /** Internal data storage, do NOT modify! */
00143     typedef struct {
00144       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00145       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00146       int32_t ultrasonic_direction; /**< 
00147       Direction that was used to gather the ultrasonic readings.
00148      */
00149     } StartUltrasonicMessage_data_t;
00150 #pragma pack(pop)
00151 
00152     StartUltrasonicMessage_data_t *data;
00153 
00154    public:
00155     StartUltrasonicMessage(const UltrasonicDirection ini_ultrasonic_direction);
00156     StartUltrasonicMessage();
00157     ~StartUltrasonicMessage();
00158 
00159     StartUltrasonicMessage(const StartUltrasonicMessage *m);
00160     /* Methods */
00161     UltrasonicDirection ultrasonic_direction() const;
00162     void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction);
00163     size_t maxlenof_ultrasonic_direction() const;
00164     virtual Message * clone() const;
00165   };
00166 
00167   class StopUltrasonicMessage : public Message
00168   {
00169    private:
00170 #pragma pack(push,4)
00171     /** Internal data storage, do NOT modify! */
00172     typedef struct {
00173       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00174       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00175     } StopUltrasonicMessage_data_t;
00176 #pragma pack(pop)
00177 
00178     StopUltrasonicMessage_data_t *data;
00179 
00180    public:
00181     StopUltrasonicMessage();
00182     ~StopUltrasonicMessage();
00183 
00184     StopUltrasonicMessage(const StopUltrasonicMessage *m);
00185     /* Methods */
00186     virtual Message * clone() const;
00187   };
00188 
00189   virtual bool message_valid(const Message *message) const;
00190  private:
00191   NaoSensorInterface();
00192   ~NaoSensorInterface();
00193 
00194  public:
00195   /* Methods */
00196   float accel_x() const;
00197   void set_accel_x(const float new_accel_x);
00198   size_t maxlenof_accel_x() const;
00199   float accel_y() const;
00200   void set_accel_y(const float new_accel_y);
00201   size_t maxlenof_accel_y() const;
00202   float accel_z() const;
00203   void set_accel_z(const float new_accel_z);
00204   size_t maxlenof_accel_z() const;
00205   float gyro_x() const;
00206   void set_gyro_x(const float new_gyro_x);
00207   size_t maxlenof_gyro_x() const;
00208   float gyro_y() const;
00209   void set_gyro_y(const float new_gyro_y);
00210   size_t maxlenof_gyro_y() const;
00211   float gyro_ref() const;
00212   void set_gyro_ref(const float new_gyro_ref);
00213   size_t maxlenof_gyro_ref() const;
00214   float angle_x() const;
00215   void set_angle_x(const float new_angle_x);
00216   size_t maxlenof_angle_x() const;
00217   float angle_y() const;
00218   void set_angle_y(const float new_angle_y);
00219   size_t maxlenof_angle_y() const;
00220   float l_fsr_fl() const;
00221   void set_l_fsr_fl(const float new_l_fsr_fl);
00222   size_t maxlenof_l_fsr_fl() const;
00223   float l_fsr_fr() const;
00224   void set_l_fsr_fr(const float new_l_fsr_fr);
00225   size_t maxlenof_l_fsr_fr() const;
00226   float l_fsr_rl() const;
00227   void set_l_fsr_rl(const float new_l_fsr_rl);
00228   size_t maxlenof_l_fsr_rl() const;
00229   float l_fsr_rr() const;
00230   void set_l_fsr_rr(const float new_l_fsr_rr);
00231   size_t maxlenof_l_fsr_rr() const;
00232   float r_fsr_fl() const;
00233   void set_r_fsr_fl(const float new_r_fsr_fl);
00234   size_t maxlenof_r_fsr_fl() const;
00235   float r_fsr_fr() const;
00236   void set_r_fsr_fr(const float new_r_fsr_fr);
00237   size_t maxlenof_r_fsr_fr() const;
00238   float r_fsr_rl() const;
00239   void set_r_fsr_rl(const float new_r_fsr_rl);
00240   size_t maxlenof_r_fsr_rl() const;
00241   float r_fsr_rr() const;
00242   void set_r_fsr_rr(const float new_r_fsr_rr);
00243   size_t maxlenof_r_fsr_rr() const;
00244   float l_total_weight() const;
00245   void set_l_total_weight(const float new_l_total_weight);
00246   size_t maxlenof_l_total_weight() const;
00247   float r_total_weight() const;
00248   void set_r_total_weight(const float new_r_total_weight);
00249   size_t maxlenof_r_total_weight() const;
00250   float l_cop_x() const;
00251   void set_l_cop_x(const float new_l_cop_x);
00252   size_t maxlenof_l_cop_x() const;
00253   float l_cop_y() const;
00254   void set_l_cop_y(const float new_l_cop_y);
00255   size_t maxlenof_l_cop_y() const;
00256   float r_cop_x() const;
00257   void set_r_cop_x(const float new_r_cop_x);
00258   size_t maxlenof_r_cop_x() const;
00259   float r_cop_y() const;
00260   void set_r_cop_y(const float new_r_cop_y);
00261   size_t maxlenof_r_cop_y() const;
00262   float * ultrasonic_distance_left() const;
00263   float ultrasonic_distance_left(unsigned int index) const;
00264   void set_ultrasonic_distance_left(unsigned int index, const float new_ultrasonic_distance_left);
00265   void set_ultrasonic_distance_left(const float * new_ultrasonic_distance_left);
00266   size_t maxlenof_ultrasonic_distance_left() const;
00267   float * ultrasonic_distance_right() const;
00268   float ultrasonic_distance_right(unsigned int index) const;
00269   void set_ultrasonic_distance_right(unsigned int index, const float new_ultrasonic_distance_right);
00270   void set_ultrasonic_distance_right(const float * new_ultrasonic_distance_right);
00271   size_t maxlenof_ultrasonic_distance_right() const;
00272   UltrasonicDirection ultrasonic_direction() const;
00273   void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction);
00274   size_t maxlenof_ultrasonic_direction() const;
00275   uint8_t l_foot_bumper_l() const;
00276   void set_l_foot_bumper_l(const uint8_t new_l_foot_bumper_l);
00277   size_t maxlenof_l_foot_bumper_l() const;
00278   uint8_t l_foot_bumper_r() const;
00279   void set_l_foot_bumper_r(const uint8_t new_l_foot_bumper_r);
00280   size_t maxlenof_l_foot_bumper_r() const;
00281   uint8_t r_foot_bumper_l() const;
00282   void set_r_foot_bumper_l(const uint8_t new_r_foot_bumper_l);
00283   size_t maxlenof_r_foot_bumper_l() const;
00284   uint8_t r_foot_bumper_r() const;
00285   void set_r_foot_bumper_r(const uint8_t new_r_foot_bumper_r);
00286   size_t maxlenof_r_foot_bumper_r() const;
00287   uint8_t head_touch_front() const;
00288   void set_head_touch_front(const uint8_t new_head_touch_front);
00289   size_t maxlenof_head_touch_front() const;
00290   uint8_t head_touch_middle() const;
00291   void set_head_touch_middle(const uint8_t new_head_touch_middle);
00292   size_t maxlenof_head_touch_middle() const;
00293   uint8_t head_touch_rear() const;
00294   void set_head_touch_rear(const uint8_t new_head_touch_rear);
00295   size_t maxlenof_head_touch_rear() const;
00296   uint8_t chest_button() const;
00297   void set_chest_button(const uint8_t new_chest_button);
00298   size_t maxlenof_chest_button() const;
00299   float battery_charge() const;
00300   void set_battery_charge(const float new_battery_charge);
00301   size_t maxlenof_battery_charge() const;
00302   virtual Message * create_message(const char *type) const;
00303 
00304   virtual void copy_values(const Interface *other);
00305   virtual const char * enum_tostring(const char *enumtype, int val) const;
00306 
00307 };
00308 
00309 } // end namespace fawkes
00310 
00311 #endif