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 <cstring>
29 #include <cstdlib>
30 
31 namespace fawkes {
32 
33 /** @class MotorInterface <interfaces/MotorInterface.h>
34  * MotorInterface Fawkes BlackBoard Interface.
35  * This interface is currently prepared best for a holonomic robot.
36  It will need modifications or a split to support differential drives.
37 
38  * @ingroup FawkesInterfaces
39  */
40 
41 
42 /** MOTOR_ENABLED constant */
43 const uint32_t MotorInterface::MOTOR_ENABLED = 0u;
44 /** MOTOR_DISABLED constant */
45 const uint32_t MotorInterface::MOTOR_DISABLED = 1u;
46 /** DRIVE_MODE_RPM constant */
47 const uint32_t MotorInterface::DRIVE_MODE_RPM = 1u;
48 /** DRIVE_MODE_TRANS constant */
49 const uint32_t MotorInterface::DRIVE_MODE_TRANS = 2u;
50 /** DRIVE_MODE_ROT constant */
51 const uint32_t MotorInterface::DRIVE_MODE_ROT = 3u;
52 /** DRIVE_MODE_TRANS_ROT constant */
53 const uint32_t MotorInterface::DRIVE_MODE_TRANS_ROT = 4u;
54 /** DRIVE_MODE_ORBIT constant */
55 const uint32_t MotorInterface::DRIVE_MODE_ORBIT = 5u;
56 /** DRIVE_MODE_LINE_TRANS_ROT constant */
58 
59 /** Constructor */
60 MotorInterface::MotorInterface() : Interface()
61 {
62  data_size = sizeof(MotorInterface_data_t);
63  data_ptr = malloc(data_size);
64  data = (MotorInterface_data_t *)data_ptr;
65  data_ts = (interface_data_ts_t *)data_ptr;
66  memset(data_ptr, 0, data_size);
67  add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state, "");
68  add_fieldinfo(IFT_UINT32, "drive_mode", 1, &data->drive_mode, "");
69  add_fieldinfo(IFT_INT32, "right_rpm", 1, &data->right_rpm, "");
70  add_fieldinfo(IFT_INT32, "rear_rpm", 1, &data->rear_rpm, "");
71  add_fieldinfo(IFT_INT32, "left_rpm", 1, &data->left_rpm, "");
72  add_fieldinfo(IFT_FLOAT, "odometry_path_length", 1, &data->odometry_path_length, "");
73  add_fieldinfo(IFT_FLOAT, "odometry_position_x", 1, &data->odometry_position_x, "");
74  add_fieldinfo(IFT_FLOAT, "odometry_position_y", 1, &data->odometry_position_y, "");
75  add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation, "");
76  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
77  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
78  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
79  add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller, "");
80  add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name, "");
81  add_messageinfo("SetMotorStateMessage");
82  add_messageinfo("AcquireControlMessage");
83  add_messageinfo("ResetOdometryMessage");
84  add_messageinfo("DriveRPMMessage");
85  add_messageinfo("GotoMessage");
86  add_messageinfo("TransMessage");
87  add_messageinfo("RotMessage");
88  add_messageinfo("TransRotMessage");
89  add_messageinfo("OrbitMessage");
90  add_messageinfo("LinTransRotMessage");
91  unsigned char tmp_hash[] = {0x4d, 0x9b, 0xb8, 0x1e, 0xb7, 0x9e, 0xc1, 0xea, 0xc6, 0xad, 0xf9, 0x6, 0xd7, 0x6d, 0xa4, 0xa5};
92  set_hash(tmp_hash);
93 }
94 
95 /** Destructor */
96 MotorInterface::~MotorInterface()
97 {
98  free(data_ptr);
99 }
100 /* Methods */
101 /** Get motor_state value.
102  *
103  The current state of the motor.
104 
105  * @return motor_state value
106  */
107 uint32_t
109 {
110  return data->motor_state;
111 }
112 
113 /** Get maximum length of motor_state value.
114  * @return length of motor_state value, can be length of the array or number of
115  * maximum number of characters for a string
116  */
117 size_t
119 {
120  return 1;
121 }
122 
123 /** Set motor_state value.
124  *
125  The current state of the motor.
126 
127  * @param new_motor_state new motor_state value
128  */
129 void
130 MotorInterface::set_motor_state(const uint32_t new_motor_state)
131 {
132  data->motor_state = new_motor_state;
133  data_changed = true;
134 }
135 
136 /** Get drive_mode value.
137  *
138  The current drive mode of the motor.
139 
140  * @return drive_mode value
141  */
142 uint32_t
144 {
145  return data->drive_mode;
146 }
147 
148 /** Get maximum length of drive_mode value.
149  * @return length of drive_mode value, can be length of the array or number of
150  * maximum number of characters for a string
151  */
152 size_t
154 {
155  return 1;
156 }
157 
158 /** Set drive_mode value.
159  *
160  The current drive mode of the motor.
161 
162  * @param new_drive_mode new drive_mode value
163  */
164 void
165 MotorInterface::set_drive_mode(const uint32_t new_drive_mode)
166 {
167  data->drive_mode = new_drive_mode;
168  data_changed = true;
169 }
170 
171 /** Get right_rpm value.
172  *
173  RPM of the motor on the right front of the robot.
174 
175  * @return right_rpm value
176  */
177 int32_t
179 {
180  return data->right_rpm;
181 }
182 
183 /** Get maximum length of right_rpm value.
184  * @return length of right_rpm value, can be length of the array or number of
185  * maximum number of characters for a string
186  */
187 size_t
189 {
190  return 1;
191 }
192 
193 /** Set right_rpm value.
194  *
195  RPM of the motor on the right front of the robot.
196 
197  * @param new_right_rpm new right_rpm value
198  */
199 void
200 MotorInterface::set_right_rpm(const int32_t new_right_rpm)
201 {
202  data->right_rpm = new_right_rpm;
203  data_changed = true;
204 }
205 
206 /** Get rear_rpm value.
207  *
208  RPM of motor on the rear of the robot.
209 
210  * @return rear_rpm value
211  */
212 int32_t
214 {
215  return data->rear_rpm;
216 }
217 
218 /** Get maximum length of rear_rpm value.
219  * @return length of rear_rpm value, can be length of the array or number of
220  * maximum number of characters for a string
221  */
222 size_t
224 {
225  return 1;
226 }
227 
228 /** Set rear_rpm value.
229  *
230  RPM of motor on the rear of the robot.
231 
232  * @param new_rear_rpm new rear_rpm value
233  */
234 void
235 MotorInterface::set_rear_rpm(const int32_t new_rear_rpm)
236 {
237  data->rear_rpm = new_rear_rpm;
238  data_changed = true;
239 }
240 
241 /** Get left_rpm value.
242  *
243  RPM of the motor on the left front of the robot.
244 
245  * @return left_rpm value
246  */
247 int32_t
249 {
250  return data->left_rpm;
251 }
252 
253 /** Get maximum length of left_rpm value.
254  * @return length of left_rpm value, can be length of the array or number of
255  * maximum number of characters for a string
256  */
257 size_t
259 {
260  return 1;
261 }
262 
263 /** Set left_rpm value.
264  *
265  RPM of the motor on the left front of the robot.
266 
267  * @param new_left_rpm new left_rpm value
268  */
269 void
270 MotorInterface::set_left_rpm(const int32_t new_left_rpm)
271 {
272  data->left_rpm = new_left_rpm;
273  data_changed = true;
274 }
275 
276 /** Get odometry_path_length value.
277  *
278  The actual length of the robot's trajectory since the last ResetOdometry.
279 
280  * @return odometry_path_length value
281  */
282 float
284 {
285  return data->odometry_path_length;
286 }
287 
288 /** Get maximum length of odometry_path_length value.
289  * @return length of odometry_path_length value, can be length of the array or number of
290  * maximum number of characters for a string
291  */
292 size_t
294 {
295  return 1;
296 }
297 
298 /** Set odometry_path_length value.
299  *
300  The actual length of the robot's trajectory since the last ResetOdometry.
301 
302  * @param new_odometry_path_length new odometry_path_length value
303  */
304 void
305 MotorInterface::set_odometry_path_length(const float new_odometry_path_length)
306 {
307  data->odometry_path_length = new_odometry_path_length;
308  data_changed = true;
309 }
310 
311 /** Get odometry_position_x value.
312  *
313  The actual position of the robot relative to the position at the last ResetOdometry.
314 
315  * @return odometry_position_x value
316  */
317 float
319 {
320  return data->odometry_position_x;
321 }
322 
323 /** Get maximum length of odometry_position_x value.
324  * @return length of odometry_position_x value, can be length of the array or number of
325  * maximum number of characters for a string
326  */
327 size_t
329 {
330  return 1;
331 }
332 
333 /** Set odometry_position_x value.
334  *
335  The actual position of the robot relative to the position at the last ResetOdometry.
336 
337  * @param new_odometry_position_x new odometry_position_x value
338  */
339 void
340 MotorInterface::set_odometry_position_x(const float new_odometry_position_x)
341 {
342  data->odometry_position_x = new_odometry_position_x;
343  data_changed = true;
344 }
345 
346 /** Get odometry_position_y value.
347  *
348  The actual position of the robot relative to the position at the last ResetOdometry.
349 
350  * @return odometry_position_y value
351  */
352 float
354 {
355  return data->odometry_position_y;
356 }
357 
358 /** Get maximum length of odometry_position_y value.
359  * @return length of odometry_position_y value, can be length of the array or number of
360  * maximum number of characters for a string
361  */
362 size_t
364 {
365  return 1;
366 }
367 
368 /** Set odometry_position_y value.
369  *
370  The actual position of the robot relative to the position at the last ResetOdometry.
371 
372  * @param new_odometry_position_y new odometry_position_y value
373  */
374 void
375 MotorInterface::set_odometry_position_y(const float new_odometry_position_y)
376 {
377  data->odometry_position_y = new_odometry_position_y;
378  data_changed = true;
379 }
380 
381 /** Get odometry_orientation value.
382  *
383  The actual orientation of the robot relative to the orientation at the last ResetOdometry.
384 
385  * @return odometry_orientation value
386  */
387 float
389 {
390  return data->odometry_orientation;
391 }
392 
393 /** Get maximum length of odometry_orientation value.
394  * @return length of odometry_orientation value, can be length of the array or number of
395  * maximum number of characters for a string
396  */
397 size_t
399 {
400  return 1;
401 }
402 
403 /** Set odometry_orientation value.
404  *
405  The actual orientation of the robot relative to the orientation at the last ResetOdometry.
406 
407  * @param new_odometry_orientation new odometry_orientation value
408  */
409 void
410 MotorInterface::set_odometry_orientation(const float new_odometry_orientation)
411 {
412  data->odometry_orientation = new_odometry_orientation;
413  data_changed = true;
414 }
415 
416 /** Get vx value.
417  *
418  VX of the robot in m/s. Forward.
419 
420  * @return vx value
421  */
422 float
424 {
425  return data->vx;
426 }
427 
428 /** Get maximum length of vx value.
429  * @return length of vx value, can be length of the array or number of
430  * maximum number of characters for a string
431  */
432 size_t
434 {
435  return 1;
436 }
437 
438 /** Set vx value.
439  *
440  VX of the robot in m/s. Forward.
441 
442  * @param new_vx new vx value
443  */
444 void
445 MotorInterface::set_vx(const float new_vx)
446 {
447  data->vx = new_vx;
448  data_changed = true;
449 }
450 
451 /** Get vy value.
452  *
453  VY of the robot in m/s. Left.
454 
455  * @return vy value
456  */
457 float
459 {
460  return data->vy;
461 }
462 
463 /** Get maximum length of vy value.
464  * @return length of vy value, can be length of the array or number of
465  * maximum number of characters for a string
466  */
467 size_t
469 {
470  return 1;
471 }
472 
473 /** Set vy value.
474  *
475  VY of the robot in m/s. Left.
476 
477  * @param new_vy new vy value
478  */
479 void
480 MotorInterface::set_vy(const float new_vy)
481 {
482  data->vy = new_vy;
483  data_changed = true;
484 }
485 
486 /** Get omega value.
487  *
488  Rotation speed of the robot in rad/s.
489 
490  * @return omega value
491  */
492 float
494 {
495  return data->omega;
496 }
497 
498 /** Get maximum length of omega value.
499  * @return length of omega value, can be length of the array or number of
500  * maximum number of characters for a string
501  */
502 size_t
504 {
505  return 1;
506 }
507 
508 /** Set omega value.
509  *
510  Rotation speed of the robot in rad/s.
511 
512  * @param new_omega new omega value
513  */
514 void
515 MotorInterface::set_omega(const float new_omega)
516 {
517  data->omega = new_omega;
518  data_changed = true;
519 }
520 
521 /** Get controller value.
522  *
523  The ID of the controller. The controller ID is the instance serial of the sending
524  interface. Only from this interface instance command messages are accepted.
525 
526  * @return controller value
527  */
528 uint32_t
530 {
531  return data->controller;
532 }
533 
534 /** Get maximum length of controller value.
535  * @return length of controller value, can be length of the array or number of
536  * maximum number of characters for a string
537  */
538 size_t
540 {
541  return 1;
542 }
543 
544 /** Set controller value.
545  *
546  The ID of the controller. The controller ID is the instance serial of the sending
547  interface. Only from this interface instance command messages are accepted.
548 
549  * @param new_controller new controller value
550  */
551 void
552 MotorInterface::set_controller(const uint32_t new_controller)
553 {
554  data->controller = new_controller;
555  data_changed = true;
556 }
557 
558 /** Get controller_thread_name value.
559  *
560  The name of the controlling thread, for easier debugging. This is informative only
561  and actually two threads may share an interface instance (although this should be
562  avoided since the interface locking has to be reproduced for these threads then).
563 
564  * @return controller_thread_name value
565  */
566 char *
568 {
569  return data->controller_thread_name;
570 }
571 
572 /** Get maximum length of controller_thread_name value.
573  * @return length of controller_thread_name value, can be length of the array or number of
574  * maximum number of characters for a string
575  */
576 size_t
578 {
579  return 64;
580 }
581 
582 /** Set controller_thread_name value.
583  *
584  The name of the controlling thread, for easier debugging. This is informative only
585  and actually two threads may share an interface instance (although this should be
586  avoided since the interface locking has to be reproduced for these threads then).
587 
588  * @param new_controller_thread_name new controller_thread_name value
589  */
590 void
591 MotorInterface::set_controller_thread_name(const char * new_controller_thread_name)
592 {
593  strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
594  data_changed = true;
595 }
596 
597 /* =========== message create =========== */
598 Message *
600 {
601  if ( strncmp("SetMotorStateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
602  return new SetMotorStateMessage();
603  } else if ( strncmp("AcquireControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
604  return new AcquireControlMessage();
605  } else if ( strncmp("ResetOdometryMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
606  return new ResetOdometryMessage();
607  } else if ( strncmp("DriveRPMMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
608  return new DriveRPMMessage();
609  } else if ( strncmp("GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
610  return new GotoMessage();
611  } else if ( strncmp("TransMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
612  return new TransMessage();
613  } else if ( strncmp("RotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
614  return new RotMessage();
615  } else if ( strncmp("TransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
616  return new TransRotMessage();
617  } else if ( strncmp("OrbitMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
618  return new OrbitMessage();
619  } else if ( strncmp("LinTransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
620  return new LinTransRotMessage();
621  } else {
622  throw UnknownTypeException("The given type '%s' does not match any known "
623  "message type for this interface type.", type);
624  }
625 }
626 
627 
628 /** Copy values from other interface.
629  * @param other other interface to copy values from
630  */
631 void
633 {
634  const MotorInterface *oi = dynamic_cast<const MotorInterface *>(other);
635  if (oi == NULL) {
636  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
637  type(), other->type());
638  }
639  memcpy(data, oi->data, sizeof(MotorInterface_data_t));
640 }
641 
642 const char *
643 MotorInterface::enum_tostring(const char *enumtype, int val) const
644 {
645  throw UnknownTypeException("Unknown enum type %s", enumtype);
646 }
647 
648 /* =========== messages =========== */
649 /** @class MotorInterface::SetMotorStateMessage <interfaces/MotorInterface.h>
650  * SetMotorStateMessage Fawkes BlackBoard Interface Message.
651  *
652 
653  */
654 
655 
656 /** Constructor with initial values.
657  * @param ini_motor_state initial value for motor_state
658  */
659 MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const uint32_t ini_motor_state) : Message("SetMotorStateMessage")
660 {
661  data_size = sizeof(SetMotorStateMessage_data_t);
662  data_ptr = malloc(data_size);
663  memset(data_ptr, 0, data_size);
664  data = (SetMotorStateMessage_data_t *)data_ptr;
666  data->motor_state = ini_motor_state;
667  add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state, "");
668 }
669 /** Constructor */
671 {
672  data_size = sizeof(SetMotorStateMessage_data_t);
673  data_ptr = malloc(data_size);
674  memset(data_ptr, 0, data_size);
675  data = (SetMotorStateMessage_data_t *)data_ptr;
677  add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state, "");
678 }
679 
680 /** Destructor */
682 {
683  free(data_ptr);
684 }
685 
686 /** Copy constructor.
687  * @param m message to copy from
688  */
690 {
691  data_size = m->data_size;
692  data_ptr = malloc(data_size);
693  memcpy(data_ptr, m->data_ptr, data_size);
694  data = (SetMotorStateMessage_data_t *)data_ptr;
696 }
697 
698 /* Methods */
699 /** Get motor_state value.
700  *
701  The new motor state to set. Use the MOTOR_* constants.
702 
703  * @return motor_state value
704  */
705 uint32_t
707 {
708  return data->motor_state;
709 }
710 
711 /** Get maximum length of motor_state value.
712  * @return length of motor_state value, can be length of the array or number of
713  * maximum number of characters for a string
714  */
715 size_t
717 {
718  return 1;
719 }
720 
721 /** Set motor_state value.
722  *
723  The new motor state to set. Use the MOTOR_* constants.
724 
725  * @param new_motor_state new motor_state value
726  */
727 void
729 {
730  data->motor_state = new_motor_state;
731 }
732 
733 /** Clone this message.
734  * Produces a message of the same type as this message and copies the
735  * data to the new message.
736  * @return clone of this message
737  */
738 Message *
740 {
741  return new MotorInterface::SetMotorStateMessage(this);
742 }
743 /** @class MotorInterface::AcquireControlMessage <interfaces/MotorInterface.h>
744  * AcquireControlMessage Fawkes BlackBoard Interface Message.
745  *
746 
747  */
748 
749 
750 /** Constructor with initial values.
751  * @param ini_controller initial value for controller
752  * @param ini_controller_thread_name initial value for controller_thread_name
753  */
754 MotorInterface::AcquireControlMessage::AcquireControlMessage(const uint32_t ini_controller, const char * ini_controller_thread_name) : Message("AcquireControlMessage")
755 {
756  data_size = sizeof(AcquireControlMessage_data_t);
757  data_ptr = malloc(data_size);
758  memset(data_ptr, 0, data_size);
759  data = (AcquireControlMessage_data_t *)data_ptr;
761  data->controller = ini_controller;
762  strncpy(data->controller_thread_name, ini_controller_thread_name, 64);
763  add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller, "");
764  add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name, "");
765 }
766 /** Constructor */
768 {
769  data_size = sizeof(AcquireControlMessage_data_t);
770  data_ptr = malloc(data_size);
771  memset(data_ptr, 0, data_size);
772  data = (AcquireControlMessage_data_t *)data_ptr;
774  add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller, "");
775  add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name, "");
776 }
777 
778 /** Destructor */
780 {
781  free(data_ptr);
782 }
783 
784 /** Copy constructor.
785  * @param m message to copy from
786  */
788 {
789  data_size = m->data_size;
790  data_ptr = malloc(data_size);
791  memcpy(data_ptr, m->data_ptr, data_size);
792  data = (AcquireControlMessage_data_t *)data_ptr;
794 }
795 
796 /* Methods */
797 /** Get controller value.
798  *
799  The ID of the controller. The controller ID is the instance serial of the sending
800  interface. Only from this interface instance command messages are accepted.
801 
802  * @return controller value
803  */
804 uint32_t
806 {
807  return data->controller;
808 }
809 
810 /** Get maximum length of controller value.
811  * @return length of controller value, can be length of the array or number of
812  * maximum number of characters for a string
813  */
814 size_t
816 {
817  return 1;
818 }
819 
820 /** Set controller value.
821  *
822  The ID of the controller. The controller ID is the instance serial of the sending
823  interface. Only from this interface instance command messages are accepted.
824 
825  * @param new_controller new controller value
826  */
827 void
829 {
830  data->controller = new_controller;
831 }
832 
833 /** Get controller_thread_name value.
834  *
835  The name of the controlling thread, for easier debugging. This is informative only
836  and actually two threads may share an interface instance (although this should be
837  avoided since the interface locking has to be reproduced for these threads then).
838 
839  * @return controller_thread_name value
840  */
841 char *
843 {
844  return data->controller_thread_name;
845 }
846 
847 /** Get maximum length of controller_thread_name value.
848  * @return length of controller_thread_name value, can be length of the array or number of
849  * maximum number of characters for a string
850  */
851 size_t
853 {
854  return 64;
855 }
856 
857 /** Set controller_thread_name value.
858  *
859  The name of the controlling thread, for easier debugging. This is informative only
860  and actually two threads may share an interface instance (although this should be
861  avoided since the interface locking has to be reproduced for these threads then).
862 
863  * @param new_controller_thread_name new controller_thread_name value
864  */
865 void
867 {
868  strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
869 }
870 
871 /** Clone this message.
872  * Produces a message of the same type as this message and copies the
873  * data to the new message.
874  * @return clone of this message
875  */
876 Message *
878 {
879  return new MotorInterface::AcquireControlMessage(this);
880 }
881 /** @class MotorInterface::ResetOdometryMessage <interfaces/MotorInterface.h>
882  * ResetOdometryMessage Fawkes BlackBoard Interface Message.
883  *
884 
885  */
886 
887 
888 /** Constructor */
890 {
891  data_size = sizeof(ResetOdometryMessage_data_t);
892  data_ptr = malloc(data_size);
893  memset(data_ptr, 0, data_size);
894  data = (ResetOdometryMessage_data_t *)data_ptr;
896 }
897 
898 /** Destructor */
900 {
901  free(data_ptr);
902 }
903 
904 /** Copy constructor.
905  * @param m message to copy from
906  */
908 {
909  data_size = m->data_size;
910  data_ptr = malloc(data_size);
911  memcpy(data_ptr, m->data_ptr, data_size);
912  data = (ResetOdometryMessage_data_t *)data_ptr;
914 }
915 
916 /* Methods */
917 /** Clone this message.
918  * Produces a message of the same type as this message and copies the
919  * data to the new message.
920  * @return clone of this message
921  */
922 Message *
924 {
925  return new MotorInterface::ResetOdometryMessage(this);
926 }
927 /** @class MotorInterface::DriveRPMMessage <interfaces/MotorInterface.h>
928  * DriveRPMMessage Fawkes BlackBoard Interface Message.
929  *
930 
931  */
932 
933 
934 /** Constructor with initial values.
935  * @param ini_front_right initial value for front_right
936  * @param ini_front_left initial value for front_left
937  * @param ini_rear initial value for rear
938  */
939 MotorInterface::DriveRPMMessage::DriveRPMMessage(const float ini_front_right, const float ini_front_left, const float ini_rear) : Message("DriveRPMMessage")
940 {
941  data_size = sizeof(DriveRPMMessage_data_t);
942  data_ptr = malloc(data_size);
943  memset(data_ptr, 0, data_size);
944  data = (DriveRPMMessage_data_t *)data_ptr;
946  data->front_right = ini_front_right;
947  data->front_left = ini_front_left;
948  data->rear = ini_rear;
949  add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right, "");
950  add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left, "");
951  add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear, "");
952 }
953 /** Constructor */
955 {
956  data_size = sizeof(DriveRPMMessage_data_t);
957  data_ptr = malloc(data_size);
958  memset(data_ptr, 0, data_size);
959  data = (DriveRPMMessage_data_t *)data_ptr;
961  add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right, "");
962  add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left, "");
963  add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear, "");
964 }
965 
966 /** Destructor */
968 {
969  free(data_ptr);
970 }
971 
972 /** Copy constructor.
973  * @param m message to copy from
974  */
976 {
977  data_size = m->data_size;
978  data_ptr = malloc(data_size);
979  memcpy(data_ptr, m->data_ptr, data_size);
980  data = (DriveRPMMessage_data_t *)data_ptr;
982 }
983 
984 /* Methods */
985 /** Get front_right value.
986  * Rotation in RPM of the right front wheel.
987  * @return front_right value
988  */
989 float
991 {
992  return data->front_right;
993 }
994 
995 /** Get maximum length of front_right value.
996  * @return length of front_right value, can be length of the array or number of
997  * maximum number of characters for a string
998  */
999 size_t
1001 {
1002  return 1;
1003 }
1004 
1005 /** Set front_right value.
1006  * Rotation in RPM of the right front wheel.
1007  * @param new_front_right new front_right value
1008  */
1009 void
1011 {
1012  data->front_right = new_front_right;
1013 }
1014 
1015 /** Get front_left value.
1016  * Rotation in RPM of the left front wheel.
1017  * @return front_left value
1018  */
1019 float
1021 {
1022  return data->front_left;
1023 }
1024 
1025 /** Get maximum length of front_left value.
1026  * @return length of front_left value, can be length of the array or number of
1027  * maximum number of characters for a string
1028  */
1029 size_t
1031 {
1032  return 1;
1033 }
1034 
1035 /** Set front_left value.
1036  * Rotation in RPM of the left front wheel.
1037  * @param new_front_left new front_left value
1038  */
1039 void
1041 {
1042  data->front_left = new_front_left;
1043 }
1044 
1045 /** Get rear value.
1046  * Rotation in RPM of the rear wheel.
1047  * @return rear value
1048  */
1049 float
1051 {
1052  return data->rear;
1053 }
1054 
1055 /** Get maximum length of rear value.
1056  * @return length of rear value, can be length of the array or number of
1057  * maximum number of characters for a string
1058  */
1059 size_t
1061 {
1062  return 1;
1063 }
1064 
1065 /** Set rear value.
1066  * Rotation in RPM of the rear wheel.
1067  * @param new_rear new rear value
1068  */
1069 void
1071 {
1072  data->rear = new_rear;
1073 }
1074 
1075 /** Clone this message.
1076  * Produces a message of the same type as this message and copies the
1077  * data to the new message.
1078  * @return clone of this message
1079  */
1080 Message *
1082 {
1083  return new MotorInterface::DriveRPMMessage(this);
1084 }
1085 /** @class MotorInterface::GotoMessage <interfaces/MotorInterface.h>
1086  * GotoMessage Fawkes BlackBoard Interface Message.
1087  *
1088 
1089  */
1090 
1091 
1092 /** Constructor with initial values.
1093  * @param ini_x initial value for x
1094  * @param ini_y initial value for y
1095  * @param ini_phi initial value for phi
1096  * @param ini_time_sec initial value for time_sec
1097  */
1098 MotorInterface::GotoMessage::GotoMessage(const float ini_x, const float ini_y, const float ini_phi, const float ini_time_sec) : Message("GotoMessage")
1099 {
1100  data_size = sizeof(GotoMessage_data_t);
1101  data_ptr = malloc(data_size);
1102  memset(data_ptr, 0, data_size);
1103  data = (GotoMessage_data_t *)data_ptr;
1105  data->x = ini_x;
1106  data->y = ini_y;
1107  data->phi = ini_phi;
1108  data->time_sec = ini_time_sec;
1109  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
1110  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
1111  add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi, "");
1112  add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec, "");
1113 }
1114 /** Constructor */
1116 {
1117  data_size = sizeof(GotoMessage_data_t);
1118  data_ptr = malloc(data_size);
1119  memset(data_ptr, 0, data_size);
1120  data = (GotoMessage_data_t *)data_ptr;
1122  add_fieldinfo(IFT_FLOAT, "x", 1, &data->x, "");
1123  add_fieldinfo(IFT_FLOAT, "y", 1, &data->y, "");
1124  add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi, "");
1125  add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec, "");
1126 }
1127 
1128 /** Destructor */
1130 {
1131  free(data_ptr);
1132 }
1133 
1134 /** Copy constructor.
1135  * @param m message to copy from
1136  */
1138 {
1139  data_size = m->data_size;
1140  data_ptr = malloc(data_size);
1141  memcpy(data_ptr, m->data_ptr, data_size);
1142  data = (GotoMessage_data_t *)data_ptr;
1144 }
1145 
1146 /* Methods */
1147 /** Get x value.
1148  * X distance in m.
1149  * @return x value
1150  */
1151 float
1153 {
1154  return data->x;
1155 }
1156 
1157 /** Get maximum length of x value.
1158  * @return length of x value, can be length of the array or number of
1159  * maximum number of characters for a string
1160  */
1161 size_t
1163 {
1164  return 1;
1165 }
1166 
1167 /** Set x value.
1168  * X distance in m.
1169  * @param new_x new x value
1170  */
1171 void
1173 {
1174  data->x = new_x;
1175 }
1176 
1177 /** Get y value.
1178  * Y distance in m.
1179  * @return y value
1180  */
1181 float
1183 {
1184  return data->y;
1185 }
1186 
1187 /** Get maximum length of y value.
1188  * @return length of y value, can be length of the array or number of
1189  * maximum number of characters for a string
1190  */
1191 size_t
1193 {
1194  return 1;
1195 }
1196 
1197 /** Set y value.
1198  * Y distance in m.
1199  * @param new_y new y value
1200  */
1201 void
1203 {
1204  data->y = new_y;
1205 }
1206 
1207 /** Get phi value.
1208  * Angle relative to current angle in rad.
1209  * @return phi value
1210  */
1211 float
1213 {
1214  return data->phi;
1215 }
1216 
1217 /** Get maximum length of phi value.
1218  * @return length of phi value, can be length of the array or number of
1219  * maximum number of characters for a string
1220  */
1221 size_t
1223 {
1224  return 1;
1225 }
1226 
1227 /** Set phi value.
1228  * Angle relative to current angle in rad.
1229  * @param new_phi new phi value
1230  */
1231 void
1233 {
1234  data->phi = new_phi;
1235 }
1236 
1237 /** Get time_sec value.
1238  * When to reach the desired location.
1239  * @return time_sec value
1240  */
1241 float
1243 {
1244  return data->time_sec;
1245 }
1246 
1247 /** Get maximum length of time_sec value.
1248  * @return length of time_sec value, can be length of the array or number of
1249  * maximum number of characters for a string
1250  */
1251 size_t
1253 {
1254  return 1;
1255 }
1256 
1257 /** Set time_sec value.
1258  * When to reach the desired location.
1259  * @param new_time_sec new time_sec value
1260  */
1261 void
1263 {
1264  data->time_sec = new_time_sec;
1265 }
1266 
1267 /** Clone this message.
1268  * Produces a message of the same type as this message and copies the
1269  * data to the new message.
1270  * @return clone of this message
1271  */
1272 Message *
1274 {
1275  return new MotorInterface::GotoMessage(this);
1276 }
1277 /** @class MotorInterface::TransMessage <interfaces/MotorInterface.h>
1278  * TransMessage Fawkes BlackBoard Interface Message.
1279  *
1280 
1281  */
1282 
1283 
1284 /** Constructor with initial values.
1285  * @param ini_vx initial value for vx
1286  * @param ini_vy initial value for vy
1287  */
1288 MotorInterface::TransMessage::TransMessage(const float ini_vx, const float ini_vy) : Message("TransMessage")
1289 {
1290  data_size = sizeof(TransMessage_data_t);
1291  data_ptr = malloc(data_size);
1292  memset(data_ptr, 0, data_size);
1293  data = (TransMessage_data_t *)data_ptr;
1295  data->vx = ini_vx;
1296  data->vy = ini_vy;
1297  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
1298  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
1299 }
1300 /** Constructor */
1302 {
1303  data_size = sizeof(TransMessage_data_t);
1304  data_ptr = malloc(data_size);
1305  memset(data_ptr, 0, data_size);
1306  data = (TransMessage_data_t *)data_ptr;
1308  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
1309  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
1310 }
1311 
1312 /** Destructor */
1314 {
1315  free(data_ptr);
1316 }
1317 
1318 /** Copy constructor.
1319  * @param m message to copy from
1320  */
1322 {
1323  data_size = m->data_size;
1324  data_ptr = malloc(data_size);
1325  memcpy(data_ptr, m->data_ptr, data_size);
1326  data = (TransMessage_data_t *)data_ptr;
1328 }
1329 
1330 /* Methods */
1331 /** Get vx value.
1332  * Speed in X direction in m/s.
1333  * @return vx value
1334  */
1335 float
1337 {
1338  return data->vx;
1339 }
1340 
1341 /** Get maximum length of vx value.
1342  * @return length of vx value, can be length of the array or number of
1343  * maximum number of characters for a string
1344  */
1345 size_t
1347 {
1348  return 1;
1349 }
1350 
1351 /** Set vx value.
1352  * Speed in X direction in m/s.
1353  * @param new_vx new vx value
1354  */
1355 void
1357 {
1358  data->vx = new_vx;
1359 }
1360 
1361 /** Get vy value.
1362  * Speed in Y direction in m/s.
1363  * @return vy value
1364  */
1365 float
1367 {
1368  return data->vy;
1369 }
1370 
1371 /** Get maximum length of vy value.
1372  * @return length of vy value, can be length of the array or number of
1373  * maximum number of characters for a string
1374  */
1375 size_t
1377 {
1378  return 1;
1379 }
1380 
1381 /** Set vy value.
1382  * Speed in Y direction in m/s.
1383  * @param new_vy new vy value
1384  */
1385 void
1387 {
1388  data->vy = new_vy;
1389 }
1390 
1391 /** Clone this message.
1392  * Produces a message of the same type as this message and copies the
1393  * data to the new message.
1394  * @return clone of this message
1395  */
1396 Message *
1398 {
1399  return new MotorInterface::TransMessage(this);
1400 }
1401 /** @class MotorInterface::RotMessage <interfaces/MotorInterface.h>
1402  * RotMessage Fawkes BlackBoard Interface Message.
1403  *
1404 
1405  */
1406 
1407 
1408 /** Constructor with initial values.
1409  * @param ini_omega initial value for omega
1410  */
1411 MotorInterface::RotMessage::RotMessage(const float ini_omega) : Message("RotMessage")
1412 {
1413  data_size = sizeof(RotMessage_data_t);
1414  data_ptr = malloc(data_size);
1415  memset(data_ptr, 0, data_size);
1416  data = (RotMessage_data_t *)data_ptr;
1418  data->omega = ini_omega;
1419  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1420 }
1421 /** Constructor */
1423 {
1424  data_size = sizeof(RotMessage_data_t);
1425  data_ptr = malloc(data_size);
1426  memset(data_ptr, 0, data_size);
1427  data = (RotMessage_data_t *)data_ptr;
1429  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1430 }
1431 
1432 /** Destructor */
1434 {
1435  free(data_ptr);
1436 }
1437 
1438 /** Copy constructor.
1439  * @param m message to copy from
1440  */
1442 {
1443  data_size = m->data_size;
1444  data_ptr = malloc(data_size);
1445  memcpy(data_ptr, m->data_ptr, data_size);
1446  data = (RotMessage_data_t *)data_ptr;
1448 }
1449 
1450 /* Methods */
1451 /** Get omega value.
1452  * Angle rotation in rad/s.
1453  * @return omega value
1454  */
1455 float
1457 {
1458  return data->omega;
1459 }
1460 
1461 /** Get maximum length of omega value.
1462  * @return length of omega value, can be length of the array or number of
1463  * maximum number of characters for a string
1464  */
1465 size_t
1467 {
1468  return 1;
1469 }
1470 
1471 /** Set omega value.
1472  * Angle rotation in rad/s.
1473  * @param new_omega new omega value
1474  */
1475 void
1477 {
1478  data->omega = new_omega;
1479 }
1480 
1481 /** Clone this message.
1482  * Produces a message of the same type as this message and copies the
1483  * data to the new message.
1484  * @return clone of this message
1485  */
1486 Message *
1488 {
1489  return new MotorInterface::RotMessage(this);
1490 }
1491 /** @class MotorInterface::TransRotMessage <interfaces/MotorInterface.h>
1492  * TransRotMessage Fawkes BlackBoard Interface Message.
1493  *
1494 
1495  */
1496 
1497 
1498 /** Constructor with initial values.
1499  * @param ini_vx initial value for vx
1500  * @param ini_vy initial value for vy
1501  * @param ini_omega initial value for omega
1502  */
1503 MotorInterface::TransRotMessage::TransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("TransRotMessage")
1504 {
1505  data_size = sizeof(TransRotMessage_data_t);
1506  data_ptr = malloc(data_size);
1507  memset(data_ptr, 0, data_size);
1508  data = (TransRotMessage_data_t *)data_ptr;
1510  data->vx = ini_vx;
1511  data->vy = ini_vy;
1512  data->omega = ini_omega;
1513  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
1514  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
1515  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1516 }
1517 /** Constructor */
1519 {
1520  data_size = sizeof(TransRotMessage_data_t);
1521  data_ptr = malloc(data_size);
1522  memset(data_ptr, 0, data_size);
1523  data = (TransRotMessage_data_t *)data_ptr;
1525  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
1526  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
1527  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1528 }
1529 
1530 /** Destructor */
1532 {
1533  free(data_ptr);
1534 }
1535 
1536 /** Copy constructor.
1537  * @param m message to copy from
1538  */
1540 {
1541  data_size = m->data_size;
1542  data_ptr = malloc(data_size);
1543  memcpy(data_ptr, m->data_ptr, data_size);
1544  data = (TransRotMessage_data_t *)data_ptr;
1546 }
1547 
1548 /* Methods */
1549 /** Get vx value.
1550  * Speed in X direction in m/s.
1551  * @return vx value
1552  */
1553 float
1555 {
1556  return data->vx;
1557 }
1558 
1559 /** Get maximum length of vx value.
1560  * @return length of vx value, can be length of the array or number of
1561  * maximum number of characters for a string
1562  */
1563 size_t
1565 {
1566  return 1;
1567 }
1568 
1569 /** Set vx value.
1570  * Speed in X direction in m/s.
1571  * @param new_vx new vx value
1572  */
1573 void
1575 {
1576  data->vx = new_vx;
1577 }
1578 
1579 /** Get vy value.
1580  * Speed in Y direction in m/s.
1581  * @return vy value
1582  */
1583 float
1585 {
1586  return data->vy;
1587 }
1588 
1589 /** Get maximum length of vy value.
1590  * @return length of vy value, can be length of the array or number of
1591  * maximum number of characters for a string
1592  */
1593 size_t
1595 {
1596  return 1;
1597 }
1598 
1599 /** Set vy value.
1600  * Speed in Y direction in m/s.
1601  * @param new_vy new vy value
1602  */
1603 void
1605 {
1606  data->vy = new_vy;
1607 }
1608 
1609 /** Get omega value.
1610  * Angle rotation in rad/s.
1611  * @return omega value
1612  */
1613 float
1615 {
1616  return data->omega;
1617 }
1618 
1619 /** Get maximum length of omega value.
1620  * @return length of omega value, can be length of the array or number of
1621  * maximum number of characters for a string
1622  */
1623 size_t
1625 {
1626  return 1;
1627 }
1628 
1629 /** Set omega value.
1630  * Angle rotation in rad/s.
1631  * @param new_omega new omega value
1632  */
1633 void
1635 {
1636  data->omega = new_omega;
1637 }
1638 
1639 /** Clone this message.
1640  * Produces a message of the same type as this message and copies the
1641  * data to the new message.
1642  * @return clone of this message
1643  */
1644 Message *
1646 {
1647  return new MotorInterface::TransRotMessage(this);
1648 }
1649 /** @class MotorInterface::OrbitMessage <interfaces/MotorInterface.h>
1650  * OrbitMessage Fawkes BlackBoard Interface Message.
1651  *
1652 
1653  */
1654 
1655 
1656 /** Constructor with initial values.
1657  * @param ini_px initial value for px
1658  * @param ini_py initial value for py
1659  * @param ini_omega initial value for omega
1660  */
1661 MotorInterface::OrbitMessage::OrbitMessage(const float ini_px, const float ini_py, const float ini_omega) : Message("OrbitMessage")
1662 {
1663  data_size = sizeof(OrbitMessage_data_t);
1664  data_ptr = malloc(data_size);
1665  memset(data_ptr, 0, data_size);
1666  data = (OrbitMessage_data_t *)data_ptr;
1668  data->px = ini_px;
1669  data->py = ini_py;
1670  data->omega = ini_omega;
1671  add_fieldinfo(IFT_FLOAT, "px", 1, &data->px, "");
1672  add_fieldinfo(IFT_FLOAT, "py", 1, &data->py, "");
1673  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1674 }
1675 /** Constructor */
1677 {
1678  data_size = sizeof(OrbitMessage_data_t);
1679  data_ptr = malloc(data_size);
1680  memset(data_ptr, 0, data_size);
1681  data = (OrbitMessage_data_t *)data_ptr;
1683  add_fieldinfo(IFT_FLOAT, "px", 1, &data->px, "");
1684  add_fieldinfo(IFT_FLOAT, "py", 1, &data->py, "");
1685  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1686 }
1687 
1688 /** Destructor */
1690 {
1691  free(data_ptr);
1692 }
1693 
1694 /** Copy constructor.
1695  * @param m message to copy from
1696  */
1698 {
1699  data_size = m->data_size;
1700  data_ptr = malloc(data_size);
1701  memcpy(data_ptr, m->data_ptr, data_size);
1702  data = (OrbitMessage_data_t *)data_ptr;
1704 }
1705 
1706 /* Methods */
1707 /** Get px value.
1708  * Point's X coordinate to orbit.
1709  * @return px value
1710  */
1711 float
1713 {
1714  return data->px;
1715 }
1716 
1717 /** Get maximum length of px value.
1718  * @return length of px value, can be length of the array or number of
1719  * maximum number of characters for a string
1720  */
1721 size_t
1723 {
1724  return 1;
1725 }
1726 
1727 /** Set px value.
1728  * Point's X coordinate to orbit.
1729  * @param new_px new px value
1730  */
1731 void
1733 {
1734  data->px = new_px;
1735 }
1736 
1737 /** Get py value.
1738  * Point's Y coordinate to orbit.
1739  * @return py value
1740  */
1741 float
1743 {
1744  return data->py;
1745 }
1746 
1747 /** Get maximum length of py value.
1748  * @return length of py value, can be length of the array or number of
1749  * maximum number of characters for a string
1750  */
1751 size_t
1753 {
1754  return 1;
1755 }
1756 
1757 /** Set py value.
1758  * Point's Y coordinate to orbit.
1759  * @param new_py new py value
1760  */
1761 void
1763 {
1764  data->py = new_py;
1765 }
1766 
1767 /** Get omega value.
1768  * Angular speed around point in rad/s.
1769  * @return omega value
1770  */
1771 float
1773 {
1774  return data->omega;
1775 }
1776 
1777 /** Get maximum length of omega value.
1778  * @return length of omega value, can be length of the array or number of
1779  * maximum number of characters for a string
1780  */
1781 size_t
1783 {
1784  return 1;
1785 }
1786 
1787 /** Set omega value.
1788  * Angular speed around point in rad/s.
1789  * @param new_omega new omega value
1790  */
1791 void
1793 {
1794  data->omega = new_omega;
1795 }
1796 
1797 /** Clone this message.
1798  * Produces a message of the same type as this message and copies the
1799  * data to the new message.
1800  * @return clone of this message
1801  */
1802 Message *
1804 {
1805  return new MotorInterface::OrbitMessage(this);
1806 }
1807 /** @class MotorInterface::LinTransRotMessage <interfaces/MotorInterface.h>
1808  * LinTransRotMessage Fawkes BlackBoard Interface Message.
1809  *
1810 
1811  */
1812 
1813 
1814 /** Constructor with initial values.
1815  * @param ini_vx initial value for vx
1816  * @param ini_vy initial value for vy
1817  * @param ini_omega initial value for omega
1818  */
1819 MotorInterface::LinTransRotMessage::LinTransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("LinTransRotMessage")
1820 {
1821  data_size = sizeof(LinTransRotMessage_data_t);
1822  data_ptr = malloc(data_size);
1823  memset(data_ptr, 0, data_size);
1824  data = (LinTransRotMessage_data_t *)data_ptr;
1826  data->vx = ini_vx;
1827  data->vy = ini_vy;
1828  data->omega = ini_omega;
1829  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
1830  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
1831  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1832 }
1833 /** Constructor */
1835 {
1836  data_size = sizeof(LinTransRotMessage_data_t);
1837  data_ptr = malloc(data_size);
1838  memset(data_ptr, 0, data_size);
1839  data = (LinTransRotMessage_data_t *)data_ptr;
1841  add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx, "");
1842  add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy, "");
1843  add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega, "");
1844 }
1845 
1846 /** Destructor */
1848 {
1849  free(data_ptr);
1850 }
1851 
1852 /** Copy constructor.
1853  * @param m message to copy from
1854  */
1856 {
1857  data_size = m->data_size;
1858  data_ptr = malloc(data_size);
1859  memcpy(data_ptr, m->data_ptr, data_size);
1860  data = (LinTransRotMessage_data_t *)data_ptr;
1862 }
1863 
1864 /* Methods */
1865 /** Get vx value.
1866  * Speed for translation in X direction in m/s.
1867  * @return vx value
1868  */
1869 float
1871 {
1872  return data->vx;
1873 }
1874 
1875 /** Get maximum length of vx value.
1876  * @return length of vx value, can be length of the array or number of
1877  * maximum number of characters for a string
1878  */
1879 size_t
1881 {
1882  return 1;
1883 }
1884 
1885 /** Set vx value.
1886  * Speed for translation in X direction in m/s.
1887  * @param new_vx new vx value
1888  */
1889 void
1891 {
1892  data->vx = new_vx;
1893 }
1894 
1895 /** Get vy value.
1896  * Speed for translation in Y direction in m/s.
1897  * @return vy value
1898  */
1899 float
1901 {
1902  return data->vy;
1903 }
1904 
1905 /** Get maximum length of vy value.
1906  * @return length of vy value, can be length of the array or number of
1907  * maximum number of characters for a string
1908  */
1909 size_t
1911 {
1912  return 1;
1913 }
1914 
1915 /** Set vy value.
1916  * Speed for translation in Y direction in m/s.
1917  * @param new_vy new vy value
1918  */
1919 void
1921 {
1922  data->vy = new_vy;
1923 }
1924 
1925 /** Get omega value.
1926  * Rotational speed in rad/s.
1927  * @return omega value
1928  */
1929 float
1931 {
1932  return data->omega;
1933 }
1934 
1935 /** Get maximum length of omega value.
1936  * @return length of omega value, can be length of the array or number of
1937  * maximum number of characters for a string
1938  */
1939 size_t
1941 {
1942  return 1;
1943 }
1944 
1945 /** Set omega value.
1946  * Rotational speed in rad/s.
1947  * @param new_omega new omega value
1948  */
1949 void
1951 {
1952  data->omega = new_omega;
1953 }
1954 
1955 /** Clone this message.
1956  * Produces a message of the same type as this message and copies the
1957  * data to the new message.
1958  * @return clone of this message
1959  */
1960 Message *
1962 {
1963  return new MotorInterface::LinTransRotMessage(this);
1964 }
1965 /** Check if message is valid and can be enqueued.
1966  * @param message Message to check
1967  * @return true if the message is valid, false otherwise.
1968  */
1969 bool
1971 {
1972  const SetMotorStateMessage *m0 = dynamic_cast<const SetMotorStateMessage *>(message);
1973  if ( m0 != NULL ) {
1974  return true;
1975  }
1976  const AcquireControlMessage *m1 = dynamic_cast<const AcquireControlMessage *>(message);
1977  if ( m1 != NULL ) {
1978  return true;
1979  }
1980  const ResetOdometryMessage *m2 = dynamic_cast<const ResetOdometryMessage *>(message);
1981  if ( m2 != NULL ) {
1982  return true;
1983  }
1984  const DriveRPMMessage *m3 = dynamic_cast<const DriveRPMMessage *>(message);
1985  if ( m3 != NULL ) {
1986  return true;
1987  }
1988  const GotoMessage *m4 = dynamic_cast<const GotoMessage *>(message);
1989  if ( m4 != NULL ) {
1990  return true;
1991  }
1992  const TransMessage *m5 = dynamic_cast<const TransMessage *>(message);
1993  if ( m5 != NULL ) {
1994  return true;
1995  }
1996  const RotMessage *m6 = dynamic_cast<const RotMessage *>(message);
1997  if ( m6 != NULL ) {
1998  return true;
1999  }
2000  const TransRotMessage *m7 = dynamic_cast<const TransRotMessage *>(message);
2001  if ( m7 != NULL ) {
2002  return true;
2003  }
2004  const OrbitMessage *m8 = dynamic_cast<const OrbitMessage *>(message);
2005  if ( m8 != NULL ) {
2006  return true;
2007  }
2008  const LinTransRotMessage *m9 = dynamic_cast<const LinTransRotMessage *>(message);
2009  if ( m9 != NULL ) {
2010  return true;
2011  }
2012  return false;
2013 }
2014 
2015 /// @cond INTERNALS
2016 EXPORT_INTERFACE(MotorInterface)
2017 /// @endcond
2018 
2019 
2020 } // end namespace fawkes
void set_vy(const float new_vy)
Set vy value.
virtual Message * create_message(const char *type) const
Create message based on type name.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_omega(const float new_omega)
Set omega value.
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:114
SetMotorStateMessage Fawkes BlackBoard Interface Message.
static const uint32_t DRIVE_MODE_LINE_TRANS_ROT
DRIVE_MODE_LINE_TRANS_ROT constant.
RotMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_left_rpm() const
Get maximum length of left_rpm value.
float py() const
Get py value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
virtual Message * clone() const
Clone this message.
float omega() const
Get omega value.
static const uint32_t MOTOR_ENABLED
MOTOR_ENABLED constant.
void set_rear(const float new_rear)
Set rear value.
float px() const
Get px value.
size_t maxlenof_odometry_path_length() const
Get maximum length of odometry_path_length value.
static const uint32_t DRIVE_MODE_RPM
DRIVE_MODE_RPM constant.
void set_omega(const float new_omega)
Set omega value.
float x() const
Get x value.
void set_vx(const float new_vx)
Set vx value.
size_t maxlenof_y() const
Get maximum length of y value.
TransRotMessage Fawkes BlackBoard Interface Message.
float phi() const
Get phi value.
size_t maxlenof_motor_state() const
Get maximum length of motor_state value.
void set_hash(unsigned char *ihash)
Set hash.
Definition: interface.cpp:312
uint32_t controller() const
Get controller value.
int32_t rear_rpm() const
Get rear_rpm value.
virtual Message * clone() const
Clone this message.
void set_odometry_position_y(const float new_odometry_position_y)
Set odometry_position_y value.
Fawkes library namespace.
size_t maxlenof_omega() const
Get maximum length of omega value.
size_t maxlenof_px() const
Get maximum length of px value.
size_t maxlenof_vy() const
Get maximum length of vy 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:119
size_t maxlenof_drive_mode() const
Get maximum length of drive_mode value.
float rear() const
Get rear value.
float time_sec() const
Get time_sec value.
float vx() const
Get vx value.
size_t maxlenof_front_left() const
Get maximum length of front_left value.
void set_vy(const float new_vy)
Set vy 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.
size_t maxlenof_motor_state() const
Get maximum length of motor_state value.
virtual Message * clone() const
Clone this message.
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:45
void set_front_right(const float new_front_right)
Set front_right value.
OrbitMessage Fawkes BlackBoard Interface Message.
void set_motor_state(const uint32_t new_motor_state)
Set motor_state value.
char * controller_thread_name() const
Get controller_thread_name value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
uint32_t motor_state() const
Get motor_state value.
void set_time_sec(const float new_time_sec)
Set time_sec value.
float odometry_orientation() const
Get odometry_orientation value.
void set_omega(const float new_omega)
Set omega value.
size_t maxlenof_vy() const
Get maximum length of vy 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 omega() const
Get omega value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:123
float vy() const
Get vy value.
ResetOdometryMessage Fawkes BlackBoard Interface Message.
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:115
void set_odometry_path_length(const float new_odometry_path_length)
Set odometry_path_length value.
AcquireControlMessage Fawkes BlackBoard Interface Message.
float omega() const
Get omega value.
void add_messageinfo(const char *name)
Add an entry to the message info list.
Definition: interface.cpp:368
char * controller_thread_name() const
Get controller_thread_name value.
size_t maxlenof_vx() const
Get maximum length of vx value.
bool data_changed
Indicator if data has changed.
Definition: interface.h:208
virtual Message * clone() const
Clone this message.
float front_right() const
Get front_right value.
size_t maxlenof_odometry_orientation() const
Get maximum length of odometry_orientation value.
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:206
static const uint32_t DRIVE_MODE_TRANS_ROT
DRIVE_MODE_TRANS_ROT constant.
float front_left() const
Get front_left value.
float odometry_position_y() const
Get odometry_position_y value.
size_t maxlenof_controller_thread_name() const
Get maximum length of controller_thread_name value.
void set_vy(const float new_vy)
Set vy value.
size_t maxlenof_omega() const
Get maximum length of omega value.
void set_phi(const float new_phi)
Set phi value.
float vy() const
Get vy value.
void set_vx(const float new_vx)
Set vx value.
size_t maxlenof_omega() const
Get maximum length of omega value.
void set_omega(const float new_omega)
Set omega value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_py(const float new_py)
Set py value.
float y() const
Get y 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_x() const
Get maximum length of x value.
virtual Message * clone() const
Clone this message.
void set_front_left(const float new_front_left)
Set front_left value.
size_t maxlenof_vy() const
Get maximum length of vy value.
int32_t left_rpm() const
Get left_rpm value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_controller_thread_name(const char *new_controller_thread_name)
Set controller_thread_name value.
LinTransRotMessage Fawkes BlackBoard Interface Message.
void set_px(const float new_px)
Set px value.
virtual Message * clone() const
Clone this message.
uint32_t drive_mode() const
Get drive_mode value.
size_t maxlenof_omega() const
Get maximum length of omega value.
float field
Definition: types.h:43
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
float omega() const
Get omega value.
size_t maxlenof_front_right() const
Get maximum length of front_right value.
size_t maxlenof_phi() const
Get maximum length of phi value.
32 bit integer field
Definition: types.h:39
virtual Message * clone() const
Clone this message.
DriveRPMMessage Fawkes BlackBoard Interface Message.
float omega() const
Get omega value.
void set_drive_mode(const uint32_t new_drive_mode)
Set drive_mode value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_vx(const float new_vx)
Set vx value.
void set_vx(const float new_vx)
Set vx value.
float vx() const
Get vx value.
virtual Message * clone() const
Clone this message.
float odometry_path_length() const
Get odometry_path_length value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_rear_rpm() const
Get maximum length of rear_rpm value.
size_t maxlenof_odometry_position_y() const
Get maximum length of odometry_position_y value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the info list.
Definition: message.cpp:435
static const uint32_t MOTOR_DISABLED
MOTOR_DISABLED constant.
size_t maxlenof_rear() const
Get maximum length of rear value.
void set_odometry_position_x(const float new_odometry_position_x)
Set odometry_position_x value.
uint32_t controller() const
Get controller value.
size_t maxlenof_controller_thread_name() const
Get maximum length of controller_thread_name value.
size_t maxlenof_controller() const
Get maximum length of controller value.
static const uint32_t DRIVE_MODE_ORBIT
DRIVE_MODE_ORBIT constant.
size_t maxlenof_controller() const
Get maximum length of controller value.
MotorInterface Fawkes BlackBoard Interface.
size_t maxlenof_omega() const
Get maximum length of omega value.
float odometry_position_x() const
Get odometry_position_x value.
GotoMessage Fawkes BlackBoard Interface Message.
const char * type() const
Get type of interface.
Definition: interface.cpp:635
int32_t right_rpm() const
Get right_rpm 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.
32 bit unsigned integer field
Definition: types.h:40
size_t maxlenof_odometry_position_x() const
Get maximum length of odometry_position_x value.
size_t maxlenof_vy() const
Get maximum length of vy value.
static const uint32_t DRIVE_MODE_ROT
DRIVE_MODE_ROT constant.
virtual void copy_values(const Interface *other)
Copy values from other interface.
uint32_t motor_state() const
Get motor_state value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
TransMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_py() const
Get maximum length of py value.
size_t maxlenof_right_rpm() const
Get maximum length of right_rpm value.
void set_y(const float new_y)
Set y value.
virtual Message * clone() const
Clone this message.