00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <interfaces/MotorInterface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 const unsigned int MotorInterface::MOTOR_ENABLED = 0;
00044
00045 const unsigned int MotorInterface::MOTOR_DISABLED = 1;
00046
00047 const unsigned int MotorInterface::DRIVE_MODE_RPM = 1;
00048
00049 const unsigned int MotorInterface::DRIVE_MODE_TRANS = 2;
00050
00051 const unsigned int MotorInterface::DRIVE_MODE_ROT = 3;
00052
00053 const unsigned int MotorInterface::DRIVE_MODE_TRANS_ROT = 4;
00054
00055 const unsigned int MotorInterface::DRIVE_MODE_ORBIT = 5;
00056
00057 const unsigned int MotorInterface::DRIVE_MODE_LINE_TRANS_ROT = 6;
00058
00059
00060 MotorInterface::MotorInterface() : Interface()
00061 {
00062 data_size = sizeof(MotorInterface_data_t);
00063 data_ptr = malloc(data_size);
00064 data = (MotorInterface_data_t *)data_ptr;
00065 memset(data_ptr, 0, data_size);
00066 add_fieldinfo(IFT_UINT, "motor_state", 1, &data->motor_state);
00067 add_fieldinfo(IFT_UINT, "drive_mode", 1, &data->drive_mode);
00068 add_fieldinfo(IFT_INT, "right_rpm", 1, &data->right_rpm);
00069 add_fieldinfo(IFT_INT, "rear_rpm", 1, &data->rear_rpm);
00070 add_fieldinfo(IFT_INT, "left_rpm", 1, &data->left_rpm);
00071 add_fieldinfo(IFT_FLOAT, "odometry_path_length", 1, &data->odometry_path_length);
00072 add_fieldinfo(IFT_FLOAT, "odometry_position_x", 1, &data->odometry_position_x);
00073 add_fieldinfo(IFT_FLOAT, "odometry_position_y", 1, &data->odometry_position_y);
00074 add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
00075 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
00076 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
00077 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
00078 add_fieldinfo(IFT_UINT, "controller", 1, &data->controller);
00079 add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
00080 add_messageinfo("SetMotorStateMessage");
00081 add_messageinfo("AcquireControlMessage");
00082 add_messageinfo("ResetOdometryMessage");
00083 add_messageinfo("DriveRPMMessage");
00084 add_messageinfo("GotoMessage");
00085 add_messageinfo("TransMessage");
00086 add_messageinfo("RotMessage");
00087 add_messageinfo("TransRotMessage");
00088 add_messageinfo("OrbitMessage");
00089 add_messageinfo("LinTransRotMessage");
00090 unsigned char tmp_hash[] = {0x60, 0x28, 0x2b, 0x64, 0x6d, 0xe1, 0x7d, 0xba, 0x1b, 0x43, 0xad, 0x7e, 0x38, 0xa9, 0x76, 0x38};
00091 set_hash(tmp_hash);
00092 }
00093
00094
00095 MotorInterface::~MotorInterface()
00096 {
00097 free(data_ptr);
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 unsigned int
00107 MotorInterface::motor_state() const
00108 {
00109 return data->motor_state;
00110 }
00111
00112
00113
00114
00115
00116 size_t
00117 MotorInterface::maxlenof_motor_state() const
00118 {
00119 return 1;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128 void
00129 MotorInterface::set_motor_state(const unsigned int new_motor_state)
00130 {
00131 data->motor_state = new_motor_state;
00132 }
00133
00134
00135
00136
00137
00138
00139
00140 unsigned int
00141 MotorInterface::drive_mode() const
00142 {
00143 return data->drive_mode;
00144 }
00145
00146
00147
00148
00149
00150 size_t
00151 MotorInterface::maxlenof_drive_mode() const
00152 {
00153 return 1;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 void
00163 MotorInterface::set_drive_mode(const unsigned int new_drive_mode)
00164 {
00165 data->drive_mode = new_drive_mode;
00166 }
00167
00168
00169
00170
00171
00172
00173
00174 int
00175 MotorInterface::right_rpm() const
00176 {
00177 return data->right_rpm;
00178 }
00179
00180
00181
00182
00183
00184 size_t
00185 MotorInterface::maxlenof_right_rpm() const
00186 {
00187 return 1;
00188 }
00189
00190
00191
00192
00193
00194
00195
00196 void
00197 MotorInterface::set_right_rpm(const int new_right_rpm)
00198 {
00199 data->right_rpm = new_right_rpm;
00200 }
00201
00202
00203
00204
00205
00206
00207
00208 int
00209 MotorInterface::rear_rpm() const
00210 {
00211 return data->rear_rpm;
00212 }
00213
00214
00215
00216
00217
00218 size_t
00219 MotorInterface::maxlenof_rear_rpm() const
00220 {
00221 return 1;
00222 }
00223
00224
00225
00226
00227
00228
00229
00230 void
00231 MotorInterface::set_rear_rpm(const int new_rear_rpm)
00232 {
00233 data->rear_rpm = new_rear_rpm;
00234 }
00235
00236
00237
00238
00239
00240
00241
00242 int
00243 MotorInterface::left_rpm() const
00244 {
00245 return data->left_rpm;
00246 }
00247
00248
00249
00250
00251
00252 size_t
00253 MotorInterface::maxlenof_left_rpm() const
00254 {
00255 return 1;
00256 }
00257
00258
00259
00260
00261
00262
00263
00264 void
00265 MotorInterface::set_left_rpm(const int new_left_rpm)
00266 {
00267 data->left_rpm = new_left_rpm;
00268 }
00269
00270
00271
00272
00273
00274
00275
00276 float
00277 MotorInterface::odometry_path_length() const
00278 {
00279 return data->odometry_path_length;
00280 }
00281
00282
00283
00284
00285
00286 size_t
00287 MotorInterface::maxlenof_odometry_path_length() const
00288 {
00289 return 1;
00290 }
00291
00292
00293
00294
00295
00296
00297
00298 void
00299 MotorInterface::set_odometry_path_length(const float new_odometry_path_length)
00300 {
00301 data->odometry_path_length = new_odometry_path_length;
00302 }
00303
00304
00305
00306
00307
00308
00309
00310 float
00311 MotorInterface::odometry_position_x() const
00312 {
00313 return data->odometry_position_x;
00314 }
00315
00316
00317
00318
00319
00320 size_t
00321 MotorInterface::maxlenof_odometry_position_x() const
00322 {
00323 return 1;
00324 }
00325
00326
00327
00328
00329
00330
00331
00332 void
00333 MotorInterface::set_odometry_position_x(const float new_odometry_position_x)
00334 {
00335 data->odometry_position_x = new_odometry_position_x;
00336 }
00337
00338
00339
00340
00341
00342
00343
00344 float
00345 MotorInterface::odometry_position_y() const
00346 {
00347 return data->odometry_position_y;
00348 }
00349
00350
00351
00352
00353
00354 size_t
00355 MotorInterface::maxlenof_odometry_position_y() const
00356 {
00357 return 1;
00358 }
00359
00360
00361
00362
00363
00364
00365
00366 void
00367 MotorInterface::set_odometry_position_y(const float new_odometry_position_y)
00368 {
00369 data->odometry_position_y = new_odometry_position_y;
00370 }
00371
00372
00373
00374
00375
00376
00377
00378 float
00379 MotorInterface::odometry_orientation() const
00380 {
00381 return data->odometry_orientation;
00382 }
00383
00384
00385
00386
00387
00388 size_t
00389 MotorInterface::maxlenof_odometry_orientation() const
00390 {
00391 return 1;
00392 }
00393
00394
00395
00396
00397
00398
00399
00400 void
00401 MotorInterface::set_odometry_orientation(const float new_odometry_orientation)
00402 {
00403 data->odometry_orientation = new_odometry_orientation;
00404 }
00405
00406
00407
00408
00409
00410
00411
00412 float
00413 MotorInterface::vx() const
00414 {
00415 return data->vx;
00416 }
00417
00418
00419
00420
00421
00422 size_t
00423 MotorInterface::maxlenof_vx() const
00424 {
00425 return 1;
00426 }
00427
00428
00429
00430
00431
00432
00433
00434 void
00435 MotorInterface::set_vx(const float new_vx)
00436 {
00437 data->vx = new_vx;
00438 }
00439
00440
00441
00442
00443
00444
00445
00446 float
00447 MotorInterface::vy() const
00448 {
00449 return data->vy;
00450 }
00451
00452
00453
00454
00455
00456 size_t
00457 MotorInterface::maxlenof_vy() const
00458 {
00459 return 1;
00460 }
00461
00462
00463
00464
00465
00466
00467
00468 void
00469 MotorInterface::set_vy(const float new_vy)
00470 {
00471 data->vy = new_vy;
00472 }
00473
00474
00475
00476
00477
00478
00479
00480 float
00481 MotorInterface::omega() const
00482 {
00483 return data->omega;
00484 }
00485
00486
00487
00488
00489
00490 size_t
00491 MotorInterface::maxlenof_omega() const
00492 {
00493 return 1;
00494 }
00495
00496
00497
00498
00499
00500
00501
00502 void
00503 MotorInterface::set_omega(const float new_omega)
00504 {
00505 data->omega = new_omega;
00506 }
00507
00508
00509
00510
00511
00512
00513
00514
00515 unsigned int
00516 MotorInterface::controller() const
00517 {
00518 return data->controller;
00519 }
00520
00521
00522
00523
00524
00525 size_t
00526 MotorInterface::maxlenof_controller() const
00527 {
00528 return 1;
00529 }
00530
00531
00532
00533
00534
00535
00536
00537
00538 void
00539 MotorInterface::set_controller(const unsigned int new_controller)
00540 {
00541 data->controller = new_controller;
00542 }
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 char *
00553 MotorInterface::controller_thread_name() const
00554 {
00555 return data->controller_thread_name;
00556 }
00557
00558
00559
00560
00561
00562 size_t
00563 MotorInterface::maxlenof_controller_thread_name() const
00564 {
00565 return 64;
00566 }
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 void
00577 MotorInterface::set_controller_thread_name(const char * new_controller_thread_name)
00578 {
00579 strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
00580 }
00581
00582
00583 Message *
00584 MotorInterface::create_message(const char *type) const
00585 {
00586 if ( strncmp("SetMotorStateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00587 return new SetMotorStateMessage();
00588 } else if ( strncmp("AcquireControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00589 return new AcquireControlMessage();
00590 } else if ( strncmp("ResetOdometryMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00591 return new ResetOdometryMessage();
00592 } else if ( strncmp("DriveRPMMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00593 return new DriveRPMMessage();
00594 } else if ( strncmp("GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00595 return new GotoMessage();
00596 } else if ( strncmp("TransMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00597 return new TransMessage();
00598 } else if ( strncmp("RotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00599 return new RotMessage();
00600 } else if ( strncmp("TransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00601 return new TransRotMessage();
00602 } else if ( strncmp("OrbitMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00603 return new OrbitMessage();
00604 } else if ( strncmp("LinTransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00605 return new LinTransRotMessage();
00606 } else {
00607 throw UnknownTypeException("The given type '%s' does not match any known "
00608 "message type for this interface type.", type);
00609 }
00610 }
00611
00612
00613
00614
00615
00616 void
00617 MotorInterface::copy_values(const Interface *other)
00618 {
00619 const MotorInterface *oi = dynamic_cast<const MotorInterface *>(other);
00620 if (oi == NULL) {
00621 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00622 type(), other->type());
00623 }
00624 memcpy(data, oi->data, sizeof(MotorInterface_data_t));
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638 MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const unsigned int ini_motor_state) : Message("SetMotorStateMessage")
00639 {
00640 data_size = sizeof(SetMotorStateMessage_data_t);
00641 data_ptr = malloc(data_size);
00642 memset(data_ptr, 0, data_size);
00643 data = (SetMotorStateMessage_data_t *)data_ptr;
00644 data->motor_state = ini_motor_state;
00645 add_fieldinfo(IFT_UINT, "motor_state", 1, &data->motor_state);
00646 }
00647
00648 MotorInterface::SetMotorStateMessage::SetMotorStateMessage() : Message("SetMotorStateMessage")
00649 {
00650 data_size = sizeof(SetMotorStateMessage_data_t);
00651 data_ptr = malloc(data_size);
00652 memset(data_ptr, 0, data_size);
00653 data = (SetMotorStateMessage_data_t *)data_ptr;
00654 add_fieldinfo(IFT_UINT, "motor_state", 1, &data->motor_state);
00655 }
00656
00657
00658 MotorInterface::SetMotorStateMessage::~SetMotorStateMessage()
00659 {
00660 free(data_ptr);
00661 }
00662
00663
00664
00665
00666 MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const SetMotorStateMessage *m) : Message("SetMotorStateMessage")
00667 {
00668 data_size = m->data_size;
00669 data_ptr = malloc(data_size);
00670 memcpy(data_ptr, m->data_ptr, data_size);
00671 data = (SetMotorStateMessage_data_t *)data_ptr;
00672 }
00673
00674
00675
00676
00677
00678
00679
00680
00681 unsigned int
00682 MotorInterface::SetMotorStateMessage::motor_state() const
00683 {
00684 return data->motor_state;
00685 }
00686
00687
00688
00689
00690
00691 size_t
00692 MotorInterface::SetMotorStateMessage::maxlenof_motor_state() const
00693 {
00694 return 1;
00695 }
00696
00697
00698
00699
00700
00701
00702
00703 void
00704 MotorInterface::SetMotorStateMessage::set_motor_state(const unsigned int new_motor_state)
00705 {
00706 data->motor_state = new_motor_state;
00707 }
00708
00709
00710
00711
00712
00713
00714 Message *
00715 MotorInterface::SetMotorStateMessage::clone() const
00716 {
00717 return new MotorInterface::SetMotorStateMessage(this);
00718 }
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730 MotorInterface::AcquireControlMessage::AcquireControlMessage(const unsigned int ini_controller, const char * ini_controller_thread_name) : Message("AcquireControlMessage")
00731 {
00732 data_size = sizeof(AcquireControlMessage_data_t);
00733 data_ptr = malloc(data_size);
00734 memset(data_ptr, 0, data_size);
00735 data = (AcquireControlMessage_data_t *)data_ptr;
00736 data->controller = ini_controller;
00737 strncpy(data->controller_thread_name, ini_controller_thread_name, 64);
00738 add_fieldinfo(IFT_UINT, "controller", 1, &data->controller);
00739 add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
00740 }
00741
00742 MotorInterface::AcquireControlMessage::AcquireControlMessage() : Message("AcquireControlMessage")
00743 {
00744 data_size = sizeof(AcquireControlMessage_data_t);
00745 data_ptr = malloc(data_size);
00746 memset(data_ptr, 0, data_size);
00747 data = (AcquireControlMessage_data_t *)data_ptr;
00748 add_fieldinfo(IFT_UINT, "controller", 1, &data->controller);
00749 add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
00750 }
00751
00752
00753 MotorInterface::AcquireControlMessage::~AcquireControlMessage()
00754 {
00755 free(data_ptr);
00756 }
00757
00758
00759
00760
00761 MotorInterface::AcquireControlMessage::AcquireControlMessage(const AcquireControlMessage *m) : Message("AcquireControlMessage")
00762 {
00763 data_size = m->data_size;
00764 data_ptr = malloc(data_size);
00765 memcpy(data_ptr, m->data_ptr, data_size);
00766 data = (AcquireControlMessage_data_t *)data_ptr;
00767 }
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 unsigned int
00778 MotorInterface::AcquireControlMessage::controller() const
00779 {
00780 return data->controller;
00781 }
00782
00783
00784
00785
00786
00787 size_t
00788 MotorInterface::AcquireControlMessage::maxlenof_controller() const
00789 {
00790 return 1;
00791 }
00792
00793
00794
00795
00796
00797
00798
00799
00800 void
00801 MotorInterface::AcquireControlMessage::set_controller(const unsigned int new_controller)
00802 {
00803 data->controller = new_controller;
00804 }
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814 char *
00815 MotorInterface::AcquireControlMessage::controller_thread_name() const
00816 {
00817 return data->controller_thread_name;
00818 }
00819
00820
00821
00822
00823
00824 size_t
00825 MotorInterface::AcquireControlMessage::maxlenof_controller_thread_name() const
00826 {
00827 return 64;
00828 }
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838 void
00839 MotorInterface::AcquireControlMessage::set_controller_thread_name(const char * new_controller_thread_name)
00840 {
00841 strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
00842 }
00843
00844
00845
00846
00847
00848
00849 Message *
00850 MotorInterface::AcquireControlMessage::clone() const
00851 {
00852 return new MotorInterface::AcquireControlMessage(this);
00853 }
00854
00855
00856
00857
00858
00859
00860
00861
00862 MotorInterface::ResetOdometryMessage::ResetOdometryMessage() : Message("ResetOdometryMessage")
00863 {
00864 data_size = 0;
00865 data_ptr = NULL;
00866 }
00867
00868
00869 MotorInterface::ResetOdometryMessage::~ResetOdometryMessage()
00870 {
00871 }
00872
00873
00874
00875
00876 MotorInterface::ResetOdometryMessage::ResetOdometryMessage(const ResetOdometryMessage *m) : Message("ResetOdometryMessage")
00877 {
00878 data_size = 0;
00879 data_ptr = NULL;
00880 }
00881
00882
00883
00884
00885
00886
00887
00888 Message *
00889 MotorInterface::ResetOdometryMessage::clone() const
00890 {
00891 return new MotorInterface::ResetOdometryMessage(this);
00892 }
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905 MotorInterface::DriveRPMMessage::DriveRPMMessage(const float ini_front_right, const float ini_front_left, const float ini_rear) : Message("DriveRPMMessage")
00906 {
00907 data_size = sizeof(DriveRPMMessage_data_t);
00908 data_ptr = malloc(data_size);
00909 memset(data_ptr, 0, data_size);
00910 data = (DriveRPMMessage_data_t *)data_ptr;
00911 data->front_right = ini_front_right;
00912 data->front_left = ini_front_left;
00913 data->rear = ini_rear;
00914 add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
00915 add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
00916 add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
00917 }
00918
00919 MotorInterface::DriveRPMMessage::DriveRPMMessage() : Message("DriveRPMMessage")
00920 {
00921 data_size = sizeof(DriveRPMMessage_data_t);
00922 data_ptr = malloc(data_size);
00923 memset(data_ptr, 0, data_size);
00924 data = (DriveRPMMessage_data_t *)data_ptr;
00925 add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
00926 add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
00927 add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
00928 }
00929
00930
00931 MotorInterface::DriveRPMMessage::~DriveRPMMessage()
00932 {
00933 free(data_ptr);
00934 }
00935
00936
00937
00938
00939 MotorInterface::DriveRPMMessage::DriveRPMMessage(const DriveRPMMessage *m) : Message("DriveRPMMessage")
00940 {
00941 data_size = m->data_size;
00942 data_ptr = malloc(data_size);
00943 memcpy(data_ptr, m->data_ptr, data_size);
00944 data = (DriveRPMMessage_data_t *)data_ptr;
00945 }
00946
00947
00948
00949
00950
00951
00952 float
00953 MotorInterface::DriveRPMMessage::front_right() const
00954 {
00955 return data->front_right;
00956 }
00957
00958
00959
00960
00961
00962 size_t
00963 MotorInterface::DriveRPMMessage::maxlenof_front_right() const
00964 {
00965 return 1;
00966 }
00967
00968
00969
00970
00971
00972 void
00973 MotorInterface::DriveRPMMessage::set_front_right(const float new_front_right)
00974 {
00975 data->front_right = new_front_right;
00976 }
00977
00978
00979
00980
00981
00982 float
00983 MotorInterface::DriveRPMMessage::front_left() const
00984 {
00985 return data->front_left;
00986 }
00987
00988
00989
00990
00991
00992 size_t
00993 MotorInterface::DriveRPMMessage::maxlenof_front_left() const
00994 {
00995 return 1;
00996 }
00997
00998
00999
01000
01001
01002 void
01003 MotorInterface::DriveRPMMessage::set_front_left(const float new_front_left)
01004 {
01005 data->front_left = new_front_left;
01006 }
01007
01008
01009
01010
01011
01012 float
01013 MotorInterface::DriveRPMMessage::rear() const
01014 {
01015 return data->rear;
01016 }
01017
01018
01019
01020
01021
01022 size_t
01023 MotorInterface::DriveRPMMessage::maxlenof_rear() const
01024 {
01025 return 1;
01026 }
01027
01028
01029
01030
01031
01032 void
01033 MotorInterface::DriveRPMMessage::set_rear(const float new_rear)
01034 {
01035 data->rear = new_rear;
01036 }
01037
01038
01039
01040
01041
01042
01043 Message *
01044 MotorInterface::DriveRPMMessage::clone() const
01045 {
01046 return new MotorInterface::DriveRPMMessage(this);
01047 }
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061 MotorInterface::GotoMessage::GotoMessage(const float ini_x, const float ini_y, const float ini_phi, const float ini_time_sec) : Message("GotoMessage")
01062 {
01063 data_size = sizeof(GotoMessage_data_t);
01064 data_ptr = malloc(data_size);
01065 memset(data_ptr, 0, data_size);
01066 data = (GotoMessage_data_t *)data_ptr;
01067 data->x = ini_x;
01068 data->y = ini_y;
01069 data->phi = ini_phi;
01070 data->time_sec = ini_time_sec;
01071 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
01072 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
01073 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
01074 add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
01075 }
01076
01077 MotorInterface::GotoMessage::GotoMessage() : Message("GotoMessage")
01078 {
01079 data_size = sizeof(GotoMessage_data_t);
01080 data_ptr = malloc(data_size);
01081 memset(data_ptr, 0, data_size);
01082 data = (GotoMessage_data_t *)data_ptr;
01083 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
01084 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
01085 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
01086 add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
01087 }
01088
01089
01090 MotorInterface::GotoMessage::~GotoMessage()
01091 {
01092 free(data_ptr);
01093 }
01094
01095
01096
01097
01098 MotorInterface::GotoMessage::GotoMessage(const GotoMessage *m) : Message("GotoMessage")
01099 {
01100 data_size = m->data_size;
01101 data_ptr = malloc(data_size);
01102 memcpy(data_ptr, m->data_ptr, data_size);
01103 data = (GotoMessage_data_t *)data_ptr;
01104 }
01105
01106
01107
01108
01109
01110
01111 float
01112 MotorInterface::GotoMessage::x() const
01113 {
01114 return data->x;
01115 }
01116
01117
01118
01119
01120
01121 size_t
01122 MotorInterface::GotoMessage::maxlenof_x() const
01123 {
01124 return 1;
01125 }
01126
01127
01128
01129
01130
01131 void
01132 MotorInterface::GotoMessage::set_x(const float new_x)
01133 {
01134 data->x = new_x;
01135 }
01136
01137
01138
01139
01140
01141 float
01142 MotorInterface::GotoMessage::y() const
01143 {
01144 return data->y;
01145 }
01146
01147
01148
01149
01150
01151 size_t
01152 MotorInterface::GotoMessage::maxlenof_y() const
01153 {
01154 return 1;
01155 }
01156
01157
01158
01159
01160
01161 void
01162 MotorInterface::GotoMessage::set_y(const float new_y)
01163 {
01164 data->y = new_y;
01165 }
01166
01167
01168
01169
01170
01171 float
01172 MotorInterface::GotoMessage::phi() const
01173 {
01174 return data->phi;
01175 }
01176
01177
01178
01179
01180
01181 size_t
01182 MotorInterface::GotoMessage::maxlenof_phi() const
01183 {
01184 return 1;
01185 }
01186
01187
01188
01189
01190
01191 void
01192 MotorInterface::GotoMessage::set_phi(const float new_phi)
01193 {
01194 data->phi = new_phi;
01195 }
01196
01197
01198
01199
01200
01201 float
01202 MotorInterface::GotoMessage::time_sec() const
01203 {
01204 return data->time_sec;
01205 }
01206
01207
01208
01209
01210
01211 size_t
01212 MotorInterface::GotoMessage::maxlenof_time_sec() const
01213 {
01214 return 1;
01215 }
01216
01217
01218
01219
01220
01221 void
01222 MotorInterface::GotoMessage::set_time_sec(const float new_time_sec)
01223 {
01224 data->time_sec = new_time_sec;
01225 }
01226
01227
01228
01229
01230
01231
01232 Message *
01233 MotorInterface::GotoMessage::clone() const
01234 {
01235 return new MotorInterface::GotoMessage(this);
01236 }
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248 MotorInterface::TransMessage::TransMessage(const float ini_vx, const float ini_vy) : Message("TransMessage")
01249 {
01250 data_size = sizeof(TransMessage_data_t);
01251 data_ptr = malloc(data_size);
01252 memset(data_ptr, 0, data_size);
01253 data = (TransMessage_data_t *)data_ptr;
01254 data->vx = ini_vx;
01255 data->vy = ini_vy;
01256 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01257 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01258 }
01259
01260 MotorInterface::TransMessage::TransMessage() : Message("TransMessage")
01261 {
01262 data_size = sizeof(TransMessage_data_t);
01263 data_ptr = malloc(data_size);
01264 memset(data_ptr, 0, data_size);
01265 data = (TransMessage_data_t *)data_ptr;
01266 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01267 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01268 }
01269
01270
01271 MotorInterface::TransMessage::~TransMessage()
01272 {
01273 free(data_ptr);
01274 }
01275
01276
01277
01278
01279 MotorInterface::TransMessage::TransMessage(const TransMessage *m) : Message("TransMessage")
01280 {
01281 data_size = m->data_size;
01282 data_ptr = malloc(data_size);
01283 memcpy(data_ptr, m->data_ptr, data_size);
01284 data = (TransMessage_data_t *)data_ptr;
01285 }
01286
01287
01288
01289
01290
01291
01292 float
01293 MotorInterface::TransMessage::vx() const
01294 {
01295 return data->vx;
01296 }
01297
01298
01299
01300
01301
01302 size_t
01303 MotorInterface::TransMessage::maxlenof_vx() const
01304 {
01305 return 1;
01306 }
01307
01308
01309
01310
01311
01312 void
01313 MotorInterface::TransMessage::set_vx(const float new_vx)
01314 {
01315 data->vx = new_vx;
01316 }
01317
01318
01319
01320
01321
01322 float
01323 MotorInterface::TransMessage::vy() const
01324 {
01325 return data->vy;
01326 }
01327
01328
01329
01330
01331
01332 size_t
01333 MotorInterface::TransMessage::maxlenof_vy() const
01334 {
01335 return 1;
01336 }
01337
01338
01339
01340
01341
01342 void
01343 MotorInterface::TransMessage::set_vy(const float new_vy)
01344 {
01345 data->vy = new_vy;
01346 }
01347
01348
01349
01350
01351
01352
01353 Message *
01354 MotorInterface::TransMessage::clone() const
01355 {
01356 return new MotorInterface::TransMessage(this);
01357 }
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368 MotorInterface::RotMessage::RotMessage(const float ini_omega) : Message("RotMessage")
01369 {
01370 data_size = sizeof(RotMessage_data_t);
01371 data_ptr = malloc(data_size);
01372 memset(data_ptr, 0, data_size);
01373 data = (RotMessage_data_t *)data_ptr;
01374 data->omega = ini_omega;
01375 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01376 }
01377
01378 MotorInterface::RotMessage::RotMessage() : Message("RotMessage")
01379 {
01380 data_size = sizeof(RotMessage_data_t);
01381 data_ptr = malloc(data_size);
01382 memset(data_ptr, 0, data_size);
01383 data = (RotMessage_data_t *)data_ptr;
01384 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01385 }
01386
01387
01388 MotorInterface::RotMessage::~RotMessage()
01389 {
01390 free(data_ptr);
01391 }
01392
01393
01394
01395
01396 MotorInterface::RotMessage::RotMessage(const RotMessage *m) : Message("RotMessage")
01397 {
01398 data_size = m->data_size;
01399 data_ptr = malloc(data_size);
01400 memcpy(data_ptr, m->data_ptr, data_size);
01401 data = (RotMessage_data_t *)data_ptr;
01402 }
01403
01404
01405
01406
01407
01408
01409 float
01410 MotorInterface::RotMessage::omega() const
01411 {
01412 return data->omega;
01413 }
01414
01415
01416
01417
01418
01419 size_t
01420 MotorInterface::RotMessage::maxlenof_omega() const
01421 {
01422 return 1;
01423 }
01424
01425
01426
01427
01428
01429 void
01430 MotorInterface::RotMessage::set_omega(const float new_omega)
01431 {
01432 data->omega = new_omega;
01433 }
01434
01435
01436
01437
01438
01439
01440 Message *
01441 MotorInterface::RotMessage::clone() const
01442 {
01443 return new MotorInterface::RotMessage(this);
01444 }
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457 MotorInterface::TransRotMessage::TransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("TransRotMessage")
01458 {
01459 data_size = sizeof(TransRotMessage_data_t);
01460 data_ptr = malloc(data_size);
01461 memset(data_ptr, 0, data_size);
01462 data = (TransRotMessage_data_t *)data_ptr;
01463 data->vx = ini_vx;
01464 data->vy = ini_vy;
01465 data->omega = ini_omega;
01466 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01467 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01468 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01469 }
01470
01471 MotorInterface::TransRotMessage::TransRotMessage() : Message("TransRotMessage")
01472 {
01473 data_size = sizeof(TransRotMessage_data_t);
01474 data_ptr = malloc(data_size);
01475 memset(data_ptr, 0, data_size);
01476 data = (TransRotMessage_data_t *)data_ptr;
01477 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01478 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01479 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01480 }
01481
01482
01483 MotorInterface::TransRotMessage::~TransRotMessage()
01484 {
01485 free(data_ptr);
01486 }
01487
01488
01489
01490
01491 MotorInterface::TransRotMessage::TransRotMessage(const TransRotMessage *m) : Message("TransRotMessage")
01492 {
01493 data_size = m->data_size;
01494 data_ptr = malloc(data_size);
01495 memcpy(data_ptr, m->data_ptr, data_size);
01496 data = (TransRotMessage_data_t *)data_ptr;
01497 }
01498
01499
01500
01501
01502
01503
01504 float
01505 MotorInterface::TransRotMessage::vx() const
01506 {
01507 return data->vx;
01508 }
01509
01510
01511
01512
01513
01514 size_t
01515 MotorInterface::TransRotMessage::maxlenof_vx() const
01516 {
01517 return 1;
01518 }
01519
01520
01521
01522
01523
01524 void
01525 MotorInterface::TransRotMessage::set_vx(const float new_vx)
01526 {
01527 data->vx = new_vx;
01528 }
01529
01530
01531
01532
01533
01534 float
01535 MotorInterface::TransRotMessage::vy() const
01536 {
01537 return data->vy;
01538 }
01539
01540
01541
01542
01543
01544 size_t
01545 MotorInterface::TransRotMessage::maxlenof_vy() const
01546 {
01547 return 1;
01548 }
01549
01550
01551
01552
01553
01554 void
01555 MotorInterface::TransRotMessage::set_vy(const float new_vy)
01556 {
01557 data->vy = new_vy;
01558 }
01559
01560
01561
01562
01563
01564 float
01565 MotorInterface::TransRotMessage::omega() const
01566 {
01567 return data->omega;
01568 }
01569
01570
01571
01572
01573
01574 size_t
01575 MotorInterface::TransRotMessage::maxlenof_omega() const
01576 {
01577 return 1;
01578 }
01579
01580
01581
01582
01583
01584 void
01585 MotorInterface::TransRotMessage::set_omega(const float new_omega)
01586 {
01587 data->omega = new_omega;
01588 }
01589
01590
01591
01592
01593
01594
01595 Message *
01596 MotorInterface::TransRotMessage::clone() const
01597 {
01598 return new MotorInterface::TransRotMessage(this);
01599 }
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612 MotorInterface::OrbitMessage::OrbitMessage(const float ini_px, const float ini_py, const float ini_omega) : Message("OrbitMessage")
01613 {
01614 data_size = sizeof(OrbitMessage_data_t);
01615 data_ptr = malloc(data_size);
01616 memset(data_ptr, 0, data_size);
01617 data = (OrbitMessage_data_t *)data_ptr;
01618 data->px = ini_px;
01619 data->py = ini_py;
01620 data->omega = ini_omega;
01621 add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
01622 add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
01623 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01624 }
01625
01626 MotorInterface::OrbitMessage::OrbitMessage() : Message("OrbitMessage")
01627 {
01628 data_size = sizeof(OrbitMessage_data_t);
01629 data_ptr = malloc(data_size);
01630 memset(data_ptr, 0, data_size);
01631 data = (OrbitMessage_data_t *)data_ptr;
01632 add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
01633 add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
01634 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01635 }
01636
01637
01638 MotorInterface::OrbitMessage::~OrbitMessage()
01639 {
01640 free(data_ptr);
01641 }
01642
01643
01644
01645
01646 MotorInterface::OrbitMessage::OrbitMessage(const OrbitMessage *m) : Message("OrbitMessage")
01647 {
01648 data_size = m->data_size;
01649 data_ptr = malloc(data_size);
01650 memcpy(data_ptr, m->data_ptr, data_size);
01651 data = (OrbitMessage_data_t *)data_ptr;
01652 }
01653
01654
01655
01656
01657
01658
01659 float
01660 MotorInterface::OrbitMessage::px() const
01661 {
01662 return data->px;
01663 }
01664
01665
01666
01667
01668
01669 size_t
01670 MotorInterface::OrbitMessage::maxlenof_px() const
01671 {
01672 return 1;
01673 }
01674
01675
01676
01677
01678
01679 void
01680 MotorInterface::OrbitMessage::set_px(const float new_px)
01681 {
01682 data->px = new_px;
01683 }
01684
01685
01686
01687
01688
01689 float
01690 MotorInterface::OrbitMessage::py() const
01691 {
01692 return data->py;
01693 }
01694
01695
01696
01697
01698
01699 size_t
01700 MotorInterface::OrbitMessage::maxlenof_py() const
01701 {
01702 return 1;
01703 }
01704
01705
01706
01707
01708
01709 void
01710 MotorInterface::OrbitMessage::set_py(const float new_py)
01711 {
01712 data->py = new_py;
01713 }
01714
01715
01716
01717
01718
01719 float
01720 MotorInterface::OrbitMessage::omega() const
01721 {
01722 return data->omega;
01723 }
01724
01725
01726
01727
01728
01729 size_t
01730 MotorInterface::OrbitMessage::maxlenof_omega() const
01731 {
01732 return 1;
01733 }
01734
01735
01736
01737
01738
01739 void
01740 MotorInterface::OrbitMessage::set_omega(const float new_omega)
01741 {
01742 data->omega = new_omega;
01743 }
01744
01745
01746
01747
01748
01749
01750 Message *
01751 MotorInterface::OrbitMessage::clone() const
01752 {
01753 return new MotorInterface::OrbitMessage(this);
01754 }
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767 MotorInterface::LinTransRotMessage::LinTransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("LinTransRotMessage")
01768 {
01769 data_size = sizeof(LinTransRotMessage_data_t);
01770 data_ptr = malloc(data_size);
01771 memset(data_ptr, 0, data_size);
01772 data = (LinTransRotMessage_data_t *)data_ptr;
01773 data->vx = ini_vx;
01774 data->vy = ini_vy;
01775 data->omega = ini_omega;
01776 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01777 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01778 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01779 }
01780
01781 MotorInterface::LinTransRotMessage::LinTransRotMessage() : Message("LinTransRotMessage")
01782 {
01783 data_size = sizeof(LinTransRotMessage_data_t);
01784 data_ptr = malloc(data_size);
01785 memset(data_ptr, 0, data_size);
01786 data = (LinTransRotMessage_data_t *)data_ptr;
01787 add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01788 add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01789 add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01790 }
01791
01792
01793 MotorInterface::LinTransRotMessage::~LinTransRotMessage()
01794 {
01795 free(data_ptr);
01796 }
01797
01798
01799
01800
01801 MotorInterface::LinTransRotMessage::LinTransRotMessage(const LinTransRotMessage *m) : Message("LinTransRotMessage")
01802 {
01803 data_size = m->data_size;
01804 data_ptr = malloc(data_size);
01805 memcpy(data_ptr, m->data_ptr, data_size);
01806 data = (LinTransRotMessage_data_t *)data_ptr;
01807 }
01808
01809
01810
01811
01812
01813
01814 float
01815 MotorInterface::LinTransRotMessage::vx() const
01816 {
01817 return data->vx;
01818 }
01819
01820
01821
01822
01823
01824 size_t
01825 MotorInterface::LinTransRotMessage::maxlenof_vx() const
01826 {
01827 return 1;
01828 }
01829
01830
01831
01832
01833
01834 void
01835 MotorInterface::LinTransRotMessage::set_vx(const float new_vx)
01836 {
01837 data->vx = new_vx;
01838 }
01839
01840
01841
01842
01843
01844 float
01845 MotorInterface::LinTransRotMessage::vy() const
01846 {
01847 return data->vy;
01848 }
01849
01850
01851
01852
01853
01854 size_t
01855 MotorInterface::LinTransRotMessage::maxlenof_vy() const
01856 {
01857 return 1;
01858 }
01859
01860
01861
01862
01863
01864 void
01865 MotorInterface::LinTransRotMessage::set_vy(const float new_vy)
01866 {
01867 data->vy = new_vy;
01868 }
01869
01870
01871
01872
01873
01874 float
01875 MotorInterface::LinTransRotMessage::omega() const
01876 {
01877 return data->omega;
01878 }
01879
01880
01881
01882
01883
01884 size_t
01885 MotorInterface::LinTransRotMessage::maxlenof_omega() const
01886 {
01887 return 1;
01888 }
01889
01890
01891
01892
01893
01894 void
01895 MotorInterface::LinTransRotMessage::set_omega(const float new_omega)
01896 {
01897 data->omega = new_omega;
01898 }
01899
01900
01901
01902
01903
01904
01905 Message *
01906 MotorInterface::LinTransRotMessage::clone() const
01907 {
01908 return new MotorInterface::LinTransRotMessage(this);
01909 }
01910
01911
01912
01913 bool
01914 MotorInterface::message_valid(const Message *message) const
01915 {
01916 const SetMotorStateMessage *m0 = dynamic_cast<const SetMotorStateMessage *>(message);
01917 if ( m0 != NULL ) {
01918 return true;
01919 }
01920 const AcquireControlMessage *m1 = dynamic_cast<const AcquireControlMessage *>(message);
01921 if ( m1 != NULL ) {
01922 return true;
01923 }
01924 const ResetOdometryMessage *m2 = dynamic_cast<const ResetOdometryMessage *>(message);
01925 if ( m2 != NULL ) {
01926 return true;
01927 }
01928 const DriveRPMMessage *m3 = dynamic_cast<const DriveRPMMessage *>(message);
01929 if ( m3 != NULL ) {
01930 return true;
01931 }
01932 const GotoMessage *m4 = dynamic_cast<const GotoMessage *>(message);
01933 if ( m4 != NULL ) {
01934 return true;
01935 }
01936 const TransMessage *m5 = dynamic_cast<const TransMessage *>(message);
01937 if ( m5 != NULL ) {
01938 return true;
01939 }
01940 const RotMessage *m6 = dynamic_cast<const RotMessage *>(message);
01941 if ( m6 != NULL ) {
01942 return true;
01943 }
01944 const TransRotMessage *m7 = dynamic_cast<const TransRotMessage *>(message);
01945 if ( m7 != NULL ) {
01946 return true;
01947 }
01948 const OrbitMessage *m8 = dynamic_cast<const OrbitMessage *>(message);
01949 if ( m8 != NULL ) {
01950 return true;
01951 }
01952 const LinTransRotMessage *m9 = dynamic_cast<const LinTransRotMessage *>(message);
01953 if ( m9 != NULL ) {
01954 return true;
01955 }
01956 return false;
01957 }
01958
01959
01960 EXPORT_INTERFACE(MotorInterface)
01961
01962
01963
01964 }