Fawkes API  Fawkes Development Version
MotorInterface.cpp
1 
2 /***************************************************************************
3  * MotorInterface.cpp - Fawkes BlackBoard Interface - MotorInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2007 Martin Liebenberg, Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <interfaces/MotorInterface.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 MotorInterface <interfaces/MotorInterface.h>
36  * MotorInterface Fawkes BlackBoard Interface.
37  * This interface is currently prepared best for a holonomic robot.
38  It will need modifications or a split to support differential drives.
39 
40  * @ingroup FawkesInterfaces
41  */
42 
43 
44 /** MOTOR_ENABLED constant */
45 const uint32_t MotorInterface::MOTOR_ENABLED = 0u;
46 /** MOTOR_DISABLED constant */
47 const uint32_t MotorInterface::MOTOR_DISABLED = 1u;
48 /** DRIVE_MODE_RPM constant */
49 const uint32_t MotorInterface::DRIVE_MODE_RPM = 1u;
50 /** DRIVE_MODE_TRANS constant */
51 const uint32_t MotorInterface::DRIVE_MODE_TRANS = 2u;
52 /** DRIVE_MODE_ROT constant */
53 const uint32_t MotorInterface::DRIVE_MODE_ROT = 3u;
54 /** DRIVE_MODE_TRANS_ROT constant */
55 const uint32_t MotorInterface::DRIVE_MODE_TRANS_ROT = 4u;
56 /** DRIVE_MODE_ORBIT constant */
57 const uint32_t MotorInterface::DRIVE_MODE_ORBIT = 5u;
58 /** DRIVE_MODE_LINE_TRANS_ROT constant */
60 
61 /** Constructor */
62 MotorInterface::MotorInterface() : Interface()
63 {
64  data_size = sizeof(MotorInterface_data_t);
65  data_ptr = malloc(data_size);
66  data = (MotorInterface_data_t *)data_ptr;
67  data_ts = (interface_data_ts_t *)data_ptr;
68  memset(data_ptr, 0, data_size);
69  add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state);
70  add_fieldinfo(IFT_UINT32, "drive_mode", 1, &data->drive_mode);
71  add_fieldinfo(IFT_INT32, "right_rpm", 1, &data->right_rpm);
72  add_fieldinfo(IFT_INT32, "rear_rpm", 1, &data->rear_rpm);
73  add_fieldinfo(IFT_INT32, "left_rpm", 1, &data->left_rpm);
74  add_fieldinfo(IFT_FLOAT, "odometry_path_length", 1, &data->odometry_path_length);
75  add_fieldinfo(IFT_FLOAT, "odometry_position_x", 1, &data->odometry_position_x);
76  add_fieldinfo(IFT_FLOAT, "odometry_position_y", 1, &data->odometry_position_y);
77  add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
78  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
79  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
80  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
81  add_fieldinfo(IFT_FLOAT, "des_vx", 1, &data->des_vx);
82  add_fieldinfo(IFT_FLOAT, "des_vy", 1, &data->des_vy);
83  add_fieldinfo(IFT_FLOAT, "des_omega", 1, &data->des_omega);
84  add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller);
85  add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
86  add_messageinfo("SetMotorStateMessage");
87  add_messageinfo("AcquireControlMessage");
88  add_messageinfo("ResetOdometryMessage");
89  add_messageinfo("SetOdometryMessage");
90  add_messageinfo("DriveRPMMessage");
91  add_messageinfo("GotoMessage");
92  add_messageinfo("TransMessage");
93  add_messageinfo("RotMessage");
94  add_messageinfo("TransRotMessage");
95  add_messageinfo("OrbitMessage");
96  add_messageinfo("LinTransRotMessage");
97  unsigned char tmp_hash[] = {0x62, 0x6c, 0x3f, 0x33, 0x1c, 0x3a, 0x9e, 0x18, 0xd5, 0xee, 0xab, 0x30, 0xfb, 0x10, 0xf0, 0x79};
98  set_hash(tmp_hash);
99 }
100 
101 /** Destructor */
102 MotorInterface::~MotorInterface()
103 {
104  free(data_ptr);
105 }
106 /* Methods */
107 /** Get motor_state value.
108  *
109  The current state of the motor.
110 
111  * @return motor_state value
112  */
113 uint32_t
115 {
116  return data->motor_state;
117 }
118 
119 /** Get maximum length of motor_state value.
120  * @return length of motor_state value, can be length of the array or number of
121  * maximum number of characters for a string
122  */
123 size_t
125 {
126  return 1;
127 }
128 
129 /** Set motor_state value.
130  *
131  The current state of the motor.
132 
133  * @param new_motor_state new motor_state value
134  */
135 void
136 MotorInterface::set_motor_state(const uint32_t new_motor_state)
137 {
138  data->motor_state = new_motor_state;
139  data_changed = true;
140 }
141 
142 /** Get drive_mode value.
143  *
144  The current drive mode of the motor.
145 
146  * @return drive_mode value
147  */
148 uint32_t
150 {
151  return data->drive_mode;
152 }
153 
154 /** Get maximum length of drive_mode value.
155  * @return length of drive_mode value, can be length of the array or number of
156  * maximum number of characters for a string
157  */
158 size_t
160 {
161  return 1;
162 }
163 
164 /** Set drive_mode value.
165  *
166  The current drive mode of the motor.
167 
168  * @param new_drive_mode new drive_mode value
169  */
170 void
171 MotorInterface::set_drive_mode(const uint32_t new_drive_mode)
172 {
173  data->drive_mode = new_drive_mode;
174  data_changed = true;
175 }
176 
177 /** Get right_rpm value.
178  *
179  RPM of the motor on the right front of the robot.
180 
181  * @return right_rpm value
182  */
183 int32_t
185 {
186  return data->right_rpm;
187 }
188 
189 /** Get maximum length of right_rpm value.
190  * @return length of right_rpm 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 right_rpm value.
200  *
201  RPM of the motor on the right front of the robot.
202 
203  * @param new_right_rpm new right_rpm value
204  */
205 void
206 MotorInterface::set_right_rpm(const int32_t new_right_rpm)
207 {
208  data->right_rpm = new_right_rpm;
209  data_changed = true;
210 }
211 
212 /** Get rear_rpm value.
213  *
214  RPM of motor on the rear of the robot.
215 
216  * @return rear_rpm value
217  */
218 int32_t
220 {
221  return data->rear_rpm;
222 }
223 
224 /** Get maximum length of rear_rpm value.
225  * @return length of rear_rpm value, can be length of the array or number of
226  * maximum number of characters for a string
227  */
228 size_t
230 {
231  return 1;
232 }
233 
234 /** Set rear_rpm value.
235  *
236  RPM of motor on the rear of the robot.
237 
238  * @param new_rear_rpm new rear_rpm value
239  */
240 void
241 MotorInterface::set_rear_rpm(const int32_t new_rear_rpm)
242 {
243  data->rear_rpm = new_rear_rpm;
244  data_changed = true;
245 }
246 
247 /** Get left_rpm value.
248  *
249  RPM of the motor on the left front of the robot.
250 
251  * @return left_rpm value
252  */
253 int32_t
255 {
256  return data->left_rpm;
257 }
258 
259 /** Get maximum length of left_rpm value.
260  * @return length of left_rpm value, can be length of the array or number of
261  * maximum number of characters for a string
262  */
263 size_t
265 {
266  return 1;
267 }
268 
269 /** Set left_rpm value.
270  *
271  RPM of the motor on the left front of the robot.
272 
273  * @param new_left_rpm new left_rpm value
274  */
275 void
276 MotorInterface::set_left_rpm(const int32_t new_left_rpm)
277 {
278  data->left_rpm = new_left_rpm;
279  data_changed = true;
280 }
281 
282 /** Get odometry_path_length value.
283  *
284  The actual length of the robot's trajectory since the last ResetOdometry.
285 
286  * @return odometry_path_length value
287  */
288 float
290 {
291  return data->odometry_path_length;
292 }
293 
294 /** Get maximum length of odometry_path_length value.
295  * @return length of odometry_path_length value, can be length of the array or number of
296  * maximum number of characters for a string
297  */
298 size_t
300 {
301  return 1;
302 }
303 
304 /** Set odometry_path_length value.
305  *
306  The actual length of the robot's trajectory since the last ResetOdometry.
307 
308  * @param new_odometry_path_length new odometry_path_length value
309  */
310 void
311 MotorInterface::set_odometry_path_length(const float new_odometry_path_length)
312 {
313  data->odometry_path_length = new_odometry_path_length;
314  data_changed = true;
315 }
316 
317 /** Get odometry_position_x value.
318  *
319  The actual position of the robot relative to the position at the last ResetOdometry.
320 
321  * @return odometry_position_x value
322  */
323 float
325 {
326  return data->odometry_position_x;
327 }
328 
329 /** Get maximum length of odometry_position_x value.
330  * @return length of odometry_position_x value, can be length of the array or number of
331  * maximum number of characters for a string
332  */
333 size_t
335 {
336  return 1;
337 }
338 
339 /** Set odometry_position_x value.
340  *
341  The actual position of the robot relative to the position at the last ResetOdometry.
342 
343  * @param new_odometry_position_x new odometry_position_x value
344  */
345 void
346 MotorInterface::set_odometry_position_x(const float new_odometry_position_x)
347 {
348  data->odometry_position_x = new_odometry_position_x;
349  data_changed = true;
350 }
351 
352 /** Get odometry_position_y value.
353  *
354  The actual position of the robot relative to the position at the last ResetOdometry.
355 
356  * @return odometry_position_y value
357  */
358 float
360 {
361  return data->odometry_position_y;
362 }
363 
364 /** Get maximum length of odometry_position_y value.
365  * @return length of odometry_position_y value, can be length of the array or number of
366  * maximum number of characters for a string
367  */
368 size_t
370 {
371  return 1;
372 }
373 
374 /** Set odometry_position_y value.
375  *
376  The actual position of the robot relative to the position at the last ResetOdometry.
377 
378  * @param new_odometry_position_y new odometry_position_y value
379  */
380 void
381 MotorInterface::set_odometry_position_y(const float new_odometry_position_y)
382 {
383  data->odometry_position_y = new_odometry_position_y;
384  data_changed = true;
385 }
386 
387 /** Get odometry_orientation value.
388  *
389  The actual orientation of the robot relative to the orientation at the last ResetOdometry.
390 
391  * @return odometry_orientation value
392  */
393 float
395 {
396  return data->odometry_orientation;
397 }
398 
399 /** Get maximum length of odometry_orientation value.
400  * @return length of odometry_orientation value, can be length of the array or number of
401  * maximum number of characters for a string
402  */
403 size_t
405 {
406  return 1;
407 }
408 
409 /** Set odometry_orientation value.
410  *
411  The actual orientation of the robot relative to the orientation at the last ResetOdometry.
412 
413  * @param new_odometry_orientation new odometry_orientation value
414  */
415 void
416 MotorInterface::set_odometry_orientation(const float new_odometry_orientation)
417 {
418  data->odometry_orientation = new_odometry_orientation;
419  data_changed = true;
420 }
421 
422 /** Get vx value.
423  *
424  VX of the robot in m/s. Forward.
425 
426  * @return vx value
427  */
428 float
430 {
431  return data->vx;
432 }
433 
434 /** Get maximum length of vx value.
435  * @return length of vx value, can be length of the array or number of
436  * maximum number of characters for a string
437  */
438 size_t
440 {
441  return 1;
442 }
443 
444 /** Set vx value.
445  *
446  VX of the robot in m/s. Forward.
447 
448  * @param new_vx new vx value
449  */
450 void
451 MotorInterface::set_vx(const float new_vx)
452 {
453  data->vx = new_vx;
454  data_changed = true;
455 }
456 
457 /** Get vy value.
458  *
459  VY of the robot in m/s. Left.
460 
461  * @return vy value
462  */
463 float
465 {
466  return data->vy;
467 }
468 
469 /** Get maximum length of vy value.
470  * @return length of vy value, can be length of the array or number of
471  * maximum number of characters for a string
472  */
473 size_t
475 {
476  return 1;
477 }
478 
479 /** Set vy value.
480  *
481  VY of the robot in m/s. Left.
482 
483  * @param new_vy new vy value
484  */
485 void
486 MotorInterface::set_vy(const float new_vy)
487 {
488  data->vy = new_vy;
489  data_changed = true;
490 }
491 
492 /** Get omega value.
493  *
494  Rotation speed of the robot in rad/s.
495 
496  * @return omega value
497  */
498 float
500 {
501  return data->omega;
502 }
503 
504 /** Get maximum length of omega value.
505  * @return length of omega value, can be length of the array or number of
506  * maximum number of characters for a string
507  */
508 size_t
510 {
511  return 1;
512 }
513 
514 /** Set omega value.
515  *
516  Rotation speed of the robot in rad/s.
517 
518  * @param new_omega new omega value
519  */
520 void
521 MotorInterface::set_omega(const float new_omega)
522 {
523  data->omega = new_omega;
524  data_changed = true;
525 }
526 
527 /** Get des_vx value.
528  *
529  Desired VX of the robot in m/s. Forward.
530 
531  * @return des_vx value
532  */
533 float
535 {
536  return data->des_vx;
537 }
538 
539 /** Get maximum length of des_vx value.
540  * @return length of des_vx value, can be length of the array or number of
541  * maximum number of characters for a string
542  */
543 size_t
545 {
546  return 1;
547 }
548 
549 /** Set des_vx value.
550  *
551  Desired VX of the robot in m/s. Forward.
552 
553  * @param new_des_vx new des_vx value
554  */
555 void
556 MotorInterface::set_des_vx(const float new_des_vx)
557 {
558  data->des_vx = new_des_vx;
559  data_changed = true;
560 }
561 
562 /** Get des_vy value.
563  *
564  Desired VY of the robot in m/s. Left.
565 
566  * @return des_vy value
567  */
568 float
570 {
571  return data->des_vy;
572 }
573 
574 /** Get maximum length of des_vy value.
575  * @return length of des_vy value, can be length of the array or number of
576  * maximum number of characters for a string
577  */
578 size_t
580 {
581  return 1;
582 }
583 
584 /** Set des_vy value.
585  *
586  Desired VY of the robot in m/s. Left.
587 
588  * @param new_des_vy new des_vy value
589  */
590 void
591 MotorInterface::set_des_vy(const float new_des_vy)
592 {
593  data->des_vy = new_des_vy;
594  data_changed = true;
595 }
596 
597 /** Get des_omega value.
598  *
599  Desired Rotation speed of the robot in rad/s.
600 
601  * @return des_omega value
602  */
603 float
605 {
606  return data->des_omega;
607 }
608 
609 /** Get maximum length of des_omega value.
610  * @return length of des_omega value, can be length of the array or number of
611  * maximum number of characters for a string
612  */
613 size_t
615 {
616  return 1;
617 }
618 
619 /** Set des_omega value.
620  *
621  Desired Rotation speed of the robot in rad/s.
622 
623  * @param new_des_omega new des_omega value
624  */
625 void
626 MotorInterface::set_des_omega(const float new_des_omega)
627 {
628  data->des_omega = new_des_omega;
629  data_changed = true;
630 }
631 
632 /** Get controller value.
633  *
634  The ID of the controller. The controller ID is the instance serial of the sending
635  interface. Only from this interface instance command messages are accepted.
636 
637  * @return controller value
638  */
639 uint32_t
641 {
642  return data->controller;
643 }
644 
645 /** Get maximum length of controller value.
646  * @return length of controller value, can be length of the array or number of
647  * maximum number of characters for a string
648  */
649 size_t
651 {
652  return 1;
653 }
654 
655 /** Set controller value.
656  *
657  The ID of the controller. The controller ID is the instance serial of the sending
658  interface. Only from this interface instance command messages are accepted.
659 
660  * @param new_controller new controller value
661  */
662 void
663 MotorInterface::set_controller(const uint32_t new_controller)
664 {
665  data->controller = new_controller;
666  data_changed = true;
667 }
668 
669 /** Get controller_thread_name value.
670  *
671  The name of the controlling thread, for easier debugging. This is informative only
672  and actually two threads may share an interface instance (although this should be
673  avoided since the interface locking has to be reproduced for these threads then).
674 
675  * @return controller_thread_name value
676  */
677 char *
679 {
680  return data->controller_thread_name;
681 }
682 
683 /** Get maximum length of controller_thread_name value.
684  * @return length of controller_thread_name value, can be length of the array or number of
685  * maximum number of characters for a string
686  */
687 size_t
689 {
690  return 64;
691 }
692 
693 /** Set controller_thread_name value.
694  *
695  The name of the controlling thread, for easier debugging. This is informative only
696  and actually two threads may share an interface instance (although this should be
697  avoided since the interface locking has to be reproduced for these threads then).
698 
699  * @param new_controller_thread_name new controller_thread_name value
700  */
701 void
702 MotorInterface::set_controller_thread_name(const char * new_controller_thread_name)
703 {
704  strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
705  data_changed = true;
706 }
707 
708 /* =========== message create =========== */
709 Message *
711 {
712  if ( strncmp("SetMotorStateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
713  return new SetMotorStateMessage();
714  } else if ( strncmp("AcquireControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
715  return new AcquireControlMessage();
716  } else if ( strncmp("ResetOdometryMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
717  return new ResetOdometryMessage();
718  } else if ( strncmp("SetOdometryMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
719  return new SetOdometryMessage();
720  } else if ( strncmp("DriveRPMMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
721  return new DriveRPMMessage();
722  } else if ( strncmp("GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
723  return new GotoMessage();
724  } else if ( strncmp("TransMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
725  return new TransMessage();
726  } else if ( strncmp("RotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
727  return new RotMessage();
728  } else if ( strncmp("TransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
729  return new TransRotMessage();
730  } else if ( strncmp("OrbitMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
731  return new OrbitMessage();
732  } else if ( strncmp("LinTransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
733  return new LinTransRotMessage();
734  } else {
735  throw UnknownTypeException("The given type '%s' does not match any known "
736  "message type for this interface type.", type);
737  }
738 }
739 
740 
741 /** Copy values from other interface.
742  * @param other other interface to copy values from
743  */
744 void
746 {
747  const MotorInterface *oi = dynamic_cast<const MotorInterface *>(other);
748  if (oi == NULL) {
749  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
750  type(), other->type());
751  }
752  memcpy(data, oi->data, sizeof(MotorInterface_data_t));
753 }
754 
755 const char *
756 MotorInterface::enum_tostring(const char *enumtype, int val) const
757 {
758  throw UnknownTypeException("Unknown enum type %s", enumtype);
759 }
760 
761 /* =========== messages =========== */
762 /** @class MotorInterface::SetMotorStateMessage <interfaces/MotorInterface.h>
763  * SetMotorStateMessage Fawkes BlackBoard Interface Message.
764  *
765 
766  */
767 
768 
769 /** Constructor with initial values.
770  * @param ini_motor_state initial value for motor_state
771  */
772 MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const uint32_t ini_motor_state) : Message("SetMotorStateMessage")
773 {
774  data_size = sizeof(SetMotorStateMessage_data_t);
775  data_ptr = malloc(data_size);
776  memset(data_ptr, 0, data_size);
777  data = (SetMotorStateMessage_data_t *)data_ptr;
779  data->motor_state = ini_motor_state;
780  add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state);
781 }
782 /** Constructor */
784 {
785  data_size = sizeof(SetMotorStateMessage_data_t);
786  data_ptr = malloc(data_size);
787  memset(data_ptr, 0, data_size);
788  data = (SetMotorStateMessage_data_t *)data_ptr;
790  add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state);
791 }
792 
793 /** Destructor */
795 {
796  free(data_ptr);
797 }
798 
799 /** Copy constructor.
800  * @param m message to copy from
801  */
803 {
804  data_size = m->data_size;
805  data_ptr = malloc(data_size);
806  memcpy(data_ptr, m->data_ptr, data_size);
807  data = (SetMotorStateMessage_data_t *)data_ptr;
809 }
810 
811 /* Methods */
812 /** Get motor_state value.
813  *
814  The new motor state to set. Use the MOTOR_* constants.
815 
816  * @return motor_state value
817  */
818 uint32_t
820 {
821  return data->motor_state;
822 }
823 
824 /** Get maximum length of motor_state value.
825  * @return length of motor_state value, can be length of the array or number of
826  * maximum number of characters for a string
827  */
828 size_t
830 {
831  return 1;
832 }
833 
834 /** Set motor_state value.
835  *
836  The new motor state to set. Use the MOTOR_* constants.
837 
838  * @param new_motor_state new motor_state value
839  */
840 void
842 {
843  data->motor_state = new_motor_state;
844 }
845 
846 /** Clone this message.
847  * Produces a message of the same type as this message and copies the
848  * data to the new message.
849  * @return clone of this message
850  */
851 Message *
853 {
854  return new MotorInterface::SetMotorStateMessage(this);
855 }
856 /** @class MotorInterface::AcquireControlMessage <interfaces/MotorInterface.h>
857  * AcquireControlMessage Fawkes BlackBoard Interface Message.
858  *
859 
860  */
861 
862 
863 /** Constructor with initial values.
864  * @param ini_controller initial value for controller
865  * @param ini_controller_thread_name initial value for controller_thread_name
866  */
867 MotorInterface::AcquireControlMessage::AcquireControlMessage(const uint32_t ini_controller, const char * ini_controller_thread_name) : Message("AcquireControlMessage")
868 {
869  data_size = sizeof(AcquireControlMessage_data_t);
870  data_ptr = malloc(data_size);
871  memset(data_ptr, 0, data_size);
872  data = (AcquireControlMessage_data_t *)data_ptr;
874  data->controller = ini_controller;
875  strncpy(data->controller_thread_name, ini_controller_thread_name, 64);
876  add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller);
877  add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
878 }
879 /** Constructor */
881 {
882  data_size = sizeof(AcquireControlMessage_data_t);
883  data_ptr = malloc(data_size);
884  memset(data_ptr, 0, data_size);
885  data = (AcquireControlMessage_data_t *)data_ptr;
887  add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller);
888  add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
889 }
890 
891 /** Destructor */
893 {
894  free(data_ptr);
895 }
896 
897 /** Copy constructor.
898  * @param m message to copy from
899  */
901 {
902  data_size = m->data_size;
903  data_ptr = malloc(data_size);
904  memcpy(data_ptr, m->data_ptr, data_size);
905  data = (AcquireControlMessage_data_t *)data_ptr;
907 }
908 
909 /* Methods */
910 /** Get controller value.
911  *
912  The ID of the controller. The controller ID is the instance serial of the sending
913  interface. Only from this interface instance command messages are accepted.
914 
915  * @return controller value
916  */
917 uint32_t
919 {
920  return data->controller;
921 }
922 
923 /** Get maximum length of controller value.
924  * @return length of controller value, can be length of the array or number of
925  * maximum number of characters for a string
926  */
927 size_t
929 {
930  return 1;
931 }
932 
933 /** Set controller value.
934  *
935  The ID of the controller. The controller ID is the instance serial of the sending
936  interface. Only from this interface instance command messages are accepted.
937 
938  * @param new_controller new controller value
939  */
940 void
942 {
943  data->controller = new_controller;
944 }
945 
946 /** Get controller_thread_name value.
947  *
948  The name of the controlling thread, for easier debugging. This is informative only
949  and actually two threads may share an interface instance (although this should be
950  avoided since the interface locking has to be reproduced for these threads then).
951 
952  * @return controller_thread_name value
953  */
954 char *
956 {
957  return data->controller_thread_name;
958 }
959 
960 /** Get maximum length of controller_thread_name value.
961  * @return length of controller_thread_name value, can be length of the array or number of
962  * maximum number of characters for a string
963  */
964 size_t
966 {
967  return 64;
968 }
969 
970 /** Set controller_thread_name value.
971  *
972  The name of the controlling thread, for easier debugging. This is informative only
973  and actually two threads may share an interface instance (although this should be
974  avoided since the interface locking has to be reproduced for these threads then).
975 
976  * @param new_controller_thread_name new controller_thread_name value
977  */
978 void
980 {
981  strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
982 }
983 
984 /** Clone this message.
985  * Produces a message of the same type as this message and copies the
986  * data to the new message.
987  * @return clone of this message
988  */
989 Message *
991 {
992  return new MotorInterface::AcquireControlMessage(this);
993 }
994 /** @class MotorInterface::ResetOdometryMessage <interfaces/MotorInterface.h>
995  * ResetOdometryMessage Fawkes BlackBoard Interface Message.
996  *
997 
998  */
999 
1000 
1001 /** Constructor */
1003 {
1004  data_size = sizeof(ResetOdometryMessage_data_t);
1005  data_ptr = malloc(data_size);
1006  memset(data_ptr, 0, data_size);
1007  data = (ResetOdometryMessage_data_t *)data_ptr;
1009 }
1010 
1011 /** Destructor */
1013 {
1014  free(data_ptr);
1015 }
1016 
1017 /** Copy constructor.
1018  * @param m message to copy from
1019  */
1021 {
1022  data_size = m->data_size;
1023  data_ptr = malloc(data_size);
1024  memcpy(data_ptr, m->data_ptr, data_size);
1025  data = (ResetOdometryMessage_data_t *)data_ptr;
1027 }
1028 
1029 /* Methods */
1030 /** Clone this message.
1031  * Produces a message of the same type as this message and copies the
1032  * data to the new message.
1033  * @return clone of this message
1034  */
1035 Message *
1037 {
1038  return new MotorInterface::ResetOdometryMessage(this);
1039 }
1040 /** @class MotorInterface::SetOdometryMessage <interfaces/MotorInterface.h>
1041  * SetOdometryMessage Fawkes BlackBoard Interface Message.
1042  *
1043 
1044  */
1045 
1046 
1047 /** Constructor with initial values.
1048  * @param ini_x initial value for x
1049  * @param ini_y initial value for y
1050  * @param ini_odometry_orientation initial value for odometry_orientation
1051  */
1052 MotorInterface::SetOdometryMessage::SetOdometryMessage(const float ini_x, const float ini_y, const float ini_odometry_orientation) : Message("SetOdometryMessage")
1053 {
1054  data_size = sizeof(SetOdometryMessage_data_t);
1055  data_ptr = malloc(data_size);
1056  memset(data_ptr, 0, data_size);
1057  data = (SetOdometryMessage_data_t *)data_ptr;
1059  data->x = ini_x;
1060  data->y = ini_y;
1061  data->odometry_orientation = ini_odometry_orientation;
1062  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1063  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1064  add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
1065 }
1066 /** Constructor */
1068 {
1069  data_size = sizeof(SetOdometryMessage_data_t);
1070  data_ptr = malloc(data_size);
1071  memset(data_ptr, 0, data_size);
1072  data = (SetOdometryMessage_data_t *)data_ptr;
1074  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1075  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1076  add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
1077 }
1078 
1079 /** Destructor */
1081 {
1082  free(data_ptr);
1083 }
1084 
1085 /** Copy constructor.
1086  * @param m message to copy from
1087  */
1089 {
1090  data_size = m->data_size;
1091  data_ptr = malloc(data_size);
1092  memcpy(data_ptr, m->data_ptr, data_size);
1093  data = (SetOdometryMessage_data_t *)data_ptr;
1095 }
1096 
1097 /* Methods */
1098 /** Get x value.
1099  * Translation in x direction in m
1100  * @return x value
1101  */
1102 float
1104 {
1105  return data->x;
1106 }
1107 
1108 /** Get maximum length of x value.
1109  * @return length of x value, can be length of the array or number of
1110  * maximum number of characters for a string
1111  */
1112 size_t
1114 {
1115  return 1;
1116 }
1117 
1118 /** Set x value.
1119  * Translation in x direction in m
1120  * @param new_x new x value
1121  */
1122 void
1124 {
1125  data->x = new_x;
1126 }
1127 
1128 /** Get y value.
1129  * Translation in y direction in m
1130  * @return y value
1131  */
1132 float
1134 {
1135  return data->y;
1136 }
1137 
1138 /** Get maximum length of y value.
1139  * @return length of y value, can be length of the array or number of
1140  * maximum number of characters for a string
1141  */
1142 size_t
1144 {
1145  return 1;
1146 }
1147 
1148 /** Set y value.
1149  * Translation in y direction in m
1150  * @param new_y new y value
1151  */
1152 void
1154 {
1155  data->y = new_y;
1156 }
1157 
1158 /** Get odometry_orientation value.
1159  * OdometryOrientation in m
1160  * @return odometry_orientation value
1161  */
1162 float
1164 {
1165  return data->odometry_orientation;
1166 }
1167 
1168 /** Get maximum length of odometry_orientation value.
1169  * @return length of odometry_orientation value, can be length of the array or number of
1170  * maximum number of characters for a string
1171  */
1172 size_t
1174 {
1175  return 1;
1176 }
1177 
1178 /** Set odometry_orientation value.
1179  * OdometryOrientation in m
1180  * @param new_odometry_orientation new odometry_orientation value
1181  */
1182 void
1184 {
1185  data->odometry_orientation = new_odometry_orientation;
1186 }
1187 
1188 /** Clone this message.
1189  * Produces a message of the same type as this message and copies the
1190  * data to the new message.
1191  * @return clone of this message
1192  */
1193 Message *
1195 {
1196  return new MotorInterface::SetOdometryMessage(this);
1197 }
1198 /** @class MotorInterface::DriveRPMMessage <interfaces/MotorInterface.h>
1199  * DriveRPMMessage Fawkes BlackBoard Interface Message.
1200  *
1201 
1202  */
1203 
1204 
1205 /** Constructor with initial values.
1206  * @param ini_front_right initial value for front_right
1207  * @param ini_front_left initial value for front_left
1208  * @param ini_rear initial value for rear
1209  */
1210 MotorInterface::DriveRPMMessage::DriveRPMMessage(const float ini_front_right, const float ini_front_left, const float ini_rear) : Message("DriveRPMMessage")
1211 {
1212  data_size = sizeof(DriveRPMMessage_data_t);
1213  data_ptr = malloc(data_size);
1214  memset(data_ptr, 0, data_size);
1215  data = (DriveRPMMessage_data_t *)data_ptr;
1217  data->front_right = ini_front_right;
1218  data->front_left = ini_front_left;
1219  data->rear = ini_rear;
1220  add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
1221  add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
1222  add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
1223 }
1224 /** Constructor */
1226 {
1227  data_size = sizeof(DriveRPMMessage_data_t);
1228  data_ptr = malloc(data_size);
1229  memset(data_ptr, 0, data_size);
1230  data = (DriveRPMMessage_data_t *)data_ptr;
1232  add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
1233  add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
1234  add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
1235 }
1236 
1237 /** Destructor */
1239 {
1240  free(data_ptr);
1241 }
1242 
1243 /** Copy constructor.
1244  * @param m message to copy from
1245  */
1247 {
1248  data_size = m->data_size;
1249  data_ptr = malloc(data_size);
1250  memcpy(data_ptr, m->data_ptr, data_size);
1251  data = (DriveRPMMessage_data_t *)data_ptr;
1253 }
1254 
1255 /* Methods */
1256 /** Get front_right value.
1257  * Rotation in RPM of the right front wheel.
1258  * @return front_right value
1259  */
1260 float
1262 {
1263  return data->front_right;
1264 }
1265 
1266 /** Get maximum length of front_right value.
1267  * @return length of front_right value, can be length of the array or number of
1268  * maximum number of characters for a string
1269  */
1270 size_t
1272 {
1273  return 1;
1274 }
1275 
1276 /** Set front_right value.
1277  * Rotation in RPM of the right front wheel.
1278  * @param new_front_right new front_right value
1279  */
1280 void
1282 {
1283  data->front_right = new_front_right;
1284 }
1285 
1286 /** Get front_left value.
1287  * Rotation in RPM of the left front wheel.
1288  * @return front_left value
1289  */
1290 float
1292 {
1293  return data->front_left;
1294 }
1295 
1296 /** Get maximum length of front_left value.
1297  * @return length of front_left value, can be length of the array or number of
1298  * maximum number of characters for a string
1299  */
1300 size_t
1302 {
1303  return 1;
1304 }
1305 
1306 /** Set front_left value.
1307  * Rotation in RPM of the left front wheel.
1308  * @param new_front_left new front_left value
1309  */
1310 void
1312 {
1313  data->front_left = new_front_left;
1314 }
1315 
1316 /** Get rear value.
1317  * Rotation in RPM of the rear wheel.
1318  * @return rear value
1319  */
1320 float
1322 {
1323  return data->rear;
1324 }
1325 
1326 /** Get maximum length of rear value.
1327  * @return length of rear value, can be length of the array or number of
1328  * maximum number of characters for a string
1329  */
1330 size_t
1332 {
1333  return 1;
1334 }
1335 
1336 /** Set rear value.
1337  * Rotation in RPM of the rear wheel.
1338  * @param new_rear new rear value
1339  */
1340 void
1342 {
1343  data->rear = new_rear;
1344 }
1345 
1346 /** Clone this message.
1347  * Produces a message of the same type as this message and copies the
1348  * data to the new message.
1349  * @return clone of this message
1350  */
1351 Message *
1353 {
1354  return new MotorInterface::DriveRPMMessage(this);
1355 }
1356 /** @class MotorInterface::GotoMessage <interfaces/MotorInterface.h>
1357  * GotoMessage Fawkes BlackBoard Interface Message.
1358  *
1359 
1360  */
1361 
1362 
1363 /** Constructor with initial values.
1364  * @param ini_x initial value for x
1365  * @param ini_y initial value for y
1366  * @param ini_phi initial value for phi
1367  * @param ini_time_sec initial value for time_sec
1368  */
1369 MotorInterface::GotoMessage::GotoMessage(const float ini_x, const float ini_y, const float ini_phi, const float ini_time_sec) : Message("GotoMessage")
1370 {
1371  data_size = sizeof(GotoMessage_data_t);
1372  data_ptr = malloc(data_size);
1373  memset(data_ptr, 0, data_size);
1374  data = (GotoMessage_data_t *)data_ptr;
1376  data->x = ini_x;
1377  data->y = ini_y;
1378  data->phi = ini_phi;
1379  data->time_sec = ini_time_sec;
1380  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1381  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1382  add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
1383  add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
1384 }
1385 /** Constructor */
1387 {
1388  data_size = sizeof(GotoMessage_data_t);
1389  data_ptr = malloc(data_size);
1390  memset(data_ptr, 0, data_size);
1391  data = (GotoMessage_data_t *)data_ptr;
1393  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1394  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1395  add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
1396  add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
1397 }
1398 
1399 /** Destructor */
1401 {
1402  free(data_ptr);
1403 }
1404 
1405 /** Copy constructor.
1406  * @param m message to copy from
1407  */
1409 {
1410  data_size = m->data_size;
1411  data_ptr = malloc(data_size);
1412  memcpy(data_ptr, m->data_ptr, data_size);
1413  data = (GotoMessage_data_t *)data_ptr;
1415 }
1416 
1417 /* Methods */
1418 /** Get x value.
1419  * X distance in m.
1420  * @return x value
1421  */
1422 float
1424 {
1425  return data->x;
1426 }
1427 
1428 /** Get maximum length of x value.
1429  * @return length of x value, can be length of the array or number of
1430  * maximum number of characters for a string
1431  */
1432 size_t
1434 {
1435  return 1;
1436 }
1437 
1438 /** Set x value.
1439  * X distance in m.
1440  * @param new_x new x value
1441  */
1442 void
1444 {
1445  data->x = new_x;
1446 }
1447 
1448 /** Get y value.
1449  * Y distance in m.
1450  * @return y value
1451  */
1452 float
1454 {
1455  return data->y;
1456 }
1457 
1458 /** Get maximum length of y value.
1459  * @return length of y value, can be length of the array or number of
1460  * maximum number of characters for a string
1461  */
1462 size_t
1464 {
1465  return 1;
1466 }
1467 
1468 /** Set y value.
1469  * Y distance in m.
1470  * @param new_y new y value
1471  */
1472 void
1474 {
1475  data->y = new_y;
1476 }
1477 
1478 /** Get phi value.
1479  * Angle relative to current angle in rad.
1480  * @return phi value
1481  */
1482 float
1484 {
1485  return data->phi;
1486 }
1487 
1488 /** Get maximum length of phi value.
1489  * @return length of phi value, can be length of the array or number of
1490  * maximum number of characters for a string
1491  */
1492 size_t
1494 {
1495  return 1;
1496 }
1497 
1498 /** Set phi value.
1499  * Angle relative to current angle in rad.
1500  * @param new_phi new phi value
1501  */
1502 void
1504 {
1505  data->phi = new_phi;
1506 }
1507 
1508 /** Get time_sec value.
1509  * When to reach the desired location.
1510  * @return time_sec value
1511  */
1512 float
1514 {
1515  return data->time_sec;
1516 }
1517 
1518 /** Get maximum length of time_sec value.
1519  * @return length of time_sec value, can be length of the array or number of
1520  * maximum number of characters for a string
1521  */
1522 size_t
1524 {
1525  return 1;
1526 }
1527 
1528 /** Set time_sec value.
1529  * When to reach the desired location.
1530  * @param new_time_sec new time_sec value
1531  */
1532 void
1534 {
1535  data->time_sec = new_time_sec;
1536 }
1537 
1538 /** Clone this message.
1539  * Produces a message of the same type as this message and copies the
1540  * data to the new message.
1541  * @return clone of this message
1542  */
1543 Message *
1545 {
1546  return new MotorInterface::GotoMessage(this);
1547 }
1548 /** @class MotorInterface::TransMessage <interfaces/MotorInterface.h>
1549  * TransMessage Fawkes BlackBoard Interface Message.
1550  *
1551 
1552  */
1553 
1554 
1555 /** Constructor with initial values.
1556  * @param ini_vx initial value for vx
1557  * @param ini_vy initial value for vy
1558  */
1559 MotorInterface::TransMessage::TransMessage(const float ini_vx, const float ini_vy) : Message("TransMessage")
1560 {
1561  data_size = sizeof(TransMessage_data_t);
1562  data_ptr = malloc(data_size);
1563  memset(data_ptr, 0, data_size);
1564  data = (TransMessage_data_t *)data_ptr;
1566  data->vx = ini_vx;
1567  data->vy = ini_vy;
1568  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1569  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1570 }
1571 /** Constructor */
1573 {
1574  data_size = sizeof(TransMessage_data_t);
1575  data_ptr = malloc(data_size);
1576  memset(data_ptr, 0, data_size);
1577  data = (TransMessage_data_t *)data_ptr;
1579  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1580  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1581 }
1582 
1583 /** Destructor */
1585 {
1586  free(data_ptr);
1587 }
1588 
1589 /** Copy constructor.
1590  * @param m message to copy from
1591  */
1593 {
1594  data_size = m->data_size;
1595  data_ptr = malloc(data_size);
1596  memcpy(data_ptr, m->data_ptr, data_size);
1597  data = (TransMessage_data_t *)data_ptr;
1599 }
1600 
1601 /* Methods */
1602 /** Get vx value.
1603  * Speed in X direction in m/s.
1604  * @return vx value
1605  */
1606 float
1608 {
1609  return data->vx;
1610 }
1611 
1612 /** Get maximum length of vx value.
1613  * @return length of vx value, can be length of the array or number of
1614  * maximum number of characters for a string
1615  */
1616 size_t
1618 {
1619  return 1;
1620 }
1621 
1622 /** Set vx value.
1623  * Speed in X direction in m/s.
1624  * @param new_vx new vx value
1625  */
1626 void
1628 {
1629  data->vx = new_vx;
1630 }
1631 
1632 /** Get vy value.
1633  * Speed in Y direction in m/s.
1634  * @return vy value
1635  */
1636 float
1638 {
1639  return data->vy;
1640 }
1641 
1642 /** Get maximum length of vy value.
1643  * @return length of vy value, can be length of the array or number of
1644  * maximum number of characters for a string
1645  */
1646 size_t
1648 {
1649  return 1;
1650 }
1651 
1652 /** Set vy value.
1653  * Speed in Y direction in m/s.
1654  * @param new_vy new vy value
1655  */
1656 void
1658 {
1659  data->vy = new_vy;
1660 }
1661 
1662 /** Clone this message.
1663  * Produces a message of the same type as this message and copies the
1664  * data to the new message.
1665  * @return clone of this message
1666  */
1667 Message *
1669 {
1670  return new MotorInterface::TransMessage(this);
1671 }
1672 /** @class MotorInterface::RotMessage <interfaces/MotorInterface.h>
1673  * RotMessage Fawkes BlackBoard Interface Message.
1674  *
1675 
1676  */
1677 
1678 
1679 /** Constructor with initial values.
1680  * @param ini_omega initial value for omega
1681  */
1682 MotorInterface::RotMessage::RotMessage(const float ini_omega) : Message("RotMessage")
1683 {
1684  data_size = sizeof(RotMessage_data_t);
1685  data_ptr = malloc(data_size);
1686  memset(data_ptr, 0, data_size);
1687  data = (RotMessage_data_t *)data_ptr;
1689  data->omega = ini_omega;
1690  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1691 }
1692 /** Constructor */
1694 {
1695  data_size = sizeof(RotMessage_data_t);
1696  data_ptr = malloc(data_size);
1697  memset(data_ptr, 0, data_size);
1698  data = (RotMessage_data_t *)data_ptr;
1700  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1701 }
1702 
1703 /** Destructor */
1705 {
1706  free(data_ptr);
1707 }
1708 
1709 /** Copy constructor.
1710  * @param m message to copy from
1711  */
1713 {
1714  data_size = m->data_size;
1715  data_ptr = malloc(data_size);
1716  memcpy(data_ptr, m->data_ptr, data_size);
1717  data = (RotMessage_data_t *)data_ptr;
1719 }
1720 
1721 /* Methods */
1722 /** Get omega value.
1723  * Angle rotation in rad/s.
1724  * @return omega value
1725  */
1726 float
1728 {
1729  return data->omega;
1730 }
1731 
1732 /** Get maximum length of omega value.
1733  * @return length of omega value, can be length of the array or number of
1734  * maximum number of characters for a string
1735  */
1736 size_t
1738 {
1739  return 1;
1740 }
1741 
1742 /** Set omega value.
1743  * Angle rotation in rad/s.
1744  * @param new_omega new omega value
1745  */
1746 void
1748 {
1749  data->omega = new_omega;
1750 }
1751 
1752 /** Clone this message.
1753  * Produces a message of the same type as this message and copies the
1754  * data to the new message.
1755  * @return clone of this message
1756  */
1757 Message *
1759 {
1760  return new MotorInterface::RotMessage(this);
1761 }
1762 /** @class MotorInterface::TransRotMessage <interfaces/MotorInterface.h>
1763  * TransRotMessage Fawkes BlackBoard Interface Message.
1764  *
1765 
1766  */
1767 
1768 
1769 /** Constructor with initial values.
1770  * @param ini_vx initial value for vx
1771  * @param ini_vy initial value for vy
1772  * @param ini_omega initial value for omega
1773  */
1774 MotorInterface::TransRotMessage::TransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("TransRotMessage")
1775 {
1776  data_size = sizeof(TransRotMessage_data_t);
1777  data_ptr = malloc(data_size);
1778  memset(data_ptr, 0, data_size);
1779  data = (TransRotMessage_data_t *)data_ptr;
1781  data->vx = ini_vx;
1782  data->vy = ini_vy;
1783  data->omega = ini_omega;
1784  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1785  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1786  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1787 }
1788 /** Constructor */
1790 {
1791  data_size = sizeof(TransRotMessage_data_t);
1792  data_ptr = malloc(data_size);
1793  memset(data_ptr, 0, data_size);
1794  data = (TransRotMessage_data_t *)data_ptr;
1796  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1797  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1798  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1799 }
1800 
1801 /** Destructor */
1803 {
1804  free(data_ptr);
1805 }
1806 
1807 /** Copy constructor.
1808  * @param m message to copy from
1809  */
1811 {
1812  data_size = m->data_size;
1813  data_ptr = malloc(data_size);
1814  memcpy(data_ptr, m->data_ptr, data_size);
1815  data = (TransRotMessage_data_t *)data_ptr;
1817 }
1818 
1819 /* Methods */
1820 /** Get vx value.
1821  * Speed in X direction in m/s.
1822  * @return vx value
1823  */
1824 float
1826 {
1827  return data->vx;
1828 }
1829 
1830 /** Get maximum length of vx value.
1831  * @return length of vx value, can be length of the array or number of
1832  * maximum number of characters for a string
1833  */
1834 size_t
1836 {
1837  return 1;
1838 }
1839 
1840 /** Set vx value.
1841  * Speed in X direction in m/s.
1842  * @param new_vx new vx value
1843  */
1844 void
1846 {
1847  data->vx = new_vx;
1848 }
1849 
1850 /** Get vy value.
1851  * Speed in Y direction in m/s.
1852  * @return vy value
1853  */
1854 float
1856 {
1857  return data->vy;
1858 }
1859 
1860 /** Get maximum length of vy value.
1861  * @return length of vy value, can be length of the array or number of
1862  * maximum number of characters for a string
1863  */
1864 size_t
1866 {
1867  return 1;
1868 }
1869 
1870 /** Set vy value.
1871  * Speed in Y direction in m/s.
1872  * @param new_vy new vy value
1873  */
1874 void
1876 {
1877  data->vy = new_vy;
1878 }
1879 
1880 /** Get omega value.
1881  * Angle rotation in rad/s.
1882  * @return omega value
1883  */
1884 float
1886 {
1887  return data->omega;
1888 }
1889 
1890 /** Get maximum length of omega value.
1891  * @return length of omega value, can be length of the array or number of
1892  * maximum number of characters for a string
1893  */
1894 size_t
1896 {
1897  return 1;
1898 }
1899 
1900 /** Set omega value.
1901  * Angle rotation in rad/s.
1902  * @param new_omega new omega value
1903  */
1904 void
1906 {
1907  data->omega = new_omega;
1908 }
1909 
1910 /** Clone this message.
1911  * Produces a message of the same type as this message and copies the
1912  * data to the new message.
1913  * @return clone of this message
1914  */
1915 Message *
1917 {
1918  return new MotorInterface::TransRotMessage(this);
1919 }
1920 /** @class MotorInterface::OrbitMessage <interfaces/MotorInterface.h>
1921  * OrbitMessage Fawkes BlackBoard Interface Message.
1922  *
1923 
1924  */
1925 
1926 
1927 /** Constructor with initial values.
1928  * @param ini_px initial value for px
1929  * @param ini_py initial value for py
1930  * @param ini_omega initial value for omega
1931  */
1932 MotorInterface::OrbitMessage::OrbitMessage(const float ini_px, const float ini_py, const float ini_omega) : Message("OrbitMessage")
1933 {
1934  data_size = sizeof(OrbitMessage_data_t);
1935  data_ptr = malloc(data_size);
1936  memset(data_ptr, 0, data_size);
1937  data = (OrbitMessage_data_t *)data_ptr;
1939  data->px = ini_px;
1940  data->py = ini_py;
1941  data->omega = ini_omega;
1942  add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
1943  add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
1944  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1945 }
1946 /** Constructor */
1948 {
1949  data_size = sizeof(OrbitMessage_data_t);
1950  data_ptr = malloc(data_size);
1951  memset(data_ptr, 0, data_size);
1952  data = (OrbitMessage_data_t *)data_ptr;
1954  add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
1955  add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
1956  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1957 }
1958 
1959 /** Destructor */
1961 {
1962  free(data_ptr);
1963 }
1964 
1965 /** Copy constructor.
1966  * @param m message to copy from
1967  */
1969 {
1970  data_size = m->data_size;
1971  data_ptr = malloc(data_size);
1972  memcpy(data_ptr, m->data_ptr, data_size);
1973  data = (OrbitMessage_data_t *)data_ptr;
1975 }
1976 
1977 /* Methods */
1978 /** Get px value.
1979  * Point's X coordinate to orbit.
1980  * @return px value
1981  */
1982 float
1984 {
1985  return data->px;
1986 }
1987 
1988 /** Get maximum length of px value.
1989  * @return length of px value, can be length of the array or number of
1990  * maximum number of characters for a string
1991  */
1992 size_t
1994 {
1995  return 1;
1996 }
1997 
1998 /** Set px value.
1999  * Point's X coordinate to orbit.
2000  * @param new_px new px value
2001  */
2002 void
2004 {
2005  data->px = new_px;
2006 }
2007 
2008 /** Get py value.
2009  * Point's Y coordinate to orbit.
2010  * @return py value
2011  */
2012 float
2014 {
2015  return data->py;
2016 }
2017 
2018 /** Get maximum length of py value.
2019  * @return length of py value, can be length of the array or number of
2020  * maximum number of characters for a string
2021  */
2022 size_t
2024 {
2025  return 1;
2026 }
2027 
2028 /** Set py value.
2029  * Point's Y coordinate to orbit.
2030  * @param new_py new py value
2031  */
2032 void
2034 {
2035  data->py = new_py;
2036 }
2037 
2038 /** Get omega value.
2039  * Angular speed around point in rad/s.
2040  * @return omega value
2041  */
2042 float
2044 {
2045  return data->omega;
2046 }
2047 
2048 /** Get maximum length of omega value.
2049  * @return length of omega value, can be length of the array or number of
2050  * maximum number of characters for a string
2051  */
2052 size_t
2054 {
2055  return 1;
2056 }
2057 
2058 /** Set omega value.
2059  * Angular speed around point in rad/s.
2060  * @param new_omega new omega value
2061  */
2062 void
2064 {
2065  data->omega = new_omega;
2066 }
2067 
2068 /** Clone this message.
2069  * Produces a message of the same type as this message and copies the
2070  * data to the new message.
2071  * @return clone of this message
2072  */
2073 Message *
2075 {
2076  return new MotorInterface::OrbitMessage(this);
2077 }
2078 /** @class MotorInterface::LinTransRotMessage <interfaces/MotorInterface.h>
2079  * LinTransRotMessage Fawkes BlackBoard Interface Message.
2080  *
2081 
2082  */
2083 
2084 
2085 /** Constructor with initial values.
2086  * @param ini_vx initial value for vx
2087  * @param ini_vy initial value for vy
2088  * @param ini_omega initial value for omega
2089  */
2090 MotorInterface::LinTransRotMessage::LinTransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("LinTransRotMessage")
2091 {
2092  data_size = sizeof(LinTransRotMessage_data_t);
2093  data_ptr = malloc(data_size);
2094  memset(data_ptr, 0, data_size);
2095  data = (LinTransRotMessage_data_t *)data_ptr;
2097  data->vx = ini_vx;
2098  data->vy = ini_vy;
2099  data->omega = ini_omega;
2100  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
2101  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
2102  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
2103 }
2104 /** Constructor */
2106 {
2107  data_size = sizeof(LinTransRotMessage_data_t);
2108  data_ptr = malloc(data_size);
2109  memset(data_ptr, 0, data_size);
2110  data = (LinTransRotMessage_data_t *)data_ptr;
2112  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
2113  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
2114  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
2115 }
2116 
2117 /** Destructor */
2119 {
2120  free(data_ptr);
2121 }
2122 
2123 /** Copy constructor.
2124  * @param m message to copy from
2125  */
2127 {
2128  data_size = m->data_size;
2129  data_ptr = malloc(data_size);
2130  memcpy(data_ptr, m->data_ptr, data_size);
2131  data = (LinTransRotMessage_data_t *)data_ptr;
2133 }
2134 
2135 /* Methods */
2136 /** Get vx value.
2137  * Speed for translation in X direction in m/s.
2138  * @return vx value
2139  */
2140 float
2142 {
2143  return data->vx;
2144 }
2145 
2146 /** Get maximum length of vx value.
2147  * @return length of vx value, can be length of the array or number of
2148  * maximum number of characters for a string
2149  */
2150 size_t
2152 {
2153  return 1;
2154 }
2155 
2156 /** Set vx value.
2157  * Speed for translation in X direction in m/s.
2158  * @param new_vx new vx value
2159  */
2160 void
2162 {
2163  data->vx = new_vx;
2164 }
2165 
2166 /** Get vy value.
2167  * Speed for translation in Y direction in m/s.
2168  * @return vy value
2169  */
2170 float
2172 {
2173  return data->vy;
2174 }
2175 
2176 /** Get maximum length of vy value.
2177  * @return length of vy value, can be length of the array or number of
2178  * maximum number of characters for a string
2179  */
2180 size_t
2182 {
2183  return 1;
2184 }
2185 
2186 /** Set vy value.
2187  * Speed for translation in Y direction in m/s.
2188  * @param new_vy new vy value
2189  */
2190 void
2192 {
2193  data->vy = new_vy;
2194 }
2195 
2196 /** Get omega value.
2197  * Rotational speed in rad/s.
2198  * @return omega value
2199  */
2200 float
2202 {
2203  return data->omega;
2204 }
2205 
2206 /** Get maximum length of omega value.
2207  * @return length of omega value, can be length of the array or number of
2208  * maximum number of characters for a string
2209  */
2210 size_t
2212 {
2213  return 1;
2214 }
2215 
2216 /** Set omega value.
2217  * Rotational speed in rad/s.
2218  * @param new_omega new omega value
2219  */
2220 void
2222 {
2223  data->omega = new_omega;
2224 }
2225 
2226 /** Clone this message.
2227  * Produces a message of the same type as this message and copies the
2228  * data to the new message.
2229  * @return clone of this message
2230  */
2231 Message *
2233 {
2234  return new MotorInterface::LinTransRotMessage(this);
2235 }
2236 /** Check if message is valid and can be enqueued.
2237  * @param message Message to check
2238  * @return true if the message is valid, false otherwise.
2239  */
2240 bool
2242 {
2243  const SetMotorStateMessage *m0 = dynamic_cast<const SetMotorStateMessage *>(message);
2244  if ( m0 != NULL ) {
2245  return true;
2246  }
2247  const AcquireControlMessage *m1 = dynamic_cast<const AcquireControlMessage *>(message);
2248  if ( m1 != NULL ) {
2249  return true;
2250  }
2251  const ResetOdometryMessage *m2 = dynamic_cast<const ResetOdometryMessage *>(message);
2252  if ( m2 != NULL ) {
2253  return true;
2254  }
2255  const SetOdometryMessage *m3 = dynamic_cast<const SetOdometryMessage *>(message);
2256  if ( m3 != NULL ) {
2257  return true;
2258  }
2259  const DriveRPMMessage *m4 = dynamic_cast<const DriveRPMMessage *>(message);
2260  if ( m4 != NULL ) {
2261  return true;
2262  }
2263  const GotoMessage *m5 = dynamic_cast<const GotoMessage *>(message);
2264  if ( m5 != NULL ) {
2265  return true;
2266  }
2267  const TransMessage *m6 = dynamic_cast<const TransMessage *>(message);
2268  if ( m6 != NULL ) {
2269  return true;
2270  }
2271  const RotMessage *m7 = dynamic_cast<const RotMessage *>(message);
2272  if ( m7 != NULL ) {
2273  return true;
2274  }
2275  const TransRotMessage *m8 = dynamic_cast<const TransRotMessage *>(message);
2276  if ( m8 != NULL ) {
2277  return true;
2278  }
2279  const OrbitMessage *m9 = dynamic_cast<const OrbitMessage *>(message);
2280  if ( m9 != NULL ) {
2281  return true;
2282  }
2283  const LinTransRotMessage *m10 = dynamic_cast<const LinTransRotMessage *>(message);
2284  if ( m10 != NULL ) {
2285  return true;
2286  }
2287  return false;
2288 }
2289 
2290 /// @cond INTERNALS
2291 EXPORT_INTERFACE(MotorInterface)
2292 /// @endcond
2293 
2294 
2295 } // end namespace fawkes
void set_des_vx(const float new_des_vx)
Set des_vx value.
size_t maxlenof_motor_state() const
Get maximum length of motor_state value.
void set_vy(const float new_vy)
Set vy value.
virtual Message * clone() const
Clone this message.
void set_omega(const float new_omega)
Set omega value.
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:124
SetMotorStateMessage Fawkes BlackBoard Interface Message.
static const uint32_t DRIVE_MODE_LINE_TRANS_ROT
DRIVE_MODE_LINE_TRANS_ROT constant.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
float px() const
Get px value.
size_t maxlenof_omega() const
Get maximum length of omega value.
virtual Message * clone() const
Clone this message.
RotMessage Fawkes BlackBoard Interface Message.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
static const uint32_t MOTOR_ENABLED
MOTOR_ENABLED constant.
size_t maxlenof_controller() const
Get maximum length of controller value.
float odometry_position_x() const
Get odometry_position_x value.
uint32_t controller() const
Get controller value.
size_t maxlenof_omega() const
Get maximum length of omega value.
virtual Message * clone() const
Clone this message.
void set_rear(const float new_rear)
Set rear value.
float vy() const
Get vy value.
static const uint32_t DRIVE_MODE_RPM
DRIVE_MODE_RPM constant.
virtual Message * clone() const
Clone this message.
void set_omega(const float new_omega)
Set omega value.
void set_vx(const float new_vx)
Set vx value.
TransRotMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_x() const
Get maximum length of x value.
float front_left() const
Get front_left value.
size_t maxlenof_odometry_position_x() const
Get maximum length of odometry_position_x value.
void set_hash(unsigned char *ihash)
Set hash.
Definition: interface.cpp:314
void set_odometry_position_y(const float new_odometry_position_y)
Set odometry_position_y value.
float omega() const
Get omega value.
uint32_t controller() const
Get controller value.
Fawkes library namespace.
size_t maxlenof_rear_rpm() const
Get maximum length of rear_rpm value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_controller(const uint32_t new_controller)
Set controller value.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
Definition: message.h:129
void set_vy(const float new_vy)
Set vy value.
void set_y(const float new_y)
Set y value.
int32_t left_rpm() const
Get left_rpm value.
void set_motor_state(const uint32_t new_motor_state)
Set motor_state value.
void set_vy(const float new_vy)
Set vy value.
float odometry_path_length() const
Get odometry_path_length value.
virtual Message * create_message(const char *type) const
Create message based on type name.
void set_controller(const uint32_t new_controller)
Set controller value.
void set_odometry_orientation(const float new_odometry_orientation)
Set odometry_orientation value.
void set_rear_rpm(const int32_t new_rear_rpm)
Set rear_rpm value.
string field
Definition: types.h:47
void set_front_right(const float new_front_right)
Set front_right value.
virtual Message * clone() const
Clone this message.
OrbitMessage Fawkes BlackBoard Interface Message.
void set_motor_state(const uint32_t new_motor_state)
Set motor_state value.
size_t maxlenof_front_left() const
Get maximum length of front_left value.
uint32_t drive_mode() const
Get drive_mode value.
size_t maxlenof_right_rpm() const
Get maximum length of right_rpm value.
size_t maxlenof_phi() const
Get maximum length of phi value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
size_t maxlenof_controller() const
Get maximum length of controller value.
int32_t rear_rpm() const
Get rear_rpm value.
size_t maxlenof_odometry_orientation() const
Get maximum length of odometry_orientation value.
void set_time_sec(const float new_time_sec)
Set time_sec value.
size_t maxlenof_motor_state() const
Get maximum length of motor_state value.
void set_omega(const float new_omega)
Set omega value.
size_t maxlenof_odometry_orientation() const
Get maximum length of odometry_orientation value.
size_t maxlenof_front_right() const
Get maximum length of front_right value.
void set_right_rpm(const int32_t new_right_rpm)
Set right_rpm value.
void set_left_rpm(const int32_t new_left_rpm)
Set left_rpm value.
float vx() const
Get vx value.
void set_des_omega(const float new_des_omega)
Set des_omega value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:133
float phi() const
Get phi value.
ResetOdometryMessage Fawkes BlackBoard Interface Message.
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:125
void set_odometry_path_length(const float new_odometry_path_length)
Set odometry_path_length value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_drive_mode() const
Get maximum length of drive_mode value.
float odometry_orientation() const
Get odometry_orientation value.
float odometry_position_y() const
Get odometry_position_y value.
AcquireControlMessage Fawkes BlackBoard Interface Message.
void add_messageinfo(const char *name)
Add an entry to the message info list.
Definition: interface.cpp:373
float time_sec() const
Get time_sec value.
bool data_changed
Indicator if data has changed.
Definition: interface.h:222
size_t maxlenof_px() const
Get maximum length of px value.
void set_des_vy(const float new_des_vy)
Set des_vy value.
float vy() const
Get vy value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
size_t maxlenof_vy() const
Get maximum length of vy value.
static const uint32_t DRIVE_MODE_TRANS_ROT
DRIVE_MODE_TRANS_ROT constant.
void set_x(const float new_x)
Set x value.
void set_vy(const float new_vy)
Set vy value.
void set_phi(const float new_phi)
Set phi value.
void set_vx(const float new_vx)
Set vx value.
void set_omega(const float new_omega)
Set omega value.
float rear() const
Get rear value.
void set_py(const float new_py)
Set py value.
float omega() const
Get omega value.
static const uint32_t DRIVE_MODE_TRANS
DRIVE_MODE_TRANS constant.
void set_omega(const float new_omega)
Set omega value.
size_t maxlenof_des_vy() const
Get maximum length of des_vy value.
void set_odometry_orientation(const float new_odometry_orientation)
Set odometry_orientation value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_front_left(const float new_front_left)
Set front_left value.
float omega() const
Get omega value.
size_t maxlenof_y() const
Get maximum length of y value.
int32_t right_rpm() const
Get right_rpm value.
size_t maxlenof_rear() const
Get maximum length of rear value.
void set_controller_thread_name(const char *new_controller_thread_name)
Set controller_thread_name value.
LinTransRotMessage Fawkes BlackBoard Interface Message.
float vx() const
Get vx value.
void set_px(const float new_px)
Set px value.
float omega() const
Get omega value.
uint32_t motor_state() const
Get motor_state value.
size_t maxlenof_vx() const
Get maximum length of vx value.
size_t maxlenof_controller_thread_name() const
Get maximum length of controller_thread_name value.
char * controller_thread_name() const
Get controller_thread_name value.
float field
Definition: types.h:45
char * controller_thread_name() const
Get controller_thread_name value.
32 bit integer field
Definition: types.h:41
virtual Message * clone() const
Clone this message.
float des_vx() const
Get des_vx value.
DriveRPMMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_omega() const
Get maximum length of omega value.
size_t maxlenof_y() const
Get maximum length of y value.
void set_drive_mode(const uint32_t new_drive_mode)
Set drive_mode value.
void set_vx(const float new_vx)
Set vx value.
float front_right() const
Get front_right value.
virtual Message * clone() const
Clone this message.
void set_vx(const float new_vx)
Set vx value.
size_t maxlenof_vy() const
Get maximum length of vy value.
size_t maxlenof_vx() const
Get maximum length of vx value.
float des_omega() const
Get des_omega value.
virtual Message * clone() const
Clone this message.
static const uint32_t MOTOR_DISABLED
MOTOR_DISABLED constant.
void set_odometry_position_x(const float new_odometry_position_x)
Set odometry_position_x value.
float des_vy() const
Get des_vy value.
size_t maxlenof_omega() const
Get maximum length of omega value.
size_t maxlenof_left_rpm() const
Get maximum length of left_rpm value.
size_t maxlenof_odometry_position_y() const
Get maximum length of odometry_position_y value.
static const uint32_t DRIVE_MODE_ORBIT
DRIVE_MODE_ORBIT constant.
size_t maxlenof_controller_thread_name() const
Get maximum length of controller_thread_name value.
MotorInterface Fawkes BlackBoard Interface.
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
float py() const
Get py value.
size_t maxlenof_des_omega() const
Get maximum length of des_omega value.
size_t maxlenof_odometry_path_length() const
Get maximum length of odometry_path_length value.
float odometry_orientation() const
Get odometry_orientation 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
GotoMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_des_vx() const
Get maximum length of des_vx value.
SetOdometryMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_omega() const
Get maximum length of omega value.
const char * type() const
Get message type.
Definition: message.cpp:378
size_t maxlenof_vy() const
Get maximum length of vy value.
void set_controller_thread_name(const char *new_controller_thread_name)
Set controller_thread_name value.
void set_x(const float new_x)
Set x value.
uint32_t motor_state() const
Get motor_state value.
32 bit unsigned integer field
Definition: types.h:42
size_t maxlenof_py() const
Get maximum length of py value.
static const uint32_t DRIVE_MODE_ROT
DRIVE_MODE_ROT constant.
virtual void copy_values(const Interface *other)
Copy values from other interface.
size_t maxlenof_x() const
Get maximum length of x value.
TransMessage Fawkes BlackBoard Interface Message.
float omega() const
Get omega value.
size_t maxlenof_vy() const
Get maximum length of vy value.
void set_y(const float new_y)
Set y value.