Fawkes API  Fawkes Development Version
RobotinoSensorInterface.h
00001 
00002 /***************************************************************************
00003  *  RobotinoSensorInterface.h - Fawkes BlackBoard Interface - RobotinoSensorInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2012  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_ROBOTINOSENSORINTERFACE_H_
00025 #define __INTERFACES_ROBOTINOSENSORINTERFACE_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 RobotinoSensorInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(RobotinoSensorInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040 
00041  private:
00042 #pragma pack(push,4)
00043   /** Internal data storage, do NOT modify! */
00044   typedef struct {
00045     int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00046     int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00047     float mot_velocity[3]; /**< Velocities of the wheels. */
00048     int32_t mot_position[3]; /**< Positions of the wheels. */
00049     float mot_current[3]; /**< Motor currents. */
00050     bool bumper; /**< Bumper pressed indicator. */
00051     float distance[9]; /**< Distance sensor values. */
00052     bool digital_in[8]; /**< Digital input values. */
00053     float analog_in[8]; /**< Analog input values. */
00054     bool gyro_available; /**< True if gyro is available */
00055     float gyro_angle; /**< Gyro angle value; rad */
00056     float gyro_rate; /**< Gyro rate value; rad/sec */
00057   } RobotinoSensorInterface_data_t;
00058 #pragma pack(pop)
00059 
00060   RobotinoSensorInterface_data_t *data;
00061 
00062  public:
00063   /* messages */
00064   virtual bool message_valid(const Message *message) const;
00065  private:
00066   RobotinoSensorInterface();
00067   ~RobotinoSensorInterface();
00068 
00069  public:
00070   /* Methods */
00071   float * mot_velocity() const;
00072   float mot_velocity(unsigned int index) const;
00073   void set_mot_velocity(unsigned int index, const float new_mot_velocity);
00074   void set_mot_velocity(const float * new_mot_velocity);
00075   size_t maxlenof_mot_velocity() const;
00076   int32_t * mot_position() const;
00077   int32_t mot_position(unsigned int index) const;
00078   void set_mot_position(unsigned int index, const int32_t new_mot_position);
00079   void set_mot_position(const int32_t * new_mot_position);
00080   size_t maxlenof_mot_position() const;
00081   float * mot_current() const;
00082   float mot_current(unsigned int index) const;
00083   void set_mot_current(unsigned int index, const float new_mot_current);
00084   void set_mot_current(const float * new_mot_current);
00085   size_t maxlenof_mot_current() const;
00086   bool is_bumper() const;
00087   void set_bumper(const bool new_bumper);
00088   size_t maxlenof_bumper() const;
00089   float * distance() const;
00090   float distance(unsigned int index) const;
00091   void set_distance(unsigned int index, const float new_distance);
00092   void set_distance(const float * new_distance);
00093   size_t maxlenof_distance() const;
00094   bool * is_digital_in() const;
00095   bool is_digital_in(unsigned int index) const;
00096   void set_digital_in(unsigned int index, const bool new_digital_in);
00097   void set_digital_in(const bool * new_digital_in);
00098   size_t maxlenof_digital_in() const;
00099   float * analog_in() const;
00100   float analog_in(unsigned int index) const;
00101   void set_analog_in(unsigned int index, const float new_analog_in);
00102   void set_analog_in(const float * new_analog_in);
00103   size_t maxlenof_analog_in() const;
00104   bool is_gyro_available() const;
00105   void set_gyro_available(const bool new_gyro_available);
00106   size_t maxlenof_gyro_available() const;
00107   float gyro_angle() const;
00108   void set_gyro_angle(const float new_gyro_angle);
00109   size_t maxlenof_gyro_angle() const;
00110   float gyro_rate() const;
00111   void set_gyro_rate(const float new_gyro_rate);
00112   size_t maxlenof_gyro_rate() const;
00113   virtual Message * create_message(const char *type) const;
00114 
00115   virtual void copy_values(const Interface *other);
00116   virtual const char * enum_tostring(const char *enumtype, int val) const;
00117 
00118 };
00119 
00120 } // end namespace fawkes
00121 
00122 #endif