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 <map>
29 #include <string>
30 #include <cstring>
31 #include <cstdlib>
32 
33 namespace fawkes {
34 
35 /** @class OpenRaveInterface <interfaces/OpenRaveInterface.h>
36  * OpenRaveInterface Fawkes BlackBoard Interface.
37  *
38  Interface providing access to OpenRAVE functionality
39 
40  * @ingroup FawkesInterfaces
41  */
42 
43 
44 
45 /** Constructor */
46 OpenRaveInterface::OpenRaveInterface() : Interface()
47 {
48  data_size = sizeof(OpenRaveInterface_data_t);
49  data_ptr = malloc(data_size);
50  data = (OpenRaveInterface_data_t *)data_ptr;
51  data_ts = (interface_data_ts_t *)data_ptr;
52  memset(data_ptr, 0, data_size);
53  add_fieldinfo(IFT_UINT32, "msgid", 1, &data->msgid);
54  add_fieldinfo(IFT_BOOL, "final", 1, &data->final);
55  add_fieldinfo(IFT_UINT32, "error_code", 1, &data->error_code);
56  add_fieldinfo(IFT_BOOL, "success", 1, &data->success);
57  add_messageinfo("StartViewerMessage");
58  add_messageinfo("AddObjectMessage");
59  add_messageinfo("DeleteObjectMessage");
60  add_messageinfo("DeleteAllObjectsMessage");
61  add_messageinfo("AttachObjectMessage");
62  add_messageinfo("ReleaseObjectMessage");
63  add_messageinfo("ReleaseAllObjectsMessage");
64  add_messageinfo("MoveObjectMessage");
65  add_messageinfo("RotateObjectQuatMessage");
66  add_messageinfo("RotateObjectMessage");
67  add_messageinfo("RenameObjectMessage");
68  unsigned char tmp_hash[] = {0xac, 0x95, 0xde, 0xc, 0xea, 0xa4, 0x97, 0x56, 0x5c, 0x46, 0x11, 0x5b, 0xf7, 0x60, 0x41, 0xb};
69  set_hash(tmp_hash);
70 }
71 
72 /** Destructor */
73 OpenRaveInterface::~OpenRaveInterface()
74 {
75  free(data_ptr);
76 }
77 /* Methods */
78 /** Get msgid value.
79  * The ID of the message that is currently being
80  processed, or 0 if no message is being processed.
81  * @return msgid value
82  */
83 uint32_t
85 {
86  return data->msgid;
87 }
88 
89 /** Get maximum length of msgid value.
90  * @return length of msgid value, can be length of the array or number of
91  * maximum number of characters for a string
92  */
93 size_t
95 {
96  return 1;
97 }
98 
99 /** Set msgid value.
100  * The ID of the message that is currently being
101  processed, or 0 if no message is being processed.
102  * @param new_msgid new msgid value
103  */
104 void
105 OpenRaveInterface::set_msgid(const uint32_t new_msgid)
106 {
107  data->msgid = new_msgid;
108  data_changed = true;
109 }
110 
111 /** Get final value.
112  * True, if the last goto command has been finished,
113  false if it is still running
114  * @return final value
115  */
116 bool
118 {
119  return data->final;
120 }
121 
122 /** Get maximum length of final value.
123  * @return length of final value, can be length of the array or number of
124  * maximum number of characters for a string
125  */
126 size_t
128 {
129  return 1;
130 }
131 
132 /** Set final value.
133  * True, if the last goto command has been finished,
134  false if it is still running
135  * @param new_final new final value
136  */
137 void
138 OpenRaveInterface::set_final(const bool new_final)
139 {
140  data->final = new_final;
141  data_changed = true;
142 }
143 
144 /** Get error_code value.
145  * Failure code set if
146  final is true. 0 if no error occured, an error code from ERROR_*
147  constants otherwise (or a bit-wise combination).
148  * @return error_code value
149  */
150 uint32_t
152 {
153  return data->error_code;
154 }
155 
156 /** Get maximum length of error_code value.
157  * @return length of error_code value, can be length of the array or number of
158  * maximum number of characters for a string
159  */
160 size_t
162 {
163  return 1;
164 }
165 
166 /** Set error_code value.
167  * Failure code set if
168  final is true. 0 if no error occured, an error code from ERROR_*
169  constants otherwise (or a bit-wise combination).
170  * @param new_error_code new error_code value
171  */
172 void
173 OpenRaveInterface::set_error_code(const uint32_t new_error_code)
174 {
175  data->error_code = new_error_code;
176  data_changed = true;
177 }
178 
179 /** Get success value.
180  * True, if last command was successful. False otherwise
181  * @return success value
182  */
183 bool
185 {
186  return data->success;
187 }
188 
189 /** Get maximum length of success value.
190  * @return length of success value, can be length of the array or number of
191  * maximum number of characters for a string
192  */
193 size_t
195 {
196  return 1;
197 }
198 
199 /** Set success value.
200  * True, if last command was successful. False otherwise
201  * @param new_success new success value
202  */
203 void
204 OpenRaveInterface::set_success(const bool new_success)
205 {
206  data->success = new_success;
207  data_changed = true;
208 }
209 
210 /* =========== message create =========== */
211 Message *
212 OpenRaveInterface::create_message(const char *type) const
213 {
214  if ( strncmp("StartViewerMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
215  return new StartViewerMessage();
216  } else if ( strncmp("AddObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
217  return new AddObjectMessage();
218  } else if ( strncmp("DeleteObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
219  return new DeleteObjectMessage();
220  } else if ( strncmp("DeleteAllObjectsMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
221  return new DeleteAllObjectsMessage();
222  } else if ( strncmp("AttachObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
223  return new AttachObjectMessage();
224  } else if ( strncmp("ReleaseObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
225  return new ReleaseObjectMessage();
226  } else if ( strncmp("ReleaseAllObjectsMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
227  return new ReleaseAllObjectsMessage();
228  } else if ( strncmp("MoveObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
229  return new MoveObjectMessage();
230  } else if ( strncmp("RotateObjectQuatMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
231  return new RotateObjectQuatMessage();
232  } else if ( strncmp("RotateObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
233  return new RotateObjectMessage();
234  } else if ( strncmp("RenameObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
235  return new RenameObjectMessage();
236  } else {
237  throw UnknownTypeException("The given type '%s' does not match any known "
238  "message type for this interface type.", type);
239  }
240 }
241 
242 
243 /** Copy values from other interface.
244  * @param other other interface to copy values from
245  */
246 void
248 {
249  const OpenRaveInterface *oi = dynamic_cast<const OpenRaveInterface *>(other);
250  if (oi == NULL) {
251  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
252  type(), other->type());
253  }
254  memcpy(data, oi->data, sizeof(OpenRaveInterface_data_t));
255 }
256 
257 const char *
258 OpenRaveInterface::enum_tostring(const char *enumtype, int val) const
259 {
260  throw UnknownTypeException("Unknown enum type %s", enumtype);
261 }
262 
263 /* =========== messages =========== */
264 /** @class OpenRaveInterface::StartViewerMessage <interfaces/OpenRaveInterface.h>
265  * StartViewerMessage Fawkes BlackBoard Interface Message.
266  *
267  Start the qtcoin viewer, showing the current OpenRAVE environment.
268 
269  */
270 
271 
272 /** Constructor */
274 {
275  data_size = sizeof(StartViewerMessage_data_t);
276  data_ptr = malloc(data_size);
277  memset(data_ptr, 0, data_size);
278  data = (StartViewerMessage_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 = (StartViewerMessage_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 OpenRaveInterface::StartViewerMessage(this);
310 }
311 /** @class OpenRaveInterface::AddObjectMessage <interfaces/OpenRaveInterface.h>
312  * AddObjectMessage Fawkes BlackBoard Interface Message.
313  *
314 
315  */
316 
317 
318 /** Constructor with initial values.
319  * @param ini_name initial value for name
320  * @param ini_path initial value for path
321  */
322 OpenRaveInterface::AddObjectMessage::AddObjectMessage(const char * ini_name, const char * ini_path) : Message("AddObjectMessage")
323 {
324  data_size = sizeof(AddObjectMessage_data_t);
325  data_ptr = malloc(data_size);
326  memset(data_ptr, 0, data_size);
327  data = (AddObjectMessage_data_t *)data_ptr;
329  strncpy(data->name, ini_name, 30);
330  strncpy(data->path, ini_path, 1024);
331  add_fieldinfo(IFT_STRING, "name", 30, data->name);
332  add_fieldinfo(IFT_STRING, "path", 1024, data->path);
333 }
334 /** Constructor */
336 {
337  data_size = sizeof(AddObjectMessage_data_t);
338  data_ptr = malloc(data_size);
339  memset(data_ptr, 0, data_size);
340  data = (AddObjectMessage_data_t *)data_ptr;
342  add_fieldinfo(IFT_STRING, "name", 30, data->name);
343  add_fieldinfo(IFT_STRING, "path", 1024, data->path);
344 }
345 
346 /** Destructor */
348 {
349  free(data_ptr);
350 }
351 
352 /** Copy constructor.
353  * @param m message to copy from
354  */
356 {
357  data_size = m->data_size;
358  data_ptr = malloc(data_size);
359  memcpy(data_ptr, m->data_ptr, data_size);
360  data = (AddObjectMessage_data_t *)data_ptr;
362 }
363 
364 /* Methods */
365 /** Get name value.
366  * Name of object
367  * @return name value
368  */
369 char *
371 {
372  return data->name;
373 }
374 
375 /** Get maximum length of name value.
376  * @return length of name value, can be length of the array or number of
377  * maximum number of characters for a string
378  */
379 size_t
381 {
382  return 30;
383 }
384 
385 /** Set name value.
386  * Name of object
387  * @param new_name new name value
388  */
389 void
391 {
392  strncpy(data->name, new_name, sizeof(data->name));
393 }
394 
395 /** Get path value.
396  * Path to object xml file
397  * @return path value
398  */
399 char *
401 {
402  return data->path;
403 }
404 
405 /** Get maximum length of path value.
406  * @return length of path value, can be length of the array or number of
407  * maximum number of characters for a string
408  */
409 size_t
411 {
412  return 1024;
413 }
414 
415 /** Set path value.
416  * Path to object xml file
417  * @param new_path new path value
418  */
419 void
421 {
422  strncpy(data->path, new_path, sizeof(data->path));
423 }
424 
425 /** Clone this message.
426  * Produces a message of the same type as this message and copies the
427  * data to the new message.
428  * @return clone of this message
429  */
430 Message *
432 {
433  return new OpenRaveInterface::AddObjectMessage(this);
434 }
435 /** @class OpenRaveInterface::DeleteObjectMessage <interfaces/OpenRaveInterface.h>
436  * DeleteObjectMessage Fawkes BlackBoard Interface Message.
437  *
438 
439  */
440 
441 
442 /** Constructor with initial values.
443  * @param ini_name initial value for name
444  */
445 OpenRaveInterface::DeleteObjectMessage::DeleteObjectMessage(const char * ini_name) : Message("DeleteObjectMessage")
446 {
447  data_size = sizeof(DeleteObjectMessage_data_t);
448  data_ptr = malloc(data_size);
449  memset(data_ptr, 0, data_size);
450  data = (DeleteObjectMessage_data_t *)data_ptr;
452  strncpy(data->name, ini_name, 30);
453  add_fieldinfo(IFT_STRING, "name", 30, data->name);
454 }
455 /** Constructor */
457 {
458  data_size = sizeof(DeleteObjectMessage_data_t);
459  data_ptr = malloc(data_size);
460  memset(data_ptr, 0, data_size);
461  data = (DeleteObjectMessage_data_t *)data_ptr;
463  add_fieldinfo(IFT_STRING, "name", 30, data->name);
464 }
465 
466 /** Destructor */
468 {
469  free(data_ptr);
470 }
471 
472 /** Copy constructor.
473  * @param m message to copy from
474  */
476 {
477  data_size = m->data_size;
478  data_ptr = malloc(data_size);
479  memcpy(data_ptr, m->data_ptr, data_size);
480  data = (DeleteObjectMessage_data_t *)data_ptr;
482 }
483 
484 /* Methods */
485 /** Get name value.
486  * Name of object
487  * @return name value
488  */
489 char *
491 {
492  return data->name;
493 }
494 
495 /** Get maximum length of name value.
496  * @return length of name value, can be length of the array or number of
497  * maximum number of characters for a string
498  */
499 size_t
501 {
502  return 30;
503 }
504 
505 /** Set name value.
506  * Name of object
507  * @param new_name new name value
508  */
509 void
511 {
512  strncpy(data->name, new_name, sizeof(data->name));
513 }
514 
515 /** Clone this message.
516  * Produces a message of the same type as this message and copies the
517  * data to the new message.
518  * @return clone of this message
519  */
520 Message *
522 {
524 }
525 /** @class OpenRaveInterface::DeleteAllObjectsMessage <interfaces/OpenRaveInterface.h>
526  * DeleteAllObjectsMessage Fawkes BlackBoard Interface Message.
527  *
528 
529  */
530 
531 
532 /** Constructor */
534 {
535  data_size = sizeof(DeleteAllObjectsMessage_data_t);
536  data_ptr = malloc(data_size);
537  memset(data_ptr, 0, data_size);
538  data = (DeleteAllObjectsMessage_data_t *)data_ptr;
540 }
541 
542 /** Destructor */
544 {
545  free(data_ptr);
546 }
547 
548 /** Copy constructor.
549  * @param m message to copy from
550  */
552 {
553  data_size = m->data_size;
554  data_ptr = malloc(data_size);
555  memcpy(data_ptr, m->data_ptr, data_size);
556  data = (DeleteAllObjectsMessage_data_t *)data_ptr;
558 }
559 
560 /* Methods */
561 /** Clone this message.
562  * Produces a message of the same type as this message and copies the
563  * data to the new message.
564  * @return clone of this message
565  */
566 Message *
568 {
570 }
571 /** @class OpenRaveInterface::AttachObjectMessage <interfaces/OpenRaveInterface.h>
572  * AttachObjectMessage Fawkes BlackBoard Interface Message.
573  *
574 
575  */
576 
577 
578 /** Constructor with initial values.
579  * @param ini_name initial value for name
580  * @param ini_manip_name initial value for manip_name
581  */
582 OpenRaveInterface::AttachObjectMessage::AttachObjectMessage(const char * ini_name, const char * ini_manip_name) : Message("AttachObjectMessage")
583 {
584  data_size = sizeof(AttachObjectMessage_data_t);
585  data_ptr = malloc(data_size);
586  memset(data_ptr, 0, data_size);
587  data = (AttachObjectMessage_data_t *)data_ptr;
589  strncpy(data->name, ini_name, 30);
590  strncpy(data->manip_name, ini_manip_name, 30);
591  add_fieldinfo(IFT_STRING, "name", 30, data->name);
592  add_fieldinfo(IFT_STRING, "manip_name", 30, data->manip_name);
593 }
594 /** Constructor */
596 {
597  data_size = sizeof(AttachObjectMessage_data_t);
598  data_ptr = malloc(data_size);
599  memset(data_ptr, 0, data_size);
600  data = (AttachObjectMessage_data_t *)data_ptr;
602  add_fieldinfo(IFT_STRING, "name", 30, data->name);
603  add_fieldinfo(IFT_STRING, "manip_name", 30, data->manip_name);
604 }
605 
606 /** Destructor */
608 {
609  free(data_ptr);
610 }
611 
612 /** Copy constructor.
613  * @param m message to copy from
614  */
616 {
617  data_size = m->data_size;
618  data_ptr = malloc(data_size);
619  memcpy(data_ptr, m->data_ptr, data_size);
620  data = (AttachObjectMessage_data_t *)data_ptr;
622 }
623 
624 /* Methods */
625 /** Get name value.
626  * Name of object
627  * @return name value
628  */
629 char *
631 {
632  return data->name;
633 }
634 
635 /** Get maximum length of name value.
636  * @return length of name value, can be length of the array or number of
637  * maximum number of characters for a string
638  */
639 size_t
641 {
642  return 30;
643 }
644 
645 /** Set name value.
646  * Name of object
647  * @param new_name new name value
648  */
649 void
651 {
652  strncpy(data->name, new_name, sizeof(data->name));
653 }
654 
655 /** Get manip_name value.
656  * Name of manipulator
657  * @return manip_name value
658  */
659 char *
661 {
662  return data->manip_name;
663 }
664 
665 /** Get maximum length of manip_name value.
666  * @return length of manip_name value, can be length of the array or number of
667  * maximum number of characters for a string
668  */
669 size_t
671 {
672  return 30;
673 }
674 
675 /** Set manip_name value.
676  * Name of manipulator
677  * @param new_manip_name new manip_name value
678  */
679 void
681 {
682  strncpy(data->manip_name, new_manip_name, sizeof(data->manip_name));
683 }
684 
685 /** Clone this message.
686  * Produces a message of the same type as this message and copies the
687  * data to the new message.
688  * @return clone of this message
689  */
690 Message *
692 {
694 }
695 /** @class OpenRaveInterface::ReleaseObjectMessage <interfaces/OpenRaveInterface.h>
696  * ReleaseObjectMessage Fawkes BlackBoard Interface Message.
697  *
698 
699  */
700 
701 
702 /** Constructor with initial values.
703  * @param ini_name initial value for name
704  */
705 OpenRaveInterface::ReleaseObjectMessage::ReleaseObjectMessage(const char * ini_name) : Message("ReleaseObjectMessage")
706 {
707  data_size = sizeof(ReleaseObjectMessage_data_t);
708  data_ptr = malloc(data_size);
709  memset(data_ptr, 0, data_size);
710  data = (ReleaseObjectMessage_data_t *)data_ptr;
712  strncpy(data->name, ini_name, 30);
713  add_fieldinfo(IFT_STRING, "name", 30, data->name);
714 }
715 /** Constructor */
717 {
718  data_size = sizeof(ReleaseObjectMessage_data_t);
719  data_ptr = malloc(data_size);
720  memset(data_ptr, 0, data_size);
721  data = (ReleaseObjectMessage_data_t *)data_ptr;
723  add_fieldinfo(IFT_STRING, "name", 30, data->name);
724 }
725 
726 /** Destructor */
728 {
729  free(data_ptr);
730 }
731 
732 /** Copy constructor.
733  * @param m message to copy from
734  */
736 {
737  data_size = m->data_size;
738  data_ptr = malloc(data_size);
739  memcpy(data_ptr, m->data_ptr, data_size);
740  data = (ReleaseObjectMessage_data_t *)data_ptr;
742 }
743 
744 /* Methods */
745 /** Get name value.
746  * Name of object
747  * @return name value
748  */
749 char *
751 {
752  return data->name;
753 }
754 
755 /** Get maximum length of name value.
756  * @return length of name value, can be length of the array or number of
757  * maximum number of characters for a string
758  */
759 size_t
761 {
762  return 30;
763 }
764 
765 /** Set name value.
766  * Name of object
767  * @param new_name new name value
768  */
769 void
771 {
772  strncpy(data->name, new_name, sizeof(data->name));
773 }
774 
775 /** Clone this message.
776  * Produces a message of the same type as this message and copies the
777  * data to the new message.
778  * @return clone of this message
779  */
780 Message *
782 {
784 }
785 /** @class OpenRaveInterface::ReleaseAllObjectsMessage <interfaces/OpenRaveInterface.h>
786  * ReleaseAllObjectsMessage Fawkes BlackBoard Interface Message.
787  *
788 
789  */
790 
791 
792 /** Constructor */
794 {
795  data_size = sizeof(ReleaseAllObjectsMessage_data_t);
796  data_ptr = malloc(data_size);
797  memset(data_ptr, 0, data_size);
798  data = (ReleaseAllObjectsMessage_data_t *)data_ptr;
800 }
801 
802 /** Destructor */
804 {
805  free(data_ptr);
806 }
807 
808 /** Copy constructor.
809  * @param m message to copy from
810  */
812 {
813  data_size = m->data_size;
814  data_ptr = malloc(data_size);
815  memcpy(data_ptr, m->data_ptr, data_size);
816  data = (ReleaseAllObjectsMessage_data_t *)data_ptr;
818 }
819 
820 /* Methods */
821 /** Clone this message.
822  * Produces a message of the same type as this message and copies the
823  * data to the new message.
824  * @return clone of this message
825  */
826 Message *
828 {
830 }
831 /** @class OpenRaveInterface::MoveObjectMessage <interfaces/OpenRaveInterface.h>
832  * MoveObjectMessage Fawkes BlackBoard Interface Message.
833  *
834 
835  */
836 
837 
838 /** Constructor with initial values.
839  * @param ini_name initial value for name
840  * @param ini_x initial value for x
841  * @param ini_y initial value for y
842  * @param ini_z initial value for z
843  */
844 OpenRaveInterface::MoveObjectMessage::MoveObjectMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z) : Message("MoveObjectMessage")
845 {
846  data_size = sizeof(MoveObjectMessage_data_t);
847  data_ptr = malloc(data_size);
848  memset(data_ptr, 0, data_size);
849  data = (MoveObjectMessage_data_t *)data_ptr;
851  strncpy(data->name, ini_name, 30);
852  data->x = ini_x;
853  data->y = ini_y;
854  data->z = ini_z;
855  add_fieldinfo(IFT_STRING, "name", 30, data->name);
856  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
857  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
858  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
859 }
860 /** Constructor */
862 {
863  data_size = sizeof(MoveObjectMessage_data_t);
864  data_ptr = malloc(data_size);
865  memset(data_ptr, 0, data_size);
866  data = (MoveObjectMessage_data_t *)data_ptr;
868  add_fieldinfo(IFT_STRING, "name", 30, data->name);
869  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
870  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
871  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
872 }
873 
874 /** Destructor */
876 {
877  free(data_ptr);
878 }
879 
880 /** Copy constructor.
881  * @param m message to copy from
882  */
884 {
885  data_size = m->data_size;
886  data_ptr = malloc(data_size);
887  memcpy(data_ptr, m->data_ptr, data_size);
888  data = (MoveObjectMessage_data_t *)data_ptr;
890 }
891 
892 /* Methods */
893 /** Get name value.
894  * Name of object
895  * @return name value
896  */
897 char *
899 {
900  return data->name;
901 }
902 
903 /** Get maximum length of name value.
904  * @return length of name value, can be length of the array or number of
905  * maximum number of characters for a string
906  */
907 size_t
909 {
910  return 30;
911 }
912 
913 /** Set name value.
914  * Name of object
915  * @param new_name new name value
916  */
917 void
919 {
920  strncpy(data->name, new_name, sizeof(data->name));
921 }
922 
923 /** Get x value.
924  * x position of object (meters)
925  * @return x value
926  */
927 float
929 {
930  return data->x;
931 }
932 
933 /** Get maximum length of x value.
934  * @return length of x value, can be length of the array or number of
935  * maximum number of characters for a string
936  */
937 size_t
939 {
940  return 1;
941 }
942 
943 /** Set x value.
944  * x position of object (meters)
945  * @param new_x new x value
946  */
947 void
949 {
950  data->x = new_x;
951 }
952 
953 /** Get y value.
954  * y position of object (meters)
955  * @return y value
956  */
957 float
959 {
960  return data->y;
961 }
962 
963 /** Get maximum length of y value.
964  * @return length of y value, can be length of the array or number of
965  * maximum number of characters for a string
966  */
967 size_t
969 {
970  return 1;
971 }
972 
973 /** Set y value.
974  * y position of object (meters)
975  * @param new_y new y value
976  */
977 void
979 {
980  data->y = new_y;
981 }
982 
983 /** Get z value.
984  * z position of object (meters)
985  * @return z value
986  */
987 float
989 {
990  return data->z;
991 }
992 
993 /** Get maximum length of z value.
994  * @return length of z value, can be length of the array or number of
995  * maximum number of characters for a string
996  */
997 size_t
999 {
1000  return 1;
1001 }
1002 
1003 /** Set z value.
1004  * z position of object (meters)
1005  * @param new_z new z value
1006  */
1007 void
1009 {
1010  data->z = new_z;
1011 }
1012 
1013 /** Clone this message.
1014  * Produces a message of the same type as this message and copies the
1015  * data to the new message.
1016  * @return clone of this message
1017  */
1018 Message *
1020 {
1021  return new OpenRaveInterface::MoveObjectMessage(this);
1022 }
1023 /** @class OpenRaveInterface::RotateObjectQuatMessage <interfaces/OpenRaveInterface.h>
1024  * RotateObjectQuatMessage Fawkes BlackBoard Interface Message.
1025  *
1026 
1027  */
1028 
1029 
1030 /** Constructor with initial values.
1031  * @param ini_name initial value for name
1032  * @param ini_x initial value for x
1033  * @param ini_y initial value for y
1034  * @param ini_z initial value for z
1035  * @param ini_w initial value for w
1036  */
1037 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")
1038 {
1039  data_size = sizeof(RotateObjectQuatMessage_data_t);
1040  data_ptr = malloc(data_size);
1041  memset(data_ptr, 0, data_size);
1042  data = (RotateObjectQuatMessage_data_t *)data_ptr;
1044  strncpy(data->name, ini_name, 30);
1045  data->x = ini_x;
1046  data->y = ini_y;
1047  data->z = ini_z;
1048  data->w = ini_w;
1049  add_fieldinfo(IFT_STRING, "name", 30, data->name);
1050  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1051  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1052  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1053  add_fieldinfo(IFT_FLOAT, "w", 1, &data->w);
1054 }
1055 /** Constructor */
1057 {
1058  data_size = sizeof(RotateObjectQuatMessage_data_t);
1059  data_ptr = malloc(data_size);
1060  memset(data_ptr, 0, data_size);
1061  data = (RotateObjectQuatMessage_data_t *)data_ptr;
1063  add_fieldinfo(IFT_STRING, "name", 30, data->name);
1064  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1065  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1066  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1067  add_fieldinfo(IFT_FLOAT, "w", 1, &data->w);
1068 }
1069 
1070 /** Destructor */
1072 {
1073  free(data_ptr);
1074 }
1075 
1076 /** Copy constructor.
1077  * @param m message to copy from
1078  */
1080 {
1081  data_size = m->data_size;
1082  data_ptr = malloc(data_size);
1083  memcpy(data_ptr, m->data_ptr, data_size);
1084  data = (RotateObjectQuatMessage_data_t *)data_ptr;
1086 }
1087 
1088 /* Methods */
1089 /** Get name value.
1090  * Name of object
1091  * @return name value
1092  */
1093 char *
1095 {
1096  return data->name;
1097 }
1098 
1099 /** Get maximum length of name value.
1100  * @return length of name value, can be length of the array or number of
1101  * maximum number of characters for a string
1102  */
1103 size_t
1105 {
1106  return 30;
1107 }
1108 
1109 /** Set name value.
1110  * Name of object
1111  * @param new_name new name value
1112  */
1113 void
1115 {
1116  strncpy(data->name, new_name, sizeof(data->name));
1117 }
1118 
1119 /** Get x value.
1120  * x value of quaternion
1121  * @return x value
1122  */
1123 float
1125 {
1126  return data->x;
1127 }
1128 
1129 /** Get maximum length of x value.
1130  * @return length of x value, can be length of the array or number of
1131  * maximum number of characters for a string
1132  */
1133 size_t
1135 {
1136  return 1;
1137 }
1138 
1139 /** Set x value.
1140  * x value of quaternion
1141  * @param new_x new x value
1142  */
1143 void
1145 {
1146  data->x = new_x;
1147 }
1148 
1149 /** Get y value.
1150  * y value of quaternion
1151  * @return y value
1152  */
1153 float
1155 {
1156  return data->y;
1157 }
1158 
1159 /** Get maximum length of y value.
1160  * @return length of y value, can be length of the array or number of
1161  * maximum number of characters for a string
1162  */
1163 size_t
1165 {
1166  return 1;
1167 }
1168 
1169 /** Set y value.
1170  * y value of quaternion
1171  * @param new_y new y value
1172  */
1173 void
1175 {
1176  data->y = new_y;
1177 }
1178 
1179 /** Get z value.
1180  * z value of quaternion
1181  * @return z value
1182  */
1183 float
1185 {
1186  return data->z;
1187 }
1188 
1189 /** Get maximum length of z value.
1190  * @return length of z 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 z value.
1200  * z value of quaternion
1201  * @param new_z new z value
1202  */
1203 void
1205 {
1206  data->z = new_z;
1207 }
1208 
1209 /** Get w value.
1210  * w value of quaternion
1211  * @return w value
1212  */
1213 float
1215 {
1216  return data->w;
1217 }
1218 
1219 /** Get maximum length of w value.
1220  * @return length of w value, can be length of the array or number of
1221  * maximum number of characters for a string
1222  */
1223 size_t
1225 {
1226  return 1;
1227 }
1228 
1229 /** Set w value.
1230  * w value of quaternion
1231  * @param new_w new w value
1232  */
1233 void
1235 {
1236  data->w = new_w;
1237 }
1238 
1239 /** Clone this message.
1240  * Produces a message of the same type as this message and copies the
1241  * data to the new message.
1242  * @return clone of this message
1243  */
1244 Message *
1246 {
1248 }
1249 /** @class OpenRaveInterface::RotateObjectMessage <interfaces/OpenRaveInterface.h>
1250  * RotateObjectMessage Fawkes BlackBoard Interface Message.
1251  *
1252 
1253  */
1254 
1255 
1256 /** Constructor with initial values.
1257  * @param ini_name initial value for name
1258  * @param ini_x initial value for x
1259  * @param ini_y initial value for y
1260  * @param ini_z initial value for z
1261  */
1262 OpenRaveInterface::RotateObjectMessage::RotateObjectMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z) : Message("RotateObjectMessage")
1263 {
1264  data_size = sizeof(RotateObjectMessage_data_t);
1265  data_ptr = malloc(data_size);
1266  memset(data_ptr, 0, data_size);
1267  data = (RotateObjectMessage_data_t *)data_ptr;
1269  strncpy(data->name, ini_name, 30);
1270  data->x = ini_x;
1271  data->y = ini_y;
1272  data->z = ini_z;
1273  add_fieldinfo(IFT_STRING, "name", 30, data->name);
1274  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1275  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1276  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1277 }
1278 /** Constructor */
1280 {
1281  data_size = sizeof(RotateObjectMessage_data_t);
1282  data_ptr = malloc(data_size);
1283  memset(data_ptr, 0, data_size);
1284  data = (RotateObjectMessage_data_t *)data_ptr;
1286  add_fieldinfo(IFT_STRING, "name", 30, data->name);
1287  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1288  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1289  add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1290 }
1291 
1292 /** Destructor */
1294 {
1295  free(data_ptr);
1296 }
1297 
1298 /** Copy constructor.
1299  * @param m message to copy from
1300  */
1302 {
1303  data_size = m->data_size;
1304  data_ptr = malloc(data_size);
1305  memcpy(data_ptr, m->data_ptr, data_size);
1306  data = (RotateObjectMessage_data_t *)data_ptr;
1308 }
1309 
1310 /* Methods */
1311 /** Get name value.
1312  * Name of object
1313  * @return name value
1314  */
1315 char *
1317 {
1318  return data->name;
1319 }
1320 
1321 /** Get maximum length of name value.
1322  * @return length of name value, can be length of the array or number of
1323  * maximum number of characters for a string
1324  */
1325 size_t
1327 {
1328  return 30;
1329 }
1330 
1331 /** Set name value.
1332  * Name of object
1333  * @param new_name new name value
1334  */
1335 void
1337 {
1338  strncpy(data->name, new_name, sizeof(data->name));
1339 }
1340 
1341 /** Get x value.
1342  * x-axis rotation of object (rad)
1343  * @return x value
1344  */
1345 float
1347 {
1348  return data->x;
1349 }
1350 
1351 /** Get maximum length of x value.
1352  * @return length of x value, can be length of the array or number of
1353  * maximum number of characters for a string
1354  */
1355 size_t
1357 {
1358  return 1;
1359 }
1360 
1361 /** Set x value.
1362  * x-axis rotation of object (rad)
1363  * @param new_x new x value
1364  */
1365 void
1367 {
1368  data->x = new_x;
1369 }
1370 
1371 /** Get y value.
1372  * y-axis rotation of object (rad)
1373  * @return y value
1374  */
1375 float
1377 {
1378  return data->y;
1379 }
1380 
1381 /** Get maximum length of y value.
1382  * @return length of y value, can be length of the array or number of
1383  * maximum number of characters for a string
1384  */
1385 size_t
1387 {
1388  return 1;
1389 }
1390 
1391 /** Set y value.
1392  * y-axis rotation of object (rad)
1393  * @param new_y new y value
1394  */
1395 void
1397 {
1398  data->y = new_y;
1399 }
1400 
1401 /** Get z value.
1402  * z-axis rotation of object (rad)
1403  * @return z value
1404  */
1405 float
1407 {
1408  return data->z;
1409 }
1410 
1411 /** Get maximum length of z value.
1412  * @return length of z value, can be length of the array or number of
1413  * maximum number of characters for a string
1414  */
1415 size_t
1417 {
1418  return 1;
1419 }
1420 
1421 /** Set z value.
1422  * z-axis rotation of object (rad)
1423  * @param new_z new z value
1424  */
1425 void
1427 {
1428  data->z = new_z;
1429 }
1430 
1431 /** Clone this message.
1432  * Produces a message of the same type as this message and copies the
1433  * data to the new message.
1434  * @return clone of this message
1435  */
1436 Message *
1438 {
1439  return new OpenRaveInterface::RotateObjectMessage(this);
1440 }
1441 /** @class OpenRaveInterface::RenameObjectMessage <interfaces/OpenRaveInterface.h>
1442  * RenameObjectMessage Fawkes BlackBoard Interface Message.
1443  *
1444 
1445  */
1446 
1447 
1448 /** Constructor with initial values.
1449  * @param ini_name initial value for name
1450  * @param ini_newName initial value for newName
1451  */
1452 OpenRaveInterface::RenameObjectMessage::RenameObjectMessage(const char * ini_name, const char * ini_newName) : Message("RenameObjectMessage")
1453 {
1454  data_size = sizeof(RenameObjectMessage_data_t);
1455  data_ptr = malloc(data_size);
1456  memset(data_ptr, 0, data_size);
1457  data = (RenameObjectMessage_data_t *)data_ptr;
1459  strncpy(data->name, ini_name, 30);
1460  strncpy(data->newName, ini_newName, 30);
1461  add_fieldinfo(IFT_STRING, "name", 30, data->name);
1462  add_fieldinfo(IFT_STRING, "newName", 30, data->newName);
1463 }
1464 /** Constructor */
1466 {
1467  data_size = sizeof(RenameObjectMessage_data_t);
1468  data_ptr = malloc(data_size);
1469  memset(data_ptr, 0, data_size);
1470  data = (RenameObjectMessage_data_t *)data_ptr;
1472  add_fieldinfo(IFT_STRING, "name", 30, data->name);
1473  add_fieldinfo(IFT_STRING, "newName", 30, data->newName);
1474 }
1475 
1476 /** Destructor */
1478 {
1479  free(data_ptr);
1480 }
1481 
1482 /** Copy constructor.
1483  * @param m message to copy from
1484  */
1486 {
1487  data_size = m->data_size;
1488  data_ptr = malloc(data_size);
1489  memcpy(data_ptr, m->data_ptr, data_size);
1490  data = (RenameObjectMessage_data_t *)data_ptr;
1492 }
1493 
1494 /* Methods */
1495 /** Get name value.
1496  * Name of object
1497  * @return name value
1498  */
1499 char *
1501 {
1502  return data->name;
1503 }
1504 
1505 /** Get maximum length of name value.
1506  * @return length of name value, can be length of the array or number of
1507  * maximum number of characters for a string
1508  */
1509 size_t
1511 {
1512  return 30;
1513 }
1514 
1515 /** Set name value.
1516  * Name of object
1517  * @param new_name new name value
1518  */
1519 void
1521 {
1522  strncpy(data->name, new_name, sizeof(data->name));
1523 }
1524 
1525 /** Get newName value.
1526  * New name of object
1527  * @return newName value
1528  */
1529 char *
1531 {
1532  return data->newName;
1533 }
1534 
1535 /** Get maximum length of newName value.
1536  * @return length of newName value, can be length of the array or number of
1537  * maximum number of characters for a string
1538  */
1539 size_t
1541 {
1542  return 30;
1543 }
1544 
1545 /** Set newName value.
1546  * New name of object
1547  * @param new_newName new newName value
1548  */
1549 void
1551 {
1552  strncpy(data->newName, new_newName, sizeof(data->newName));
1553 }
1554 
1555 /** Clone this message.
1556  * Produces a message of the same type as this message and copies the
1557  * data to the new message.
1558  * @return clone of this message
1559  */
1560 Message *
1562 {
1563  return new OpenRaveInterface::RenameObjectMessage(this);
1564 }
1565 /** Check if message is valid and can be enqueued.
1566  * @param message Message to check
1567  * @return true if the message is valid, false otherwise.
1568  */
1569 bool
1571 {
1572  const StartViewerMessage *m0 = dynamic_cast<const StartViewerMessage *>(message);
1573  if ( m0 != NULL ) {
1574  return true;
1575  }
1576  const AddObjectMessage *m1 = dynamic_cast<const AddObjectMessage *>(message);
1577  if ( m1 != NULL ) {
1578  return true;
1579  }
1580  const DeleteObjectMessage *m2 = dynamic_cast<const DeleteObjectMessage *>(message);
1581  if ( m2 != NULL ) {
1582  return true;
1583  }
1584  const DeleteAllObjectsMessage *m3 = dynamic_cast<const DeleteAllObjectsMessage *>(message);
1585  if ( m3 != NULL ) {
1586  return true;
1587  }
1588  const AttachObjectMessage *m4 = dynamic_cast<const AttachObjectMessage *>(message);
1589  if ( m4 != NULL ) {
1590  return true;
1591  }
1592  const ReleaseObjectMessage *m5 = dynamic_cast<const ReleaseObjectMessage *>(message);
1593  if ( m5 != NULL ) {
1594  return true;
1595  }
1596  const ReleaseAllObjectsMessage *m6 = dynamic_cast<const ReleaseAllObjectsMessage *>(message);
1597  if ( m6 != NULL ) {
1598  return true;
1599  }
1600  const MoveObjectMessage *m7 = dynamic_cast<const MoveObjectMessage *>(message);
1601  if ( m7 != NULL ) {
1602  return true;
1603  }
1604  const RotateObjectQuatMessage *m8 = dynamic_cast<const RotateObjectQuatMessage *>(message);
1605  if ( m8 != NULL ) {
1606  return true;
1607  }
1608  const RotateObjectMessage *m9 = dynamic_cast<const RotateObjectMessage *>(message);
1609  if ( m9 != NULL ) {
1610  return true;
1611  }
1612  const RenameObjectMessage *m10 = dynamic_cast<const RenameObjectMessage *>(message);
1613  if ( m10 != NULL ) {
1614  return true;
1615  }
1616  return false;
1617 }
1618 
1619 /// @cond INTERNALS
1620 EXPORT_INTERFACE(OpenRaveInterface)
1621 /// @endcond
1622 
1623 
1624 } // end namespace fawkes
virtual Message * clone() const
Clone this message.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_newName() const
Get maximum length of newName value.
void set_path(const char *new_path)
Set path value.
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:124
RotateObjectQuatMessage Fawkes BlackBoard Interface Message.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_name() const
Get maximum length of name value.
uint32_t error_code() const
Get error_code value.
void set_error_code(const uint32_t new_error_code)
Set error_code value.
size_t maxlenof_name() const
Get maximum length of name value.
bool is_final() const
Get final value.
size_t maxlenof_x() const
Get maximum length of x value.
void set_success(const bool new_success)
Set success value.
ReleaseAllObjectsMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_y() const
Get maximum length of y value.
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
Definition: message.h:129
virtual Message * clone() const
Clone this message.
virtual void copy_values(const Interface *other)
Copy values from other interface.
void set_manip_name(const char *new_manip_name)
Set manip_name value.
void set_final(const bool new_final)
Set final value.
string field
Definition: types.h:47
void set_z(const float new_z)
Set z value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_manip_name() const
Get maximum length of manip_name value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
size_t maxlenof_name() const
Get maximum length of name value.
RotateObjectMessage Fawkes BlackBoard Interface Message.
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:133
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:125
size_t maxlenof_name() const
Get maximum length of name value.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
void set_x(const float new_x)
Set x value.
size_t maxlenof_y() const
Get maximum length of y value.
StartViewerMessage Fawkes BlackBoard Interface Message.
void set_y(const float new_y)
Set y value.
size_t maxlenof_z() const
Get maximum length of z value.
size_t maxlenof_z() const
Get maximum length of z value.
size_t maxlenof_z() const
Get maximum length of z value.
void set_newName(const char *new_newName)
Set newName value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
void set_msgid(const uint32_t new_msgid)
Set msgid value.
size_t maxlenof_w() const
Get maximum length of w value.
AttachObjectMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_final() const
Get maximum length of final 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.
DeleteAllObjectsMessage Fawkes BlackBoard Interface Message.
void set_z(const float new_z)
Set z value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_name() const
Get maximum length of name value.
float field
Definition: types.h:45
virtual Message * create_message(const char *type) const
Create message based on type name.
ReleaseObjectMessage Fawkes BlackBoard Interface Message.
void set_x(const float new_x)
Set x value.
size_t maxlenof_path() const
Get maximum length of path value.
virtual Message * clone() const
Clone this message.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_name() const
Get maximum length of name value.
RenameObjectMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_success() const
Get maximum length of success value.
virtual Message * clone() const
Clone this message.
void set_name(const char *new_name)
Set name value.
void set_name(const char *new_name)
Set name value.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_x() const
Get maximum length of x value.
void set_name(const char *new_name)
Set name value.
char * manip_name() const
Get manip_name value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
Definition: message.cpp:436
boolean field
Definition: types.h:36
void set_name(const char *new_name)
Set name value.
size_t maxlenof_error_code() const
Get maximum length of error_code value.
DeleteObjectMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_name() const
Get maximum length of name value.
virtual Message * clone() const
Clone this message.
MoveObjectMessage Fawkes BlackBoard Interface Message.
uint32_t msgid() const
Get msgid value.
32 bit unsigned integer field
Definition: types.h:42
bool is_success() const
Get success value.
size_t maxlenof_x() const
Get maximum length of x value.
OpenRaveInterface Fawkes BlackBoard Interface.
size_t maxlenof_y() const
Get maximum length of y value.
AddObjectMessage Fawkes BlackBoard Interface Message.