Fawkes API  Fawkes Development Version
RobotinoSensorInterface.h
1 
2 /***************************************************************************
3  * RobotinoSensorInterface.h - Fawkes BlackBoard Interface - RobotinoSensorInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2012 Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __INTERFACES_ROBOTINOSENSORINTERFACE_H_
25 #define __INTERFACES_ROBOTINOSENSORINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(RobotinoSensorInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42 #pragma pack(push,4)
43  /** Internal data storage, do NOT modify! */
44  typedef struct {
45  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
46  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
47  float mot_velocity[3]; /**< Velocities of the wheels. */
48  int32_t mot_position[3]; /**< Positions of the wheels. */
49  float mot_current[3]; /**< Motor currents. */
50  bool bumper; /**< Bumper pressed indicator. */
51  float distance[9]; /**< Distance sensor values. */
52  bool digital_in[8]; /**< Digital input values. */
53  float analog_in[8]; /**< Analog input values. */
54  bool gyro_available; /**< True if gyro is available */
55  float gyro_angle; /**< Gyro angle value; rad */
56  float gyro_rate; /**< Gyro rate value; rad/sec */
57  } RobotinoSensorInterface_data_t;
58 #pragma pack(pop)
59 
60  RobotinoSensorInterface_data_t *data;
61 
62  public:
63  /* messages */
64  virtual bool message_valid(const Message *message) const;
65  private:
68 
69  public:
70  /* Methods */
71  float * mot_velocity() const;
72  float mot_velocity(unsigned int index) const;
73  void set_mot_velocity(unsigned int index, const float new_mot_velocity);
74  void set_mot_velocity(const float * new_mot_velocity);
75  size_t maxlenof_mot_velocity() const;
76  int32_t * mot_position() const;
77  int32_t mot_position(unsigned int index) const;
78  void set_mot_position(unsigned int index, const int32_t new_mot_position);
79  void set_mot_position(const int32_t * new_mot_position);
80  size_t maxlenof_mot_position() const;
81  float * mot_current() const;
82  float mot_current(unsigned int index) const;
83  void set_mot_current(unsigned int index, const float new_mot_current);
84  void set_mot_current(const float * new_mot_current);
85  size_t maxlenof_mot_current() const;
86  bool is_bumper() const;
87  void set_bumper(const bool new_bumper);
88  size_t maxlenof_bumper() const;
89  float * distance() const;
90  float distance(unsigned int index) const;
91  void set_distance(unsigned int index, const float new_distance);
92  void set_distance(const float * new_distance);
93  size_t maxlenof_distance() const;
94  bool * is_digital_in() const;
95  bool is_digital_in(unsigned int index) const;
96  void set_digital_in(unsigned int index, const bool new_digital_in);
97  void set_digital_in(const bool * new_digital_in);
98  size_t maxlenof_digital_in() const;
99  float * analog_in() const;
100  float analog_in(unsigned int index) const;
101  void set_analog_in(unsigned int index, const float new_analog_in);
102  void set_analog_in(const float * new_analog_in);
103  size_t maxlenof_analog_in() const;
104  bool is_gyro_available() const;
105  void set_gyro_available(const bool new_gyro_available);
106  size_t maxlenof_gyro_available() const;
107  float gyro_angle() const;
108  void set_gyro_angle(const float new_gyro_angle);
109  size_t maxlenof_gyro_angle() const;
110  float gyro_rate() const;
111  void set_gyro_rate(const float new_gyro_rate);
112  size_t maxlenof_gyro_rate() const;
113  virtual Message * create_message(const char *type) const;
114 
115  virtual void copy_values(const Interface *other);
116  virtual const char * enum_tostring(const char *enumtype, int val) const;
117 
118 };
119 
120 } // end namespace fawkes
121 
122 #endif
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
void set_gyro_rate(const float new_gyro_rate)
Set gyro_rate value.
bool is_bumper() const
Get bumper value.
Fawkes library namespace.
size_t maxlenof_gyro_available() const
Get maximum length of gyro_available value.
void set_gyro_angle(const float new_gyro_angle)
Set gyro_angle value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
float * distance() const
Get distance value.
virtual Message * create_message(const char *type) const
Create message based on type name.
size_t maxlenof_gyro_rate() const
Get maximum length of gyro_rate value.
void set_analog_in(unsigned int index, const float new_analog_in)
Set analog_in value at given index.
RobotinoSensorInterface Fawkes BlackBoard Interface.
size_t maxlenof_mot_position() const
Get maximum length of mot_position value.
float * mot_current() const
Get mot_current value.
size_t maxlenof_digital_in() const
Get maximum length of digital_in value.
float * analog_in() const
Get analog_in value.
float * mot_velocity() const
Get mot_velocity value.
int32_t * mot_position() const
Get mot_position value.
size_t maxlenof_mot_velocity() const
Get maximum length of mot_velocity value.
void set_mot_velocity(unsigned int index, const float new_mot_velocity)
Set mot_velocity value at given index.
virtual void copy_values(const Interface *other)
Copy values from other interface.
bool is_gyro_available() const
Get gyro_available value.
void set_digital_in(unsigned int index, const bool new_digital_in)
Set digital_in value at given index.
float gyro_angle() const
Get gyro_angle value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
size_t maxlenof_gyro_angle() const
Get maximum length of gyro_angle value.
void set_distance(unsigned int index, const float new_distance)
Set distance value at given index.
float gyro_rate() const
Get gyro_rate value.
void set_mot_current(unsigned int index, const float new_mot_current)
Set mot_current value at given index.
void set_mot_position(unsigned int index, const int32_t new_mot_position)
Set mot_position value at given index.
void set_bumper(const bool new_bumper)
Set bumper value.
bool * is_digital_in() const
Get digital_in value.
size_t maxlenof_mot_current() const
Get maximum length of mot_current value.
size_t maxlenof_distance() const
Get maximum length of distance value.
const char * type() const
Get type of interface.
Definition: interface.cpp:635
size_t maxlenof_analog_in() const
Get maximum length of analog_in value.
size_t maxlenof_bumper() const
Get maximum length of bumper value.
void set_gyro_available(const bool new_gyro_available)
Set gyro_available value.