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