Fawkes API  Fawkes Development Version
NaoSensorInterface.cpp
1 
2 /***************************************************************************
3  * NaoSensorInterface.cpp - 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 #include <interfaces/NaoSensorInterface.h>
25 
26 #include <core/exceptions/software.h>
27 
28 #include <map>
29 #include <string>
30 #include <cstring>
31 #include <cstdlib>
32 
33 namespace fawkes {
34 
35 /** @class NaoSensorInterface <interfaces/NaoSensorInterface.h>
36  * NaoSensorInterface Fawkes BlackBoard Interface.
37  *
38  This interface provides access to Nao sensors.
39 
40  * @ingroup FawkesInterfaces
41  */
42 
43 
44 
45 /** Constructor */
46 NaoSensorInterface::NaoSensorInterface() : Interface()
47 {
48  data_size = sizeof(NaoSensorInterface_data_t);
49  data_ptr = malloc(data_size);
50  data = (NaoSensorInterface_data_t *)data_ptr;
51  data_ts = (interface_data_ts_t *)data_ptr;
52  memset(data_ptr, 0, data_size);
53  enum_map_UltrasonicDirection[(int)USD_NONE] = "USD_NONE";
54  enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] = "USD_LEFT_LEFT";
55  enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] = "USD_LEFT_RIGHT";
56  enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] = "USD_RIGHT_RIGHT";
57  enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] = "USD_RIGHT_LEFT";
58  enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] = "USD_BOTH_BOTH";
59  add_fieldinfo(IFT_FLOAT, "accel_x", 1, &data->accel_x);
60  add_fieldinfo(IFT_FLOAT, "accel_y", 1, &data->accel_y);
61  add_fieldinfo(IFT_FLOAT, "accel_z", 1, &data->accel_z);
62  add_fieldinfo(IFT_FLOAT, "gyro_x", 1, &data->gyro_x);
63  add_fieldinfo(IFT_FLOAT, "gyro_y", 1, &data->gyro_y);
64  add_fieldinfo(IFT_FLOAT, "gyro_ref", 1, &data->gyro_ref);
65  add_fieldinfo(IFT_FLOAT, "angle_x", 1, &data->angle_x);
66  add_fieldinfo(IFT_FLOAT, "angle_y", 1, &data->angle_y);
67  add_fieldinfo(IFT_FLOAT, "l_fsr_fl", 1, &data->l_fsr_fl);
68  add_fieldinfo(IFT_FLOAT, "l_fsr_fr", 1, &data->l_fsr_fr);
69  add_fieldinfo(IFT_FLOAT, "l_fsr_rl", 1, &data->l_fsr_rl);
70  add_fieldinfo(IFT_FLOAT, "l_fsr_rr", 1, &data->l_fsr_rr);
71  add_fieldinfo(IFT_FLOAT, "r_fsr_fl", 1, &data->r_fsr_fl);
72  add_fieldinfo(IFT_FLOAT, "r_fsr_fr", 1, &data->r_fsr_fr);
73  add_fieldinfo(IFT_FLOAT, "r_fsr_rl", 1, &data->r_fsr_rl);
74  add_fieldinfo(IFT_FLOAT, "r_fsr_rr", 1, &data->r_fsr_rr);
75  add_fieldinfo(IFT_FLOAT, "l_total_weight", 1, &data->l_total_weight);
76  add_fieldinfo(IFT_FLOAT, "r_total_weight", 1, &data->r_total_weight);
77  add_fieldinfo(IFT_FLOAT, "l_cop_x", 1, &data->l_cop_x);
78  add_fieldinfo(IFT_FLOAT, "l_cop_y", 1, &data->l_cop_y);
79  add_fieldinfo(IFT_FLOAT, "r_cop_x", 1, &data->r_cop_x);
80  add_fieldinfo(IFT_FLOAT, "r_cop_y", 1, &data->r_cop_y);
81  add_fieldinfo(IFT_FLOAT, "ultrasonic_distance_left", 4, &data->ultrasonic_distance_left);
82  add_fieldinfo(IFT_FLOAT, "ultrasonic_distance_right", 4, &data->ultrasonic_distance_right);
83  add_fieldinfo(IFT_ENUM, "ultrasonic_direction", 1, &data->ultrasonic_direction, "UltrasonicDirection", &enum_map_UltrasonicDirection);
84  add_fieldinfo(IFT_UINT8, "l_foot_bumper_l", 1, &data->l_foot_bumper_l);
85  add_fieldinfo(IFT_UINT8, "l_foot_bumper_r", 1, &data->l_foot_bumper_r);
86  add_fieldinfo(IFT_UINT8, "r_foot_bumper_l", 1, &data->r_foot_bumper_l);
87  add_fieldinfo(IFT_UINT8, "r_foot_bumper_r", 1, &data->r_foot_bumper_r);
88  add_fieldinfo(IFT_UINT8, "head_touch_front", 1, &data->head_touch_front);
89  add_fieldinfo(IFT_UINT8, "head_touch_middle", 1, &data->head_touch_middle);
90  add_fieldinfo(IFT_UINT8, "head_touch_rear", 1, &data->head_touch_rear);
91  add_fieldinfo(IFT_UINT8, "chest_button", 1, &data->chest_button);
92  add_fieldinfo(IFT_FLOAT, "battery_charge", 1, &data->battery_charge);
93  add_messageinfo("EmitUltrasonicWaveMessage");
94  add_messageinfo("StartUltrasonicMessage");
95  add_messageinfo("StopUltrasonicMessage");
96  unsigned char tmp_hash[] = {0x41, 0x41, 0x54, 0x94, 0xca, 0xe8, 0x3d, 0x7a, 0xb8, 0xaa, 0xc2, 0x4e, 0x2c, 0xac, 0xcb, 0x15};
97  set_hash(tmp_hash);
98 }
99 
100 /** Destructor */
101 NaoSensorInterface::~NaoSensorInterface()
102 {
103  free(data_ptr);
104 }
105 /** Convert UltrasonicDirection constant to string.
106  * @param value value to convert to string
107  * @return constant value as string.
108  */
109 const char *
111 {
112  switch (value) {
113  case USD_NONE: return "USD_NONE";
114  case USD_LEFT_LEFT: return "USD_LEFT_LEFT";
115  case USD_LEFT_RIGHT: return "USD_LEFT_RIGHT";
116  case USD_RIGHT_RIGHT: return "USD_RIGHT_RIGHT";
117  case USD_RIGHT_LEFT: return "USD_RIGHT_LEFT";
118  case USD_BOTH_BOTH: return "USD_BOTH_BOTH";
119  default: return "UNKNOWN";
120  }
121 }
122 /* Methods */
123 /** Get accel_x value.
124  * Accelerometer x
125  * @return accel_x value
126  */
127 float
129 {
130  return data->accel_x;
131 }
132 
133 /** Get maximum length of accel_x value.
134  * @return length of accel_x value, can be length of the array or number of
135  * maximum number of characters for a string
136  */
137 size_t
139 {
140  return 1;
141 }
142 
143 /** Set accel_x value.
144  * Accelerometer x
145  * @param new_accel_x new accel_x value
146  */
147 void
148 NaoSensorInterface::set_accel_x(const float new_accel_x)
149 {
150  data->accel_x = new_accel_x;
151  data_changed = true;
152 }
153 
154 /** Get accel_y value.
155  * Accelerometer y
156  * @return accel_y value
157  */
158 float
160 {
161  return data->accel_y;
162 }
163 
164 /** Get maximum length of accel_y value.
165  * @return length of accel_y value, can be length of the array or number of
166  * maximum number of characters for a string
167  */
168 size_t
170 {
171  return 1;
172 }
173 
174 /** Set accel_y value.
175  * Accelerometer y
176  * @param new_accel_y new accel_y value
177  */
178 void
179 NaoSensorInterface::set_accel_y(const float new_accel_y)
180 {
181  data->accel_y = new_accel_y;
182  data_changed = true;
183 }
184 
185 /** Get accel_z value.
186  * Accelerometer z
187  * @return accel_z value
188  */
189 float
191 {
192  return data->accel_z;
193 }
194 
195 /** Get maximum length of accel_z value.
196  * @return length of accel_z value, can be length of the array or number of
197  * maximum number of characters for a string
198  */
199 size_t
201 {
202  return 1;
203 }
204 
205 /** Set accel_z value.
206  * Accelerometer z
207  * @param new_accel_z new accel_z value
208  */
209 void
210 NaoSensorInterface::set_accel_z(const float new_accel_z)
211 {
212  data->accel_z = new_accel_z;
213  data_changed = true;
214 }
215 
216 /** Get gyro_x value.
217  * Gyrometer x
218  * @return gyro_x value
219  */
220 float
222 {
223  return data->gyro_x;
224 }
225 
226 /** Get maximum length of gyro_x value.
227  * @return length of gyro_x value, can be length of the array or number of
228  * maximum number of characters for a string
229  */
230 size_t
232 {
233  return 1;
234 }
235 
236 /** Set gyro_x value.
237  * Gyrometer x
238  * @param new_gyro_x new gyro_x value
239  */
240 void
241 NaoSensorInterface::set_gyro_x(const float new_gyro_x)
242 {
243  data->gyro_x = new_gyro_x;
244  data_changed = true;
245 }
246 
247 /** Get gyro_y value.
248  * Gyrometer y
249  * @return gyro_y value
250  */
251 float
253 {
254  return data->gyro_y;
255 }
256 
257 /** Get maximum length of gyro_y value.
258  * @return length of gyro_y value, can be length of the array or number of
259  * maximum number of characters for a string
260  */
261 size_t
263 {
264  return 1;
265 }
266 
267 /** Set gyro_y value.
268  * Gyrometer y
269  * @param new_gyro_y new gyro_y value
270  */
271 void
272 NaoSensorInterface::set_gyro_y(const float new_gyro_y)
273 {
274  data->gyro_y = new_gyro_y;
275  data_changed = true;
276 }
277 
278 /** Get gyro_ref value.
279  * Gyrometer reference
280  * @return gyro_ref value
281  */
282 float
284 {
285  return data->gyro_ref;
286 }
287 
288 /** Get maximum length of gyro_ref value.
289  * @return length of gyro_ref value, can be length of the array or number of
290  * maximum number of characters for a string
291  */
292 size_t
294 {
295  return 1;
296 }
297 
298 /** Set gyro_ref value.
299  * Gyrometer reference
300  * @param new_gyro_ref new gyro_ref value
301  */
302 void
303 NaoSensorInterface::set_gyro_ref(const float new_gyro_ref)
304 {
305  data->gyro_ref = new_gyro_ref;
306  data_changed = true;
307 }
308 
309 /** Get angle_x value.
310  * Angle x
311  * @return angle_x value
312  */
313 float
315 {
316  return data->angle_x;
317 }
318 
319 /** Get maximum length of angle_x value.
320  * @return length of angle_x value, can be length of the array or number of
321  * maximum number of characters for a string
322  */
323 size_t
325 {
326  return 1;
327 }
328 
329 /** Set angle_x value.
330  * Angle x
331  * @param new_angle_x new angle_x value
332  */
333 void
334 NaoSensorInterface::set_angle_x(const float new_angle_x)
335 {
336  data->angle_x = new_angle_x;
337  data_changed = true;
338 }
339 
340 /** Get angle_y value.
341  * Angle y
342  * @return angle_y value
343  */
344 float
346 {
347  return data->angle_y;
348 }
349 
350 /** Get maximum length of angle_y value.
351  * @return length of angle_y value, can be length of the array or number of
352  * maximum number of characters for a string
353  */
354 size_t
356 {
357  return 1;
358 }
359 
360 /** Set angle_y value.
361  * Angle y
362  * @param new_angle_y new angle_y value
363  */
364 void
365 NaoSensorInterface::set_angle_y(const float new_angle_y)
366 {
367  data->angle_y = new_angle_y;
368  data_changed = true;
369 }
370 
371 /** Get l_fsr_fl value.
372  * Left FSR front left
373  * @return l_fsr_fl value
374  */
375 float
377 {
378  return data->l_fsr_fl;
379 }
380 
381 /** Get maximum length of l_fsr_fl value.
382  * @return length of l_fsr_fl value, can be length of the array or number of
383  * maximum number of characters for a string
384  */
385 size_t
387 {
388  return 1;
389 }
390 
391 /** Set l_fsr_fl value.
392  * Left FSR front left
393  * @param new_l_fsr_fl new l_fsr_fl value
394  */
395 void
396 NaoSensorInterface::set_l_fsr_fl(const float new_l_fsr_fl)
397 {
398  data->l_fsr_fl = new_l_fsr_fl;
399  data_changed = true;
400 }
401 
402 /** Get l_fsr_fr value.
403  * Left FSR front right
404  * @return l_fsr_fr value
405  */
406 float
408 {
409  return data->l_fsr_fr;
410 }
411 
412 /** Get maximum length of l_fsr_fr value.
413  * @return length of l_fsr_fr value, can be length of the array or number of
414  * maximum number of characters for a string
415  */
416 size_t
418 {
419  return 1;
420 }
421 
422 /** Set l_fsr_fr value.
423  * Left FSR front right
424  * @param new_l_fsr_fr new l_fsr_fr value
425  */
426 void
427 NaoSensorInterface::set_l_fsr_fr(const float new_l_fsr_fr)
428 {
429  data->l_fsr_fr = new_l_fsr_fr;
430  data_changed = true;
431 }
432 
433 /** Get l_fsr_rl value.
434  * Left FSR rear left
435  * @return l_fsr_rl value
436  */
437 float
439 {
440  return data->l_fsr_rl;
441 }
442 
443 /** Get maximum length of l_fsr_rl value.
444  * @return length of l_fsr_rl value, can be length of the array or number of
445  * maximum number of characters for a string
446  */
447 size_t
449 {
450  return 1;
451 }
452 
453 /** Set l_fsr_rl value.
454  * Left FSR rear left
455  * @param new_l_fsr_rl new l_fsr_rl value
456  */
457 void
458 NaoSensorInterface::set_l_fsr_rl(const float new_l_fsr_rl)
459 {
460  data->l_fsr_rl = new_l_fsr_rl;
461  data_changed = true;
462 }
463 
464 /** Get l_fsr_rr value.
465  * Left FSR rear right
466  * @return l_fsr_rr value
467  */
468 float
470 {
471  return data->l_fsr_rr;
472 }
473 
474 /** Get maximum length of l_fsr_rr value.
475  * @return length of l_fsr_rr value, can be length of the array or number of
476  * maximum number of characters for a string
477  */
478 size_t
480 {
481  return 1;
482 }
483 
484 /** Set l_fsr_rr value.
485  * Left FSR rear right
486  * @param new_l_fsr_rr new l_fsr_rr value
487  */
488 void
489 NaoSensorInterface::set_l_fsr_rr(const float new_l_fsr_rr)
490 {
491  data->l_fsr_rr = new_l_fsr_rr;
492  data_changed = true;
493 }
494 
495 /** Get r_fsr_fl value.
496  * Right FSR front left
497  * @return r_fsr_fl value
498  */
499 float
501 {
502  return data->r_fsr_fl;
503 }
504 
505 /** Get maximum length of r_fsr_fl value.
506  * @return length of r_fsr_fl value, can be length of the array or number of
507  * maximum number of characters for a string
508  */
509 size_t
511 {
512  return 1;
513 }
514 
515 /** Set r_fsr_fl value.
516  * Right FSR front left
517  * @param new_r_fsr_fl new r_fsr_fl value
518  */
519 void
520 NaoSensorInterface::set_r_fsr_fl(const float new_r_fsr_fl)
521 {
522  data->r_fsr_fl = new_r_fsr_fl;
523  data_changed = true;
524 }
525 
526 /** Get r_fsr_fr value.
527  * Right FSR front right
528  * @return r_fsr_fr value
529  */
530 float
532 {
533  return data->r_fsr_fr;
534 }
535 
536 /** Get maximum length of r_fsr_fr value.
537  * @return length of r_fsr_fr value, can be length of the array or number of
538  * maximum number of characters for a string
539  */
540 size_t
542 {
543  return 1;
544 }
545 
546 /** Set r_fsr_fr value.
547  * Right FSR front right
548  * @param new_r_fsr_fr new r_fsr_fr value
549  */
550 void
551 NaoSensorInterface::set_r_fsr_fr(const float new_r_fsr_fr)
552 {
553  data->r_fsr_fr = new_r_fsr_fr;
554  data_changed = true;
555 }
556 
557 /** Get r_fsr_rl value.
558  * Right FSR rear left
559  * @return r_fsr_rl value
560  */
561 float
563 {
564  return data->r_fsr_rl;
565 }
566 
567 /** Get maximum length of r_fsr_rl value.
568  * @return length of r_fsr_rl value, can be length of the array or number of
569  * maximum number of characters for a string
570  */
571 size_t
573 {
574  return 1;
575 }
576 
577 /** Set r_fsr_rl value.
578  * Right FSR rear left
579  * @param new_r_fsr_rl new r_fsr_rl value
580  */
581 void
582 NaoSensorInterface::set_r_fsr_rl(const float new_r_fsr_rl)
583 {
584  data->r_fsr_rl = new_r_fsr_rl;
585  data_changed = true;
586 }
587 
588 /** Get r_fsr_rr value.
589  * Right FSR rear right
590  * @return r_fsr_rr value
591  */
592 float
594 {
595  return data->r_fsr_rr;
596 }
597 
598 /** Get maximum length of r_fsr_rr value.
599  * @return length of r_fsr_rr value, can be length of the array or number of
600  * maximum number of characters for a string
601  */
602 size_t
604 {
605  return 1;
606 }
607 
608 /** Set r_fsr_rr value.
609  * Right FSR rear right
610  * @param new_r_fsr_rr new r_fsr_rr value
611  */
612 void
613 NaoSensorInterface::set_r_fsr_rr(const float new_r_fsr_rr)
614 {
615  data->r_fsr_rr = new_r_fsr_rr;
616  data_changed = true;
617 }
618 
619 /** Get l_total_weight value.
620  * Total weight on left foot
621  * @return l_total_weight value
622  */
623 float
625 {
626  return data->l_total_weight;
627 }
628 
629 /** Get maximum length of l_total_weight value.
630  * @return length of l_total_weight value, can be length of the array or number of
631  * maximum number of characters for a string
632  */
633 size_t
635 {
636  return 1;
637 }
638 
639 /** Set l_total_weight value.
640  * Total weight on left foot
641  * @param new_l_total_weight new l_total_weight value
642  */
643 void
644 NaoSensorInterface::set_l_total_weight(const float new_l_total_weight)
645 {
646  data->l_total_weight = new_l_total_weight;
647  data_changed = true;
648 }
649 
650 /** Get r_total_weight value.
651  * Total weight on right foot
652  * @return r_total_weight value
653  */
654 float
656 {
657  return data->r_total_weight;
658 }
659 
660 /** Get maximum length of r_total_weight value.
661  * @return length of r_total_weight value, can be length of the array or number of
662  * maximum number of characters for a string
663  */
664 size_t
666 {
667  return 1;
668 }
669 
670 /** Set r_total_weight value.
671  * Total weight on right foot
672  * @param new_r_total_weight new r_total_weight value
673  */
674 void
675 NaoSensorInterface::set_r_total_weight(const float new_r_total_weight)
676 {
677  data->r_total_weight = new_r_total_weight;
678  data_changed = true;
679 }
680 
681 /** Get l_cop_x value.
682  * Center of pressure X for left foot.
683  * @return l_cop_x value
684  */
685 float
687 {
688  return data->l_cop_x;
689 }
690 
691 /** Get maximum length of l_cop_x value.
692  * @return length of l_cop_x value, can be length of the array or number of
693  * maximum number of characters for a string
694  */
695 size_t
697 {
698  return 1;
699 }
700 
701 /** Set l_cop_x value.
702  * Center of pressure X for left foot.
703  * @param new_l_cop_x new l_cop_x value
704  */
705 void
706 NaoSensorInterface::set_l_cop_x(const float new_l_cop_x)
707 {
708  data->l_cop_x = new_l_cop_x;
709  data_changed = true;
710 }
711 
712 /** Get l_cop_y value.
713  * Center of pressure Y for left foot.
714  * @return l_cop_y value
715  */
716 float
718 {
719  return data->l_cop_y;
720 }
721 
722 /** Get maximum length of l_cop_y value.
723  * @return length of l_cop_y value, can be length of the array or number of
724  * maximum number of characters for a string
725  */
726 size_t
728 {
729  return 1;
730 }
731 
732 /** Set l_cop_y value.
733  * Center of pressure Y for left foot.
734  * @param new_l_cop_y new l_cop_y value
735  */
736 void
737 NaoSensorInterface::set_l_cop_y(const float new_l_cop_y)
738 {
739  data->l_cop_y = new_l_cop_y;
740  data_changed = true;
741 }
742 
743 /** Get r_cop_x value.
744  * Center of pressure X for right foot.
745  * @return r_cop_x value
746  */
747 float
749 {
750  return data->r_cop_x;
751 }
752 
753 /** Get maximum length of r_cop_x value.
754  * @return length of r_cop_x value, can be length of the array or number of
755  * maximum number of characters for a string
756  */
757 size_t
759 {
760  return 1;
761 }
762 
763 /** Set r_cop_x value.
764  * Center of pressure X for right foot.
765  * @param new_r_cop_x new r_cop_x value
766  */
767 void
768 NaoSensorInterface::set_r_cop_x(const float new_r_cop_x)
769 {
770  data->r_cop_x = new_r_cop_x;
771  data_changed = true;
772 }
773 
774 /** Get r_cop_y value.
775  * Center of pressure Y for right foot.
776  * @return r_cop_y value
777  */
778 float
780 {
781  return data->r_cop_y;
782 }
783 
784 /** Get maximum length of r_cop_y value.
785  * @return length of r_cop_y value, can be length of the array or number of
786  * maximum number of characters for a string
787  */
788 size_t
790 {
791  return 1;
792 }
793 
794 /** Set r_cop_y value.
795  * Center of pressure Y for right foot.
796  * @param new_r_cop_y new r_cop_y value
797  */
798 void
799 NaoSensorInterface::set_r_cop_y(const float new_r_cop_y)
800 {
801  data->r_cop_y = new_r_cop_y;
802  data_changed = true;
803 }
804 
805 /** Get ultrasonic_distance_left value.
806  *
807  First four ultrasonic sensor readings from left receiver. Distance
808  to detected object is in meters.
809 
810  * @return ultrasonic_distance_left value
811  */
812 float *
814 {
815  return data->ultrasonic_distance_left;
816 }
817 
818 /** Get ultrasonic_distance_left value at given index.
819  *
820  First four ultrasonic sensor readings from left receiver. Distance
821  to detected object is in meters.
822 
823  * @param index index of value
824  * @return ultrasonic_distance_left value
825  * @exception Exception thrown if index is out of bounds
826  */
827 float
829 {
830  if (index > 4) {
831  throw Exception("Index value %u out of bounds (0..4)", index);
832  }
833  return data->ultrasonic_distance_left[index];
834 }
835 
836 /** Get maximum length of ultrasonic_distance_left value.
837  * @return length of ultrasonic_distance_left value, can be length of the array or number of
838  * maximum number of characters for a string
839  */
840 size_t
842 {
843  return 4;
844 }
845 
846 /** Set ultrasonic_distance_left value.
847  *
848  First four ultrasonic sensor readings from left receiver. Distance
849  to detected object is in meters.
850 
851  * @param new_ultrasonic_distance_left new ultrasonic_distance_left value
852  */
853 void
854 NaoSensorInterface::set_ultrasonic_distance_left(const float * new_ultrasonic_distance_left)
855 {
856  memcpy(data->ultrasonic_distance_left, new_ultrasonic_distance_left, sizeof(float) * 4);
857  data_changed = true;
858 }
859 
860 /** Set ultrasonic_distance_left value at given index.
861  *
862  First four ultrasonic sensor readings from left receiver. Distance
863  to detected object is in meters.
864 
865  * @param new_ultrasonic_distance_left new ultrasonic_distance_left value
866  * @param index index for of the value
867  */
868 void
869 NaoSensorInterface::set_ultrasonic_distance_left(unsigned int index, const float new_ultrasonic_distance_left)
870 {
871  if (index > 4) {
872  throw Exception("Index value %u out of bounds (0..4)", index);
873  }
874  data->ultrasonic_distance_left[index] = new_ultrasonic_distance_left;
875  data_changed = true;
876 }
877 /** Get ultrasonic_distance_right value.
878  *
879  First four ultrasonic sensor readings from right receiver. Distance
880  to detected object is in meters.
881 
882  * @return ultrasonic_distance_right value
883  */
884 float *
886 {
887  return data->ultrasonic_distance_right;
888 }
889 
890 /** Get ultrasonic_distance_right value at given index.
891  *
892  First four ultrasonic sensor readings from right receiver. Distance
893  to detected object is in meters.
894 
895  * @param index index of value
896  * @return ultrasonic_distance_right value
897  * @exception Exception thrown if index is out of bounds
898  */
899 float
901 {
902  if (index > 4) {
903  throw Exception("Index value %u out of bounds (0..4)", index);
904  }
905  return data->ultrasonic_distance_right[index];
906 }
907 
908 /** Get maximum length of ultrasonic_distance_right value.
909  * @return length of ultrasonic_distance_right value, can be length of the array or number of
910  * maximum number of characters for a string
911  */
912 size_t
914 {
915  return 4;
916 }
917 
918 /** Set ultrasonic_distance_right value.
919  *
920  First four ultrasonic sensor readings from right receiver. Distance
921  to detected object is in meters.
922 
923  * @param new_ultrasonic_distance_right new ultrasonic_distance_right value
924  */
925 void
926 NaoSensorInterface::set_ultrasonic_distance_right(const float * new_ultrasonic_distance_right)
927 {
928  memcpy(data->ultrasonic_distance_right, new_ultrasonic_distance_right, sizeof(float) * 4);
929  data_changed = true;
930 }
931 
932 /** Set ultrasonic_distance_right value at given index.
933  *
934  First four ultrasonic sensor readings from right receiver. Distance
935  to detected object is in meters.
936 
937  * @param new_ultrasonic_distance_right new ultrasonic_distance_right value
938  * @param index index for of the value
939  */
940 void
941 NaoSensorInterface::set_ultrasonic_distance_right(unsigned int index, const float new_ultrasonic_distance_right)
942 {
943  if (index > 4) {
944  throw Exception("Index value %u out of bounds (0..4)", index);
945  }
946  data->ultrasonic_distance_right[index] = new_ultrasonic_distance_right;
947  data_changed = true;
948 }
949 /** Get ultrasonic_direction value.
950  *
951  Direction that was used to gather the ultrasonic readings.
952 
953  * @return ultrasonic_direction value
954  */
957 {
958  return (NaoSensorInterface::UltrasonicDirection)data->ultrasonic_direction;
959 }
960 
961 /** Get maximum length of ultrasonic_direction value.
962  * @return length of ultrasonic_direction value, can be length of the array or number of
963  * maximum number of characters for a string
964  */
965 size_t
967 {
968  return 1;
969 }
970 
971 /** Set ultrasonic_direction value.
972  *
973  Direction that was used to gather the ultrasonic readings.
974 
975  * @param new_ultrasonic_direction new ultrasonic_direction value
976  */
977 void
979 {
980  data->ultrasonic_direction = new_ultrasonic_direction;
981  data_changed = true;
982 }
983 
984 /** Get l_foot_bumper_l value.
985  * Left foot bumper left side
986  * @return l_foot_bumper_l value
987  */
988 uint8_t
990 {
991  return data->l_foot_bumper_l;
992 }
993 
994 /** Get maximum length of l_foot_bumper_l value.
995  * @return length of l_foot_bumper_l value, can be length of the array or number of
996  * maximum number of characters for a string
997  */
998 size_t
1000 {
1001  return 1;
1002 }
1003 
1004 /** Set l_foot_bumper_l value.
1005  * Left foot bumper left side
1006  * @param new_l_foot_bumper_l new l_foot_bumper_l value
1007  */
1008 void
1009 NaoSensorInterface::set_l_foot_bumper_l(const uint8_t new_l_foot_bumper_l)
1010 {
1011  data->l_foot_bumper_l = new_l_foot_bumper_l;
1012  data_changed = true;
1013 }
1014 
1015 /** Get l_foot_bumper_r value.
1016  * Left foot bumper right side
1017  * @return l_foot_bumper_r value
1018  */
1019 uint8_t
1021 {
1022  return data->l_foot_bumper_r;
1023 }
1024 
1025 /** Get maximum length of l_foot_bumper_r value.
1026  * @return length of l_foot_bumper_r value, can be length of the array or number of
1027  * maximum number of characters for a string
1028  */
1029 size_t
1031 {
1032  return 1;
1033 }
1034 
1035 /** Set l_foot_bumper_r value.
1036  * Left foot bumper right side
1037  * @param new_l_foot_bumper_r new l_foot_bumper_r value
1038  */
1039 void
1040 NaoSensorInterface::set_l_foot_bumper_r(const uint8_t new_l_foot_bumper_r)
1041 {
1042  data->l_foot_bumper_r = new_l_foot_bumper_r;
1043  data_changed = true;
1044 }
1045 
1046 /** Get r_foot_bumper_l value.
1047  * Right foot bumper left side
1048  * @return r_foot_bumper_l value
1049  */
1050 uint8_t
1052 {
1053  return data->r_foot_bumper_l;
1054 }
1055 
1056 /** Get maximum length of r_foot_bumper_l value.
1057  * @return length of r_foot_bumper_l value, can be length of the array or number of
1058  * maximum number of characters for a string
1059  */
1060 size_t
1062 {
1063  return 1;
1064 }
1065 
1066 /** Set r_foot_bumper_l value.
1067  * Right foot bumper left side
1068  * @param new_r_foot_bumper_l new r_foot_bumper_l value
1069  */
1070 void
1071 NaoSensorInterface::set_r_foot_bumper_l(const uint8_t new_r_foot_bumper_l)
1072 {
1073  data->r_foot_bumper_l = new_r_foot_bumper_l;
1074  data_changed = true;
1075 }
1076 
1077 /** Get r_foot_bumper_r value.
1078  * Right foot bumper right side
1079  * @return r_foot_bumper_r value
1080  */
1081 uint8_t
1083 {
1084  return data->r_foot_bumper_r;
1085 }
1086 
1087 /** Get maximum length of r_foot_bumper_r value.
1088  * @return length of r_foot_bumper_r value, can be length of the array or number of
1089  * maximum number of characters for a string
1090  */
1091 size_t
1093 {
1094  return 1;
1095 }
1096 
1097 /** Set r_foot_bumper_r value.
1098  * Right foot bumper right side
1099  * @param new_r_foot_bumper_r new r_foot_bumper_r value
1100  */
1101 void
1102 NaoSensorInterface::set_r_foot_bumper_r(const uint8_t new_r_foot_bumper_r)
1103 {
1104  data->r_foot_bumper_r = new_r_foot_bumper_r;
1105  data_changed = true;
1106 }
1107 
1108 /** Get head_touch_front value.
1109  * Front part of head touch sensor (only Academics robot)
1110  * @return head_touch_front value
1111  */
1112 uint8_t
1114 {
1115  return data->head_touch_front;
1116 }
1117 
1118 /** Get maximum length of head_touch_front value.
1119  * @return length of head_touch_front value, can be length of the array or number of
1120  * maximum number of characters for a string
1121  */
1122 size_t
1124 {
1125  return 1;
1126 }
1127 
1128 /** Set head_touch_front value.
1129  * Front part of head touch sensor (only Academics robot)
1130  * @param new_head_touch_front new head_touch_front value
1131  */
1132 void
1133 NaoSensorInterface::set_head_touch_front(const uint8_t new_head_touch_front)
1134 {
1135  data->head_touch_front = new_head_touch_front;
1136  data_changed = true;
1137 }
1138 
1139 /** Get head_touch_middle value.
1140  * Middle part of head touch sensor (only Academics robot)
1141  * @return head_touch_middle value
1142  */
1143 uint8_t
1145 {
1146  return data->head_touch_middle;
1147 }
1148 
1149 /** Get maximum length of head_touch_middle value.
1150  * @return length of head_touch_middle value, can be length of the array or number of
1151  * maximum number of characters for a string
1152  */
1153 size_t
1155 {
1156  return 1;
1157 }
1158 
1159 /** Set head_touch_middle value.
1160  * Middle part of head touch sensor (only Academics robot)
1161  * @param new_head_touch_middle new head_touch_middle value
1162  */
1163 void
1164 NaoSensorInterface::set_head_touch_middle(const uint8_t new_head_touch_middle)
1165 {
1166  data->head_touch_middle = new_head_touch_middle;
1167  data_changed = true;
1168 }
1169 
1170 /** Get head_touch_rear value.
1171  * Rear part of head touch sensor (only Academics robot)
1172  * @return head_touch_rear value
1173  */
1174 uint8_t
1176 {
1177  return data->head_touch_rear;
1178 }
1179 
1180 /** Get maximum length of head_touch_rear value.
1181  * @return length of head_touch_rear value, can be length of the array or number of
1182  * maximum number of characters for a string
1183  */
1184 size_t
1186 {
1187  return 1;
1188 }
1189 
1190 /** Set head_touch_rear value.
1191  * Rear part of head touch sensor (only Academics robot)
1192  * @param new_head_touch_rear new head_touch_rear value
1193  */
1194 void
1195 NaoSensorInterface::set_head_touch_rear(const uint8_t new_head_touch_rear)
1196 {
1197  data->head_touch_rear = new_head_touch_rear;
1198  data_changed = true;
1199 }
1200 
1201 /** Get chest_button value.
1202  * Chest button state
1203  * @return chest_button value
1204  */
1205 uint8_t
1207 {
1208  return data->chest_button;
1209 }
1210 
1211 /** Get maximum length of chest_button value.
1212  * @return length of chest_button value, can be length of the array or number of
1213  * maximum number of characters for a string
1214  */
1215 size_t
1217 {
1218  return 1;
1219 }
1220 
1221 /** Set chest_button value.
1222  * Chest button state
1223  * @param new_chest_button new chest_button value
1224  */
1225 void
1226 NaoSensorInterface::set_chest_button(const uint8_t new_chest_button)
1227 {
1228  data->chest_button = new_chest_button;
1229  data_changed = true;
1230 }
1231 
1232 /** Get battery_charge value.
1233  * Battery charge
1234  * @return battery_charge value
1235  */
1236 float
1238 {
1239  return data->battery_charge;
1240 }
1241 
1242 /** Get maximum length of battery_charge value.
1243  * @return length of battery_charge value, can be length of the array or number of
1244  * maximum number of characters for a string
1245  */
1246 size_t
1248 {
1249  return 1;
1250 }
1251 
1252 /** Set battery_charge value.
1253  * Battery charge
1254  * @param new_battery_charge new battery_charge value
1255  */
1256 void
1257 NaoSensorInterface::set_battery_charge(const float new_battery_charge)
1258 {
1259  data->battery_charge = new_battery_charge;
1260  data_changed = true;
1261 }
1262 
1263 /* =========== message create =========== */
1264 Message *
1266 {
1267  if ( strncmp("EmitUltrasonicWaveMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
1268  return new EmitUltrasonicWaveMessage();
1269  } else if ( strncmp("StartUltrasonicMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
1270  return new StartUltrasonicMessage();
1271  } else if ( strncmp("StopUltrasonicMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
1272  return new StopUltrasonicMessage();
1273  } else {
1274  throw UnknownTypeException("The given type '%s' does not match any known "
1275  "message type for this interface type.", type);
1276  }
1277 }
1278 
1279 
1280 /** Copy values from other interface.
1281  * @param other other interface to copy values from
1282  */
1283 void
1285 {
1286  const NaoSensorInterface *oi = dynamic_cast<const NaoSensorInterface *>(other);
1287  if (oi == NULL) {
1288  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
1289  type(), other->type());
1290  }
1291  memcpy(data, oi->data, sizeof(NaoSensorInterface_data_t));
1292 }
1293 
1294 const char *
1295 NaoSensorInterface::enum_tostring(const char *enumtype, int val) const
1296 {
1297  if (strcmp(enumtype, "UltrasonicDirection") == 0) {
1298  return tostring_UltrasonicDirection((UltrasonicDirection)val);
1299  }
1300  throw UnknownTypeException("Unknown enum type %s", enumtype);
1301 }
1302 
1303 /* =========== messages =========== */
1304 /** @class NaoSensorInterface::EmitUltrasonicWaveMessage <interfaces/NaoSensorInterface.h>
1305  * EmitUltrasonicWaveMessage Fawkes BlackBoard Interface Message.
1306  *
1307 
1308  */
1309 
1310 
1311 /** Constructor with initial values.
1312  * @param ini_ultrasonic_direction initial value for ultrasonic_direction
1313  */
1315 {
1316  data_size = sizeof(EmitUltrasonicWaveMessage_data_t);
1317  data_ptr = malloc(data_size);
1318  memset(data_ptr, 0, data_size);
1319  data = (EmitUltrasonicWaveMessage_data_t *)data_ptr;
1321  data->ultrasonic_direction = ini_ultrasonic_direction;
1322  enum_map_UltrasonicDirection[(int)USD_NONE] = "USD_NONE";
1323  enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] = "USD_LEFT_LEFT";
1324  enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] = "USD_LEFT_RIGHT";
1325  enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] = "USD_RIGHT_RIGHT";
1326  enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] = "USD_RIGHT_LEFT";
1327  enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] = "USD_BOTH_BOTH";
1328  add_fieldinfo(IFT_ENUM, "ultrasonic_direction", 1, &data->ultrasonic_direction, "UltrasonicDirection", &enum_map_UltrasonicDirection);
1329 }
1330 /** Constructor */
1332 {
1333  data_size = sizeof(EmitUltrasonicWaveMessage_data_t);
1334  data_ptr = malloc(data_size);
1335  memset(data_ptr, 0, data_size);
1336  data = (EmitUltrasonicWaveMessage_data_t *)data_ptr;
1338  enum_map_UltrasonicDirection[(int)USD_NONE] = "USD_NONE";
1339  enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] = "USD_LEFT_LEFT";
1340  enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] = "USD_LEFT_RIGHT";
1341  enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] = "USD_RIGHT_RIGHT";
1342  enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] = "USD_RIGHT_LEFT";
1343  enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] = "USD_BOTH_BOTH";
1344  add_fieldinfo(IFT_ENUM, "ultrasonic_direction", 1, &data->ultrasonic_direction, "UltrasonicDirection", &enum_map_UltrasonicDirection);
1345 }
1346 
1347 /** Destructor */
1349 {
1350  free(data_ptr);
1351 }
1352 
1353 /** Copy constructor.
1354  * @param m message to copy from
1355  */
1357 {
1358  data_size = m->data_size;
1359  data_ptr = malloc(data_size);
1360  memcpy(data_ptr, m->data_ptr, data_size);
1361  data = (EmitUltrasonicWaveMessage_data_t *)data_ptr;
1363 }
1364 
1365 /* Methods */
1366 /** Get ultrasonic_direction value.
1367  *
1368  Direction that was used to gather the ultrasonic readings.
1369 
1370  * @return ultrasonic_direction value
1371  */
1374 {
1375  return (NaoSensorInterface::UltrasonicDirection)data->ultrasonic_direction;
1376 }
1377 
1378 /** Get maximum length of ultrasonic_direction value.
1379  * @return length of ultrasonic_direction value, can be length of the array or number of
1380  * maximum number of characters for a string
1381  */
1382 size_t
1384 {
1385  return 1;
1386 }
1387 
1388 /** Set ultrasonic_direction value.
1389  *
1390  Direction that was used to gather the ultrasonic readings.
1391 
1392  * @param new_ultrasonic_direction new ultrasonic_direction value
1393  */
1394 void
1396 {
1397  data->ultrasonic_direction = new_ultrasonic_direction;
1398 }
1399 
1400 /** Clone this message.
1401  * Produces a message of the same type as this message and copies the
1402  * data to the new message.
1403  * @return clone of this message
1404  */
1405 Message *
1407 {
1409 }
1410 /** @class NaoSensorInterface::StartUltrasonicMessage <interfaces/NaoSensorInterface.h>
1411  * StartUltrasonicMessage Fawkes BlackBoard Interface Message.
1412  *
1413 
1414  */
1415 
1416 
1417 /** Constructor with initial values.
1418  * @param ini_ultrasonic_direction initial value for ultrasonic_direction
1419  */
1421 {
1422  data_size = sizeof(StartUltrasonicMessage_data_t);
1423  data_ptr = malloc(data_size);
1424  memset(data_ptr, 0, data_size);
1425  data = (StartUltrasonicMessage_data_t *)data_ptr;
1427  data->ultrasonic_direction = ini_ultrasonic_direction;
1428  enum_map_UltrasonicDirection[(int)USD_NONE] = "USD_NONE";
1429  enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] = "USD_LEFT_LEFT";
1430  enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] = "USD_LEFT_RIGHT";
1431  enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] = "USD_RIGHT_RIGHT";
1432  enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] = "USD_RIGHT_LEFT";
1433  enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] = "USD_BOTH_BOTH";
1434  add_fieldinfo(IFT_ENUM, "ultrasonic_direction", 1, &data->ultrasonic_direction, "UltrasonicDirection", &enum_map_UltrasonicDirection);
1435 }
1436 /** Constructor */
1438 {
1439  data_size = sizeof(StartUltrasonicMessage_data_t);
1440  data_ptr = malloc(data_size);
1441  memset(data_ptr, 0, data_size);
1442  data = (StartUltrasonicMessage_data_t *)data_ptr;
1444  enum_map_UltrasonicDirection[(int)USD_NONE] = "USD_NONE";
1445  enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] = "USD_LEFT_LEFT";
1446  enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] = "USD_LEFT_RIGHT";
1447  enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] = "USD_RIGHT_RIGHT";
1448  enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] = "USD_RIGHT_LEFT";
1449  enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] = "USD_BOTH_BOTH";
1450  add_fieldinfo(IFT_ENUM, "ultrasonic_direction", 1, &data->ultrasonic_direction, "UltrasonicDirection", &enum_map_UltrasonicDirection);
1451 }
1452 
1453 /** Destructor */
1455 {
1456  free(data_ptr);
1457 }
1458 
1459 /** Copy constructor.
1460  * @param m message to copy from
1461  */
1463 {
1464  data_size = m->data_size;
1465  data_ptr = malloc(data_size);
1466  memcpy(data_ptr, m->data_ptr, data_size);
1467  data = (StartUltrasonicMessage_data_t *)data_ptr;
1469 }
1470 
1471 /* Methods */
1472 /** Get ultrasonic_direction value.
1473  *
1474  Direction that was used to gather the ultrasonic readings.
1475 
1476  * @return ultrasonic_direction value
1477  */
1480 {
1481  return (NaoSensorInterface::UltrasonicDirection)data->ultrasonic_direction;
1482 }
1483 
1484 /** Get maximum length of ultrasonic_direction value.
1485  * @return length of ultrasonic_direction value, can be length of the array or number of
1486  * maximum number of characters for a string
1487  */
1488 size_t
1490 {
1491  return 1;
1492 }
1493 
1494 /** Set ultrasonic_direction value.
1495  *
1496  Direction that was used to gather the ultrasonic readings.
1497 
1498  * @param new_ultrasonic_direction new ultrasonic_direction value
1499  */
1500 void
1502 {
1503  data->ultrasonic_direction = new_ultrasonic_direction;
1504 }
1505 
1506 /** Clone this message.
1507  * Produces a message of the same type as this message and copies the
1508  * data to the new message.
1509  * @return clone of this message
1510  */
1511 Message *
1513 {
1515 }
1516 /** @class NaoSensorInterface::StopUltrasonicMessage <interfaces/NaoSensorInterface.h>
1517  * StopUltrasonicMessage Fawkes BlackBoard Interface Message.
1518  *
1519 
1520  */
1521 
1522 
1523 /** Constructor */
1525 {
1526  data_size = sizeof(StopUltrasonicMessage_data_t);
1527  data_ptr = malloc(data_size);
1528  memset(data_ptr, 0, data_size);
1529  data = (StopUltrasonicMessage_data_t *)data_ptr;
1531  enum_map_UltrasonicDirection[(int)USD_NONE] = "USD_NONE";
1532  enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] = "USD_LEFT_LEFT";
1533  enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] = "USD_LEFT_RIGHT";
1534  enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] = "USD_RIGHT_RIGHT";
1535  enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] = "USD_RIGHT_LEFT";
1536  enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] = "USD_BOTH_BOTH";
1537 }
1538 
1539 /** Destructor */
1541 {
1542  free(data_ptr);
1543 }
1544 
1545 /** Copy constructor.
1546  * @param m message to copy from
1547  */
1549 {
1550  data_size = m->data_size;
1551  data_ptr = malloc(data_size);
1552  memcpy(data_ptr, m->data_ptr, data_size);
1553  data = (StopUltrasonicMessage_data_t *)data_ptr;
1555 }
1556 
1557 /* Methods */
1558 /** Clone this message.
1559  * Produces a message of the same type as this message and copies the
1560  * data to the new message.
1561  * @return clone of this message
1562  */
1563 Message *
1565 {
1567 }
1568 /** Check if message is valid and can be enqueued.
1569  * @param message Message to check
1570  * @return true if the message is valid, false otherwise.
1571  */
1572 bool
1574 {
1575  const EmitUltrasonicWaveMessage *m0 = dynamic_cast<const EmitUltrasonicWaveMessage *>(message);
1576  if ( m0 != NULL ) {
1577  return true;
1578  }
1579  const StartUltrasonicMessage *m1 = dynamic_cast<const StartUltrasonicMessage *>(message);
1580  if ( m1 != NULL ) {
1581  return true;
1582  }
1583  const StopUltrasonicMessage *m2 = dynamic_cast<const StopUltrasonicMessage *>(message);
1584  if ( m2 != NULL ) {
1585  return true;
1586  }
1587  return false;
1588 }
1589 
1590 /// @cond INTERNALS
1591 EXPORT_INTERFACE(NaoSensorInterface)
1592 /// @endcond
1593 
1594 
1595 } // end namespace fawkes
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 * data_ptr
Pointer to memory that contains local data.
Definition: message.h:124
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
size_t maxlenof_ultrasonic_direction() const
Get maximum length of ultrasonic_direction value.
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.
UltrasonicDirection ultrasonic_direction() const
Get ultrasonic_direction value.
void set_hash(unsigned char *ihash)
Set hash.
Definition: interface.cpp:314
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.
8 bit unsigned integer field
Definition: types.h:38
float l_fsr_rl() const
Get l_fsr_rl value.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
Definition: message.h:129
Right emitter and right receiver.
size_t maxlenof_ultrasonic_distance_right() const
Get maximum length of ultrasonic_distance_right value.
unsigned int data_size
Minimal data size to hold data storage.
Definition: interface.h:221
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_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction)
Set ultrasonic_direction 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.
void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction)
Set ultrasonic_direction value.
uint8_t l_foot_bumper_r() const
Get l_foot_bumper_r value.
virtual Message * clone() const
Clone this message.
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.
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:133
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the field info list.
Definition: interface.cpp:335
size_t maxlenof_head_touch_front() const
Get maximum length of head_touch_front value.
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:125
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 add_messageinfo(const char *name)
Add an entry to the message info list.
Definition: interface.cpp:373
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.
bool data_changed
Indicator if data has changed.
Definition: interface.h:222
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
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:220
float l_fsr_fr() const
Get l_fsr_fr value.
Base class for exceptions in Fawkes.
Definition: exception.h:36
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.
Left emitter and left receiver.
float accel_y() const
Get accel_y value.
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.
float field
Definition: types.h:45
size_t maxlenof_r_foot_bumper_r() const
Get maximum length of r_foot_bumper_r value.
virtual Message * clone() const
Clone this message.
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_ultrasonic_direction() const
Get maximum length of ultrasonic_direction 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.
UltrasonicDirection ultrasonic_direction() const
Get ultrasonic_direction 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.
virtual Message * clone() const
Clone this message.
size_t maxlenof_l_foot_bumper_l() const
Get maximum length of l_foot_bumper_l value.
interface_data_ts_t * data_ts
Pointer to data casted to timestamp struct.
Definition: interface.h:224
size_t maxlenof_r_cop_y() const
Get maximum length of r_cop_y value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
Definition: message.cpp:436
float battery_charge() const
Get battery_charge value.
No transmission received, yet.
uint8_t head_touch_front() const
Get head_touch_front value.
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.
field with interface specific enum type
Definition: types.h:49
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.