Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HumanoidMotionInterface.cpp
1 
2 /***************************************************************************
3  * HumanoidMotionInterface.cpp - Fawkes BlackBoard Interface - HumanoidMotionInterface
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/HumanoidMotionInterface.h>
25 
26 #include <core/exceptions/software.h>
27 
28 #include <cstring>
29 #include <cstdlib>
30 
31 namespace fawkes {
32 
33 /** @class HumanoidMotionInterface <interfaces/HumanoidMotionInterface.h>
34  * HumanoidMotionInterface Fawkes BlackBoard Interface.
35  *
36  This interface provides acces to basic humanoid motion patterns.
37 
38  * @ingroup FawkesInterfaces
39  */
40 
41 
42 
43 /** Constructor */
44 HumanoidMotionInterface::HumanoidMotionInterface() : Interface()
45 {
46  data_size = sizeof(HumanoidMotionInterface_data_t);
47  data_ptr = malloc(data_size);
48  data = (HumanoidMotionInterface_data_t *)data_ptr;
49  data_ts = (interface_data_ts_t *)data_ptr;
50  memset(data_ptr, 0, data_size);
51  add_fieldinfo(IFT_BOOL, "moving", 1, &data->moving);
52  add_fieldinfo(IFT_BOOL, "arms_enabled", 1, &data->arms_enabled);
53  add_fieldinfo(IFT_UINT32, "msgid", 1, &data->msgid);
54  add_messageinfo("StopMessage");
55  add_messageinfo("WalkStraightMessage");
56  add_messageinfo("WalkSidewaysMessage");
57  add_messageinfo("WalkArcMessage");
58  add_messageinfo("WalkVelocityMessage");
59  add_messageinfo("TurnMessage");
60  add_messageinfo("KickMessage");
61  add_messageinfo("ParkMessage");
62  add_messageinfo("GetUpMessage");
63  add_messageinfo("StandupMessage");
64  add_messageinfo("MoveHeadMessage");
65  unsigned char tmp_hash[] = {0x58, 0x4e, 0xd5, 0x1c, 0xbb, 0xf7, 0x6d, 0x85, 0x15, 0x52, 0x3b, 0x5a, 0x2b, 0x99, 0x5d, 0xc6};
66  set_hash(tmp_hash);
67 }
68 
69 /** Destructor */
70 HumanoidMotionInterface::~HumanoidMotionInterface()
71 {
72  free(data_ptr);
73 }
74 /** Convert LegEnum constant to string.
75  * @param value value to convert to string
76  * @return constant value as string.
77  */
78 const char *
79 HumanoidMotionInterface::tostring_LegEnum(LegEnum value) const
80 {
81  switch (value) {
82  case LEG_LEFT: return "LEG_LEFT";
83  case LEG_RIGHT: return "LEG_RIGHT";
84  default: return "UNKNOWN";
85  }
86 }
87 /** Convert StandupEnum constant to string.
88  * @param value value to convert to string
89  * @return constant value as string.
90  */
91 const char *
92 HumanoidMotionInterface::tostring_StandupEnum(StandupEnum value) const
93 {
94  switch (value) {
95  case STANDUP_DETECT: return "STANDUP_DETECT";
96  case STANDUP_BACK: return "STANDUP_BACK";
97  case STANDUP_FRONT: return "STANDUP_FRONT";
98  default: return "UNKNOWN";
99  }
100 }
101 /* Methods */
102 /** Get moving value.
103  * True if the robot is moving.
104  * @return moving value
105  */
106 bool
107 HumanoidMotionInterface::is_moving() const
108 {
109  return data->moving;
110 }
111 
112 /** Get maximum length of moving value.
113  * @return length of moving value, can be length of the array or number of
114  * maximum number of characters for a string
115  */
116 size_t
117 HumanoidMotionInterface::maxlenof_moving() const
118 {
119  return 1;
120 }
121 
122 /** Set moving value.
123  * True if the robot is moving.
124  * @param new_moving new moving value
125  */
126 void
127 HumanoidMotionInterface::set_moving(const bool new_moving)
128 {
129  data->moving = new_moving;
130  data_changed = true;
131 }
132 
133 /** Get arms_enabled value.
134  *
135  If true the arms are controlled during walking for balancing.
136 
137  * @return arms_enabled value
138  */
139 bool
140 HumanoidMotionInterface::is_arms_enabled() const
141 {
142  return data->arms_enabled;
143 }
144 
145 /** Get maximum length of arms_enabled value.
146  * @return length of arms_enabled value, can be length of the array or number of
147  * maximum number of characters for a string
148  */
149 size_t
150 HumanoidMotionInterface::maxlenof_arms_enabled() const
151 {
152  return 1;
153 }
154 
155 /** Set arms_enabled value.
156  *
157  If true the arms are controlled during walking for balancing.
158 
159  * @param new_arms_enabled new arms_enabled value
160  */
161 void
162 HumanoidMotionInterface::set_arms_enabled(const bool new_arms_enabled)
163 {
164  data->arms_enabled = new_arms_enabled;
165  data_changed = true;
166 }
167 
168 /** Get msgid value.
169  *
170  The ID of the message that is currently being
171  processed, or 0 if no message is being processed.
172 
173  * @return msgid value
174  */
175 uint32_t
176 HumanoidMotionInterface::msgid() const
177 {
178  return data->msgid;
179 }
180 
181 /** Get maximum length of msgid value.
182  * @return length of msgid value, can be length of the array or number of
183  * maximum number of characters for a string
184  */
185 size_t
186 HumanoidMotionInterface::maxlenof_msgid() const
187 {
188  return 1;
189 }
190 
191 /** Set msgid value.
192  *
193  The ID of the message that is currently being
194  processed, or 0 if no message is being processed.
195 
196  * @param new_msgid new msgid value
197  */
198 void
199 HumanoidMotionInterface::set_msgid(const uint32_t new_msgid)
200 {
201  data->msgid = new_msgid;
202  data_changed = true;
203 }
204 
205 /* =========== message create =========== */
206 Message *
207 HumanoidMotionInterface::create_message(const char *type) const
208 {
209  if ( strncmp("StopMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
210  return new StopMessage();
211  } else if ( strncmp("WalkStraightMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
212  return new WalkStraightMessage();
213  } else if ( strncmp("WalkSidewaysMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
214  return new WalkSidewaysMessage();
215  } else if ( strncmp("WalkArcMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
216  return new WalkArcMessage();
217  } else if ( strncmp("WalkVelocityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
218  return new WalkVelocityMessage();
219  } else if ( strncmp("TurnMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
220  return new TurnMessage();
221  } else if ( strncmp("KickMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
222  return new KickMessage();
223  } else if ( strncmp("ParkMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
224  return new ParkMessage();
225  } else if ( strncmp("GetUpMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
226  return new GetUpMessage();
227  } else if ( strncmp("StandupMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
228  return new StandupMessage();
229  } else if ( strncmp("MoveHeadMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
230  return new MoveHeadMessage();
231  } else {
232  throw UnknownTypeException("The given type '%s' does not match any known "
233  "message type for this interface type.", type);
234  }
235 }
236 
237 
238 /** Copy values from other interface.
239  * @param other other interface to copy values from
240  */
241 void
242 HumanoidMotionInterface::copy_values(const Interface *other)
243 {
244  const HumanoidMotionInterface *oi = dynamic_cast<const HumanoidMotionInterface *>(other);
245  if (oi == NULL) {
246  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
247  type(), other->type());
248  }
249  memcpy(data, oi->data, sizeof(HumanoidMotionInterface_data_t));
250 }
251 
252 const char *
253 HumanoidMotionInterface::enum_tostring(const char *enumtype, int val) const
254 {
255  if (strcmp(enumtype, "LegEnum") == 0) {
256  return tostring_LegEnum((LegEnum)val);
257  }
258  if (strcmp(enumtype, "StandupEnum") == 0) {
259  return tostring_StandupEnum((StandupEnum)val);
260  }
261  throw UnknownTypeException("Unknown enum type %s", enumtype);
262 }
263 
264 /* =========== messages =========== */
265 /** @class HumanoidMotionInterface::StopMessage <interfaces/HumanoidMotionInterface.h>
266  * StopMessage Fawkes BlackBoard Interface Message.
267  *
268 
269  */
270 
271 
272 /** Constructor */
273 HumanoidMotionInterface::StopMessage::StopMessage() : Message("StopMessage")
274 {
275  data_size = sizeof(StopMessage_data_t);
276  data_ptr = malloc(data_size);
277  memset(data_ptr, 0, data_size);
278  data = (StopMessage_data_t *)data_ptr;
280 }
281 
282 /** Destructor */
284 {
285  free(data_ptr);
286 }
287 
288 /** Copy constructor.
289  * @param m message to copy from
290  */
292 {
293  data_size = m->data_size;
294  data_ptr = malloc(data_size);
295  memcpy(data_ptr, m->data_ptr, data_size);
296  data = (StopMessage_data_t *)data_ptr;
298 }
299 
300 /* Methods */
301 /** Clone this message.
302  * Produces a message of the same type as this message and copies the
303  * data to the new message.
304  * @return clone of this message
305  */
306 Message *
308 {
309  return new HumanoidMotionInterface::StopMessage(this);
310 }
311 /** @class HumanoidMotionInterface::WalkStraightMessage <interfaces/HumanoidMotionInterface.h>
312  * WalkStraightMessage Fawkes BlackBoard Interface Message.
313  *
314 
315  */
316 
317 
318 /** Constructor with initial values.
319  * @param ini_distance initial value for distance
320  */
321 HumanoidMotionInterface::WalkStraightMessage::WalkStraightMessage(const float ini_distance) : Message("WalkStraightMessage")
322 {
323  data_size = sizeof(WalkStraightMessage_data_t);
324  data_ptr = malloc(data_size);
325  memset(data_ptr, 0, data_size);
326  data = (WalkStraightMessage_data_t *)data_ptr;
328  data->distance = ini_distance;
329  add_fieldinfo(IFT_FLOAT, "distance", 1, &data->distance);
330 }
331 /** Constructor */
333 {
334  data_size = sizeof(WalkStraightMessage_data_t);
335  data_ptr = malloc(data_size);
336  memset(data_ptr, 0, data_size);
337  data = (WalkStraightMessage_data_t *)data_ptr;
339  add_fieldinfo(IFT_FLOAT, "distance", 1, &data->distance);
340 }
341 
342 /** Destructor */
344 {
345  free(data_ptr);
346 }
347 
348 /** Copy constructor.
349  * @param m message to copy from
350  */
352 {
353  data_size = m->data_size;
354  data_ptr = malloc(data_size);
355  memcpy(data_ptr, m->data_ptr, data_size);
356  data = (WalkStraightMessage_data_t *)data_ptr;
358 }
359 
360 /* Methods */
361 /** Get distance value.
362  * Distance in m to walk.
363  * @return distance value
364  */
365 float
367 {
368  return data->distance;
369 }
370 
371 /** Get maximum length of distance value.
372  * @return length of distance value, can be length of the array or number of
373  * maximum number of characters for a string
374  */
375 size_t
377 {
378  return 1;
379 }
380 
381 /** Set distance value.
382  * Distance in m to walk.
383  * @param new_distance new distance value
384  */
385 void
387 {
388  data->distance = new_distance;
389 }
390 
391 /** Clone this message.
392  * Produces a message of the same type as this message and copies the
393  * data to the new message.
394  * @return clone of this message
395  */
396 Message *
398 {
400 }
401 /** @class HumanoidMotionInterface::WalkSidewaysMessage <interfaces/HumanoidMotionInterface.h>
402  * WalkSidewaysMessage Fawkes BlackBoard Interface Message.
403  *
404 
405  */
406 
407 
408 /** Constructor with initial values.
409  * @param ini_distance initial value for distance
410  */
411 HumanoidMotionInterface::WalkSidewaysMessage::WalkSidewaysMessage(const float ini_distance) : Message("WalkSidewaysMessage")
412 {
413  data_size = sizeof(WalkSidewaysMessage_data_t);
414  data_ptr = malloc(data_size);
415  memset(data_ptr, 0, data_size);
416  data = (WalkSidewaysMessage_data_t *)data_ptr;
418  data->distance = ini_distance;
419  add_fieldinfo(IFT_FLOAT, "distance", 1, &data->distance);
420 }
421 /** Constructor */
423 {
424  data_size = sizeof(WalkSidewaysMessage_data_t);
425  data_ptr = malloc(data_size);
426  memset(data_ptr, 0, data_size);
427  data = (WalkSidewaysMessage_data_t *)data_ptr;
429  add_fieldinfo(IFT_FLOAT, "distance", 1, &data->distance);
430 }
431 
432 /** Destructor */
434 {
435  free(data_ptr);
436 }
437 
438 /** Copy constructor.
439  * @param m message to copy from
440  */
442 {
443  data_size = m->data_size;
444  data_ptr = malloc(data_size);
445  memcpy(data_ptr, m->data_ptr, data_size);
446  data = (WalkSidewaysMessage_data_t *)data_ptr;
448 }
449 
450 /* Methods */
451 /** Get distance value.
452  * Distance in m to walk.
453  * @return distance value
454  */
455 float
457 {
458  return data->distance;
459 }
460 
461 /** Get maximum length of distance value.
462  * @return length of distance value, can be length of the array or number of
463  * maximum number of characters for a string
464  */
465 size_t
467 {
468  return 1;
469 }
470 
471 /** Set distance value.
472  * Distance in m to walk.
473  * @param new_distance new distance value
474  */
475 void
477 {
478  data->distance = new_distance;
479 }
480 
481 /** Clone this message.
482  * Produces a message of the same type as this message and copies the
483  * data to the new message.
484  * @return clone of this message
485  */
486 Message *
488 {
490 }
491 /** @class HumanoidMotionInterface::WalkArcMessage <interfaces/HumanoidMotionInterface.h>
492  * WalkArcMessage Fawkes BlackBoard Interface Message.
493  *
494 
495  */
496 
497 
498 /** Constructor with initial values.
499  * @param ini_angle initial value for angle
500  * @param ini_radius initial value for radius
501  */
502 HumanoidMotionInterface::WalkArcMessage::WalkArcMessage(const float ini_angle, const float ini_radius) : Message("WalkArcMessage")
503 {
504  data_size = sizeof(WalkArcMessage_data_t);
505  data_ptr = malloc(data_size);
506  memset(data_ptr, 0, data_size);
507  data = (WalkArcMessage_data_t *)data_ptr;
509  data->angle = ini_angle;
510  data->radius = ini_radius;
511  add_fieldinfo(IFT_FLOAT, "angle", 1, &data->angle);
512  add_fieldinfo(IFT_FLOAT, "radius", 1, &data->radius);
513 }
514 /** Constructor */
516 {
517  data_size = sizeof(WalkArcMessage_data_t);
518  data_ptr = malloc(data_size);
519  memset(data_ptr, 0, data_size);
520  data = (WalkArcMessage_data_t *)data_ptr;
522  add_fieldinfo(IFT_FLOAT, "angle", 1, &data->angle);
523  add_fieldinfo(IFT_FLOAT, "radius", 1, &data->radius);
524 }
525 
526 /** Destructor */
528 {
529  free(data_ptr);
530 }
531 
532 /** Copy constructor.
533  * @param m message to copy from
534  */
536 {
537  data_size = m->data_size;
538  data_ptr = malloc(data_size);
539  memcpy(data_ptr, m->data_ptr, data_size);
540  data = (WalkArcMessage_data_t *)data_ptr;
542 }
543 
544 /* Methods */
545 /** Get angle value.
546  * Angle in radians to turn over the way.
547  * @return angle value
548  */
549 float
551 {
552  return data->angle;
553 }
554 
555 /** Get maximum length of angle value.
556  * @return length of angle value, can be length of the array or number of
557  * maximum number of characters for a string
558  */
559 size_t
561 {
562  return 1;
563 }
564 
565 /** Set angle value.
566  * Angle in radians to turn over the way.
567  * @param new_angle new angle value
568  */
569 void
571 {
572  data->angle = new_angle;
573 }
574 
575 /** Get radius value.
576  * Radius in m of the circle in m.
577  * @return radius value
578  */
579 float
581 {
582  return data->radius;
583 }
584 
585 /** Get maximum length of radius value.
586  * @return length of radius value, can be length of the array or number of
587  * maximum number of characters for a string
588  */
589 size_t
591 {
592  return 1;
593 }
594 
595 /** Set radius value.
596  * Radius in m of the circle in m.
597  * @param new_radius new radius value
598  */
599 void
601 {
602  data->radius = new_radius;
603 }
604 
605 /** Clone this message.
606  * Produces a message of the same type as this message and copies the
607  * data to the new message.
608  * @return clone of this message
609  */
610 Message *
612 {
614 }
615 /** @class HumanoidMotionInterface::WalkVelocityMessage <interfaces/HumanoidMotionInterface.h>
616  * WalkVelocityMessage Fawkes BlackBoard Interface Message.
617  *
618 
619  */
620 
621 
622 /** Constructor with initial values.
623  * @param ini_x initial value for x
624  * @param ini_y initial value for y
625  * @param ini_theta initial value for theta
626  * @param ini_speed initial value for speed
627  */
628 HumanoidMotionInterface::WalkVelocityMessage::WalkVelocityMessage(const float ini_x, const float ini_y, const float ini_theta, const float ini_speed) : Message("WalkVelocityMessage")
629 {
630  data_size = sizeof(WalkVelocityMessage_data_t);
631  data_ptr = malloc(data_size);
632  memset(data_ptr, 0, data_size);
633  data = (WalkVelocityMessage_data_t *)data_ptr;
635  data->x = ini_x;
636  data->y = ini_y;
637  data->theta = ini_theta;
638  data->speed = ini_speed;
639  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
640  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
641  add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
642  add_fieldinfo(IFT_FLOAT, "speed", 1, &data->speed);
643 }
644 /** Constructor */
646 {
647  data_size = sizeof(WalkVelocityMessage_data_t);
648  data_ptr = malloc(data_size);
649  memset(data_ptr, 0, data_size);
650  data = (WalkVelocityMessage_data_t *)data_ptr;
652  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
653  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
654  add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
655  add_fieldinfo(IFT_FLOAT, "speed", 1, &data->speed);
656 }
657 
658 /** Destructor */
660 {
661  free(data_ptr);
662 }
663 
664 /** Copy constructor.
665  * @param m message to copy from
666  */
668 {
669  data_size = m->data_size;
670  data_ptr = malloc(data_size);
671  memcpy(data_ptr, m->data_ptr, data_size);
672  data = (WalkVelocityMessage_data_t *)data_ptr;
674 }
675 
676 /* Methods */
677 /** Get x value.
678  *
679  Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0].
680 
681  * @return x value
682  */
683 float
685 {
686  return data->x;
687 }
688 
689 /** Get maximum length of x value.
690  * @return length of x value, can be length of the array or number of
691  * maximum number of characters for a string
692  */
693 size_t
695 {
696  return 1;
697 }
698 
699 /** Set x value.
700  *
701  Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0].
702 
703  * @param new_x new x value
704  */
705 void
707 {
708  data->x = new_x;
709 }
710 
711 /** Get y value.
712  *
713  Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0].
714 
715  * @return y value
716  */
717 float
719 {
720  return data->y;
721 }
722 
723 /** Get maximum length of y value.
724  * @return length of y value, can be length of the array or number of
725  * maximum number of characters for a string
726  */
727 size_t
729 {
730  return 1;
731 }
732 
733 /** Set y value.
734  *
735  Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0].
736 
737  * @param new_y new y value
738  */
739 void
741 {
742  data->y = new_y;
743 }
744 
745 /** Get theta value.
746  *
747  Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0].
748 
749  * @return theta value
750  */
751 float
753 {
754  return data->theta;
755 }
756 
757 /** Get maximum length of theta value.
758  * @return length of theta value, can be length of the array or number of
759  * maximum number of characters for a string
760  */
761 size_t
763 {
764  return 1;
765 }
766 
767 /** Set theta value.
768  *
769  Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0].
770 
771  * @param new_theta new theta value
772  */
773 void
775 {
776  data->theta = new_theta;
777 }
778 
779 /** Get speed value.
780  *
781  Fraction of MaxStepFrequency [0.0 to 1.0].
782 
783  * @return speed value
784  */
785 float
787 {
788  return data->speed;
789 }
790 
791 /** Get maximum length of speed value.
792  * @return length of speed value, can be length of the array or number of
793  * maximum number of characters for a string
794  */
795 size_t
797 {
798  return 1;
799 }
800 
801 /** Set speed value.
802  *
803  Fraction of MaxStepFrequency [0.0 to 1.0].
804 
805  * @param new_speed new speed value
806  */
807 void
809 {
810  data->speed = new_speed;
811 }
812 
813 /** Clone this message.
814  * Produces a message of the same type as this message and copies the
815  * data to the new message.
816  * @return clone of this message
817  */
818 Message *
820 {
822 }
823 /** @class HumanoidMotionInterface::TurnMessage <interfaces/HumanoidMotionInterface.h>
824  * TurnMessage Fawkes BlackBoard Interface Message.
825  *
826 
827  */
828 
829 
830 /** Constructor with initial values.
831  * @param ini_angle initial value for angle
832  */
833 HumanoidMotionInterface::TurnMessage::TurnMessage(const float ini_angle) : Message("TurnMessage")
834 {
835  data_size = sizeof(TurnMessage_data_t);
836  data_ptr = malloc(data_size);
837  memset(data_ptr, 0, data_size);
838  data = (TurnMessage_data_t *)data_ptr;
840  data->angle = ini_angle;
841  add_fieldinfo(IFT_FLOAT, "angle", 1, &data->angle);
842 }
843 /** Constructor */
845 {
846  data_size = sizeof(TurnMessage_data_t);
847  data_ptr = malloc(data_size);
848  memset(data_ptr, 0, data_size);
849  data = (TurnMessage_data_t *)data_ptr;
851  add_fieldinfo(IFT_FLOAT, "angle", 1, &data->angle);
852 }
853 
854 /** Destructor */
856 {
857  free(data_ptr);
858 }
859 
860 /** Copy constructor.
861  * @param m message to copy from
862  */
864 {
865  data_size = m->data_size;
866  data_ptr = malloc(data_size);
867  memcpy(data_ptr, m->data_ptr, data_size);
868  data = (TurnMessage_data_t *)data_ptr;
870 }
871 
872 /* Methods */
873 /** Get angle value.
874  * Angle in radians to turn.
875  * @return angle value
876  */
877 float
879 {
880  return data->angle;
881 }
882 
883 /** Get maximum length of angle value.
884  * @return length of angle value, can be length of the array or number of
885  * maximum number of characters for a string
886  */
887 size_t
889 {
890  return 1;
891 }
892 
893 /** Set angle value.
894  * Angle in radians to turn.
895  * @param new_angle new angle value
896  */
897 void
899 {
900  data->angle = new_angle;
901 }
902 
903 /** Clone this message.
904  * Produces a message of the same type as this message and copies the
905  * data to the new message.
906  * @return clone of this message
907  */
908 Message *
910 {
911  return new HumanoidMotionInterface::TurnMessage(this);
912 }
913 /** @class HumanoidMotionInterface::KickMessage <interfaces/HumanoidMotionInterface.h>
914  * KickMessage Fawkes BlackBoard Interface Message.
915  *
916 
917  */
918 
919 
920 /** Constructor with initial values.
921  * @param ini_leg initial value for leg
922  * @param ini_strength initial value for strength
923  */
924 HumanoidMotionInterface::KickMessage::KickMessage(const LegEnum ini_leg, const float ini_strength) : Message("KickMessage")
925 {
926  data_size = sizeof(KickMessage_data_t);
927  data_ptr = malloc(data_size);
928  memset(data_ptr, 0, data_size);
929  data = (KickMessage_data_t *)data_ptr;
931  data->leg = ini_leg;
932  data->strength = ini_strength;
933  add_fieldinfo(IFT_ENUM, "leg", 1, &data->leg, "LegEnum");
934  add_fieldinfo(IFT_FLOAT, "strength", 1, &data->strength);
935 }
936 /** Constructor */
938 {
939  data_size = sizeof(KickMessage_data_t);
940  data_ptr = malloc(data_size);
941  memset(data_ptr, 0, data_size);
942  data = (KickMessage_data_t *)data_ptr;
944  add_fieldinfo(IFT_ENUM, "leg", 1, &data->leg, "LegEnum");
945  add_fieldinfo(IFT_FLOAT, "strength", 1, &data->strength);
946 }
947 
948 /** Destructor */
950 {
951  free(data_ptr);
952 }
953 
954 /** Copy constructor.
955  * @param m message to copy from
956  */
958 {
959  data_size = m->data_size;
960  data_ptr = malloc(data_size);
961  memcpy(data_ptr, m->data_ptr, data_size);
962  data = (KickMessage_data_t *)data_ptr;
964 }
965 
966 /* Methods */
967 /** Get leg value.
968  * Leg to kick with
969  * @return leg value
970  */
973 {
974  return (HumanoidMotionInterface::LegEnum)data->leg;
975 }
976 
977 /** Get maximum length of leg value.
978  * @return length of leg value, can be length of the array or number of
979  * maximum number of characters for a string
980  */
981 size_t
983 {
984  return 1;
985 }
986 
987 /** Set leg value.
988  * Leg to kick with
989  * @param new_leg new leg value
990  */
991 void
993 {
994  data->leg = new_leg;
995 }
996 
997 /** Get strength value.
998  * Kick strength
999  * @return strength value
1000  */
1001 float
1003 {
1004  return data->strength;
1005 }
1006 
1007 /** Get maximum length of strength value.
1008  * @return length of strength value, can be length of the array or number of
1009  * maximum number of characters for a string
1010  */
1011 size_t
1013 {
1014  return 1;
1015 }
1016 
1017 /** Set strength value.
1018  * Kick strength
1019  * @param new_strength new strength value
1020  */
1021 void
1023 {
1024  data->strength = new_strength;
1025 }
1026 
1027 /** Clone this message.
1028  * Produces a message of the same type as this message and copies the
1029  * data to the new message.
1030  * @return clone of this message
1031  */
1032 Message *
1034 {
1035  return new HumanoidMotionInterface::KickMessage(this);
1036 }
1037 /** @class HumanoidMotionInterface::ParkMessage <interfaces/HumanoidMotionInterface.h>
1038  * ParkMessage Fawkes BlackBoard Interface Message.
1039  *
1040 
1041  */
1042 
1043 
1044 /** Constructor */
1046 {
1047  data_size = sizeof(ParkMessage_data_t);
1048  data_ptr = malloc(data_size);
1049  memset(data_ptr, 0, data_size);
1050  data = (ParkMessage_data_t *)data_ptr;
1052 }
1053 
1054 /** Destructor */
1056 {
1057  free(data_ptr);
1058 }
1059 
1060 /** Copy constructor.
1061  * @param m message to copy from
1062  */
1064 {
1065  data_size = m->data_size;
1066  data_ptr = malloc(data_size);
1067  memcpy(data_ptr, m->data_ptr, data_size);
1068  data = (ParkMessage_data_t *)data_ptr;
1070 }
1071 
1072 /* Methods */
1073 /** Clone this message.
1074  * Produces a message of the same type as this message and copies the
1075  * data to the new message.
1076  * @return clone of this message
1077  */
1078 Message *
1080 {
1081  return new HumanoidMotionInterface::ParkMessage(this);
1082 }
1083 /** @class HumanoidMotionInterface::GetUpMessage <interfaces/HumanoidMotionInterface.h>
1084  * GetUpMessage Fawkes BlackBoard Interface Message.
1085  *
1086 
1087  */
1088 
1089 
1090 /** Constructor */
1092 {
1093  data_size = sizeof(GetUpMessage_data_t);
1094  data_ptr = malloc(data_size);
1095  memset(data_ptr, 0, data_size);
1096  data = (GetUpMessage_data_t *)data_ptr;
1098 }
1099 
1100 /** Destructor */
1102 {
1103  free(data_ptr);
1104 }
1105 
1106 /** Copy constructor.
1107  * @param m message to copy from
1108  */
1110 {
1111  data_size = m->data_size;
1112  data_ptr = malloc(data_size);
1113  memcpy(data_ptr, m->data_ptr, data_size);
1114  data = (GetUpMessage_data_t *)data_ptr;
1116 }
1117 
1118 /* Methods */
1119 /** Clone this message.
1120  * Produces a message of the same type as this message and copies the
1121  * data to the new message.
1122  * @return clone of this message
1123  */
1124 Message *
1126 {
1127  return new HumanoidMotionInterface::GetUpMessage(this);
1128 }
1129 /** @class HumanoidMotionInterface::StandupMessage <interfaces/HumanoidMotionInterface.h>
1130  * StandupMessage Fawkes BlackBoard Interface Message.
1131  *
1132 
1133  */
1134 
1135 
1136 /** Constructor with initial values.
1137  * @param ini_from_pos initial value for from_pos
1138  */
1140 {
1141  data_size = sizeof(StandupMessage_data_t);
1142  data_ptr = malloc(data_size);
1143  memset(data_ptr, 0, data_size);
1144  data = (StandupMessage_data_t *)data_ptr;
1146  data->from_pos = ini_from_pos;
1147  add_fieldinfo(IFT_ENUM, "from_pos", 1, &data->from_pos, "StandupEnum");
1148 }
1149 /** Constructor */
1151 {
1152  data_size = sizeof(StandupMessage_data_t);
1153  data_ptr = malloc(data_size);
1154  memset(data_ptr, 0, data_size);
1155  data = (StandupMessage_data_t *)data_ptr;
1157  add_fieldinfo(IFT_ENUM, "from_pos", 1, &data->from_pos, "StandupEnum");
1158 }
1159 
1160 /** Destructor */
1162 {
1163  free(data_ptr);
1164 }
1165 
1166 /** Copy constructor.
1167  * @param m message to copy from
1168  */
1170 {
1171  data_size = m->data_size;
1172  data_ptr = malloc(data_size);
1173  memcpy(data_ptr, m->data_ptr, data_size);
1174  data = (StandupMessage_data_t *)data_ptr;
1176 }
1177 
1178 /* Methods */
1179 /** Get from_pos value.
1180  * Position from where to standup.
1181  * @return from_pos value
1182  */
1185 {
1186  return (HumanoidMotionInterface::StandupEnum)data->from_pos;
1187 }
1188 
1189 /** Get maximum length of from_pos value.
1190  * @return length of from_pos value, can be length of the array or number of
1191  * maximum number of characters for a string
1192  */
1193 size_t
1195 {
1196  return 1;
1197 }
1198 
1199 /** Set from_pos value.
1200  * Position from where to standup.
1201  * @param new_from_pos new from_pos value
1202  */
1203 void
1205 {
1206  data->from_pos = new_from_pos;
1207 }
1208 
1209 /** Clone this message.
1210  * Produces a message of the same type as this message and copies the
1211  * data to the new message.
1212  * @return clone of this message
1213  */
1214 Message *
1216 {
1217  return new HumanoidMotionInterface::StandupMessage(this);
1218 }
1219 /** @class HumanoidMotionInterface::MoveHeadMessage <interfaces/HumanoidMotionInterface.h>
1220  * MoveHeadMessage Fawkes BlackBoard Interface Message.
1221  *
1222 
1223  */
1224 
1225 
1226 /** Constructor with initial values.
1227  * @param ini_yaw initial value for yaw
1228  * @param ini_pitch initial value for pitch
1229  * @param ini_speed initial value for speed
1230  */
1231 HumanoidMotionInterface::MoveHeadMessage::MoveHeadMessage(const float ini_yaw, const float ini_pitch, const float ini_speed) : Message("MoveHeadMessage")
1232 {
1233  data_size = sizeof(MoveHeadMessage_data_t);
1234  data_ptr = malloc(data_size);
1235  memset(data_ptr, 0, data_size);
1236  data = (MoveHeadMessage_data_t *)data_ptr;
1238  data->yaw = ini_yaw;
1239  data->pitch = ini_pitch;
1240  data->speed = ini_speed;
1241  add_fieldinfo(IFT_FLOAT, "yaw", 1, &data->yaw);
1242  add_fieldinfo(IFT_FLOAT, "pitch", 1, &data->pitch);
1243  add_fieldinfo(IFT_FLOAT, "speed", 1, &data->speed);
1244 }
1245 /** Constructor */
1247 {
1248  data_size = sizeof(MoveHeadMessage_data_t);
1249  data_ptr = malloc(data_size);
1250  memset(data_ptr, 0, data_size);
1251  data = (MoveHeadMessage_data_t *)data_ptr;
1253  add_fieldinfo(IFT_FLOAT, "yaw", 1, &data->yaw);
1254  add_fieldinfo(IFT_FLOAT, "pitch", 1, &data->pitch);
1255  add_fieldinfo(IFT_FLOAT, "speed", 1, &data->speed);
1256 }
1257 
1258 /** Destructor */
1260 {
1261  free(data_ptr);
1262 }
1263 
1264 /** Copy constructor.
1265  * @param m message to copy from
1266  */
1268 {
1269  data_size = m->data_size;
1270  data_ptr = malloc(data_size);
1271  memcpy(data_ptr, m->data_ptr, data_size);
1272  data = (MoveHeadMessage_data_t *)data_ptr;
1274 }
1275 
1276 /* Methods */
1277 /** Get yaw value.
1278  * Desired yaw (horizontal orientation).
1279  * @return yaw value
1280  */
1281 float
1283 {
1284  return data->yaw;
1285 }
1286 
1287 /** Get maximum length of yaw value.
1288  * @return length of yaw value, can be length of the array or number of
1289  * maximum number of characters for a string
1290  */
1291 size_t
1293 {
1294  return 1;
1295 }
1296 
1297 /** Set yaw value.
1298  * Desired yaw (horizontal orientation).
1299  * @param new_yaw new yaw value
1300  */
1301 void
1303 {
1304  data->yaw = new_yaw;
1305 }
1306 
1307 /** Get pitch value.
1308  * Desired pitch (vertical orientation).
1309  * @return pitch value
1310  */
1311 float
1313 {
1314  return data->pitch;
1315 }
1316 
1317 /** Get maximum length of pitch value.
1318  * @return length of pitch value, can be length of the array or number of
1319  * maximum number of characters for a string
1320  */
1321 size_t
1323 {
1324  return 1;
1325 }
1326 
1327 /** Set pitch value.
1328  * Desired pitch (vertical orientation).
1329  * @param new_pitch new pitch value
1330  */
1331 void
1333 {
1334  data->pitch = new_pitch;
1335 }
1336 
1337 /** Get speed value.
1338  * Maximum speed in [0.0..1.0].
1339  * @return speed value
1340  */
1341 float
1343 {
1344  return data->speed;
1345 }
1346 
1347 /** Get maximum length of speed value.
1348  * @return length of speed value, can be length of the array or number of
1349  * maximum number of characters for a string
1350  */
1351 size_t
1353 {
1354  return 1;
1355 }
1356 
1357 /** Set speed value.
1358  * Maximum speed in [0.0..1.0].
1359  * @param new_speed new speed value
1360  */
1361 void
1363 {
1364  data->speed = new_speed;
1365 }
1366 
1367 /** Clone this message.
1368  * Produces a message of the same type as this message and copies the
1369  * data to the new message.
1370  * @return clone of this message
1371  */
1372 Message *
1374 {
1376 }
1377 /** Check if message is valid and can be enqueued.
1378  * @param message Message to check
1379  * @return true if the message is valid, false otherwise.
1380  */
1381 bool
1383 {
1384  const StopMessage *m0 = dynamic_cast<const StopMessage *>(message);
1385  if ( m0 != NULL ) {
1386  return true;
1387  }
1388  const WalkStraightMessage *m1 = dynamic_cast<const WalkStraightMessage *>(message);
1389  if ( m1 != NULL ) {
1390  return true;
1391  }
1392  const WalkSidewaysMessage *m2 = dynamic_cast<const WalkSidewaysMessage *>(message);
1393  if ( m2 != NULL ) {
1394  return true;
1395  }
1396  const WalkArcMessage *m3 = dynamic_cast<const WalkArcMessage *>(message);
1397  if ( m3 != NULL ) {
1398  return true;
1399  }
1400  const WalkVelocityMessage *m4 = dynamic_cast<const WalkVelocityMessage *>(message);
1401  if ( m4 != NULL ) {
1402  return true;
1403  }
1404  const TurnMessage *m5 = dynamic_cast<const TurnMessage *>(message);
1405  if ( m5 != NULL ) {
1406  return true;
1407  }
1408  const KickMessage *m6 = dynamic_cast<const KickMessage *>(message);
1409  if ( m6 != NULL ) {
1410  return true;
1411  }
1412  const ParkMessage *m7 = dynamic_cast<const ParkMessage *>(message);
1413  if ( m7 != NULL ) {
1414  return true;
1415  }
1416  const GetUpMessage *m8 = dynamic_cast<const GetUpMessage *>(message);
1417  if ( m8 != NULL ) {
1418  return true;
1419  }
1420  const StandupMessage *m9 = dynamic_cast<const StandupMessage *>(message);
1421  if ( m9 != NULL ) {
1422  return true;
1423  }
1424  const MoveHeadMessage *m10 = dynamic_cast<const MoveHeadMessage *>(message);
1425  if ( m10 != NULL ) {
1426  return true;
1427  }
1428  return false;
1429 }
1430 
1431 /// @cond INTERNALS
1432 EXPORT_INTERFACE(HumanoidMotionInterface)
1433 /// @endcond
1434 
1435 
1436 } // end namespace fawkes