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