Fawkes API  Fawkes Development Version
OpenRaveInterface.cpp
1 
2 /***************************************************************************
3  * OpenRaveInterface.cpp - Fawkes BlackBoard Interface - OpenRaveInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2011 Bahram Maleki-Fard
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/OpenRaveInterface.h>
25 
26 #include <core/exceptions/software.h>
27 
28 #include <cstring>
29 #include <cstdlib>
30 
31 namespace fawkes {
32 
33 /** @class OpenRaveInterface <interfaces/OpenRaveInterface.h>
34  * OpenRaveInterface Fawkes BlackBoard Interface.
35  *
36  Interface providing access to OpenRAVE functionality
37 
38  * @ingroup FawkesInterfaces
39  */
40 
41 
42 
43 /** Constructor */
44 OpenRaveInterface::OpenRaveInterface() : Interface()
45 {
46  data_size = sizeof(OpenRaveInterface_data_t);
47  data_ptr = malloc(data_size);
48  data = (OpenRaveInterface_data_t *)data_ptr;
49  data_ts = (interface_data_ts_t *)data_ptr;
50  memset(data_ptr, 0, data_size);
51  add_fieldinfo(IFT_UINT32, "msgid", 1, &data->msgid, "");
52  add_fieldinfo(IFT_BOOL, "final", 1, &data->final, "");
53  add_fieldinfo(IFT_UINT32, "error_code", 1, &data->error_code, "");
54  add_fieldinfo(IFT_BOOL, "success", 1, &data->success, "");
55  add_messageinfo("AddObjectMessage");
56  add_messageinfo("DeleteObjectMessage");
57  add_messageinfo("AttachObjectMessage");
58  add_messageinfo("ReleaseObjectMessage");
59  add_messageinfo("ReleaseAllObjectsMessage");
60  add_messageinfo("MoveObjectMessage");
61  add_messageinfo("RotateObjectQuatMessage");
62  add_messageinfo("RotateObjectMessage");
63  add_messageinfo("RenameObjectMessage");
64  unsigned char tmp_hash[] = {0x7f, 0x87, 0xdf, 0x38, 0x2b, 0x2d, 0xbe, 0x36, 0x88, 0x5a, 0xf7, 0x95, 0x15, 0xb4, 0x1b, 0xaa};
65  set_hash(tmp_hash);
66 }
67 
68 /** Destructor */
69 OpenRaveInterface::~OpenRaveInterface()
70 {
71  free(data_ptr);
72 }
73 /* Methods */
74 /** Get msgid value.
75  * The ID of the message that is currently being
76  processed, or 0 if no message is being processed.
77  * @return msgid value
78  */
79 uint32_t
81 {
82  return data->msgid;
83 }
84 
85 /** Get maximum length of msgid value.
86  * @return length of msgid value, can be length of the array or number of
87  * maximum number of characters for a string
88  */
89 size_t
91 {
92  return 1;
93 }
94 
95 /** Set msgid value.
96  * The ID of the message that is currently being
97  processed, or 0 if no message is being processed.
98  * @param new_msgid new msgid value
99  */
100 void
101 OpenRaveInterface::set_msgid(const uint32_t new_msgid)
102 {
103  data->msgid = new_msgid;
104  data_changed = true;
105 }
106 
107 /** Get final value.
108  * True, if the last goto command has been finished,
109  false if it is still running
110  * @return final value
111  */
112 bool
114 {
115  return data->final;
116 }
117 
118 /** Get maximum length of final value.
119  * @return length of final value, can be length of the array or number of
120  * maximum number of characters for a string
121  */
122 size_t
124 {
125  return 1;
126 }
127 
128 /** Set final value.
129  * True, if the last goto command has been finished,
130  false if it is still running
131  * @param new_final new final value
132  */
133 void
134 OpenRaveInterface::set_final(const bool new_final)
135 {
136  data->final = new_final;
137  data_changed = true;
138 }
139 
140 /** Get error_code value.
141  * Failure code set if
142  final is true. 0 if no error occured, an error code from ERROR_*
143  constants otherwise (or a bit-wise combination).
144  * @return error_code value
145  */
146 uint32_t
148 {
149  return data->error_code;
150 }
151 
152 /** Get maximum length of error_code value.
153  * @return length of error_code value, can be length of the array or number of
154  * maximum number of characters for a string
155  */
156 size_t
158 {
159  return 1;
160 }
161 
162 /** Set error_code value.
163  * Failure code set if
164  final is true. 0 if no error occured, an error code from ERROR_*
165  constants otherwise (or a bit-wise combination).
166  * @param new_error_code new error_code value
167  */
168 void
169 OpenRaveInterface::set_error_code(const uint32_t new_error_code)
170 {
171  data->error_code = new_error_code;
172  data_changed = true;
173 }
174 
175 /** Get success value.
176  * True, if last command was successful. False otherwise
177  * @return success value
178  */
179 bool
181 {
182  return data->success;
183 }
184 
185 /** Get maximum length of success value.
186  * @return length of success value, can be length of the array or number of
187  * maximum number of characters for a string
188  */
189 size_t
191 {
192  return 1;
193 }
194 
195 /** Set success value.
196  * True, if last command was successful. False otherwise
197  * @param new_success new success value
198  */
199 void
200 OpenRaveInterface::set_success(const bool new_success)
201 {
202  data->success = new_success;
203  data_changed = true;
204 }
205 
206 /* =========== message create =========== */
207 Message *
208 OpenRaveInterface::create_message(const char *type) const
209 {
210  if ( strncmp("AddObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
211  return new AddObjectMessage();
212  } else if ( strncmp("DeleteObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
213  return new DeleteObjectMessage();
214  } else if ( strncmp("AttachObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
215  return new AttachObjectMessage();
216  } else if ( strncmp("ReleaseObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
217  return new ReleaseObjectMessage();
218  } else if ( strncmp("ReleaseAllObjectsMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
219  return new ReleaseAllObjectsMessage();
220  } else if ( strncmp("MoveObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
221  return new MoveObjectMessage();
222  } else if ( strncmp("RotateObjectQuatMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
223  return new RotateObjectQuatMessage();
224  } else if ( strncmp("RotateObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
225  return new RotateObjectMessage();
226  } else if ( strncmp("RenameObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
227  return new RenameObjectMessage();
228  } else {
229  throw UnknownTypeException("The given type '%s' does not match any known "
230  "message type for this interface type.", type);
231  }
232 }
233 
234 
235 /** Copy values from other interface.
236  * @param other other interface to copy values from
237  */
238 void
240 {
241  const OpenRaveInterface *oi = dynamic_cast<const OpenRaveInterface *>(other);
242  if (oi == NULL) {
243  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
244  type(), other->type());
245  }
246  memcpy(data, oi->data, sizeof(OpenRaveInterface_data_t));
247 }
248 
249 const char *
250 OpenRaveInterface::enum_tostring(const char *enumtype, int val) const
251 {
252  throw UnknownTypeException("Unknown enum type %s", enumtype);
253 }
254 
255 /* =========== messages =========== */
256 /** @class OpenRaveInterface::AddObjectMessage <interfaces/OpenRaveInterface.h>
257  * AddObjectMessage Fawkes BlackBoard Interface Message.
258  *
259 
260  */
261 
262 
263 /** Constructor with initial values.
264  * @param ini_name initial value for name
265  * @param ini_path initial value for path
266  */
267 OpenRaveInterface::AddObjectMessage::AddObjectMessage(const char * ini_name, const char * ini_path) : Message("AddObjectMessage")
268 {
269  data_size = sizeof(AddObjectMessage_data_t);
270  data_ptr = malloc(data_size);
271  memset(data_ptr, 0, data_size);
272  data = (AddObjectMessage_data_t *)data_ptr;
274  strncpy(data->name, ini_name, 30);
275  strncpy(data->path, ini_path, 1024);
276  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
277  add_fieldinfo(IFT_STRING, "path", 1024, data->path, "");
278 }
279 /** Constructor */
281 {
282  data_size = sizeof(AddObjectMessage_data_t);
283  data_ptr = malloc(data_size);
284  memset(data_ptr, 0, data_size);
285  data = (AddObjectMessage_data_t *)data_ptr;
287  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
288  add_fieldinfo(IFT_STRING, "path", 1024, data->path, "");
289 }
290 
291 /** Destructor */
293 {
294  free(data_ptr);
295 }
296 
297 /** Copy constructor.
298  * @param m message to copy from
299  */
301 {
302  data_size = m->data_size;
303  data_ptr = malloc(data_size);
304  memcpy(data_ptr, m->data_ptr, data_size);
305  data = (AddObjectMessage_data_t *)data_ptr;
307 }
308 
309 /* Methods */
310 /** Get name value.
311  * Name of object
312  * @return name value
313  */
314 char *
316 {
317  return data->name;
318 }
319 
320 /** Get maximum length of name value.
321  * @return length of name value, can be length of the array or number of
322  * maximum number of characters for a string
323  */
324 size_t
326 {
327  return 30;
328 }
329 
330 /** Set name value.
331  * Name of object
332  * @param new_name new name value
333  */
334 void
336 {
337  strncpy(data->name, new_name, sizeof(data->name));
338 }
339 
340 /** Get path value.
341  * Path to object xml file
342  * @return path value
343  */
344 char *
346 {
347  return data->path;
348 }
349 
350 /** Get maximum length of path value.
351  * @return length of path 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 1024;
358 }
359 
360 /** Set path value.
361  * Path to object xml file
362  * @param new_path new path value
363  */
364 void
366 {
367  strncpy(data->path, new_path, sizeof(data->path));
368 }
369 
370 /** Clone this message.
371  * Produces a message of the same type as this message and copies the
372  * data to the new message.
373  * @return clone of this message
374  */
375 Message *
377 {
378  return new OpenRaveInterface::AddObjectMessage(this);
379 }
380 /** @class OpenRaveInterface::DeleteObjectMessage <interfaces/OpenRaveInterface.h>
381  * DeleteObjectMessage Fawkes BlackBoard Interface Message.
382  *
383 
384  */
385 
386 
387 /** Constructor with initial values.
388  * @param ini_name initial value for name
389  */
390 OpenRaveInterface::DeleteObjectMessage::DeleteObjectMessage(const char * ini_name) : Message("DeleteObjectMessage")
391 {
392  data_size = sizeof(DeleteObjectMessage_data_t);
393  data_ptr = malloc(data_size);
394  memset(data_ptr, 0, data_size);
395  data = (DeleteObjectMessage_data_t *)data_ptr;
397  strncpy(data->name, ini_name, 30);
398  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
399 }
400 /** Constructor */
402 {
403  data_size = sizeof(DeleteObjectMessage_data_t);
404  data_ptr = malloc(data_size);
405  memset(data_ptr, 0, data_size);
406  data = (DeleteObjectMessage_data_t *)data_ptr;
408  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
409 }
410 
411 /** Destructor */
413 {
414  free(data_ptr);
415 }
416 
417 /** Copy constructor.
418  * @param m message to copy from
419  */
421 {
422  data_size = m->data_size;
423  data_ptr = malloc(data_size);
424  memcpy(data_ptr, m->data_ptr, data_size);
425  data = (DeleteObjectMessage_data_t *)data_ptr;
427 }
428 
429 /* Methods */
430 /** Get name value.
431  * Name of object
432  * @return name value
433  */
434 char *
436 {
437  return data->name;
438 }
439 
440 /** Get maximum length of name value.
441  * @return length of name value, can be length of the array or number of
442  * maximum number of characters for a string
443  */
444 size_t
446 {
447  return 30;
448 }
449 
450 /** Set name value.
451  * Name of object
452  * @param new_name new name value
453  */
454 void
456 {
457  strncpy(data->name, new_name, sizeof(data->name));
458 }
459 
460 /** Clone this message.
461  * Produces a message of the same type as this message and copies the
462  * data to the new message.
463  * @return clone of this message
464  */
465 Message *
467 {
469 }
470 /** @class OpenRaveInterface::AttachObjectMessage <interfaces/OpenRaveInterface.h>
471  * AttachObjectMessage Fawkes BlackBoard Interface Message.
472  *
473 
474  */
475 
476 
477 /** Constructor with initial values.
478  * @param ini_name initial value for name
479  */
480 OpenRaveInterface::AttachObjectMessage::AttachObjectMessage(const char * ini_name) : Message("AttachObjectMessage")
481 {
482  data_size = sizeof(AttachObjectMessage_data_t);
483  data_ptr = malloc(data_size);
484  memset(data_ptr, 0, data_size);
485  data = (AttachObjectMessage_data_t *)data_ptr;
487  strncpy(data->name, ini_name, 30);
488  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
489 }
490 /** Constructor */
492 {
493  data_size = sizeof(AttachObjectMessage_data_t);
494  data_ptr = malloc(data_size);
495  memset(data_ptr, 0, data_size);
496  data = (AttachObjectMessage_data_t *)data_ptr;
498  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
499 }
500 
501 /** Destructor */
503 {
504  free(data_ptr);
505 }
506 
507 /** Copy constructor.
508  * @param m message to copy from
509  */
511 {
512  data_size = m->data_size;
513  data_ptr = malloc(data_size);
514  memcpy(data_ptr, m->data_ptr, data_size);
515  data = (AttachObjectMessage_data_t *)data_ptr;
517 }
518 
519 /* Methods */
520 /** Get name value.
521  * Name of object
522  * @return name value
523  */
524 char *
526 {
527  return data->name;
528 }
529 
530 /** Get maximum length of name value.
531  * @return length of name value, can be length of the array or number of
532  * maximum number of characters for a string
533  */
534 size_t
536 {
537  return 30;
538 }
539 
540 /** Set name value.
541  * Name of object
542  * @param new_name new name value
543  */
544 void
546 {
547  strncpy(data->name, new_name, sizeof(data->name));
548 }
549 
550 /** Clone this message.
551  * Produces a message of the same type as this message and copies the
552  * data to the new message.
553  * @return clone of this message
554  */
555 Message *
557 {
559 }
560 /** @class OpenRaveInterface::ReleaseObjectMessage <interfaces/OpenRaveInterface.h>
561  * ReleaseObjectMessage Fawkes BlackBoard Interface Message.
562  *
563 
564  */
565 
566 
567 /** Constructor with initial values.
568  * @param ini_name initial value for name
569  */
570 OpenRaveInterface::ReleaseObjectMessage::ReleaseObjectMessage(const char * ini_name) : Message("ReleaseObjectMessage")
571 {
572  data_size = sizeof(ReleaseObjectMessage_data_t);
573  data_ptr = malloc(data_size);
574  memset(data_ptr, 0, data_size);
575  data = (ReleaseObjectMessage_data_t *)data_ptr;
577  strncpy(data->name, ini_name, 30);
578  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
579 }
580 /** Constructor */
582 {
583  data_size = sizeof(ReleaseObjectMessage_data_t);
584  data_ptr = malloc(data_size);
585  memset(data_ptr, 0, data_size);
586  data = (ReleaseObjectMessage_data_t *)data_ptr;
588  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
589 }
590 
591 /** Destructor */
593 {
594  free(data_ptr);
595 }
596 
597 /** Copy constructor.
598  * @param m message to copy from
599  */
601 {
602  data_size = m->data_size;
603  data_ptr = malloc(data_size);
604  memcpy(data_ptr, m->data_ptr, data_size);
605  data = (ReleaseObjectMessage_data_t *)data_ptr;
607 }
608 
609 /* Methods */
610 /** Get name value.
611  * Name of object
612  * @return name value
613  */
614 char *
616 {
617  return data->name;
618 }
619 
620 /** Get maximum length of name value.
621  * @return length of name value, can be length of the array or number of
622  * maximum number of characters for a string
623  */
624 size_t
626 {
627  return 30;
628 }
629 
630 /** Set name value.
631  * Name of object
632  * @param new_name new name value
633  */
634 void
636 {
637  strncpy(data->name, new_name, sizeof(data->name));
638 }
639 
640 /** Clone this message.
641  * Produces a message of the same type as this message and copies the
642  * data to the new message.
643  * @return clone of this message
644  */
645 Message *
647 {
649 }
650 /** @class OpenRaveInterface::ReleaseAllObjectsMessage <interfaces/OpenRaveInterface.h>
651  * ReleaseAllObjectsMessage Fawkes BlackBoard Interface Message.
652  *
653 
654  */
655 
656 
657 /** Constructor */
659 {
660  data_size = sizeof(ReleaseAllObjectsMessage_data_t);
661  data_ptr = malloc(data_size);
662  memset(data_ptr, 0, data_size);
663  data = (ReleaseAllObjectsMessage_data_t *)data_ptr;
665 }
666 
667 /** Destructor */
669 {
670  free(data_ptr);
671 }
672 
673 /** Copy constructor.
674  * @param m message to copy from
675  */
677 {
678  data_size = m->data_size;
679  data_ptr = malloc(data_size);
680  memcpy(data_ptr, m->data_ptr, data_size);
681  data = (ReleaseAllObjectsMessage_data_t *)data_ptr;
683 }
684 
685 /* Methods */
686 /** Clone this message.
687  * Produces a message of the same type as this message and copies the
688  * data to the new message.
689  * @return clone of this message
690  */
691 Message *
693 {
695 }
696 /** @class OpenRaveInterface::MoveObjectMessage <interfaces/OpenRaveInterface.h>
697  * MoveObjectMessage Fawkes BlackBoard Interface Message.
698  *
699 
700  */
701 
702 
703 /** Constructor with initial values.
704  * @param ini_name initial value for name
705  * @param ini_x initial value for x
706  * @param ini_y initial value for y
707  * @param ini_z initial value for z
708  */
709 OpenRaveInterface::MoveObjectMessage::MoveObjectMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z) : Message("MoveObjectMessage")
710 {
711  data_size = sizeof(MoveObjectMessage_data_t);
712  data_ptr = malloc(data_size);
713  memset(data_ptr, 0, data_size);
714  data = (MoveObjectMessage_data_t *)data_ptr;
716  strncpy(data->name, ini_name, 30);
717  data->x = ini_x;
718  data->y = ini_y;
719  data->z = ini_z;
720  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
721  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
722  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
723  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z, "");
724 }
725 /** Constructor */
727 {
728  data_size = sizeof(MoveObjectMessage_data_t);
729  data_ptr = malloc(data_size);
730  memset(data_ptr, 0, data_size);
731  data = (MoveObjectMessage_data_t *)data_ptr;
733  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
734  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
735  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
736  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z, "");
737 }
738 
739 /** Destructor */
741 {
742  free(data_ptr);
743 }
744 
745 /** Copy constructor.
746  * @param m message to copy from
747  */
749 {
750  data_size = m->data_size;
751  data_ptr = malloc(data_size);
752  memcpy(data_ptr, m->data_ptr, data_size);
753  data = (MoveObjectMessage_data_t *)data_ptr;
755 }
756 
757 /* Methods */
758 /** Get name value.
759  * Name of object
760  * @return name value
761  */
762 char *
764 {
765  return data->name;
766 }
767 
768 /** Get maximum length of name value.
769  * @return length of name value, can be length of the array or number of
770  * maximum number of characters for a string
771  */
772 size_t
774 {
775  return 30;
776 }
777 
778 /** Set name value.
779  * Name of object
780  * @param new_name new name value
781  */
782 void
784 {
785  strncpy(data->name, new_name, sizeof(data->name));
786 }
787 
788 /** Get x value.
789  * x position of object (meters)
790  * @return x value
791  */
792 float
794 {
795  return data->x;
796 }
797 
798 /** Get maximum length of x value.
799  * @return length of x value, can be length of the array or number of
800  * maximum number of characters for a string
801  */
802 size_t
804 {
805  return 1;
806 }
807 
808 /** Set x value.
809  * x position of object (meters)
810  * @param new_x new x value
811  */
812 void
814 {
815  data->x = new_x;
816 }
817 
818 /** Get y value.
819  * y position of object (meters)
820  * @return y value
821  */
822 float
824 {
825  return data->y;
826 }
827 
828 /** Get maximum length of y value.
829  * @return length of y value, can be length of the array or number of
830  * maximum number of characters for a string
831  */
832 size_t
834 {
835  return 1;
836 }
837 
838 /** Set y value.
839  * y position of object (meters)
840  * @param new_y new y value
841  */
842 void
844 {
845  data->y = new_y;
846 }
847 
848 /** Get z value.
849  * z position of object (meters)
850  * @return z value
851  */
852 float
854 {
855  return data->z;
856 }
857 
858 /** Get maximum length of z value.
859  * @return length of z value, can be length of the array or number of
860  * maximum number of characters for a string
861  */
862 size_t
864 {
865  return 1;
866 }
867 
868 /** Set z value.
869  * z position of object (meters)
870  * @param new_z new z value
871  */
872 void
874 {
875  data->z = new_z;
876 }
877 
878 /** Clone this message.
879  * Produces a message of the same type as this message and copies the
880  * data to the new message.
881  * @return clone of this message
882  */
883 Message *
885 {
886  return new OpenRaveInterface::MoveObjectMessage(this);
887 }
888 /** @class OpenRaveInterface::RotateObjectQuatMessage <interfaces/OpenRaveInterface.h>
889  * RotateObjectQuatMessage Fawkes BlackBoard Interface Message.
890  *
891 
892  */
893 
894 
895 /** Constructor with initial values.
896  * @param ini_name initial value for name
897  * @param ini_x initial value for x
898  * @param ini_y initial value for y
899  * @param ini_z initial value for z
900  * @param ini_w initial value for w
901  */
902 OpenRaveInterface::RotateObjectQuatMessage::RotateObjectQuatMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z, const float ini_w) : Message("RotateObjectQuatMessage")
903 {
904  data_size = sizeof(RotateObjectQuatMessage_data_t);
905  data_ptr = malloc(data_size);
906  memset(data_ptr, 0, data_size);
907  data = (RotateObjectQuatMessage_data_t *)data_ptr;
909  strncpy(data->name, ini_name, 30);
910  data->x = ini_x;
911  data->y = ini_y;
912  data->z = ini_z;
913  data->w = ini_w;
914  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
915  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
916  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
917  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z, "");
918  add_fieldinfo(IFT_FLOAT, "w", 1, &data->w, "");
919 }
920 /** Constructor */
922 {
923  data_size = sizeof(RotateObjectQuatMessage_data_t);
924  data_ptr = malloc(data_size);
925  memset(data_ptr, 0, data_size);
926  data = (RotateObjectQuatMessage_data_t *)data_ptr;
928  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
929  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
930  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
931  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z, "");
932  add_fieldinfo(IFT_FLOAT, "w", 1, &data->w, "");
933 }
934 
935 /** Destructor */
937 {
938  free(data_ptr);
939 }
940 
941 /** Copy constructor.
942  * @param m message to copy from
943  */
945 {
946  data_size = m->data_size;
947  data_ptr = malloc(data_size);
948  memcpy(data_ptr, m->data_ptr, data_size);
949  data = (RotateObjectQuatMessage_data_t *)data_ptr;
951 }
952 
953 /* Methods */
954 /** Get name value.
955  * Name of object
956  * @return name value
957  */
958 char *
960 {
961  return data->name;
962 }
963 
964 /** Get maximum length of name value.
965  * @return length of name value, can be length of the array or number of
966  * maximum number of characters for a string
967  */
968 size_t
970 {
971  return 30;
972 }
973 
974 /** Set name value.
975  * Name of object
976  * @param new_name new name value
977  */
978 void
980 {
981  strncpy(data->name, new_name, sizeof(data->name));
982 }
983 
984 /** Get x value.
985  * x value of quaternion
986  * @return x value
987  */
988 float
990 {
991  return data->x;
992 }
993 
994 /** Get maximum length of x value.
995  * @return length of x 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 x value.
1005  * x value of quaternion
1006  * @param new_x new x value
1007  */
1008 void
1010 {
1011  data->x = new_x;
1012 }
1013 
1014 /** Get y value.
1015  * y value of quaternion
1016  * @return y value
1017  */
1018 float
1020 {
1021  return data->y;
1022 }
1023 
1024 /** Get maximum length of y value.
1025  * @return length of y value, can be length of the array or number of
1026  * maximum number of characters for a string
1027  */
1028 size_t
1030 {
1031  return 1;
1032 }
1033 
1034 /** Set y value.
1035  * y value of quaternion
1036  * @param new_y new y value
1037  */
1038 void
1040 {
1041  data->y = new_y;
1042 }
1043 
1044 /** Get z value.
1045  * z value of quaternion
1046  * @return z value
1047  */
1048 float
1050 {
1051  return data->z;
1052 }
1053 
1054 /** Get maximum length of z value.
1055  * @return length of z value, can be length of the array or number of
1056  * maximum number of characters for a string
1057  */
1058 size_t
1060 {
1061  return 1;
1062 }
1063 
1064 /** Set z value.
1065  * z value of quaternion
1066  * @param new_z new z value
1067  */
1068 void
1070 {
1071  data->z = new_z;
1072 }
1073 
1074 /** Get w value.
1075  * w value of quaternion
1076  * @return w value
1077  */
1078 float
1080 {
1081  return data->w;
1082 }
1083 
1084 /** Get maximum length of w value.
1085  * @return length of w value, can be length of the array or number of
1086  * maximum number of characters for a string
1087  */
1088 size_t
1090 {
1091  return 1;
1092 }
1093 
1094 /** Set w value.
1095  * w value of quaternion
1096  * @param new_w new w value
1097  */
1098 void
1100 {
1101  data->w = new_w;
1102 }
1103 
1104 /** Clone this message.
1105  * Produces a message of the same type as this message and copies the
1106  * data to the new message.
1107  * @return clone of this message
1108  */
1109 Message *
1111 {
1113 }
1114 /** @class OpenRaveInterface::RotateObjectMessage <interfaces/OpenRaveInterface.h>
1115  * RotateObjectMessage Fawkes BlackBoard Interface Message.
1116  *
1117 
1118  */
1119 
1120 
1121 /** Constructor with initial values.
1122  * @param ini_name initial value for name
1123  * @param ini_x initial value for x
1124  * @param ini_y initial value for y
1125  * @param ini_z initial value for z
1126  */
1127 OpenRaveInterface::RotateObjectMessage::RotateObjectMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z) : Message("RotateObjectMessage")
1128 {
1129  data_size = sizeof(RotateObjectMessage_data_t);
1130  data_ptr = malloc(data_size);
1131  memset(data_ptr, 0, data_size);
1132  data = (RotateObjectMessage_data_t *)data_ptr;
1134  strncpy(data->name, ini_name, 30);
1135  data->x = ini_x;
1136  data->y = ini_y;
1137  data->z = ini_z;
1138  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
1139  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
1140  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
1141  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z, "");
1142 }
1143 /** Constructor */
1145 {
1146  data_size = sizeof(RotateObjectMessage_data_t);
1147  data_ptr = malloc(data_size);
1148  memset(data_ptr, 0, data_size);
1149  data = (RotateObjectMessage_data_t *)data_ptr;
1151  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
1152  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
1153  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
1154  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z, "");
1155 }
1156 
1157 /** Destructor */
1159 {
1160  free(data_ptr);
1161 }
1162 
1163 /** Copy constructor.
1164  * @param m message to copy from
1165  */
1167 {
1168  data_size = m->data_size;
1169  data_ptr = malloc(data_size);
1170  memcpy(data_ptr, m->data_ptr, data_size);
1171  data = (RotateObjectMessage_data_t *)data_ptr;
1173 }
1174 
1175 /* Methods */
1176 /** Get name value.
1177  * Name of object
1178  * @return name value
1179  */
1180 char *
1182 {
1183  return data->name;
1184 }
1185 
1186 /** Get maximum length of name value.
1187  * @return length of name value, can be length of the array or number of
1188  * maximum number of characters for a string
1189  */
1190 size_t
1192 {
1193  return 30;
1194 }
1195 
1196 /** Set name value.
1197  * Name of object
1198  * @param new_name new name value
1199  */
1200 void
1202 {
1203  strncpy(data->name, new_name, sizeof(data->name));
1204 }
1205 
1206 /** Get x value.
1207  * x-axis rotation of object (rad)
1208  * @return x value
1209  */
1210 float
1212 {
1213  return data->x;
1214 }
1215 
1216 /** Get maximum length of x value.
1217  * @return length of x value, can be length of the array or number of
1218  * maximum number of characters for a string
1219  */
1220 size_t
1222 {
1223  return 1;
1224 }
1225 
1226 /** Set x value.
1227  * x-axis rotation of object (rad)
1228  * @param new_x new x value
1229  */
1230 void
1232 {
1233  data->x = new_x;
1234 }
1235 
1236 /** Get y value.
1237  * y-axis rotation of object (rad)
1238  * @return y value
1239  */
1240 float
1242 {
1243  return data->y;
1244 }
1245 
1246 /** Get maximum length of y value.
1247  * @return length of y value, can be length of the array or number of
1248  * maximum number of characters for a string
1249  */
1250 size_t
1252 {
1253  return 1;
1254 }
1255 
1256 /** Set y value.
1257  * y-axis rotation of object (rad)
1258  * @param new_y new y value
1259  */
1260 void
1262 {
1263  data->y = new_y;
1264 }
1265 
1266 /** Get z value.
1267  * z-axis rotation of object (rad)
1268  * @return z value
1269  */
1270 float
1272 {
1273  return data->z;
1274 }
1275 
1276 /** Get maximum length of z value.
1277  * @return length of z value, can be length of the array or number of
1278  * maximum number of characters for a string
1279  */
1280 size_t
1282 {
1283  return 1;
1284 }
1285 
1286 /** Set z value.
1287  * z-axis rotation of object (rad)
1288  * @param new_z new z value
1289  */
1290 void
1292 {
1293  data->z = new_z;
1294 }
1295 
1296 /** Clone this message.
1297  * Produces a message of the same type as this message and copies the
1298  * data to the new message.
1299  * @return clone of this message
1300  */
1301 Message *
1303 {
1304  return new OpenRaveInterface::RotateObjectMessage(this);
1305 }
1306 /** @class OpenRaveInterface::RenameObjectMessage <interfaces/OpenRaveInterface.h>
1307  * RenameObjectMessage Fawkes BlackBoard Interface Message.
1308  *
1309 
1310  */
1311 
1312 
1313 /** Constructor with initial values.
1314  * @param ini_name initial value for name
1315  * @param ini_newName initial value for newName
1316  */
1317 OpenRaveInterface::RenameObjectMessage::RenameObjectMessage(const char * ini_name, const char * ini_newName) : Message("RenameObjectMessage")
1318 {
1319  data_size = sizeof(RenameObjectMessage_data_t);
1320  data_ptr = malloc(data_size);
1321  memset(data_ptr, 0, data_size);
1322  data = (RenameObjectMessage_data_t *)data_ptr;
1324  strncpy(data->name, ini_name, 30);
1325  strncpy(data->newName, ini_newName, 30);
1326  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
1327  add_fieldinfo(IFT_STRING, "newName", 30, data->newName, "");
1328 }
1329 /** Constructor */
1331 {
1332  data_size = sizeof(RenameObjectMessage_data_t);
1333  data_ptr = malloc(data_size);
1334  memset(data_ptr, 0, data_size);
1335  data = (RenameObjectMessage_data_t *)data_ptr;
1337  add_fieldinfo(IFT_STRING, "name", 30, data->name, "");
1338  add_fieldinfo(IFT_STRING, "newName", 30, data->newName, "");
1339 }
1340 
1341 /** Destructor */
1343 {
1344  free(data_ptr);
1345 }
1346 
1347 /** Copy constructor.
1348  * @param m message to copy from
1349  */
1351 {
1352  data_size = m->data_size;
1353  data_ptr = malloc(data_size);
1354  memcpy(data_ptr, m->data_ptr, data_size);
1355  data = (RenameObjectMessage_data_t *)data_ptr;
1357 }
1358 
1359 /* Methods */
1360 /** Get name value.
1361  * Name of object
1362  * @return name value
1363  */
1364 char *
1366 {
1367  return data->name;
1368 }
1369 
1370 /** Get maximum length of name value.
1371  * @return length of name value, can be length of the array or number of
1372  * maximum number of characters for a string
1373  */
1374 size_t
1376 {
1377  return 30;
1378 }
1379 
1380 /** Set name value.
1381  * Name of object
1382  * @param new_name new name value
1383  */
1384 void
1386 {
1387  strncpy(data->name, new_name, sizeof(data->name));
1388 }
1389 
1390 /** Get newName value.
1391  * New name of object
1392  * @return newName value
1393  */
1394 char *
1396 {
1397  return data->newName;
1398 }
1399 
1400 /** Get maximum length of newName value.
1401  * @return length of newName value, can be length of the array or number of
1402  * maximum number of characters for a string
1403  */
1404 size_t
1406 {
1407  return 30;
1408 }
1409 
1410 /** Set newName value.
1411  * New name of object
1412  * @param new_newName new newName value
1413  */
1414 void
1416 {
1417  strncpy(data->newName, new_newName, sizeof(data->newName));
1418 }
1419 
1420 /** Clone this message.
1421  * Produces a message of the same type as this message and copies the
1422  * data to the new message.
1423  * @return clone of this message
1424  */
1425 Message *
1427 {
1428  return new OpenRaveInterface::RenameObjectMessage(this);
1429 }
1430 /** Check if message is valid and can be enqueued.
1431  * @param message Message to check
1432  * @return true if the message is valid, false otherwise.
1433  */
1434 bool
1436 {
1437  const AddObjectMessage *m0 = dynamic_cast<const AddObjectMessage *>(message);
1438  if ( m0 != NULL ) {
1439  return true;
1440  }
1441  const DeleteObjectMessage *m1 = dynamic_cast<const DeleteObjectMessage *>(message);
1442  if ( m1 != NULL ) {
1443  return true;
1444  }
1445  const AttachObjectMessage *m2 = dynamic_cast<const AttachObjectMessage *>(message);
1446  if ( m2 != NULL ) {
1447  return true;
1448  }
1449  const ReleaseObjectMessage *m3 = dynamic_cast<const ReleaseObjectMessage *>(message);
1450  if ( m3 != NULL ) {
1451  return true;
1452  }
1453  const ReleaseAllObjectsMessage *m4 = dynamic_cast<const ReleaseAllObjectsMessage *>(message);
1454  if ( m4 != NULL ) {
1455  return true;
1456  }
1457  const MoveObjectMessage *m5 = dynamic_cast<const MoveObjectMessage *>(message);
1458  if ( m5 != NULL ) {
1459  return true;
1460  }
1461  const RotateObjectQuatMessage *m6 = dynamic_cast<const RotateObjectQuatMessage *>(message);
1462  if ( m6 != NULL ) {
1463  return true;
1464  }
1465  const RotateObjectMessage *m7 = dynamic_cast<const RotateObjectMessage *>(message);
1466  if ( m7 != NULL ) {
1467  return true;
1468  }
1469  const RenameObjectMessage *m8 = dynamic_cast<const RenameObjectMessage *>(message);
1470  if ( m8 != NULL ) {
1471  return true;
1472  }
1473  return false;
1474 }
1475 
1476 /// @cond INTERNALS
1477 EXPORT_INTERFACE(OpenRaveInterface)
1478 /// @endcond
1479 
1480 
1481 } // end namespace fawkes
size_t maxlenof_x() const
Get maximum length of x value.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_x() const
Get maximum length of x value.
virtual Message * clone() const
Clone this message.
void set_path(const char *new_path)
Set path value.
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:114
RotateObjectQuatMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
void set_name(const char *new_name)
Set name value.
size_t maxlenof_path() const
Get maximum length of path value.
void set_error_code(const uint32_t new_error_code)
Set error_code value.
void set_success(const bool new_success)
Set success value.
ReleaseAllObjectsMessage Fawkes BlackBoard Interface Message.
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
Definition: message.h:119
uint32_t error_code() const
Get error_code value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
void set_final(const bool new_final)
Set final value.
string field
Definition: types.h:45
size_t maxlenof_name() const
Get maximum length of name value.
virtual Message * clone() const
Clone this message.
void set_z(const float new_z)
Set z value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
size_t maxlenof_final() const
Get maximum length of final value.
size_t maxlenof_error_code() const
Get maximum length of error_code value.
virtual Message * clone() const
Clone this message.
RotateObjectMessage Fawkes BlackBoard Interface Message.
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:123
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:115
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_x(const float new_x)
Set x value.
size_t maxlenof_z() const
Get maximum length of z value.
void set_y(const float new_y)
Set y value.
size_t maxlenof_name() const
Get maximum length of name value.
virtual Message * clone() const
Clone this message.
bool data_changed
Indicator if data has changed.
Definition: interface.h:208
size_t maxlenof_y() const
Get maximum length of y value.
uint32_t msgid() const
Get msgid value.
void set_newName(const char *new_newName)
Set newName value.
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:206
void set_msgid(const uint32_t new_msgid)
Set msgid value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
AttachObjectMessage Fawkes BlackBoard Interface Message.
bool is_success() const
Get success value.
char * newName() const
Get newName value.
virtual Message * clone() const
Clone this message.
void set_y(const float new_y)
Set y value.
size_t maxlenof_name() const
Get maximum length of name value.
bool is_final() const
Get final value.
void set_z(const float new_z)
Set z value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_newName() const
Get maximum length of newName value.
float field
Definition: types.h:43
size_t maxlenof_y() const
Get maximum length of y value.
ReleaseObjectMessage Fawkes BlackBoard Interface Message.
void set_x(const float new_x)
Set x value.
size_t maxlenof_name() const
Get maximum length of name value.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
RenameObjectMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_name() const
Get maximum length of name value.
size_t maxlenof_z() const
Get maximum length of z value.
void set_name(const char *new_name)
Set name value.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_z() const
Get maximum length of z value.
size_t maxlenof_x() const
Get maximum length of x value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the info list.
Definition: message.cpp:435
void set_name(const char *new_name)
Set name value.
size_t maxlenof_w() const
Get maximum length of w value.
void set_name(const char *new_name)
Set name value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_y() const
Get maximum length of y value.
virtual Message * create_message(const char *type) const
Create message based on type name.
boolean field
Definition: types.h:34
void set_name(const char *new_name)
Set name value.
size_t maxlenof_name() const
Get maximum length of name value.
DeleteObjectMessage Fawkes BlackBoard Interface Message.
const char * type() const
Get type of interface.
Definition: interface.cpp:635
MoveObjectMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_success() const
Get maximum length of success value.
virtual Message * clone() const
Clone this message.
32 bit unsigned integer field
Definition: types.h:40
size_t maxlenof_name() const
Get maximum length of name value.
OpenRaveInterface Fawkes BlackBoard Interface.
size_t maxlenof_name() const
Get maximum length of name value.
AddObjectMessage Fawkes BlackBoard Interface Message.