Fawkes API  Fawkes Development Version
NaoSensorInterface.h
1 
2 /***************************************************************************
3  * NaoSensorInterface.h - Fawkes BlackBoard Interface - NaoSensorInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 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_NAOSENSORINTERFACE_H_
25 #define __INTERFACES_NAOSENSORINTERFACE_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(NaoSensorInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  /**
42  This determines the chosen sender/receiver.
43  */
44  typedef enum {
45  USD_NONE /**< No transmission received, yet. */,
46  USD_LEFT_LEFT /**< Left emitter and left receiver. */,
47  USD_LEFT_RIGHT /**< Left emitter and right receiver. */,
48  USD_RIGHT_RIGHT /**< Right emitter and right receiver. */,
49  USD_RIGHT_LEFT /**< Right emitter and left receiver. */,
50  USD_BOTH_BOTH /**< Both emitters and both receivers. */
52  const char * tostring_UltrasonicDirection(UltrasonicDirection value) const;
53 
54  private:
55  /** Internal data storage, do NOT modify! */
56  typedef struct __attribute__((packed)) {
57  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
58  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
59  float accel_x; /**< Accelerometer x */
60  float accel_y; /**< Accelerometer y */
61  float accel_z; /**< Accelerometer z */
62  float gyro_x; /**< Gyrometer x */
63  float gyro_y; /**< Gyrometer y */
64  float gyro_ref; /**< Gyrometer reference */
65  float angle_x; /**< Angle x */
66  float angle_y; /**< Angle y */
67  float l_fsr_fl; /**< Left FSR front left */
68  float l_fsr_fr; /**< Left FSR front right */
69  float l_fsr_rl; /**< Left FSR rear left */
70  float l_fsr_rr; /**< Left FSR rear right */
71  float r_fsr_fl; /**< Right FSR front left */
72  float r_fsr_fr; /**< Right FSR front right */
73  float r_fsr_rl; /**< Right FSR rear left */
74  float r_fsr_rr; /**< Right FSR rear right */
75  float l_total_weight; /**< Total weight on left foot */
76  float r_total_weight; /**< Total weight on right foot */
77  float l_cop_x; /**< Center of pressure X for left foot. */
78  float l_cop_y; /**< Center of pressure Y for left foot. */
79  float r_cop_x; /**< Center of pressure X for right foot. */
80  float r_cop_y; /**< Center of pressure Y for right foot. */
81  float ultrasonic_distance_left[4]; /**<
82  First four ultrasonic sensor readings from left receiver. Distance
83  to detected object is in meters.
84  */
85  float ultrasonic_distance_right[4]; /**<
86  First four ultrasonic sensor readings from right receiver. Distance
87  to detected object is in meters.
88  */
89  int32_t ultrasonic_direction; /**<
90  Direction that was used to gather the ultrasonic readings.
91  */
92  uint8_t l_foot_bumper_l; /**< Left foot bumper left side */
93  uint8_t l_foot_bumper_r; /**< Left foot bumper right side */
94  uint8_t r_foot_bumper_l; /**< Right foot bumper left side */
95  uint8_t r_foot_bumper_r; /**< Right foot bumper right side */
96  uint8_t head_touch_front; /**< Front part of head touch sensor (only Academics robot) */
97  uint8_t head_touch_middle; /**< Middle part of head touch sensor (only Academics robot) */
98  uint8_t head_touch_rear; /**< Rear part of head touch sensor (only Academics robot) */
99  uint8_t chest_button; /**< Chest button state */
100  float battery_charge; /**< Battery charge */
101  } NaoSensorInterface_data_t;
102 
103  NaoSensorInterface_data_t *data;
104 
105  interface_enum_map_t enum_map_UltrasonicDirection;
106  public:
107  /* messages */
109  {
110  private:
111  /** Internal data storage, do NOT modify! */
112  typedef struct __attribute__((packed)) {
113  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
114  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
115  int32_t ultrasonic_direction; /**<
116  Direction that was used to gather the ultrasonic readings.
117  */
118  } EmitUltrasonicWaveMessage_data_t;
119 
120  EmitUltrasonicWaveMessage_data_t *data;
121 
122  interface_enum_map_t enum_map_UltrasonicDirection;
123  public:
124  EmitUltrasonicWaveMessage(const UltrasonicDirection ini_ultrasonic_direction);
127 
129  /* Methods */
130  UltrasonicDirection ultrasonic_direction() const;
131  void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction);
132  size_t maxlenof_ultrasonic_direction() const;
133  virtual Message * clone() const;
134  };
135 
137  {
138  private:
139  /** Internal data storage, do NOT modify! */
140  typedef struct __attribute__((packed)) {
141  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
142  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
143  int32_t ultrasonic_direction; /**<
144  Direction that was used to gather the ultrasonic readings.
145  */
146  } StartUltrasonicMessage_data_t;
147 
148  StartUltrasonicMessage_data_t *data;
149 
150  interface_enum_map_t enum_map_UltrasonicDirection;
151  public:
152  StartUltrasonicMessage(const UltrasonicDirection ini_ultrasonic_direction);
155 
157  /* Methods */
158  UltrasonicDirection ultrasonic_direction() const;
159  void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction);
160  size_t maxlenof_ultrasonic_direction() const;
161  virtual Message * clone() const;
162  };
163 
165  {
166  private:
167  /** Internal data storage, do NOT modify! */
168  typedef struct __attribute__((packed)) {
169  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
170  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
171  } StopUltrasonicMessage_data_t;
172 
173  StopUltrasonicMessage_data_t *data;
174 
175  interface_enum_map_t enum_map_UltrasonicDirection;
176  public:
179 
181  /* Methods */
182  virtual Message * clone() const;
183  };
184 
185  virtual bool message_valid(const Message *message) const;
186  private:
189 
190  public:
191  /* Methods */
192  float accel_x() const;
193  void set_accel_x(const float new_accel_x);
194  size_t maxlenof_accel_x() const;
195  float accel_y() const;
196  void set_accel_y(const float new_accel_y);
197  size_t maxlenof_accel_y() const;
198  float accel_z() const;
199  void set_accel_z(const float new_accel_z);
200  size_t maxlenof_accel_z() const;
201  float gyro_x() const;
202  void set_gyro_x(const float new_gyro_x);
203  size_t maxlenof_gyro_x() const;
204  float gyro_y() const;
205  void set_gyro_y(const float new_gyro_y);
206  size_t maxlenof_gyro_y() const;
207  float gyro_ref() const;
208  void set_gyro_ref(const float new_gyro_ref);
209  size_t maxlenof_gyro_ref() const;
210  float angle_x() const;
211  void set_angle_x(const float new_angle_x);
212  size_t maxlenof_angle_x() const;
213  float angle_y() const;
214  void set_angle_y(const float new_angle_y);
215  size_t maxlenof_angle_y() const;
216  float l_fsr_fl() const;
217  void set_l_fsr_fl(const float new_l_fsr_fl);
218  size_t maxlenof_l_fsr_fl() const;
219  float l_fsr_fr() const;
220  void set_l_fsr_fr(const float new_l_fsr_fr);
221  size_t maxlenof_l_fsr_fr() const;
222  float l_fsr_rl() const;
223  void set_l_fsr_rl(const float new_l_fsr_rl);
224  size_t maxlenof_l_fsr_rl() const;
225  float l_fsr_rr() const;
226  void set_l_fsr_rr(const float new_l_fsr_rr);
227  size_t maxlenof_l_fsr_rr() const;
228  float r_fsr_fl() const;
229  void set_r_fsr_fl(const float new_r_fsr_fl);
230  size_t maxlenof_r_fsr_fl() const;
231  float r_fsr_fr() const;
232  void set_r_fsr_fr(const float new_r_fsr_fr);
233  size_t maxlenof_r_fsr_fr() const;
234  float r_fsr_rl() const;
235  void set_r_fsr_rl(const float new_r_fsr_rl);
236  size_t maxlenof_r_fsr_rl() const;
237  float r_fsr_rr() const;
238  void set_r_fsr_rr(const float new_r_fsr_rr);
239  size_t maxlenof_r_fsr_rr() const;
240  float l_total_weight() const;
241  void set_l_total_weight(const float new_l_total_weight);
242  size_t maxlenof_l_total_weight() const;
243  float r_total_weight() const;
244  void set_r_total_weight(const float new_r_total_weight);
245  size_t maxlenof_r_total_weight() const;
246  float l_cop_x() const;
247  void set_l_cop_x(const float new_l_cop_x);
248  size_t maxlenof_l_cop_x() const;
249  float l_cop_y() const;
250  void set_l_cop_y(const float new_l_cop_y);
251  size_t maxlenof_l_cop_y() const;
252  float r_cop_x() const;
253  void set_r_cop_x(const float new_r_cop_x);
254  size_t maxlenof_r_cop_x() const;
255  float r_cop_y() const;
256  void set_r_cop_y(const float new_r_cop_y);
257  size_t maxlenof_r_cop_y() const;
258  float * ultrasonic_distance_left() const;
259  float ultrasonic_distance_left(unsigned int index) const;
260  void set_ultrasonic_distance_left(unsigned int index, const float new_ultrasonic_distance_left);
261  void set_ultrasonic_distance_left(const float * new_ultrasonic_distance_left);
262  size_t maxlenof_ultrasonic_distance_left() const;
263  float * ultrasonic_distance_right() const;
264  float ultrasonic_distance_right(unsigned int index) const;
265  void set_ultrasonic_distance_right(unsigned int index, const float new_ultrasonic_distance_right);
266  void set_ultrasonic_distance_right(const float * new_ultrasonic_distance_right);
267  size_t maxlenof_ultrasonic_distance_right() const;
268  UltrasonicDirection ultrasonic_direction() const;
269  void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction);
270  size_t maxlenof_ultrasonic_direction() const;
271  uint8_t l_foot_bumper_l() const;
272  void set_l_foot_bumper_l(const uint8_t new_l_foot_bumper_l);
273  size_t maxlenof_l_foot_bumper_l() const;
274  uint8_t l_foot_bumper_r() const;
275  void set_l_foot_bumper_r(const uint8_t new_l_foot_bumper_r);
276  size_t maxlenof_l_foot_bumper_r() const;
277  uint8_t r_foot_bumper_l() const;
278  void set_r_foot_bumper_l(const uint8_t new_r_foot_bumper_l);
279  size_t maxlenof_r_foot_bumper_l() const;
280  uint8_t r_foot_bumper_r() const;
281  void set_r_foot_bumper_r(const uint8_t new_r_foot_bumper_r);
282  size_t maxlenof_r_foot_bumper_r() const;
283  uint8_t head_touch_front() const;
284  void set_head_touch_front(const uint8_t new_head_touch_front);
285  size_t maxlenof_head_touch_front() const;
286  uint8_t head_touch_middle() const;
287  void set_head_touch_middle(const uint8_t new_head_touch_middle);
288  size_t maxlenof_head_touch_middle() const;
289  uint8_t head_touch_rear() const;
290  void set_head_touch_rear(const uint8_t new_head_touch_rear);
291  size_t maxlenof_head_touch_rear() const;
292  uint8_t chest_button() const;
293  void set_chest_button(const uint8_t new_chest_button);
294  size_t maxlenof_chest_button() const;
295  float battery_charge() const;
296  void set_battery_charge(const float new_battery_charge);
297  size_t maxlenof_battery_charge() const;
298  virtual Message * create_message(const char *type) const;
299 
300  virtual void copy_values(const Interface *other);
301  virtual const char * enum_tostring(const char *enumtype, int val) const;
302 
303 };
304 
305 } // end namespace fawkes
306 
307 #endif
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
uint8_t r_foot_bumper_r() const
Get r_foot_bumper_r value.
void set_l_fsr_rl(const float new_l_fsr_rl)
Set l_fsr_rl value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
void set_r_foot_bumper_r(const uint8_t new_r_foot_bumper_r)
Set r_foot_bumper_r value.
size_t maxlenof_r_fsr_fl() const
Get maximum length of r_fsr_fl value.
void set_accel_x(const float new_accel_x)
Set accel_x value.
StopUltrasonicMessage Fawkes BlackBoard Interface Message.
uint8_t l_foot_bumper_l() const
Get l_foot_bumper_l value.
void set_l_fsr_fl(const float new_l_fsr_fl)
Set l_fsr_fl value.
size_t maxlenof_l_cop_x() const
Get maximum length of l_cop_x value.
size_t maxlenof_ultrasonic_distance_left() const
Get maximum length of ultrasonic_distance_left value.
size_t maxlenof_battery_charge() const
Get maximum length of battery_charge value.
size_t maxlenof_l_fsr_fl() const
Get maximum length of l_fsr_fl value.
void set_head_touch_front(const uint8_t new_head_touch_front)
Set head_touch_front value.
void set_chest_button(const uint8_t new_chest_button)
Set chest_button value.
float r_fsr_fr() const
Get r_fsr_fr value.
size_t maxlenof_head_touch_middle() const
Get maximum length of head_touch_middle value.
void set_accel_z(const float new_accel_z)
Set accel_z value.
size_t maxlenof_r_fsr_fr() const
Get maximum length of r_fsr_fr value.
Fawkes library namespace.
size_t maxlenof_r_total_weight() const
Get maximum length of r_total_weight value.
float l_fsr_rl() const
Get l_fsr_rl value.
Right emitter and right receiver.
size_t maxlenof_ultrasonic_distance_right() const
Get maximum length of ultrasonic_distance_right value.
void set_l_fsr_rr(const float new_l_fsr_rr)
Set l_fsr_rr value.
float l_fsr_fl() const
Get l_fsr_fl value.
Right emitter and left receiver.
size_t maxlenof_l_fsr_rl() const
Get maximum length of l_fsr_rl value.
float l_fsr_rr() const
Get l_fsr_rr value.
void set_l_total_weight(const float new_l_total_weight)
Set l_total_weight value.
float accel_x() const
Get accel_x value.
StartUltrasonicMessage Fawkes BlackBoard Interface Message.
void set_r_total_weight(const float new_r_total_weight)
Set r_total_weight value.
UltrasonicDirection ultrasonic_direction() const
Get ultrasonic_direction value.
uint8_t l_foot_bumper_r() const
Get l_foot_bumper_r value.
NaoSensorInterface Fawkes BlackBoard Interface.
void set_l_cop_y(const float new_l_cop_y)
Set l_cop_y value.
size_t maxlenof_angle_y() const
Get maximum length of angle_y value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
float * ultrasonic_distance_right() const
Get ultrasonic_distance_right value.
float angle_x() const
Get angle_x value.
void set_gyro_y(const float new_gyro_y)
Set gyro_y value.
void set_battery_charge(const float new_battery_charge)
Set battery_charge value.
size_t maxlenof_gyro_ref() const
Get maximum length of gyro_ref value.
float * ultrasonic_distance_left() const
Get ultrasonic_distance_left value.
size_t maxlenof_accel_y() const
Get maximum length of accel_y value.
size_t maxlenof_head_touch_front() const
Get maximum length of head_touch_front value.
size_t maxlenof_gyro_y() const
Get maximum length of gyro_y value.
void set_r_fsr_fr(const float new_r_fsr_fr)
Set r_fsr_fr value.
size_t maxlenof_r_foot_bumper_l() const
Get maximum length of r_foot_bumper_l value.
void set_ultrasonic_distance_right(unsigned int index, const float new_ultrasonic_distance_right)
Set ultrasonic_distance_right value at given index.
size_t maxlenof_r_fsr_rr() const
Get maximum length of r_fsr_rr value.
float r_fsr_fl() const
Get r_fsr_fl value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
void set_r_fsr_fl(const float new_r_fsr_fl)
Set r_fsr_fl value.
size_t maxlenof_gyro_x() const
Get maximum length of gyro_x value.
UltrasonicDirection
This determines the chosen sender/receiver.
void set_r_cop_y(const float new_r_cop_y)
Set r_cop_y value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
float l_fsr_fr() const
Get l_fsr_fr value.
void set_gyro_x(const float new_gyro_x)
Set gyro_x value.
float gyro_ref() const
Get gyro_ref value.
float r_cop_y() const
Get r_cop_y value.
Both emitters and both receivers.
size_t maxlenof_head_touch_rear() const
Get maximum length of head_touch_rear value.
void set_angle_y(const float new_angle_y)
Set angle_y value.
virtual Message * create_message(const char *type) const
Create message based on type name.
float accel_y() const
Get accel_y value.
Left emitter and left receiver.
void set_accel_y(const float new_accel_y)
Set accel_y value.
float accel_z() const
Get accel_z value.
void set_l_foot_bumper_r(const uint8_t new_l_foot_bumper_r)
Set l_foot_bumper_r value.
uint8_t chest_button() const
Get chest_button value.
size_t maxlenof_ultrasonic_direction() const
Get maximum length of ultrasonic_direction value.
void set_l_cop_x(const float new_l_cop_x)
Set l_cop_x value.
size_t maxlenof_l_total_weight() const
Get maximum length of l_total_weight value.
void set_r_foot_bumper_l(const uint8_t new_r_foot_bumper_l)
Set r_foot_bumper_l value.
float l_cop_y() const
Get l_cop_y value.
float angle_y() const
Get angle_y value.
void set_l_fsr_fr(const float new_l_fsr_fr)
Set l_fsr_fr value.
size_t maxlenof_chest_button() const
Get maximum length of chest_button value.
void set_head_touch_rear(const uint8_t new_head_touch_rear)
Set head_touch_rear value.
size_t maxlenof_r_foot_bumper_r() const
Get maximum length of r_foot_bumper_r value.
float gyro_y() const
Get gyro_y value.
float r_fsr_rl() const
Get r_fsr_rl value.
void set_l_foot_bumper_l(const uint8_t new_l_foot_bumper_l)
Set l_foot_bumper_l value.
size_t maxlenof_r_cop_x() const
Get maximum length of r_cop_x value.
float l_total_weight() const
Get l_total_weight value.
size_t maxlenof_accel_z() const
Get maximum length of accel_z value.
float r_cop_x() const
Get r_cop_x value.
size_t maxlenof_l_fsr_rr() const
Get maximum length of l_fsr_rr value.
float gyro_x() const
Get gyro_x value.
uint8_t head_touch_rear() const
Get head_touch_rear value.
uint8_t r_foot_bumper_l() const
Get r_foot_bumper_l value.
void set_r_fsr_rl(const float new_r_fsr_rl)
Set r_fsr_rl value.
size_t maxlenof_l_cop_y() const
Get maximum length of l_cop_y value.
EmitUltrasonicWaveMessage Fawkes BlackBoard Interface Message.
void set_ultrasonic_distance_left(unsigned int index, const float new_ultrasonic_distance_left)
Set ultrasonic_distance_left value at given index.
void set_r_fsr_rr(const float new_r_fsr_rr)
Set r_fsr_rr value.
size_t maxlenof_l_foot_bumper_l() const
Get maximum length of l_foot_bumper_l value.
size_t maxlenof_r_cop_y() const
Get maximum length of r_cop_y value.
float battery_charge() const
Get battery_charge value.
No transmission received, yet.
uint8_t head_touch_front() const
Get head_touch_front value.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:53
float l_cop_x() const
Get l_cop_x value.
size_t maxlenof_r_fsr_rl() const
Get maximum length of r_fsr_rl value.
void set_r_cop_x(const float new_r_cop_x)
Set r_cop_x value.
size_t maxlenof_accel_x() const
Get maximum length of accel_x value.
float r_fsr_rr() const
Get r_fsr_rr value.
void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction)
Set ultrasonic_direction value.
size_t maxlenof_l_fsr_fr() const
Get maximum length of l_fsr_fr value.
float r_total_weight() const
Get r_total_weight value.
const char * tostring_UltrasonicDirection(UltrasonicDirection value) const
Convert UltrasonicDirection constant to string.
void set_head_touch_middle(const uint8_t new_head_touch_middle)
Set head_touch_middle value.
size_t maxlenof_angle_x() const
Get maximum length of angle_x value.
Left emitter and right receiver.
uint8_t head_touch_middle() const
Get head_touch_middle value.
size_t maxlenof_l_foot_bumper_r() const
Get maximum length of l_foot_bumper_r value.
void set_angle_x(const float new_angle_x)
Set angle_x value.
void set_gyro_ref(const float new_gyro_ref)
Set gyro_ref value.