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
33namespace 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 */
46OpenRaveInterface::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 */
73OpenRaveInterface::~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 */
83uint32_t
84OpenRaveInterface::msgid() const
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 */
93size_t
94OpenRaveInterface::maxlenof_msgid() const
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 */
104void
105OpenRaveInterface::set_msgid(const uint32_t new_msgid)
106{
107 set_field(data->msgid, new_msgid);
108}
109
110/** Get final value.
111 * True, if the last goto command has been finished,
112 false if it is still running
113 * @return final value
114 */
115bool
116OpenRaveInterface::is_final() const
117{
118 return data->final;
119}
120
121/** Get maximum length of final value.
122 * @return length of final value, can be length of the array or number of
123 * maximum number of characters for a string
124 */
125size_t
126OpenRaveInterface::maxlenof_final() const
127{
128 return 1;
129}
130
131/** Set final value.
132 * True, if the last goto command has been finished,
133 false if it is still running
134 * @param new_final new final value
135 */
136void
137OpenRaveInterface::set_final(const bool new_final)
138{
139 set_field(data->final, new_final);
140}
141
142/** Get error_code value.
143 * Failure code set if
144 final is true. 0 if no error occured, an error code from ERROR_*
145 constants otherwise (or a bit-wise combination).
146 * @return error_code value
147 */
148uint32_t
149OpenRaveInterface::error_code() const
150{
151 return data->error_code;
152}
153
154/** Get maximum length of error_code value.
155 * @return length of error_code value, can be length of the array or number of
156 * maximum number of characters for a string
157 */
158size_t
159OpenRaveInterface::maxlenof_error_code() const
160{
161 return 1;
162}
163
164/** Set error_code value.
165 * Failure code set if
166 final is true. 0 if no error occured, an error code from ERROR_*
167 constants otherwise (or a bit-wise combination).
168 * @param new_error_code new error_code value
169 */
170void
171OpenRaveInterface::set_error_code(const uint32_t new_error_code)
172{
173 set_field(data->error_code, new_error_code);
174}
175
176/** Get success value.
177 * True, if last command was successful. False otherwise
178 * @return success value
179 */
180bool
181OpenRaveInterface::is_success() const
182{
183 return data->success;
184}
185
186/** Get maximum length of success value.
187 * @return length of success value, can be length of the array or number of
188 * maximum number of characters for a string
189 */
190size_t
191OpenRaveInterface::maxlenof_success() const
192{
193 return 1;
194}
195
196/** Set success value.
197 * True, if last command was successful. False otherwise
198 * @param new_success new success value
199 */
200void
201OpenRaveInterface::set_success(const bool new_success)
202{
203 set_field(data->success, new_success);
204}
205
206/* =========== message create =========== */
207Message *
208OpenRaveInterface::create_message(const char *type) const
209{
210 if ( strncmp("StartViewerMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
211 return new StartViewerMessage();
212 } else if ( strncmp("AddObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
213 return new AddObjectMessage();
214 } else if ( strncmp("DeleteObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
215 return new DeleteObjectMessage();
216 } else if ( strncmp("DeleteAllObjectsMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
217 return new DeleteAllObjectsMessage();
218 } else if ( strncmp("AttachObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
219 return new AttachObjectMessage();
220 } else if ( strncmp("ReleaseObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
221 return new ReleaseObjectMessage();
222 } else if ( strncmp("ReleaseAllObjectsMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
223 return new ReleaseAllObjectsMessage();
224 } else if ( strncmp("MoveObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
225 return new MoveObjectMessage();
226 } else if ( strncmp("RotateObjectQuatMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
227 return new RotateObjectQuatMessage();
228 } else if ( strncmp("RotateObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
229 return new RotateObjectMessage();
230 } else if ( strncmp("RenameObjectMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
231 return new RenameObjectMessage();
232 } else {
233 throw UnknownTypeException("The given type '%s' does not match any known "
234 "message type for this interface type.", type);
235 }
236}
237
238
239/** Copy values from other interface.
240 * @param other other interface to copy values from
241 */
242void
243OpenRaveInterface::copy_values(const Interface *other)
244{
245 const OpenRaveInterface *oi = dynamic_cast<const OpenRaveInterface *>(other);
246 if (oi == NULL) {
247 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
248 type(), other->type());
249 }
250 memcpy(data, oi->data, sizeof(OpenRaveInterface_data_t));
251}
252
253const char *
254OpenRaveInterface::enum_tostring(const char *enumtype, int val) const
255{
256 throw UnknownTypeException("Unknown enum type %s", enumtype);
257}
258
259/* =========== messages =========== */
260/** @class OpenRaveInterface::StartViewerMessage <interfaces/OpenRaveInterface.h>
261 * StartViewerMessage Fawkes BlackBoard Interface Message.
262 *
263 Start the qtcoin viewer, showing the current OpenRAVE environment.
264
265 */
266
267
268/** Constructor */
269OpenRaveInterface::StartViewerMessage::StartViewerMessage() : Message("StartViewerMessage")
270{
271 data_size = sizeof(StartViewerMessage_data_t);
272 data_ptr = malloc(data_size);
273 memset(data_ptr, 0, data_size);
274 data = (StartViewerMessage_data_t *)data_ptr;
276}
277
278/** Destructor */
280{
281 free(data_ptr);
282}
283
284/** Copy constructor.
285 * @param m message to copy from
286 */
288{
289 data_size = m->data_size;
290 data_ptr = malloc(data_size);
291 memcpy(data_ptr, m->data_ptr, data_size);
292 data = (StartViewerMessage_data_t *)data_ptr;
294}
295
296/* Methods */
297/** Clone this message.
298 * Produces a message of the same type as this message and copies the
299 * data to the new message.
300 * @return clone of this message
301 */
302Message *
304{
306}
307/** @class OpenRaveInterface::AddObjectMessage <interfaces/OpenRaveInterface.h>
308 * AddObjectMessage Fawkes BlackBoard Interface Message.
309 *
310
311 */
312
313
314/** Constructor with initial values.
315 * @param ini_name initial value for name
316 * @param ini_path initial value for path
317 */
318OpenRaveInterface::AddObjectMessage::AddObjectMessage(const char * ini_name, const char * ini_path) : Message("AddObjectMessage")
319{
320 data_size = sizeof(AddObjectMessage_data_t);
321 data_ptr = malloc(data_size);
322 memset(data_ptr, 0, data_size);
323 data = (AddObjectMessage_data_t *)data_ptr;
325 strncpy(data->name, ini_name, 30-1);
326 data->name[30-1] = 0;
327 strncpy(data->path, ini_path, 1024-1);
328 data->path[1024-1] = 0;
329 add_fieldinfo(IFT_STRING, "name", 30, data->name);
330 add_fieldinfo(IFT_STRING, "path", 1024, data->path);
331}
332/** Constructor */
334{
335 data_size = sizeof(AddObjectMessage_data_t);
336 data_ptr = malloc(data_size);
337 memset(data_ptr, 0, data_size);
338 data = (AddObjectMessage_data_t *)data_ptr;
340 add_fieldinfo(IFT_STRING, "name", 30, data->name);
341 add_fieldinfo(IFT_STRING, "path", 1024, data->path);
342}
343
344/** Destructor */
346{
347 free(data_ptr);
348}
349
350/** Copy constructor.
351 * @param m message to copy from
352 */
354{
355 data_size = m->data_size;
356 data_ptr = malloc(data_size);
357 memcpy(data_ptr, m->data_ptr, data_size);
358 data = (AddObjectMessage_data_t *)data_ptr;
360}
361
362/* Methods */
363/** Get name value.
364 * Name of object
365 * @return name value
366 */
367char *
369{
370 return data->name;
371}
372
373/** Get maximum length of name value.
374 * @return length of name value, can be length of the array or number of
375 * maximum number of characters for a string
376 */
377size_t
379{
380 return 30;
381}
382
383/** Set name value.
384 * Name of object
385 * @param new_name new name value
386 */
387void
389{
390 set_field(data->name, new_name);
391}
392
393/** Get path value.
394 * Path to object xml file
395 * @return path value
396 */
397char *
399{
400 return data->path;
401}
402
403/** Get maximum length of path value.
404 * @return length of path value, can be length of the array or number of
405 * maximum number of characters for a string
406 */
407size_t
409{
410 return 1024;
411}
412
413/** Set path value.
414 * Path to object xml file
415 * @param new_path new path value
416 */
417void
419{
420 set_field(data->path, new_path);
421}
422
423/** Clone this message.
424 * Produces a message of the same type as this message and copies the
425 * data to the new message.
426 * @return clone of this message
427 */
428Message *
430{
432}
433/** @class OpenRaveInterface::DeleteObjectMessage <interfaces/OpenRaveInterface.h>
434 * DeleteObjectMessage Fawkes BlackBoard Interface Message.
435 *
436
437 */
438
439
440/** Constructor with initial values.
441 * @param ini_name initial value for name
442 */
443OpenRaveInterface::DeleteObjectMessage::DeleteObjectMessage(const char * ini_name) : Message("DeleteObjectMessage")
444{
445 data_size = sizeof(DeleteObjectMessage_data_t);
446 data_ptr = malloc(data_size);
447 memset(data_ptr, 0, data_size);
448 data = (DeleteObjectMessage_data_t *)data_ptr;
450 strncpy(data->name, ini_name, 30-1);
451 data->name[30-1] = 0;
452 add_fieldinfo(IFT_STRING, "name", 30, data->name);
453}
454/** Constructor */
456{
457 data_size = sizeof(DeleteObjectMessage_data_t);
458 data_ptr = malloc(data_size);
459 memset(data_ptr, 0, data_size);
460 data = (DeleteObjectMessage_data_t *)data_ptr;
462 add_fieldinfo(IFT_STRING, "name", 30, data->name);
463}
464
465/** Destructor */
467{
468 free(data_ptr);
469}
470
471/** Copy constructor.
472 * @param m message to copy from
473 */
475{
476 data_size = m->data_size;
477 data_ptr = malloc(data_size);
478 memcpy(data_ptr, m->data_ptr, data_size);
479 data = (DeleteObjectMessage_data_t *)data_ptr;
481}
482
483/* Methods */
484/** Get name value.
485 * Name of object
486 * @return name value
487 */
488char *
490{
491 return data->name;
492}
493
494/** Get maximum length of name value.
495 * @return length of name value, can be length of the array or number of
496 * maximum number of characters for a string
497 */
498size_t
500{
501 return 30;
502}
503
504/** Set name value.
505 * Name of object
506 * @param new_name new name value
507 */
508void
510{
511 set_field(data->name, new_name);
512}
513
514/** Clone this message.
515 * Produces a message of the same type as this message and copies the
516 * data to the new message.
517 * @return clone of this message
518 */
519Message *
521{
523}
524/** @class OpenRaveInterface::DeleteAllObjectsMessage <interfaces/OpenRaveInterface.h>
525 * DeleteAllObjectsMessage Fawkes BlackBoard Interface Message.
526 *
527
528 */
529
530
531/** Constructor */
533{
534 data_size = sizeof(DeleteAllObjectsMessage_data_t);
535 data_ptr = malloc(data_size);
536 memset(data_ptr, 0, data_size);
537 data = (DeleteAllObjectsMessage_data_t *)data_ptr;
539}
540
541/** Destructor */
543{
544 free(data_ptr);
545}
546
547/** Copy constructor.
548 * @param m message to copy from
549 */
551{
552 data_size = m->data_size;
553 data_ptr = malloc(data_size);
554 memcpy(data_ptr, m->data_ptr, data_size);
555 data = (DeleteAllObjectsMessage_data_t *)data_ptr;
557}
558
559/* Methods */
560/** Clone this message.
561 * Produces a message of the same type as this message and copies the
562 * data to the new message.
563 * @return clone of this message
564 */
565Message *
567{
569}
570/** @class OpenRaveInterface::AttachObjectMessage <interfaces/OpenRaveInterface.h>
571 * AttachObjectMessage Fawkes BlackBoard Interface Message.
572 *
573
574 */
575
576
577/** Constructor with initial values.
578 * @param ini_name initial value for name
579 * @param ini_manip_name initial value for manip_name
580 */
581OpenRaveInterface::AttachObjectMessage::AttachObjectMessage(const char * ini_name, const char * ini_manip_name) : Message("AttachObjectMessage")
582{
583 data_size = sizeof(AttachObjectMessage_data_t);
584 data_ptr = malloc(data_size);
585 memset(data_ptr, 0, data_size);
586 data = (AttachObjectMessage_data_t *)data_ptr;
588 strncpy(data->name, ini_name, 30-1);
589 data->name[30-1] = 0;
590 strncpy(data->manip_name, ini_manip_name, 30-1);
591 data->manip_name[30-1] = 0;
592 add_fieldinfo(IFT_STRING, "name", 30, data->name);
593 add_fieldinfo(IFT_STRING, "manip_name", 30, data->manip_name);
594}
595/** Constructor */
597{
598 data_size = sizeof(AttachObjectMessage_data_t);
599 data_ptr = malloc(data_size);
600 memset(data_ptr, 0, data_size);
601 data = (AttachObjectMessage_data_t *)data_ptr;
603 add_fieldinfo(IFT_STRING, "name", 30, data->name);
604 add_fieldinfo(IFT_STRING, "manip_name", 30, data->manip_name);
605}
606
607/** Destructor */
609{
610 free(data_ptr);
611}
612
613/** Copy constructor.
614 * @param m message to copy from
615 */
617{
618 data_size = m->data_size;
619 data_ptr = malloc(data_size);
620 memcpy(data_ptr, m->data_ptr, data_size);
621 data = (AttachObjectMessage_data_t *)data_ptr;
623}
624
625/* Methods */
626/** Get name value.
627 * Name of object
628 * @return name value
629 */
630char *
632{
633 return data->name;
634}
635
636/** Get maximum length of name value.
637 * @return length of name value, can be length of the array or number of
638 * maximum number of characters for a string
639 */
640size_t
642{
643 return 30;
644}
645
646/** Set name value.
647 * Name of object
648 * @param new_name new name value
649 */
650void
652{
653 set_field(data->name, new_name);
654}
655
656/** Get manip_name value.
657 * Name of manipulator
658 * @return manip_name value
659 */
660char *
662{
663 return data->manip_name;
664}
665
666/** Get maximum length of manip_name value.
667 * @return length of manip_name value, can be length of the array or number of
668 * maximum number of characters for a string
669 */
670size_t
672{
673 return 30;
674}
675
676/** Set manip_name value.
677 * Name of manipulator
678 * @param new_manip_name new manip_name value
679 */
680void
682{
683 set_field(data->manip_name, new_manip_name);
684}
685
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 */
691Message *
693{
695}
696/** @class OpenRaveInterface::ReleaseObjectMessage <interfaces/OpenRaveInterface.h>
697 * ReleaseObjectMessage Fawkes BlackBoard Interface Message.
698 *
699
700 */
701
702
703/** Constructor with initial values.
704 * @param ini_name initial value for name
705 */
706OpenRaveInterface::ReleaseObjectMessage::ReleaseObjectMessage(const char * ini_name) : Message("ReleaseObjectMessage")
707{
708 data_size = sizeof(ReleaseObjectMessage_data_t);
709 data_ptr = malloc(data_size);
710 memset(data_ptr, 0, data_size);
711 data = (ReleaseObjectMessage_data_t *)data_ptr;
713 strncpy(data->name, ini_name, 30-1);
714 data->name[30-1] = 0;
715 add_fieldinfo(IFT_STRING, "name", 30, data->name);
716}
717/** Constructor */
719{
720 data_size = sizeof(ReleaseObjectMessage_data_t);
721 data_ptr = malloc(data_size);
722 memset(data_ptr, 0, data_size);
723 data = (ReleaseObjectMessage_data_t *)data_ptr;
725 add_fieldinfo(IFT_STRING, "name", 30, data->name);
726}
727
728/** Destructor */
730{
731 free(data_ptr);
732}
733
734/** Copy constructor.
735 * @param m message to copy from
736 */
738{
739 data_size = m->data_size;
740 data_ptr = malloc(data_size);
741 memcpy(data_ptr, m->data_ptr, data_size);
742 data = (ReleaseObjectMessage_data_t *)data_ptr;
744}
745
746/* Methods */
747/** Get name value.
748 * Name of object
749 * @return name value
750 */
751char *
753{
754 return data->name;
755}
756
757/** Get maximum length of name value.
758 * @return length of name value, can be length of the array or number of
759 * maximum number of characters for a string
760 */
761size_t
763{
764 return 30;
765}
766
767/** Set name value.
768 * Name of object
769 * @param new_name new name value
770 */
771void
773{
774 set_field(data->name, new_name);
775}
776
777/** Clone this message.
778 * Produces a message of the same type as this message and copies the
779 * data to the new message.
780 * @return clone of this message
781 */
782Message *
784{
786}
787/** @class OpenRaveInterface::ReleaseAllObjectsMessage <interfaces/OpenRaveInterface.h>
788 * ReleaseAllObjectsMessage Fawkes BlackBoard Interface Message.
789 *
790
791 */
792
793
794/** Constructor */
796{
797 data_size = sizeof(ReleaseAllObjectsMessage_data_t);
798 data_ptr = malloc(data_size);
799 memset(data_ptr, 0, data_size);
800 data = (ReleaseAllObjectsMessage_data_t *)data_ptr;
802}
803
804/** Destructor */
806{
807 free(data_ptr);
808}
809
810/** Copy constructor.
811 * @param m message to copy from
812 */
814{
815 data_size = m->data_size;
816 data_ptr = malloc(data_size);
817 memcpy(data_ptr, m->data_ptr, data_size);
818 data = (ReleaseAllObjectsMessage_data_t *)data_ptr;
820}
821
822/* Methods */
823/** Clone this message.
824 * Produces a message of the same type as this message and copies the
825 * data to the new message.
826 * @return clone of this message
827 */
828Message *
830{
832}
833/** @class OpenRaveInterface::MoveObjectMessage <interfaces/OpenRaveInterface.h>
834 * MoveObjectMessage Fawkes BlackBoard Interface Message.
835 *
836
837 */
838
839
840/** Constructor with initial values.
841 * @param ini_name initial value for name
842 * @param ini_x initial value for x
843 * @param ini_y initial value for y
844 * @param ini_z initial value for z
845 */
846OpenRaveInterface::MoveObjectMessage::MoveObjectMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z) : Message("MoveObjectMessage")
847{
848 data_size = sizeof(MoveObjectMessage_data_t);
849 data_ptr = malloc(data_size);
850 memset(data_ptr, 0, data_size);
851 data = (MoveObjectMessage_data_t *)data_ptr;
853 strncpy(data->name, ini_name, 30-1);
854 data->name[30-1] = 0;
855 data->x = ini_x;
856 data->y = ini_y;
857 data->z = ini_z;
858 add_fieldinfo(IFT_STRING, "name", 30, data->name);
859 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
860 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
861 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
862}
863/** Constructor */
865{
866 data_size = sizeof(MoveObjectMessage_data_t);
867 data_ptr = malloc(data_size);
868 memset(data_ptr, 0, data_size);
869 data = (MoveObjectMessage_data_t *)data_ptr;
871 add_fieldinfo(IFT_STRING, "name", 30, data->name);
872 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
873 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
874 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
875}
876
877/** Destructor */
879{
880 free(data_ptr);
881}
882
883/** Copy constructor.
884 * @param m message to copy from
885 */
887{
888 data_size = m->data_size;
889 data_ptr = malloc(data_size);
890 memcpy(data_ptr, m->data_ptr, data_size);
891 data = (MoveObjectMessage_data_t *)data_ptr;
893}
894
895/* Methods */
896/** Get name value.
897 * Name of object
898 * @return name value
899 */
900char *
902{
903 return data->name;
904}
905
906/** Get maximum length of name value.
907 * @return length of name value, can be length of the array or number of
908 * maximum number of characters for a string
909 */
910size_t
912{
913 return 30;
914}
915
916/** Set name value.
917 * Name of object
918 * @param new_name new name value
919 */
920void
922{
923 set_field(data->name, new_name);
924}
925
926/** Get x value.
927 * x position of object (meters)
928 * @return x value
929 */
930float
932{
933 return data->x;
934}
935
936/** Get maximum length of x value.
937 * @return length of x value, can be length of the array or number of
938 * maximum number of characters for a string
939 */
940size_t
942{
943 return 1;
944}
945
946/** Set x value.
947 * x position of object (meters)
948 * @param new_x new x value
949 */
950void
952{
953 set_field(data->x, new_x);
954}
955
956/** Get y value.
957 * y position of object (meters)
958 * @return y value
959 */
960float
962{
963 return data->y;
964}
965
966/** Get maximum length of y value.
967 * @return length of y value, can be length of the array or number of
968 * maximum number of characters for a string
969 */
970size_t
972{
973 return 1;
974}
975
976/** Set y value.
977 * y position of object (meters)
978 * @param new_y new y value
979 */
980void
982{
983 set_field(data->y, new_y);
984}
985
986/** Get z value.
987 * z position of object (meters)
988 * @return z value
989 */
990float
992{
993 return data->z;
994}
995
996/** Get maximum length of z value.
997 * @return length of z value, can be length of the array or number of
998 * maximum number of characters for a string
999 */
1000size_t
1002{
1003 return 1;
1004}
1005
1006/** Set z value.
1007 * z position of object (meters)
1008 * @param new_z new z value
1009 */
1010void
1012{
1013 set_field(data->z, new_z);
1014}
1015
1016/** Clone this message.
1017 * Produces a message of the same type as this message and copies the
1018 * data to the new message.
1019 * @return clone of this message
1020 */
1021Message *
1023{
1024 return new OpenRaveInterface::MoveObjectMessage(this);
1025}
1026/** @class OpenRaveInterface::RotateObjectQuatMessage <interfaces/OpenRaveInterface.h>
1027 * RotateObjectQuatMessage Fawkes BlackBoard Interface Message.
1028 *
1029
1030 */
1031
1032
1033/** Constructor with initial values.
1034 * @param ini_name initial value for name
1035 * @param ini_x initial value for x
1036 * @param ini_y initial value for y
1037 * @param ini_z initial value for z
1038 * @param ini_w initial value for w
1039 */
1040OpenRaveInterface::RotateObjectQuatMessage::RotateObjectQuatMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z, const float ini_w) : Message("RotateObjectQuatMessage")
1041{
1042 data_size = sizeof(RotateObjectQuatMessage_data_t);
1043 data_ptr = malloc(data_size);
1044 memset(data_ptr, 0, data_size);
1045 data = (RotateObjectQuatMessage_data_t *)data_ptr;
1047 strncpy(data->name, ini_name, 30-1);
1048 data->name[30-1] = 0;
1049 data->x = ini_x;
1050 data->y = ini_y;
1051 data->z = ini_z;
1052 data->w = ini_w;
1053 add_fieldinfo(IFT_STRING, "name", 30, data->name);
1054 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1055 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1056 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1057 add_fieldinfo(IFT_FLOAT, "w", 1, &data->w);
1058}
1059/** Constructor */
1061{
1062 data_size = sizeof(RotateObjectQuatMessage_data_t);
1063 data_ptr = malloc(data_size);
1064 memset(data_ptr, 0, data_size);
1065 data = (RotateObjectQuatMessage_data_t *)data_ptr;
1067 add_fieldinfo(IFT_STRING, "name", 30, data->name);
1068 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1069 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1070 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1071 add_fieldinfo(IFT_FLOAT, "w", 1, &data->w);
1072}
1073
1074/** Destructor */
1076{
1077 free(data_ptr);
1078}
1079
1080/** Copy constructor.
1081 * @param m message to copy from
1082 */
1084{
1085 data_size = m->data_size;
1086 data_ptr = malloc(data_size);
1087 memcpy(data_ptr, m->data_ptr, data_size);
1088 data = (RotateObjectQuatMessage_data_t *)data_ptr;
1090}
1091
1092/* Methods */
1093/** Get name value.
1094 * Name of object
1095 * @return name value
1096 */
1097char *
1099{
1100 return data->name;
1101}
1102
1103/** Get maximum length of name value.
1104 * @return length of name value, can be length of the array or number of
1105 * maximum number of characters for a string
1106 */
1107size_t
1109{
1110 return 30;
1111}
1112
1113/** Set name value.
1114 * Name of object
1115 * @param new_name new name value
1116 */
1117void
1119{
1120 set_field(data->name, new_name);
1121}
1122
1123/** Get x value.
1124 * x value of quaternion
1125 * @return x value
1126 */
1127float
1129{
1130 return data->x;
1131}
1132
1133/** Get maximum length of x value.
1134 * @return length of x value, can be length of the array or number of
1135 * maximum number of characters for a string
1136 */
1137size_t
1139{
1140 return 1;
1141}
1142
1143/** Set x value.
1144 * x value of quaternion
1145 * @param new_x new x value
1146 */
1147void
1149{
1150 set_field(data->x, new_x);
1151}
1152
1153/** Get y value.
1154 * y value of quaternion
1155 * @return y value
1156 */
1157float
1159{
1160 return data->y;
1161}
1162
1163/** Get maximum length of y value.
1164 * @return length of y value, can be length of the array or number of
1165 * maximum number of characters for a string
1166 */
1167size_t
1169{
1170 return 1;
1171}
1172
1173/** Set y value.
1174 * y value of quaternion
1175 * @param new_y new y value
1176 */
1177void
1179{
1180 set_field(data->y, new_y);
1181}
1182
1183/** Get z value.
1184 * z value of quaternion
1185 * @return z value
1186 */
1187float
1189{
1190 return data->z;
1191}
1192
1193/** Get maximum length of z value.
1194 * @return length of z value, can be length of the array or number of
1195 * maximum number of characters for a string
1196 */
1197size_t
1199{
1200 return 1;
1201}
1202
1203/** Set z value.
1204 * z value of quaternion
1205 * @param new_z new z value
1206 */
1207void
1209{
1210 set_field(data->z, new_z);
1211}
1212
1213/** Get w value.
1214 * w value of quaternion
1215 * @return w value
1216 */
1217float
1219{
1220 return data->w;
1221}
1222
1223/** Get maximum length of w value.
1224 * @return length of w value, can be length of the array or number of
1225 * maximum number of characters for a string
1226 */
1227size_t
1229{
1230 return 1;
1231}
1232
1233/** Set w value.
1234 * w value of quaternion
1235 * @param new_w new w value
1236 */
1237void
1239{
1240 set_field(data->w, new_w);
1241}
1242
1243/** Clone this message.
1244 * Produces a message of the same type as this message and copies the
1245 * data to the new message.
1246 * @return clone of this message
1247 */
1248Message *
1250{
1252}
1253/** @class OpenRaveInterface::RotateObjectMessage <interfaces/OpenRaveInterface.h>
1254 * RotateObjectMessage Fawkes BlackBoard Interface Message.
1255 *
1256
1257 */
1258
1259
1260/** Constructor with initial values.
1261 * @param ini_name initial value for name
1262 * @param ini_x initial value for x
1263 * @param ini_y initial value for y
1264 * @param ini_z initial value for z
1265 */
1266OpenRaveInterface::RotateObjectMessage::RotateObjectMessage(const char * ini_name, const float ini_x, const float ini_y, const float ini_z) : Message("RotateObjectMessage")
1267{
1268 data_size = sizeof(RotateObjectMessage_data_t);
1269 data_ptr = malloc(data_size);
1270 memset(data_ptr, 0, data_size);
1271 data = (RotateObjectMessage_data_t *)data_ptr;
1273 strncpy(data->name, ini_name, 30-1);
1274 data->name[30-1] = 0;
1275 data->x = ini_x;
1276 data->y = ini_y;
1277 data->z = ini_z;
1278 add_fieldinfo(IFT_STRING, "name", 30, data->name);
1279 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1280 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1281 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1282}
1283/** Constructor */
1285{
1286 data_size = sizeof(RotateObjectMessage_data_t);
1287 data_ptr = malloc(data_size);
1288 memset(data_ptr, 0, data_size);
1289 data = (RotateObjectMessage_data_t *)data_ptr;
1291 add_fieldinfo(IFT_STRING, "name", 30, data->name);
1292 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1293 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1294 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
1295}
1296
1297/** Destructor */
1299{
1300 free(data_ptr);
1301}
1302
1303/** Copy constructor.
1304 * @param m message to copy from
1305 */
1307{
1308 data_size = m->data_size;
1309 data_ptr = malloc(data_size);
1310 memcpy(data_ptr, m->data_ptr, data_size);
1311 data = (RotateObjectMessage_data_t *)data_ptr;
1313}
1314
1315/* Methods */
1316/** Get name value.
1317 * Name of object
1318 * @return name value
1319 */
1320char *
1322{
1323 return data->name;
1324}
1325
1326/** Get maximum length of name value.
1327 * @return length of name value, can be length of the array or number of
1328 * maximum number of characters for a string
1329 */
1330size_t
1332{
1333 return 30;
1334}
1335
1336/** Set name value.
1337 * Name of object
1338 * @param new_name new name value
1339 */
1340void
1342{
1343 set_field(data->name, new_name);
1344}
1345
1346/** Get x value.
1347 * x-axis rotation of object (rad)
1348 * @return x value
1349 */
1350float
1352{
1353 return data->x;
1354}
1355
1356/** Get maximum length of x value.
1357 * @return length of x value, can be length of the array or number of
1358 * maximum number of characters for a string
1359 */
1360size_t
1362{
1363 return 1;
1364}
1365
1366/** Set x value.
1367 * x-axis rotation of object (rad)
1368 * @param new_x new x value
1369 */
1370void
1372{
1373 set_field(data->x, new_x);
1374}
1375
1376/** Get y value.
1377 * y-axis rotation of object (rad)
1378 * @return y value
1379 */
1380float
1382{
1383 return data->y;
1384}
1385
1386/** Get maximum length of y value.
1387 * @return length of y value, can be length of the array or number of
1388 * maximum number of characters for a string
1389 */
1390size_t
1392{
1393 return 1;
1394}
1395
1396/** Set y value.
1397 * y-axis rotation of object (rad)
1398 * @param new_y new y value
1399 */
1400void
1402{
1403 set_field(data->y, new_y);
1404}
1405
1406/** Get z value.
1407 * z-axis rotation of object (rad)
1408 * @return z value
1409 */
1410float
1412{
1413 return data->z;
1414}
1415
1416/** Get maximum length of z value.
1417 * @return length of z value, can be length of the array or number of
1418 * maximum number of characters for a string
1419 */
1420size_t
1422{
1423 return 1;
1424}
1425
1426/** Set z value.
1427 * z-axis rotation of object (rad)
1428 * @param new_z new z value
1429 */
1430void
1432{
1433 set_field(data->z, new_z);
1434}
1435
1436/** Clone this message.
1437 * Produces a message of the same type as this message and copies the
1438 * data to the new message.
1439 * @return clone of this message
1440 */
1441Message *
1443{
1445}
1446/** @class OpenRaveInterface::RenameObjectMessage <interfaces/OpenRaveInterface.h>
1447 * RenameObjectMessage Fawkes BlackBoard Interface Message.
1448 *
1449
1450 */
1451
1452
1453/** Constructor with initial values.
1454 * @param ini_name initial value for name
1455 * @param ini_newName initial value for newName
1456 */
1457OpenRaveInterface::RenameObjectMessage::RenameObjectMessage(const char * ini_name, const char * ini_newName) : Message("RenameObjectMessage")
1458{
1459 data_size = sizeof(RenameObjectMessage_data_t);
1460 data_ptr = malloc(data_size);
1461 memset(data_ptr, 0, data_size);
1462 data = (RenameObjectMessage_data_t *)data_ptr;
1464 strncpy(data->name, ini_name, 30-1);
1465 data->name[30-1] = 0;
1466 strncpy(data->newName, ini_newName, 30-1);
1467 data->newName[30-1] = 0;
1468 add_fieldinfo(IFT_STRING, "name", 30, data->name);
1469 add_fieldinfo(IFT_STRING, "newName", 30, data->newName);
1470}
1471/** Constructor */
1473{
1474 data_size = sizeof(RenameObjectMessage_data_t);
1475 data_ptr = malloc(data_size);
1476 memset(data_ptr, 0, data_size);
1477 data = (RenameObjectMessage_data_t *)data_ptr;
1479 add_fieldinfo(IFT_STRING, "name", 30, data->name);
1480 add_fieldinfo(IFT_STRING, "newName", 30, data->newName);
1481}
1482
1483/** Destructor */
1485{
1486 free(data_ptr);
1487}
1488
1489/** Copy constructor.
1490 * @param m message to copy from
1491 */
1493{
1494 data_size = m->data_size;
1495 data_ptr = malloc(data_size);
1496 memcpy(data_ptr, m->data_ptr, data_size);
1497 data = (RenameObjectMessage_data_t *)data_ptr;
1499}
1500
1501/* Methods */
1502/** Get name value.
1503 * Name of object
1504 * @return name value
1505 */
1506char *
1508{
1509 return data->name;
1510}
1511
1512/** Get maximum length of name value.
1513 * @return length of name value, can be length of the array or number of
1514 * maximum number of characters for a string
1515 */
1516size_t
1518{
1519 return 30;
1520}
1521
1522/** Set name value.
1523 * Name of object
1524 * @param new_name new name value
1525 */
1526void
1528{
1529 set_field(data->name, new_name);
1530}
1531
1532/** Get newName value.
1533 * New name of object
1534 * @return newName value
1535 */
1536char *
1538{
1539 return data->newName;
1540}
1541
1542/** Get maximum length of newName value.
1543 * @return length of newName value, can be length of the array or number of
1544 * maximum number of characters for a string
1545 */
1546size_t
1548{
1549 return 30;
1550}
1551
1552/** Set newName value.
1553 * New name of object
1554 * @param new_newName new newName value
1555 */
1556void
1558{
1559 set_field(data->newName, new_newName);
1560}
1561
1562/** Clone this message.
1563 * Produces a message of the same type as this message and copies the
1564 * data to the new message.
1565 * @return clone of this message
1566 */
1567Message *
1569{
1571}
1572/** Check if message is valid and can be enqueued.
1573 * @param message Message to check
1574 * @return true if the message is valid, false otherwise.
1575 */
1576bool
1578{
1579 const StartViewerMessage *m0 = dynamic_cast<const StartViewerMessage *>(message);
1580 if ( m0 != NULL ) {
1581 return true;
1582 }
1583 const AddObjectMessage *m1 = dynamic_cast<const AddObjectMessage *>(message);
1584 if ( m1 != NULL ) {
1585 return true;
1586 }
1587 const DeleteObjectMessage *m2 = dynamic_cast<const DeleteObjectMessage *>(message);
1588 if ( m2 != NULL ) {
1589 return true;
1590 }
1591 const DeleteAllObjectsMessage *m3 = dynamic_cast<const DeleteAllObjectsMessage *>(message);
1592 if ( m3 != NULL ) {
1593 return true;
1594 }
1595 const AttachObjectMessage *m4 = dynamic_cast<const AttachObjectMessage *>(message);
1596 if ( m4 != NULL ) {
1597 return true;
1598 }
1599 const ReleaseObjectMessage *m5 = dynamic_cast<const ReleaseObjectMessage *>(message);
1600 if ( m5 != NULL ) {
1601 return true;
1602 }
1603 const ReleaseAllObjectsMessage *m6 = dynamic_cast<const ReleaseAllObjectsMessage *>(message);
1604 if ( m6 != NULL ) {
1605 return true;
1606 }
1607 const MoveObjectMessage *m7 = dynamic_cast<const MoveObjectMessage *>(message);
1608 if ( m7 != NULL ) {
1609 return true;
1610 }
1611 const RotateObjectQuatMessage *m8 = dynamic_cast<const RotateObjectQuatMessage *>(message);
1612 if ( m8 != NULL ) {
1613 return true;
1614 }
1615 const RotateObjectMessage *m9 = dynamic_cast<const RotateObjectMessage *>(message);
1616 if ( m9 != NULL ) {
1617 return true;
1618 }
1619 const RenameObjectMessage *m10 = dynamic_cast<const RenameObjectMessage *>(message);
1620 if ( m10 != NULL ) {
1621 return true;
1622 }
1623 return false;
1624}
1625
1626/// @cond INTERNALS
1627EXPORT_INTERFACE(OpenRaveInterface)
1628/// @endcond
1629
1630
1631} // end namespace fawkes
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:244
void set_field(FieldT &field, DataT &data)
Set a field, set data_changed to true and update data_changed accordingly.
Definition: interface.h:304
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
Definition: message.cpp:435
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:146
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:156
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:147
AddObjectMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
size_t maxlenof_name() const
Get maximum length of name value.
void set_path(const char *new_path)
Set path value.
size_t maxlenof_path() const
Get maximum length of path value.
void set_name(const char *new_name)
Set name value.
AttachObjectMessage Fawkes BlackBoard Interface Message.
void set_manip_name(const char *new_manip_name)
Set manip_name value.
char * manip_name() const
Get manip_name value.
virtual Message * clone() const
Clone this message.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_manip_name() const
Get maximum length of manip_name value.
size_t maxlenof_name() const
Get maximum length of name value.
DeleteAllObjectsMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
DeleteObjectMessage Fawkes BlackBoard Interface Message.
void set_name(const char *new_name)
Set name value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_name() const
Get maximum length of name value.
MoveObjectMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_z(const float new_z)
Set z value.
void set_x(const float new_x)
Set x value.
size_t maxlenof_x() const
Get maximum length of x 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_name() const
Get maximum length of name value.
void set_y(const float new_y)
Set y value.
size_t maxlenof_y() const
Get maximum length of y value.
ReleaseAllObjectsMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
ReleaseObjectMessage Fawkes BlackBoard Interface Message.
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_name() const
Get maximum length of name value.
size_t maxlenof_newName() const
Get maximum length of newName value.
void set_name(const char *new_name)
Set name value.
void set_newName(const char *new_newName)
Set newName value.
virtual Message * clone() const
Clone this message.
RotateObjectMessage 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.
void set_x(const float new_x)
Set x value.
void set_name(const char *new_name)
Set name value.
virtual Message * clone() const
Clone this message.
void set_z(const float new_z)
Set z value.
size_t maxlenof_x() const
Get maximum length of x value.
size_t maxlenof_y() const
Get maximum length of y value.
size_t maxlenof_name() const
Get maximum length of name value.
RotateObjectQuatMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
size_t maxlenof_x() const
Get maximum length of x value.
size_t maxlenof_name() const
Get maximum length of name value.
size_t maxlenof_w() const
Get maximum length of w value.
size_t maxlenof_z() const
Get maximum length of z value.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_y() const
Get maximum length of y value.
StartViewerMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
OpenRaveInterface Fawkes BlackBoard Interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Fawkes library namespace.
@ IFT_FLOAT
float field
Definition: types.h:46
@ IFT_STRING
string field
Definition: types.h:48
Timestamp data, must be present and first entries for each interface data structs!...
Definition: message.h:152