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
33namespace 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 */
45const uint32_t MotorInterface::MOTOR_ENABLED = 0u;
46/** MOTOR_DISABLED constant */
47const uint32_t MotorInterface::MOTOR_DISABLED = 1u;
48/** DRIVE_MODE_RPM constant */
49const uint32_t MotorInterface::DRIVE_MODE_RPM = 1u;
50/** DRIVE_MODE_TRANS constant */
51const uint32_t MotorInterface::DRIVE_MODE_TRANS = 2u;
52/** DRIVE_MODE_ROT constant */
53const uint32_t MotorInterface::DRIVE_MODE_ROT = 3u;
54/** DRIVE_MODE_TRANS_ROT constant */
55const uint32_t MotorInterface::DRIVE_MODE_TRANS_ROT = 4u;
56/** DRIVE_MODE_ORBIT constant */
57const uint32_t MotorInterface::DRIVE_MODE_ORBIT = 5u;
58/** DRIVE_MODE_LINE_TRANS_ROT constant */
60
61/** Constructor */
62MotorInterface::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 */
102MotorInterface::~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 */
113uint32_t
114MotorInterface::motor_state() const
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 */
123size_t
124MotorInterface::maxlenof_motor_state() const
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 */
135void
136MotorInterface::set_motor_state(const uint32_t new_motor_state)
137{
138 set_field(data->motor_state, new_motor_state);
139}
140
141/** Get drive_mode value.
142 *
143 The current drive mode of the motor.
144
145 * @return drive_mode value
146 */
147uint32_t
148MotorInterface::drive_mode() const
149{
150 return data->drive_mode;
151}
152
153/** Get maximum length of drive_mode value.
154 * @return length of drive_mode value, can be length of the array or number of
155 * maximum number of characters for a string
156 */
157size_t
158MotorInterface::maxlenof_drive_mode() const
159{
160 return 1;
161}
162
163/** Set drive_mode value.
164 *
165 The current drive mode of the motor.
166
167 * @param new_drive_mode new drive_mode value
168 */
169void
170MotorInterface::set_drive_mode(const uint32_t new_drive_mode)
171{
172 set_field(data->drive_mode, new_drive_mode);
173}
174
175/** Get right_rpm value.
176 *
177 RPM of the motor on the right front of the robot.
178
179 * @return right_rpm value
180 */
181int32_t
182MotorInterface::right_rpm() const
183{
184 return data->right_rpm;
185}
186
187/** Get maximum length of right_rpm value.
188 * @return length of right_rpm value, can be length of the array or number of
189 * maximum number of characters for a string
190 */
191size_t
192MotorInterface::maxlenof_right_rpm() const
193{
194 return 1;
195}
196
197/** Set right_rpm value.
198 *
199 RPM of the motor on the right front of the robot.
200
201 * @param new_right_rpm new right_rpm value
202 */
203void
204MotorInterface::set_right_rpm(const int32_t new_right_rpm)
205{
206 set_field(data->right_rpm, new_right_rpm);
207}
208
209/** Get rear_rpm value.
210 *
211 RPM of motor on the rear of the robot.
212
213 * @return rear_rpm value
214 */
215int32_t
216MotorInterface::rear_rpm() const
217{
218 return data->rear_rpm;
219}
220
221/** Get maximum length of rear_rpm value.
222 * @return length of rear_rpm value, can be length of the array or number of
223 * maximum number of characters for a string
224 */
225size_t
226MotorInterface::maxlenof_rear_rpm() const
227{
228 return 1;
229}
230
231/** Set rear_rpm value.
232 *
233 RPM of motor on the rear of the robot.
234
235 * @param new_rear_rpm new rear_rpm value
236 */
237void
238MotorInterface::set_rear_rpm(const int32_t new_rear_rpm)
239{
240 set_field(data->rear_rpm, new_rear_rpm);
241}
242
243/** Get left_rpm value.
244 *
245 RPM of the motor on the left front of the robot.
246
247 * @return left_rpm value
248 */
249int32_t
250MotorInterface::left_rpm() const
251{
252 return data->left_rpm;
253}
254
255/** Get maximum length of left_rpm value.
256 * @return length of left_rpm value, can be length of the array or number of
257 * maximum number of characters for a string
258 */
259size_t
260MotorInterface::maxlenof_left_rpm() const
261{
262 return 1;
263}
264
265/** Set left_rpm value.
266 *
267 RPM of the motor on the left front of the robot.
268
269 * @param new_left_rpm new left_rpm value
270 */
271void
272MotorInterface::set_left_rpm(const int32_t new_left_rpm)
273{
274 set_field(data->left_rpm, new_left_rpm);
275}
276
277/** Get odometry_path_length value.
278 *
279 The actual length of the robot's trajectory since the last ResetOdometry.
280
281 * @return odometry_path_length value
282 */
283float
284MotorInterface::odometry_path_length() const
285{
286 return data->odometry_path_length;
287}
288
289/** Get maximum length of odometry_path_length value.
290 * @return length of odometry_path_length value, can be length of the array or number of
291 * maximum number of characters for a string
292 */
293size_t
294MotorInterface::maxlenof_odometry_path_length() const
295{
296 return 1;
297}
298
299/** Set odometry_path_length value.
300 *
301 The actual length of the robot's trajectory since the last ResetOdometry.
302
303 * @param new_odometry_path_length new odometry_path_length value
304 */
305void
306MotorInterface::set_odometry_path_length(const float new_odometry_path_length)
307{
308 set_field(data->odometry_path_length, new_odometry_path_length);
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 */
317float
318MotorInterface::odometry_position_x() const
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 */
327size_t
328MotorInterface::maxlenof_odometry_position_x() const
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 */
339void
340MotorInterface::set_odometry_position_x(const float new_odometry_position_x)
341{
342 set_field(data->odometry_position_x, new_odometry_position_x);
343}
344
345/** Get odometry_position_y value.
346 *
347 The actual position of the robot relative to the position at the last ResetOdometry.
348
349 * @return odometry_position_y value
350 */
351float
352MotorInterface::odometry_position_y() const
353{
354 return data->odometry_position_y;
355}
356
357/** Get maximum length of odometry_position_y value.
358 * @return length of odometry_position_y value, can be length of the array or number of
359 * maximum number of characters for a string
360 */
361size_t
362MotorInterface::maxlenof_odometry_position_y() const
363{
364 return 1;
365}
366
367/** Set odometry_position_y value.
368 *
369 The actual position of the robot relative to the position at the last ResetOdometry.
370
371 * @param new_odometry_position_y new odometry_position_y value
372 */
373void
374MotorInterface::set_odometry_position_y(const float new_odometry_position_y)
375{
376 set_field(data->odometry_position_y, new_odometry_position_y);
377}
378
379/** Get odometry_orientation value.
380 *
381 The actual orientation of the robot relative to the orientation at the last ResetOdometry.
382
383 * @return odometry_orientation value
384 */
385float
386MotorInterface::odometry_orientation() const
387{
388 return data->odometry_orientation;
389}
390
391/** Get maximum length of odometry_orientation value.
392 * @return length of odometry_orientation value, can be length of the array or number of
393 * maximum number of characters for a string
394 */
395size_t
396MotorInterface::maxlenof_odometry_orientation() const
397{
398 return 1;
399}
400
401/** Set odometry_orientation value.
402 *
403 The actual orientation of the robot relative to the orientation at the last ResetOdometry.
404
405 * @param new_odometry_orientation new odometry_orientation value
406 */
407void
408MotorInterface::set_odometry_orientation(const float new_odometry_orientation)
409{
410 set_field(data->odometry_orientation, new_odometry_orientation);
411}
412
413/** Get vx value.
414 *
415 VX of the robot in m/s. Forward.
416
417 * @return vx value
418 */
419float
420MotorInterface::vx() const
421{
422 return data->vx;
423}
424
425/** Get maximum length of vx value.
426 * @return length of vx value, can be length of the array or number of
427 * maximum number of characters for a string
428 */
429size_t
430MotorInterface::maxlenof_vx() const
431{
432 return 1;
433}
434
435/** Set vx value.
436 *
437 VX of the robot in m/s. Forward.
438
439 * @param new_vx new vx value
440 */
441void
442MotorInterface::set_vx(const float new_vx)
443{
444 set_field(data->vx, new_vx);
445}
446
447/** Get vy value.
448 *
449 VY of the robot in m/s. Left.
450
451 * @return vy value
452 */
453float
454MotorInterface::vy() const
455{
456 return data->vy;
457}
458
459/** Get maximum length of vy value.
460 * @return length of vy value, can be length of the array or number of
461 * maximum number of characters for a string
462 */
463size_t
464MotorInterface::maxlenof_vy() const
465{
466 return 1;
467}
468
469/** Set vy value.
470 *
471 VY of the robot in m/s. Left.
472
473 * @param new_vy new vy value
474 */
475void
476MotorInterface::set_vy(const float new_vy)
477{
478 set_field(data->vy, new_vy);
479}
480
481/** Get omega value.
482 *
483 Rotation speed of the robot in rad/s.
484
485 * @return omega value
486 */
487float
488MotorInterface::omega() const
489{
490 return data->omega;
491}
492
493/** Get maximum length of omega value.
494 * @return length of omega value, can be length of the array or number of
495 * maximum number of characters for a string
496 */
497size_t
498MotorInterface::maxlenof_omega() const
499{
500 return 1;
501}
502
503/** Set omega value.
504 *
505 Rotation speed of the robot in rad/s.
506
507 * @param new_omega new omega value
508 */
509void
510MotorInterface::set_omega(const float new_omega)
511{
512 set_field(data->omega, new_omega);
513}
514
515/** Get des_vx value.
516 *
517 Desired VX of the robot in m/s. Forward.
518
519 * @return des_vx value
520 */
521float
522MotorInterface::des_vx() const
523{
524 return data->des_vx;
525}
526
527/** Get maximum length of des_vx value.
528 * @return length of des_vx value, can be length of the array or number of
529 * maximum number of characters for a string
530 */
531size_t
532MotorInterface::maxlenof_des_vx() const
533{
534 return 1;
535}
536
537/** Set des_vx value.
538 *
539 Desired VX of the robot in m/s. Forward.
540
541 * @param new_des_vx new des_vx value
542 */
543void
544MotorInterface::set_des_vx(const float new_des_vx)
545{
546 set_field(data->des_vx, new_des_vx);
547}
548
549/** Get des_vy value.
550 *
551 Desired VY of the robot in m/s. Left.
552
553 * @return des_vy value
554 */
555float
556MotorInterface::des_vy() const
557{
558 return data->des_vy;
559}
560
561/** Get maximum length of des_vy value.
562 * @return length of des_vy value, can be length of the array or number of
563 * maximum number of characters for a string
564 */
565size_t
566MotorInterface::maxlenof_des_vy() const
567{
568 return 1;
569}
570
571/** Set des_vy value.
572 *
573 Desired VY of the robot in m/s. Left.
574
575 * @param new_des_vy new des_vy value
576 */
577void
578MotorInterface::set_des_vy(const float new_des_vy)
579{
580 set_field(data->des_vy, new_des_vy);
581}
582
583/** Get des_omega value.
584 *
585 Desired Rotation speed of the robot in rad/s.
586
587 * @return des_omega value
588 */
589float
590MotorInterface::des_omega() const
591{
592 return data->des_omega;
593}
594
595/** Get maximum length of des_omega value.
596 * @return length of des_omega value, can be length of the array or number of
597 * maximum number of characters for a string
598 */
599size_t
600MotorInterface::maxlenof_des_omega() const
601{
602 return 1;
603}
604
605/** Set des_omega value.
606 *
607 Desired Rotation speed of the robot in rad/s.
608
609 * @param new_des_omega new des_omega value
610 */
611void
612MotorInterface::set_des_omega(const float new_des_omega)
613{
614 set_field(data->des_omega, new_des_omega);
615}
616
617/** Get controller value.
618 *
619 The ID of the controller. The controller ID is the instance serial of the sending
620 interface. Only from this interface instance command messages are accepted.
621
622 * @return controller value
623 */
624uint32_t
625MotorInterface::controller() const
626{
627 return data->controller;
628}
629
630/** Get maximum length of controller value.
631 * @return length of controller value, can be length of the array or number of
632 * maximum number of characters for a string
633 */
634size_t
635MotorInterface::maxlenof_controller() const
636{
637 return 1;
638}
639
640/** Set controller value.
641 *
642 The ID of the controller. The controller ID is the instance serial of the sending
643 interface. Only from this interface instance command messages are accepted.
644
645 * @param new_controller new controller value
646 */
647void
648MotorInterface::set_controller(const uint32_t new_controller)
649{
650 set_field(data->controller, new_controller);
651}
652
653/** Get controller_thread_name value.
654 *
655 The name of the controlling thread, for easier debugging. This is informative only
656 and actually two threads may share an interface instance (although this should be
657 avoided since the interface locking has to be reproduced for these threads then).
658
659 * @return controller_thread_name value
660 */
661char *
662MotorInterface::controller_thread_name() const
663{
664 return data->controller_thread_name;
665}
666
667/** Get maximum length of controller_thread_name value.
668 * @return length of controller_thread_name value, can be length of the array or number of
669 * maximum number of characters for a string
670 */
671size_t
672MotorInterface::maxlenof_controller_thread_name() const
673{
674 return 64;
675}
676
677/** Set controller_thread_name value.
678 *
679 The name of the controlling thread, for easier debugging. This is informative only
680 and actually two threads may share an interface instance (although this should be
681 avoided since the interface locking has to be reproduced for these threads then).
682
683 * @param new_controller_thread_name new controller_thread_name value
684 */
685void
686MotorInterface::set_controller_thread_name(const char * new_controller_thread_name)
687{
688 set_field(data->controller_thread_name, new_controller_thread_name);
689}
690
691/* =========== message create =========== */
692Message *
693MotorInterface::create_message(const char *type) const
694{
695 if ( strncmp("SetMotorStateMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
696 return new SetMotorStateMessage();
697 } else if ( strncmp("AcquireControlMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
698 return new AcquireControlMessage();
699 } else if ( strncmp("ResetOdometryMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
700 return new ResetOdometryMessage();
701 } else if ( strncmp("SetOdometryMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
702 return new SetOdometryMessage();
703 } else if ( strncmp("DriveRPMMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
704 return new DriveRPMMessage();
705 } else if ( strncmp("GotoMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
706 return new GotoMessage();
707 } else if ( strncmp("TransMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
708 return new TransMessage();
709 } else if ( strncmp("RotMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
710 return new RotMessage();
711 } else if ( strncmp("TransRotMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
712 return new TransRotMessage();
713 } else if ( strncmp("OrbitMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
714 return new OrbitMessage();
715 } else if ( strncmp("LinTransRotMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
716 return new LinTransRotMessage();
717 } else {
718 throw UnknownTypeException("The given type '%s' does not match any known "
719 "message type for this interface type.", type);
720 }
721}
722
723
724/** Copy values from other interface.
725 * @param other other interface to copy values from
726 */
727void
728MotorInterface::copy_values(const Interface *other)
729{
730 const MotorInterface *oi = dynamic_cast<const MotorInterface *>(other);
731 if (oi == NULL) {
732 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
733 type(), other->type());
734 }
735 memcpy(data, oi->data, sizeof(MotorInterface_data_t));
736}
737
738const char *
739MotorInterface::enum_tostring(const char *enumtype, int val) const
740{
741 throw UnknownTypeException("Unknown enum type %s", enumtype);
742}
743
744/* =========== messages =========== */
745/** @class MotorInterface::SetMotorStateMessage <interfaces/MotorInterface.h>
746 * SetMotorStateMessage Fawkes BlackBoard Interface Message.
747 *
748
749 */
750
751
752/** Constructor with initial values.
753 * @param ini_motor_state initial value for motor_state
754 */
755MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const uint32_t ini_motor_state) : Message("SetMotorStateMessage")
756{
757 data_size = sizeof(SetMotorStateMessage_data_t);
758 data_ptr = malloc(data_size);
759 memset(data_ptr, 0, data_size);
760 data = (SetMotorStateMessage_data_t *)data_ptr;
762 data->motor_state = ini_motor_state;
763 add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state);
764}
765/** Constructor */
767{
768 data_size = sizeof(SetMotorStateMessage_data_t);
769 data_ptr = malloc(data_size);
770 memset(data_ptr, 0, data_size);
771 data = (SetMotorStateMessage_data_t *)data_ptr;
773 add_fieldinfo(IFT_UINT32, "motor_state", 1, &data->motor_state);
774}
775
776/** Destructor */
778{
779 free(data_ptr);
780}
781
782/** Copy constructor.
783 * @param m message to copy from
784 */
786{
787 data_size = m->data_size;
788 data_ptr = malloc(data_size);
789 memcpy(data_ptr, m->data_ptr, data_size);
790 data = (SetMotorStateMessage_data_t *)data_ptr;
792}
793
794/* Methods */
795/** Get motor_state value.
796 *
797 The new motor state to set. Use the MOTOR_* constants.
798
799 * @return motor_state value
800 */
801uint32_t
803{
804 return data->motor_state;
805}
806
807/** Get maximum length of motor_state value.
808 * @return length of motor_state value, can be length of the array or number of
809 * maximum number of characters for a string
810 */
811size_t
813{
814 return 1;
815}
816
817/** Set motor_state value.
818 *
819 The new motor state to set. Use the MOTOR_* constants.
820
821 * @param new_motor_state new motor_state value
822 */
823void
825{
826 set_field(data->motor_state, new_motor_state);
827}
828
829/** Clone this message.
830 * Produces a message of the same type as this message and copies the
831 * data to the new message.
832 * @return clone of this message
833 */
834Message *
836{
838}
839/** @class MotorInterface::AcquireControlMessage <interfaces/MotorInterface.h>
840 * AcquireControlMessage Fawkes BlackBoard Interface Message.
841 *
842
843 */
844
845
846/** Constructor with initial values.
847 * @param ini_controller initial value for controller
848 * @param ini_controller_thread_name initial value for controller_thread_name
849 */
850MotorInterface::AcquireControlMessage::AcquireControlMessage(const uint32_t ini_controller, const char * ini_controller_thread_name) : Message("AcquireControlMessage")
851{
852 data_size = sizeof(AcquireControlMessage_data_t);
853 data_ptr = malloc(data_size);
854 memset(data_ptr, 0, data_size);
855 data = (AcquireControlMessage_data_t *)data_ptr;
857 data->controller = ini_controller;
858 strncpy(data->controller_thread_name, ini_controller_thread_name, 64-1);
859 data->controller_thread_name[64-1] = 0;
860 add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller);
861 add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
862}
863/** Constructor */
865{
866 data_size = sizeof(AcquireControlMessage_data_t);
867 data_ptr = malloc(data_size);
868 memset(data_ptr, 0, data_size);
869 data = (AcquireControlMessage_data_t *)data_ptr;
871 add_fieldinfo(IFT_UINT32, "controller", 1, &data->controller);
872 add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
873}
874
875/** Destructor */
877{
878 free(data_ptr);
879}
880
881/** Copy constructor.
882 * @param m message to copy from
883 */
885{
886 data_size = m->data_size;
887 data_ptr = malloc(data_size);
888 memcpy(data_ptr, m->data_ptr, data_size);
889 data = (AcquireControlMessage_data_t *)data_ptr;
891}
892
893/* Methods */
894/** Get controller value.
895 *
896 The ID of the controller. The controller ID is the instance serial of the sending
897 interface. Only from this interface instance command messages are accepted.
898
899 * @return controller value
900 */
901uint32_t
903{
904 return data->controller;
905}
906
907/** Get maximum length of controller value.
908 * @return length of controller value, can be length of the array or number of
909 * maximum number of characters for a string
910 */
911size_t
913{
914 return 1;
915}
916
917/** Set controller value.
918 *
919 The ID of the controller. The controller ID is the instance serial of the sending
920 interface. Only from this interface instance command messages are accepted.
921
922 * @param new_controller new controller value
923 */
924void
926{
927 set_field(data->controller, new_controller);
928}
929
930/** Get controller_thread_name value.
931 *
932 The name of the controlling thread, for easier debugging. This is informative only
933 and actually two threads may share an interface instance (although this should be
934 avoided since the interface locking has to be reproduced for these threads then).
935
936 * @return controller_thread_name value
937 */
938char *
940{
941 return data->controller_thread_name;
942}
943
944/** Get maximum length of controller_thread_name value.
945 * @return length of controller_thread_name value, can be length of the array or number of
946 * maximum number of characters for a string
947 */
948size_t
950{
951 return 64;
952}
953
954/** Set controller_thread_name value.
955 *
956 The name of the controlling thread, for easier debugging. This is informative only
957 and actually two threads may share an interface instance (although this should be
958 avoided since the interface locking has to be reproduced for these threads then).
959
960 * @param new_controller_thread_name new controller_thread_name value
961 */
962void
964{
965 set_field(data->controller_thread_name, new_controller_thread_name);
966}
967
968/** Clone this message.
969 * Produces a message of the same type as this message and copies the
970 * data to the new message.
971 * @return clone of this message
972 */
973Message *
975{
977}
978/** @class MotorInterface::ResetOdometryMessage <interfaces/MotorInterface.h>
979 * ResetOdometryMessage Fawkes BlackBoard Interface Message.
980 *
981
982 */
983
984
985/** Constructor */
987{
988 data_size = sizeof(ResetOdometryMessage_data_t);
989 data_ptr = malloc(data_size);
990 memset(data_ptr, 0, data_size);
991 data = (ResetOdometryMessage_data_t *)data_ptr;
993}
994
995/** Destructor */
997{
998 free(data_ptr);
999}
1000
1001/** Copy constructor.
1002 * @param m message to copy from
1003 */
1005{
1006 data_size = m->data_size;
1007 data_ptr = malloc(data_size);
1008 memcpy(data_ptr, m->data_ptr, data_size);
1009 data = (ResetOdometryMessage_data_t *)data_ptr;
1011}
1012
1013/* Methods */
1014/** Clone this message.
1015 * Produces a message of the same type as this message and copies the
1016 * data to the new message.
1017 * @return clone of this message
1018 */
1019Message *
1021{
1022 return new MotorInterface::ResetOdometryMessage(this);
1023}
1024/** @class MotorInterface::SetOdometryMessage <interfaces/MotorInterface.h>
1025 * SetOdometryMessage Fawkes BlackBoard Interface Message.
1026 *
1027
1028 */
1029
1030
1031/** Constructor with initial values.
1032 * @param ini_x initial value for x
1033 * @param ini_y initial value for y
1034 * @param ini_odometry_orientation initial value for odometry_orientation
1035 */
1036MotorInterface::SetOdometryMessage::SetOdometryMessage(const float ini_x, const float ini_y, const float ini_odometry_orientation) : Message("SetOdometryMessage")
1037{
1038 data_size = sizeof(SetOdometryMessage_data_t);
1039 data_ptr = malloc(data_size);
1040 memset(data_ptr, 0, data_size);
1041 data = (SetOdometryMessage_data_t *)data_ptr;
1043 data->x = ini_x;
1044 data->y = ini_y;
1045 data->odometry_orientation = ini_odometry_orientation;
1046 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1047 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1048 add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
1049}
1050/** Constructor */
1052{
1053 data_size = sizeof(SetOdometryMessage_data_t);
1054 data_ptr = malloc(data_size);
1055 memset(data_ptr, 0, data_size);
1056 data = (SetOdometryMessage_data_t *)data_ptr;
1058 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1059 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1060 add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
1061}
1062
1063/** Destructor */
1065{
1066 free(data_ptr);
1067}
1068
1069/** Copy constructor.
1070 * @param m message to copy from
1071 */
1073{
1074 data_size = m->data_size;
1075 data_ptr = malloc(data_size);
1076 memcpy(data_ptr, m->data_ptr, data_size);
1077 data = (SetOdometryMessage_data_t *)data_ptr;
1079}
1080
1081/* Methods */
1082/** Get x value.
1083 * Translation in x direction in m
1084 * @return x value
1085 */
1086float
1088{
1089 return data->x;
1090}
1091
1092/** Get maximum length of x value.
1093 * @return length of x value, can be length of the array or number of
1094 * maximum number of characters for a string
1095 */
1096size_t
1098{
1099 return 1;
1100}
1101
1102/** Set x value.
1103 * Translation in x direction in m
1104 * @param new_x new x value
1105 */
1106void
1108{
1109 set_field(data->x, new_x);
1110}
1111
1112/** Get y value.
1113 * Translation in y direction in m
1114 * @return y value
1115 */
1116float
1118{
1119 return data->y;
1120}
1121
1122/** Get maximum length of y value.
1123 * @return length of y value, can be length of the array or number of
1124 * maximum number of characters for a string
1125 */
1126size_t
1128{
1129 return 1;
1130}
1131
1132/** Set y value.
1133 * Translation in y direction in m
1134 * @param new_y new y value
1135 */
1136void
1138{
1139 set_field(data->y, new_y);
1140}
1141
1142/** Get odometry_orientation value.
1143 * OdometryOrientation in m
1144 * @return odometry_orientation value
1145 */
1146float
1148{
1149 return data->odometry_orientation;
1150}
1151
1152/** Get maximum length of odometry_orientation value.
1153 * @return length of odometry_orientation value, can be length of the array or number of
1154 * maximum number of characters for a string
1155 */
1156size_t
1158{
1159 return 1;
1160}
1161
1162/** Set odometry_orientation value.
1163 * OdometryOrientation in m
1164 * @param new_odometry_orientation new odometry_orientation value
1165 */
1166void
1168{
1169 set_field(data->odometry_orientation, new_odometry_orientation);
1170}
1171
1172/** Clone this message.
1173 * Produces a message of the same type as this message and copies the
1174 * data to the new message.
1175 * @return clone of this message
1176 */
1177Message *
1179{
1180 return new MotorInterface::SetOdometryMessage(this);
1181}
1182/** @class MotorInterface::DriveRPMMessage <interfaces/MotorInterface.h>
1183 * DriveRPMMessage Fawkes BlackBoard Interface Message.
1184 *
1185
1186 */
1187
1188
1189/** Constructor with initial values.
1190 * @param ini_front_right initial value for front_right
1191 * @param ini_front_left initial value for front_left
1192 * @param ini_rear initial value for rear
1193 */
1194MotorInterface::DriveRPMMessage::DriveRPMMessage(const float ini_front_right, const float ini_front_left, const float ini_rear) : Message("DriveRPMMessage")
1195{
1196 data_size = sizeof(DriveRPMMessage_data_t);
1197 data_ptr = malloc(data_size);
1198 memset(data_ptr, 0, data_size);
1199 data = (DriveRPMMessage_data_t *)data_ptr;
1201 data->front_right = ini_front_right;
1202 data->front_left = ini_front_left;
1203 data->rear = ini_rear;
1204 add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
1205 add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
1206 add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
1207}
1208/** Constructor */
1210{
1211 data_size = sizeof(DriveRPMMessage_data_t);
1212 data_ptr = malloc(data_size);
1213 memset(data_ptr, 0, data_size);
1214 data = (DriveRPMMessage_data_t *)data_ptr;
1216 add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
1217 add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
1218 add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
1219}
1220
1221/** Destructor */
1223{
1224 free(data_ptr);
1225}
1226
1227/** Copy constructor.
1228 * @param m message to copy from
1229 */
1231{
1232 data_size = m->data_size;
1233 data_ptr = malloc(data_size);
1234 memcpy(data_ptr, m->data_ptr, data_size);
1235 data = (DriveRPMMessage_data_t *)data_ptr;
1237}
1238
1239/* Methods */
1240/** Get front_right value.
1241 * Rotation in RPM of the right front wheel.
1242 * @return front_right value
1243 */
1244float
1246{
1247 return data->front_right;
1248}
1249
1250/** Get maximum length of front_right value.
1251 * @return length of front_right value, can be length of the array or number of
1252 * maximum number of characters for a string
1253 */
1254size_t
1256{
1257 return 1;
1258}
1259
1260/** Set front_right value.
1261 * Rotation in RPM of the right front wheel.
1262 * @param new_front_right new front_right value
1263 */
1264void
1266{
1267 set_field(data->front_right, new_front_right);
1268}
1269
1270/** Get front_left value.
1271 * Rotation in RPM of the left front wheel.
1272 * @return front_left value
1273 */
1274float
1276{
1277 return data->front_left;
1278}
1279
1280/** Get maximum length of front_left value.
1281 * @return length of front_left value, can be length of the array or number of
1282 * maximum number of characters for a string
1283 */
1284size_t
1286{
1287 return 1;
1288}
1289
1290/** Set front_left value.
1291 * Rotation in RPM of the left front wheel.
1292 * @param new_front_left new front_left value
1293 */
1294void
1296{
1297 set_field(data->front_left, new_front_left);
1298}
1299
1300/** Get rear value.
1301 * Rotation in RPM of the rear wheel.
1302 * @return rear value
1303 */
1304float
1306{
1307 return data->rear;
1308}
1309
1310/** Get maximum length of rear value.
1311 * @return length of rear value, can be length of the array or number of
1312 * maximum number of characters for a string
1313 */
1314size_t
1316{
1317 return 1;
1318}
1319
1320/** Set rear value.
1321 * Rotation in RPM of the rear wheel.
1322 * @param new_rear new rear value
1323 */
1324void
1326{
1327 set_field(data->rear, new_rear);
1328}
1329
1330/** Clone this message.
1331 * Produces a message of the same type as this message and copies the
1332 * data to the new message.
1333 * @return clone of this message
1334 */
1335Message *
1337{
1338 return new MotorInterface::DriveRPMMessage(this);
1339}
1340/** @class MotorInterface::GotoMessage <interfaces/MotorInterface.h>
1341 * GotoMessage Fawkes BlackBoard Interface Message.
1342 *
1343
1344 */
1345
1346
1347/** Constructor with initial values.
1348 * @param ini_x initial value for x
1349 * @param ini_y initial value for y
1350 * @param ini_phi initial value for phi
1351 * @param ini_time_sec initial value for time_sec
1352 */
1353MotorInterface::GotoMessage::GotoMessage(const float ini_x, const float ini_y, const float ini_phi, const float ini_time_sec) : Message("GotoMessage")
1354{
1355 data_size = sizeof(GotoMessage_data_t);
1356 data_ptr = malloc(data_size);
1357 memset(data_ptr, 0, data_size);
1358 data = (GotoMessage_data_t *)data_ptr;
1360 data->x = ini_x;
1361 data->y = ini_y;
1362 data->phi = ini_phi;
1363 data->time_sec = ini_time_sec;
1364 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1365 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1366 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
1367 add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
1368}
1369/** Constructor */
1371{
1372 data_size = sizeof(GotoMessage_data_t);
1373 data_ptr = malloc(data_size);
1374 memset(data_ptr, 0, data_size);
1375 data = (GotoMessage_data_t *)data_ptr;
1377 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
1378 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
1379 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
1380 add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
1381}
1382
1383/** Destructor */
1385{
1386 free(data_ptr);
1387}
1388
1389/** Copy constructor.
1390 * @param m message to copy from
1391 */
1393{
1394 data_size = m->data_size;
1395 data_ptr = malloc(data_size);
1396 memcpy(data_ptr, m->data_ptr, data_size);
1397 data = (GotoMessage_data_t *)data_ptr;
1399}
1400
1401/* Methods */
1402/** Get x value.
1403 * X distance in m.
1404 * @return x value
1405 */
1406float
1408{
1409 return data->x;
1410}
1411
1412/** Get maximum length of x value.
1413 * @return length of x value, can be length of the array or number of
1414 * maximum number of characters for a string
1415 */
1416size_t
1418{
1419 return 1;
1420}
1421
1422/** Set x value.
1423 * X distance in m.
1424 * @param new_x new x value
1425 */
1426void
1428{
1429 set_field(data->x, new_x);
1430}
1431
1432/** Get y value.
1433 * Y distance in m.
1434 * @return y value
1435 */
1436float
1438{
1439 return data->y;
1440}
1441
1442/** Get maximum length of y value.
1443 * @return length of y value, can be length of the array or number of
1444 * maximum number of characters for a string
1445 */
1446size_t
1448{
1449 return 1;
1450}
1451
1452/** Set y value.
1453 * Y distance in m.
1454 * @param new_y new y value
1455 */
1456void
1458{
1459 set_field(data->y, new_y);
1460}
1461
1462/** Get phi value.
1463 * Angle relative to current angle in rad.
1464 * @return phi value
1465 */
1466float
1468{
1469 return data->phi;
1470}
1471
1472/** Get maximum length of phi value.
1473 * @return length of phi value, can be length of the array or number of
1474 * maximum number of characters for a string
1475 */
1476size_t
1478{
1479 return 1;
1480}
1481
1482/** Set phi value.
1483 * Angle relative to current angle in rad.
1484 * @param new_phi new phi value
1485 */
1486void
1488{
1489 set_field(data->phi, new_phi);
1490}
1491
1492/** Get time_sec value.
1493 * When to reach the desired location.
1494 * @return time_sec value
1495 */
1496float
1498{
1499 return data->time_sec;
1500}
1501
1502/** Get maximum length of time_sec value.
1503 * @return length of time_sec value, can be length of the array or number of
1504 * maximum number of characters for a string
1505 */
1506size_t
1508{
1509 return 1;
1510}
1511
1512/** Set time_sec value.
1513 * When to reach the desired location.
1514 * @param new_time_sec new time_sec value
1515 */
1516void
1518{
1519 set_field(data->time_sec, new_time_sec);
1520}
1521
1522/** Clone this message.
1523 * Produces a message of the same type as this message and copies the
1524 * data to the new message.
1525 * @return clone of this message
1526 */
1527Message *
1529{
1530 return new MotorInterface::GotoMessage(this);
1531}
1532/** @class MotorInterface::TransMessage <interfaces/MotorInterface.h>
1533 * TransMessage Fawkes BlackBoard Interface Message.
1534 *
1535
1536 */
1537
1538
1539/** Constructor with initial values.
1540 * @param ini_vx initial value for vx
1541 * @param ini_vy initial value for vy
1542 */
1543MotorInterface::TransMessage::TransMessage(const float ini_vx, const float ini_vy) : Message("TransMessage")
1544{
1545 data_size = sizeof(TransMessage_data_t);
1546 data_ptr = malloc(data_size);
1547 memset(data_ptr, 0, data_size);
1548 data = (TransMessage_data_t *)data_ptr;
1550 data->vx = ini_vx;
1551 data->vy = ini_vy;
1552 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1553 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1554}
1555/** Constructor */
1557{
1558 data_size = sizeof(TransMessage_data_t);
1559 data_ptr = malloc(data_size);
1560 memset(data_ptr, 0, data_size);
1561 data = (TransMessage_data_t *)data_ptr;
1563 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1564 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1565}
1566
1567/** Destructor */
1569{
1570 free(data_ptr);
1571}
1572
1573/** Copy constructor.
1574 * @param m message to copy from
1575 */
1577{
1578 data_size = m->data_size;
1579 data_ptr = malloc(data_size);
1580 memcpy(data_ptr, m->data_ptr, data_size);
1581 data = (TransMessage_data_t *)data_ptr;
1583}
1584
1585/* Methods */
1586/** Get vx value.
1587 * Speed in X direction in m/s.
1588 * @return vx value
1589 */
1590float
1592{
1593 return data->vx;
1594}
1595
1596/** Get maximum length of vx value.
1597 * @return length of vx value, can be length of the array or number of
1598 * maximum number of characters for a string
1599 */
1600size_t
1602{
1603 return 1;
1604}
1605
1606/** Set vx value.
1607 * Speed in X direction in m/s.
1608 * @param new_vx new vx value
1609 */
1610void
1612{
1613 set_field(data->vx, new_vx);
1614}
1615
1616/** Get vy value.
1617 * Speed in Y direction in m/s.
1618 * @return vy value
1619 */
1620float
1622{
1623 return data->vy;
1624}
1625
1626/** Get maximum length of vy value.
1627 * @return length of vy value, can be length of the array or number of
1628 * maximum number of characters for a string
1629 */
1630size_t
1632{
1633 return 1;
1634}
1635
1636/** Set vy value.
1637 * Speed in Y direction in m/s.
1638 * @param new_vy new vy value
1639 */
1640void
1642{
1643 set_field(data->vy, new_vy);
1644}
1645
1646/** Clone this message.
1647 * Produces a message of the same type as this message and copies the
1648 * data to the new message.
1649 * @return clone of this message
1650 */
1651Message *
1653{
1654 return new MotorInterface::TransMessage(this);
1655}
1656/** @class MotorInterface::RotMessage <interfaces/MotorInterface.h>
1657 * RotMessage Fawkes BlackBoard Interface Message.
1658 *
1659
1660 */
1661
1662
1663/** Constructor with initial values.
1664 * @param ini_omega initial value for omega
1665 */
1666MotorInterface::RotMessage::RotMessage(const float ini_omega) : Message("RotMessage")
1667{
1668 data_size = sizeof(RotMessage_data_t);
1669 data_ptr = malloc(data_size);
1670 memset(data_ptr, 0, data_size);
1671 data = (RotMessage_data_t *)data_ptr;
1673 data->omega = ini_omega;
1674 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1675}
1676/** Constructor */
1678{
1679 data_size = sizeof(RotMessage_data_t);
1680 data_ptr = malloc(data_size);
1681 memset(data_ptr, 0, data_size);
1682 data = (RotMessage_data_t *)data_ptr;
1684 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1685}
1686
1687/** Destructor */
1689{
1690 free(data_ptr);
1691}
1692
1693/** Copy constructor.
1694 * @param m message to copy from
1695 */
1697{
1698 data_size = m->data_size;
1699 data_ptr = malloc(data_size);
1700 memcpy(data_ptr, m->data_ptr, data_size);
1701 data = (RotMessage_data_t *)data_ptr;
1703}
1704
1705/* Methods */
1706/** Get omega value.
1707 * Angle rotation in rad/s.
1708 * @return omega value
1709 */
1710float
1712{
1713 return data->omega;
1714}
1715
1716/** Get maximum length of omega value.
1717 * @return length of omega value, can be length of the array or number of
1718 * maximum number of characters for a string
1719 */
1720size_t
1722{
1723 return 1;
1724}
1725
1726/** Set omega value.
1727 * Angle rotation in rad/s.
1728 * @param new_omega new omega value
1729 */
1730void
1732{
1733 set_field(data->omega, new_omega);
1734}
1735
1736/** Clone this message.
1737 * Produces a message of the same type as this message and copies the
1738 * data to the new message.
1739 * @return clone of this message
1740 */
1741Message *
1743{
1744 return new MotorInterface::RotMessage(this);
1745}
1746/** @class MotorInterface::TransRotMessage <interfaces/MotorInterface.h>
1747 * TransRotMessage Fawkes BlackBoard Interface Message.
1748 *
1749
1750 */
1751
1752
1753/** Constructor with initial values.
1754 * @param ini_vx initial value for vx
1755 * @param ini_vy initial value for vy
1756 * @param ini_omega initial value for omega
1757 */
1758MotorInterface::TransRotMessage::TransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("TransRotMessage")
1759{
1760 data_size = sizeof(TransRotMessage_data_t);
1761 data_ptr = malloc(data_size);
1762 memset(data_ptr, 0, data_size);
1763 data = (TransRotMessage_data_t *)data_ptr;
1765 data->vx = ini_vx;
1766 data->vy = ini_vy;
1767 data->omega = ini_omega;
1768 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1769 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1770 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1771}
1772/** Constructor */
1774{
1775 data_size = sizeof(TransRotMessage_data_t);
1776 data_ptr = malloc(data_size);
1777 memset(data_ptr, 0, data_size);
1778 data = (TransRotMessage_data_t *)data_ptr;
1780 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
1781 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
1782 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1783}
1784
1785/** Destructor */
1787{
1788 free(data_ptr);
1789}
1790
1791/** Copy constructor.
1792 * @param m message to copy from
1793 */
1795{
1796 data_size = m->data_size;
1797 data_ptr = malloc(data_size);
1798 memcpy(data_ptr, m->data_ptr, data_size);
1799 data = (TransRotMessage_data_t *)data_ptr;
1801}
1802
1803/* Methods */
1804/** Get vx value.
1805 * Speed in X direction in m/s.
1806 * @return vx value
1807 */
1808float
1810{
1811 return data->vx;
1812}
1813
1814/** Get maximum length of vx value.
1815 * @return length of vx value, can be length of the array or number of
1816 * maximum number of characters for a string
1817 */
1818size_t
1820{
1821 return 1;
1822}
1823
1824/** Set vx value.
1825 * Speed in X direction in m/s.
1826 * @param new_vx new vx value
1827 */
1828void
1830{
1831 set_field(data->vx, new_vx);
1832}
1833
1834/** Get vy value.
1835 * Speed in Y direction in m/s.
1836 * @return vy value
1837 */
1838float
1840{
1841 return data->vy;
1842}
1843
1844/** Get maximum length of vy value.
1845 * @return length of vy value, can be length of the array or number of
1846 * maximum number of characters for a string
1847 */
1848size_t
1850{
1851 return 1;
1852}
1853
1854/** Set vy value.
1855 * Speed in Y direction in m/s.
1856 * @param new_vy new vy value
1857 */
1858void
1860{
1861 set_field(data->vy, new_vy);
1862}
1863
1864/** Get omega value.
1865 * Angle rotation in rad/s.
1866 * @return omega value
1867 */
1868float
1870{
1871 return data->omega;
1872}
1873
1874/** Get maximum length of omega value.
1875 * @return length of omega value, can be length of the array or number of
1876 * maximum number of characters for a string
1877 */
1878size_t
1880{
1881 return 1;
1882}
1883
1884/** Set omega value.
1885 * Angle rotation in rad/s.
1886 * @param new_omega new omega value
1887 */
1888void
1890{
1891 set_field(data->omega, new_omega);
1892}
1893
1894/** Clone this message.
1895 * Produces a message of the same type as this message and copies the
1896 * data to the new message.
1897 * @return clone of this message
1898 */
1899Message *
1901{
1902 return new MotorInterface::TransRotMessage(this);
1903}
1904/** @class MotorInterface::OrbitMessage <interfaces/MotorInterface.h>
1905 * OrbitMessage Fawkes BlackBoard Interface Message.
1906 *
1907
1908 */
1909
1910
1911/** Constructor with initial values.
1912 * @param ini_px initial value for px
1913 * @param ini_py initial value for py
1914 * @param ini_omega initial value for omega
1915 */
1916MotorInterface::OrbitMessage::OrbitMessage(const float ini_px, const float ini_py, const float ini_omega) : Message("OrbitMessage")
1917{
1918 data_size = sizeof(OrbitMessage_data_t);
1919 data_ptr = malloc(data_size);
1920 memset(data_ptr, 0, data_size);
1921 data = (OrbitMessage_data_t *)data_ptr;
1923 data->px = ini_px;
1924 data->py = ini_py;
1925 data->omega = ini_omega;
1926 add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
1927 add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
1928 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1929}
1930/** Constructor */
1932{
1933 data_size = sizeof(OrbitMessage_data_t);
1934 data_ptr = malloc(data_size);
1935 memset(data_ptr, 0, data_size);
1936 data = (OrbitMessage_data_t *)data_ptr;
1938 add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
1939 add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
1940 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
1941}
1942
1943/** Destructor */
1945{
1946 free(data_ptr);
1947}
1948
1949/** Copy constructor.
1950 * @param m message to copy from
1951 */
1953{
1954 data_size = m->data_size;
1955 data_ptr = malloc(data_size);
1956 memcpy(data_ptr, m->data_ptr, data_size);
1957 data = (OrbitMessage_data_t *)data_ptr;
1959}
1960
1961/* Methods */
1962/** Get px value.
1963 * Point's X coordinate to orbit.
1964 * @return px value
1965 */
1966float
1968{
1969 return data->px;
1970}
1971
1972/** Get maximum length of px value.
1973 * @return length of px value, can be length of the array or number of
1974 * maximum number of characters for a string
1975 */
1976size_t
1978{
1979 return 1;
1980}
1981
1982/** Set px value.
1983 * Point's X coordinate to orbit.
1984 * @param new_px new px value
1985 */
1986void
1988{
1989 set_field(data->px, new_px);
1990}
1991
1992/** Get py value.
1993 * Point's Y coordinate to orbit.
1994 * @return py value
1995 */
1996float
1998{
1999 return data->py;
2000}
2001
2002/** Get maximum length of py value.
2003 * @return length of py value, can be length of the array or number of
2004 * maximum number of characters for a string
2005 */
2006size_t
2008{
2009 return 1;
2010}
2011
2012/** Set py value.
2013 * Point's Y coordinate to orbit.
2014 * @param new_py new py value
2015 */
2016void
2018{
2019 set_field(data->py, new_py);
2020}
2021
2022/** Get omega value.
2023 * Angular speed around point in rad/s.
2024 * @return omega value
2025 */
2026float
2028{
2029 return data->omega;
2030}
2031
2032/** Get maximum length of omega value.
2033 * @return length of omega value, can be length of the array or number of
2034 * maximum number of characters for a string
2035 */
2036size_t
2038{
2039 return 1;
2040}
2041
2042/** Set omega value.
2043 * Angular speed around point in rad/s.
2044 * @param new_omega new omega value
2045 */
2046void
2048{
2049 set_field(data->omega, new_omega);
2050}
2051
2052/** Clone this message.
2053 * Produces a message of the same type as this message and copies the
2054 * data to the new message.
2055 * @return clone of this message
2056 */
2057Message *
2059{
2060 return new MotorInterface::OrbitMessage(this);
2061}
2062/** @class MotorInterface::LinTransRotMessage <interfaces/MotorInterface.h>
2063 * LinTransRotMessage Fawkes BlackBoard Interface Message.
2064 *
2065
2066 */
2067
2068
2069/** Constructor with initial values.
2070 * @param ini_vx initial value for vx
2071 * @param ini_vy initial value for vy
2072 * @param ini_omega initial value for omega
2073 */
2074MotorInterface::LinTransRotMessage::LinTransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("LinTransRotMessage")
2075{
2076 data_size = sizeof(LinTransRotMessage_data_t);
2077 data_ptr = malloc(data_size);
2078 memset(data_ptr, 0, data_size);
2079 data = (LinTransRotMessage_data_t *)data_ptr;
2081 data->vx = ini_vx;
2082 data->vy = ini_vy;
2083 data->omega = ini_omega;
2084 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
2085 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
2086 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
2087}
2088/** Constructor */
2090{
2091 data_size = sizeof(LinTransRotMessage_data_t);
2092 data_ptr = malloc(data_size);
2093 memset(data_ptr, 0, data_size);
2094 data = (LinTransRotMessage_data_t *)data_ptr;
2096 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
2097 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
2098 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
2099}
2100
2101/** Destructor */
2103{
2104 free(data_ptr);
2105}
2106
2107/** Copy constructor.
2108 * @param m message to copy from
2109 */
2111{
2112 data_size = m->data_size;
2113 data_ptr = malloc(data_size);
2114 memcpy(data_ptr, m->data_ptr, data_size);
2115 data = (LinTransRotMessage_data_t *)data_ptr;
2117}
2118
2119/* Methods */
2120/** Get vx value.
2121 * Speed for translation in X direction in m/s.
2122 * @return vx value
2123 */
2124float
2126{
2127 return data->vx;
2128}
2129
2130/** Get maximum length of vx value.
2131 * @return length of vx value, can be length of the array or number of
2132 * maximum number of characters for a string
2133 */
2134size_t
2136{
2137 return 1;
2138}
2139
2140/** Set vx value.
2141 * Speed for translation in X direction in m/s.
2142 * @param new_vx new vx value
2143 */
2144void
2146{
2147 set_field(data->vx, new_vx);
2148}
2149
2150/** Get vy value.
2151 * Speed for translation in Y direction in m/s.
2152 * @return vy value
2153 */
2154float
2156{
2157 return data->vy;
2158}
2159
2160/** Get maximum length of vy value.
2161 * @return length of vy value, can be length of the array or number of
2162 * maximum number of characters for a string
2163 */
2164size_t
2166{
2167 return 1;
2168}
2169
2170/** Set vy value.
2171 * Speed for translation in Y direction in m/s.
2172 * @param new_vy new vy value
2173 */
2174void
2176{
2177 set_field(data->vy, new_vy);
2178}
2179
2180/** Get omega value.
2181 * Rotational speed in rad/s.
2182 * @return omega value
2183 */
2184float
2186{
2187 return data->omega;
2188}
2189
2190/** Get maximum length of omega value.
2191 * @return length of omega value, can be length of the array or number of
2192 * maximum number of characters for a string
2193 */
2194size_t
2196{
2197 return 1;
2198}
2199
2200/** Set omega value.
2201 * Rotational speed in rad/s.
2202 * @param new_omega new omega value
2203 */
2204void
2206{
2207 set_field(data->omega, new_omega);
2208}
2209
2210/** Clone this message.
2211 * Produces a message of the same type as this message and copies the
2212 * data to the new message.
2213 * @return clone of this message
2214 */
2215Message *
2217{
2218 return new MotorInterface::LinTransRotMessage(this);
2219}
2220/** Check if message is valid and can be enqueued.
2221 * @param message Message to check
2222 * @return true if the message is valid, false otherwise.
2223 */
2224bool
2226{
2227 const SetMotorStateMessage *m0 = dynamic_cast<const SetMotorStateMessage *>(message);
2228 if ( m0 != NULL ) {
2229 return true;
2230 }
2231 const AcquireControlMessage *m1 = dynamic_cast<const AcquireControlMessage *>(message);
2232 if ( m1 != NULL ) {
2233 return true;
2234 }
2235 const ResetOdometryMessage *m2 = dynamic_cast<const ResetOdometryMessage *>(message);
2236 if ( m2 != NULL ) {
2237 return true;
2238 }
2239 const SetOdometryMessage *m3 = dynamic_cast<const SetOdometryMessage *>(message);
2240 if ( m3 != NULL ) {
2241 return true;
2242 }
2243 const DriveRPMMessage *m4 = dynamic_cast<const DriveRPMMessage *>(message);
2244 if ( m4 != NULL ) {
2245 return true;
2246 }
2247 const GotoMessage *m5 = dynamic_cast<const GotoMessage *>(message);
2248 if ( m5 != NULL ) {
2249 return true;
2250 }
2251 const TransMessage *m6 = dynamic_cast<const TransMessage *>(message);
2252 if ( m6 != NULL ) {
2253 return true;
2254 }
2255 const RotMessage *m7 = dynamic_cast<const RotMessage *>(message);
2256 if ( m7 != NULL ) {
2257 return true;
2258 }
2259 const TransRotMessage *m8 = dynamic_cast<const TransRotMessage *>(message);
2260 if ( m8 != NULL ) {
2261 return true;
2262 }
2263 const OrbitMessage *m9 = dynamic_cast<const OrbitMessage *>(message);
2264 if ( m9 != NULL ) {
2265 return true;
2266 }
2267 const LinTransRotMessage *m10 = dynamic_cast<const LinTransRotMessage *>(message);
2268 if ( m10 != NULL ) {
2269 return true;
2270 }
2271 return false;
2272}
2273
2274/// @cond INTERNALS
2275EXPORT_INTERFACE(MotorInterface)
2276/// @endcond
2277
2278
2279} // end namespace fawkes
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:244
void set_field(FieldT &field, DataT &data)
Set a field, set data_changed to true and update data_changed accordingly.
Definition: interface.h:304
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
Definition: message.cpp:435
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:146
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:156
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:147
AcquireControlMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_controller() const
Get maximum length of controller value.
void set_controller(const uint32_t new_controller)
Set controller 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.
virtual Message * clone() const
Clone this message.
uint32_t controller() const
Get controller value.
void set_controller_thread_name(const char *new_controller_thread_name)
Set controller_thread_name value.
DriveRPMMessage Fawkes BlackBoard Interface Message.
float front_left() const
Get front_left value.
void set_front_right(const float new_front_right)
Set front_right value.
size_t maxlenof_front_right() const
Get maximum length of front_right value.
size_t maxlenof_rear() const
Get maximum length of rear value.
void set_front_left(const float new_front_left)
Set front_left value.
virtual Message * clone() const
Clone this message.
void set_rear(const float new_rear)
Set rear value.
size_t maxlenof_front_left() const
Get maximum length of front_left value.
float front_right() const
Get front_right value.
GotoMessage Fawkes BlackBoard Interface Message.
float phi() const
Get phi value.
void set_y(const float new_y)
Set y value.
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
void set_time_sec(const float new_time_sec)
Set time_sec value.
void set_phi(const float new_phi)
Set phi value.
size_t maxlenof_y() const
Get maximum length of y value.
float time_sec() const
Get time_sec value.
size_t maxlenof_x() const
Get maximum length of x value.
virtual Message * clone() const
Clone this message.
void set_x(const float new_x)
Set x value.
size_t maxlenof_phi() const
Get maximum length of phi value.
LinTransRotMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_vy() const
Get maximum length of vy value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_vx(const float new_vx)
Set vx value.
virtual Message * clone() const
Clone this message.
void set_vy(const float new_vy)
Set vy value.
size_t maxlenof_omega() const
Get maximum length of omega value.
void set_omega(const float new_omega)
Set omega value.
OrbitMessage Fawkes BlackBoard Interface Message.
float omega() const
Get omega value.
void set_omega(const float new_omega)
Set omega value.
void set_px(const float new_px)
Set px value.
void set_py(const float new_py)
Set py value.
size_t maxlenof_omega() const
Get maximum length of omega value.
size_t maxlenof_px() const
Get maximum length of px value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_py() const
Get maximum length of py value.
ResetOdometryMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
RotMessage Fawkes BlackBoard Interface Message.
float omega() const
Get omega value.
void set_omega(const float new_omega)
Set omega value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_omega() const
Get maximum length of omega value.
SetMotorStateMessage Fawkes BlackBoard Interface Message.
uint32_t motor_state() const
Get motor_state value.
virtual Message * clone() const
Clone this message.
void set_motor_state(const uint32_t new_motor_state)
Set motor_state value.
size_t maxlenof_motor_state() const
Get maximum length of motor_state value.
SetOdometryMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_odometry_orientation() const
Get maximum length of odometry_orientation value.
void set_y(const float new_y)
Set y value.
size_t maxlenof_x() const
Get maximum length of x value.
void set_odometry_orientation(const float new_odometry_orientation)
Set odometry_orientation value.
size_t maxlenof_y() const
Get maximum length of y value.
virtual Message * clone() const
Clone this message.
float odometry_orientation() const
Get odometry_orientation value.
void set_x(const float new_x)
Set x value.
TransMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_vx(const float new_vx)
Set vx value.
void set_vy(const float new_vy)
Set vy value.
size_t maxlenof_vy() const
Get maximum length of vy value.
size_t maxlenof_vx() const
Get maximum length of vx value.
TransRotMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_vy() const
Get maximum length of vy value.
void set_omega(const float new_omega)
Set omega value.
size_t maxlenof_vx() const
Get maximum length of vx value.
void set_vx(const float new_vx)
Set vx value.
void set_vy(const float new_vy)
Set vy value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_omega() const
Get maximum length of omega value.
float omega() const
Get omega value.
MotorInterface Fawkes BlackBoard Interface.
static const uint32_t DRIVE_MODE_RPM
DRIVE_MODE_RPM constant.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
static const uint32_t MOTOR_DISABLED
MOTOR_DISABLED constant.
static const uint32_t DRIVE_MODE_TRANS_ROT
DRIVE_MODE_TRANS_ROT constant.
static const uint32_t DRIVE_MODE_ORBIT
DRIVE_MODE_ORBIT constant.
static const uint32_t DRIVE_MODE_LINE_TRANS_ROT
DRIVE_MODE_LINE_TRANS_ROT constant.
static const uint32_t DRIVE_MODE_TRANS
DRIVE_MODE_TRANS constant.
static const uint32_t MOTOR_ENABLED
MOTOR_ENABLED constant.
static const uint32_t DRIVE_MODE_ROT
DRIVE_MODE_ROT constant.
Fawkes library namespace.
@ IFT_UINT32
32 bit unsigned integer field
Definition: types.h:43
@ IFT_FLOAT
float field
Definition: types.h:46
@ IFT_STRING
string field
Definition: types.h:48
Timestamp data, must be present and first entries for each interface data structs!...
Definition: message.h:152