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/KatanaInterface.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
00044 const uint32_t KatanaInterface::SENSOR_IR_RIGHT_INNER_MIDDLE = 0u;
00045
00046 const uint32_t KatanaInterface::SENSOR_IR_RIGHT_INNER_FRONT = 1u;
00047
00048 const uint32_t KatanaInterface::SENSOR_RESERVED_2 = 2u;
00049
00050 const uint32_t KatanaInterface::SENSOR_COND_BOTH = 3u;
00051
00052 const uint32_t KatanaInterface::SENSOR_IR_RIGHT_OUTER_FRONT = 4u;
00053
00054 const uint32_t KatanaInterface::SENSOR_IR_RIGHT_BOTTOM_FRONT = 5u;
00055
00056 const uint32_t KatanaInterface::SENSOR_FORCE_RIGHT_REAR = 6u;
00057
00058 const uint32_t KatanaInterface::SENSOR_FORCE_RIGHT_FRONT = 7u;
00059
00060 const uint32_t KatanaInterface::SENSOR_IR_LEFT_INNER_MIDDLE = 8u;
00061
00062 const uint32_t KatanaInterface::SENSOR_IR_LEFT_INNER_FRONT = 9u;
00063
00064 const uint32_t KatanaInterface::SENSOR_RESERVED_10 = 10u;
00065
00066 const uint32_t KatanaInterface::SENSOR_IR_CENTER_GRIPPER = 11u;
00067
00068 const uint32_t KatanaInterface::SENSOR_IR_LEFT_OUTER_FRONT = 12u;
00069
00070 const uint32_t KatanaInterface::SENSOR_IR_LEFT_BOTTOM_FRONT = 13u;
00071
00072 const uint32_t KatanaInterface::SENSOR_FORCE_LEFT_REAR = 14u;
00073
00074 const uint32_t KatanaInterface::SENSOR_FORCE_LEFT_FRONT = 15u;
00075
00076 const uint32_t KatanaInterface::ERROR_NONE = 0u;
00077
00078 const uint32_t KatanaInterface::ERROR_UNSPECIFIC = 1u;
00079
00080 const uint32_t KatanaInterface::ERROR_CMD_START_FAILED = 2u;
00081
00082 const uint32_t KatanaInterface::ERROR_NO_SOLUTION = 4u;
00083
00084 const uint32_t KatanaInterface::ERROR_COMMUNICATION = 8u;
00085
00086 const uint32_t KatanaInterface::ERROR_MOTOR_CRASHED = 16u;
00087
00088
00089 KatanaInterface::KatanaInterface() : Interface()
00090 {
00091 data_size = sizeof(KatanaInterface_data_t);
00092 data_ptr = malloc(data_size);
00093 data = (KatanaInterface_data_t *)data_ptr;
00094 data_ts = (interface_data_ts_t *)data_ptr;
00095 memset(data_ptr, 0, data_size);
00096 add_fieldinfo(IFT_BYTE, "sensor_value", 16, &data->sensor_value);
00097 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00098 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00099 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
00100 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
00101 add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
00102 add_fieldinfo(IFT_FLOAT, "psi", 1, &data->psi);
00103 add_fieldinfo(IFT_UINT32, "msgid", 1, &data->msgid);
00104 add_fieldinfo(IFT_BOOL, "final", 1, &data->final);
00105 add_fieldinfo(IFT_UINT32, "error_code", 1, &data->error_code);
00106 add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
00107 add_fieldinfo(IFT_BOOL, "calibrated", 1, &data->calibrated);
00108 add_fieldinfo(IFT_BYTE, "max_velocity", 1, &data->max_velocity);
00109 add_fieldinfo(IFT_BYTE, "num_motors", 1, &data->num_motors);
00110 add_messageinfo("StopMessage");
00111 add_messageinfo("FlushMessage");
00112 add_messageinfo("ParkMessage");
00113 add_messageinfo("LinearGotoMessage");
00114 add_messageinfo("CalibrateMessage");
00115 add_messageinfo("OpenGripperMessage");
00116 add_messageinfo("CloseGripperMessage");
00117 add_messageinfo("SetEnabledMessage");
00118 add_messageinfo("SetMaxVelocityMessage");
00119 unsigned char tmp_hash[] = {0x36, 0x80, 0x78, 0x4, 0x9f, 0x14, 0x1b, 0x27, 0x38, 0x40, 0x77, 0xb6, 0xc0, 0x7, 0xe, 0x73};
00120 set_hash(tmp_hash);
00121 }
00122
00123
00124 KatanaInterface::~KatanaInterface()
00125 {
00126 free(data_ptr);
00127 }
00128
00129
00130
00131
00132
00133
00134 uint8_t *
00135 KatanaInterface::sensor_value() const
00136 {
00137 return data->sensor_value;
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147 uint8_t
00148 KatanaInterface::sensor_value(unsigned int index) const
00149 {
00150 if (index > 16) {
00151 throw Exception("Index value %u out of bounds (0..16)", index);
00152 }
00153 return data->sensor_value[index];
00154 }
00155
00156
00157
00158
00159
00160 size_t
00161 KatanaInterface::maxlenof_sensor_value() const
00162 {
00163 return 16;
00164 }
00165
00166
00167
00168
00169
00170
00171 void
00172 KatanaInterface::set_sensor_value(const uint8_t * new_sensor_value)
00173 {
00174 memcpy(data->sensor_value, new_sensor_value, sizeof(uint8_t) * 16);
00175 data_changed = true;
00176 }
00177
00178
00179
00180
00181
00182
00183
00184 void
00185 KatanaInterface::set_sensor_value(unsigned int index, const uint8_t new_sensor_value)
00186 {
00187 if (index > 16) {
00188 throw Exception("Index value %u out of bounds (0..16)", index);
00189 }
00190 data->sensor_value[index] = new_sensor_value;
00191 }
00192
00193
00194
00195
00196
00197 float
00198 KatanaInterface::x() const
00199 {
00200 return data->x;
00201 }
00202
00203
00204
00205
00206
00207 size_t
00208 KatanaInterface::maxlenof_x() const
00209 {
00210 return 1;
00211 }
00212
00213
00214
00215
00216
00217
00218 void
00219 KatanaInterface::set_x(const float new_x)
00220 {
00221 data->x = new_x;
00222 data_changed = true;
00223 }
00224
00225
00226
00227
00228
00229
00230 float
00231 KatanaInterface::y() const
00232 {
00233 return data->y;
00234 }
00235
00236
00237
00238
00239
00240 size_t
00241 KatanaInterface::maxlenof_y() const
00242 {
00243 return 1;
00244 }
00245
00246
00247
00248
00249
00250
00251 void
00252 KatanaInterface::set_y(const float new_y)
00253 {
00254 data->y = new_y;
00255 data_changed = true;
00256 }
00257
00258
00259
00260
00261
00262
00263 float
00264 KatanaInterface::z() const
00265 {
00266 return data->z;
00267 }
00268
00269
00270
00271
00272
00273 size_t
00274 KatanaInterface::maxlenof_z() const
00275 {
00276 return 1;
00277 }
00278
00279
00280
00281
00282
00283
00284 void
00285 KatanaInterface::set_z(const float new_z)
00286 {
00287 data->z = new_z;
00288 data_changed = true;
00289 }
00290
00291
00292
00293
00294
00295 float
00296 KatanaInterface::phi() const
00297 {
00298 return data->phi;
00299 }
00300
00301
00302
00303
00304
00305 size_t
00306 KatanaInterface::maxlenof_phi() const
00307 {
00308 return 1;
00309 }
00310
00311
00312
00313
00314
00315 void
00316 KatanaInterface::set_phi(const float new_phi)
00317 {
00318 data->phi = new_phi;
00319 data_changed = true;
00320 }
00321
00322
00323
00324
00325
00326 float
00327 KatanaInterface::theta() const
00328 {
00329 return data->theta;
00330 }
00331
00332
00333
00334
00335
00336 size_t
00337 KatanaInterface::maxlenof_theta() const
00338 {
00339 return 1;
00340 }
00341
00342
00343
00344
00345
00346 void
00347 KatanaInterface::set_theta(const float new_theta)
00348 {
00349 data->theta = new_theta;
00350 data_changed = true;
00351 }
00352
00353
00354
00355
00356
00357 float
00358 KatanaInterface::psi() const
00359 {
00360 return data->psi;
00361 }
00362
00363
00364
00365
00366
00367 size_t
00368 KatanaInterface::maxlenof_psi() const
00369 {
00370 return 1;
00371 }
00372
00373
00374
00375
00376
00377 void
00378 KatanaInterface::set_psi(const float new_psi)
00379 {
00380 data->psi = new_psi;
00381 data_changed = true;
00382 }
00383
00384
00385
00386
00387
00388
00389 uint32_t
00390 KatanaInterface::msgid() const
00391 {
00392 return data->msgid;
00393 }
00394
00395
00396
00397
00398
00399 size_t
00400 KatanaInterface::maxlenof_msgid() const
00401 {
00402 return 1;
00403 }
00404
00405
00406
00407
00408
00409
00410 void
00411 KatanaInterface::set_msgid(const uint32_t new_msgid)
00412 {
00413 data->msgid = new_msgid;
00414 data_changed = true;
00415 }
00416
00417
00418
00419
00420
00421
00422 bool
00423 KatanaInterface::is_final() const
00424 {
00425 return data->final;
00426 }
00427
00428
00429
00430
00431
00432 size_t
00433 KatanaInterface::maxlenof_final() const
00434 {
00435 return 1;
00436 }
00437
00438
00439
00440
00441
00442
00443 void
00444 KatanaInterface::set_final(const bool new_final)
00445 {
00446 data->final = new_final;
00447 data_changed = true;
00448 }
00449
00450
00451
00452
00453
00454
00455
00456 uint32_t
00457 KatanaInterface::error_code() const
00458 {
00459 return data->error_code;
00460 }
00461
00462
00463
00464
00465
00466 size_t
00467 KatanaInterface::maxlenof_error_code() const
00468 {
00469 return 1;
00470 }
00471
00472
00473
00474
00475
00476
00477
00478 void
00479 KatanaInterface::set_error_code(const uint32_t new_error_code)
00480 {
00481 data->error_code = new_error_code;
00482 data_changed = true;
00483 }
00484
00485
00486
00487
00488
00489 bool
00490 KatanaInterface::is_enabled() const
00491 {
00492 return data->enabled;
00493 }
00494
00495
00496
00497
00498
00499 size_t
00500 KatanaInterface::maxlenof_enabled() const
00501 {
00502 return 1;
00503 }
00504
00505
00506
00507
00508
00509 void
00510 KatanaInterface::set_enabled(const bool new_enabled)
00511 {
00512 data->enabled = new_enabled;
00513 data_changed = true;
00514 }
00515
00516
00517
00518
00519
00520 bool
00521 KatanaInterface::is_calibrated() const
00522 {
00523 return data->calibrated;
00524 }
00525
00526
00527
00528
00529
00530 size_t
00531 KatanaInterface::maxlenof_calibrated() const
00532 {
00533 return 1;
00534 }
00535
00536
00537
00538
00539
00540 void
00541 KatanaInterface::set_calibrated(const bool new_calibrated)
00542 {
00543 data->calibrated = new_calibrated;
00544 data_changed = true;
00545 }
00546
00547
00548
00549
00550
00551 uint8_t
00552 KatanaInterface::max_velocity() const
00553 {
00554 return data->max_velocity;
00555 }
00556
00557
00558
00559
00560
00561 size_t
00562 KatanaInterface::maxlenof_max_velocity() const
00563 {
00564 return 1;
00565 }
00566
00567
00568
00569
00570
00571 void
00572 KatanaInterface::set_max_velocity(const uint8_t new_max_velocity)
00573 {
00574 data->max_velocity = new_max_velocity;
00575 data_changed = true;
00576 }
00577
00578
00579
00580
00581
00582 uint8_t
00583 KatanaInterface::num_motors() const
00584 {
00585 return data->num_motors;
00586 }
00587
00588
00589
00590
00591
00592 size_t
00593 KatanaInterface::maxlenof_num_motors() const
00594 {
00595 return 1;
00596 }
00597
00598
00599
00600
00601
00602 void
00603 KatanaInterface::set_num_motors(const uint8_t new_num_motors)
00604 {
00605 data->num_motors = new_num_motors;
00606 data_changed = true;
00607 }
00608
00609
00610 Message *
00611 KatanaInterface::create_message(const char *type) const
00612 {
00613 if ( strncmp("StopMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00614 return new StopMessage();
00615 } else if ( strncmp("FlushMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00616 return new FlushMessage();
00617 } else if ( strncmp("ParkMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00618 return new ParkMessage();
00619 } else if ( strncmp("LinearGotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00620 return new LinearGotoMessage();
00621 } else if ( strncmp("CalibrateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00622 return new CalibrateMessage();
00623 } else if ( strncmp("OpenGripperMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00624 return new OpenGripperMessage();
00625 } else if ( strncmp("CloseGripperMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00626 return new CloseGripperMessage();
00627 } else if ( strncmp("SetEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00628 return new SetEnabledMessage();
00629 } else if ( strncmp("SetMaxVelocityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00630 return new SetMaxVelocityMessage();
00631 } else {
00632 throw UnknownTypeException("The given type '%s' does not match any known "
00633 "message type for this interface type.", type);
00634 }
00635 }
00636
00637
00638
00639
00640
00641 void
00642 KatanaInterface::copy_values(const Interface *other)
00643 {
00644 const KatanaInterface *oi = dynamic_cast<const KatanaInterface *>(other);
00645 if (oi == NULL) {
00646 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00647 type(), other->type());
00648 }
00649 memcpy(data, oi->data, sizeof(KatanaInterface_data_t));
00650 }
00651
00652 const char *
00653 KatanaInterface::enum_tostring(const char *enumtype, int val) const
00654 {
00655 throw UnknownTypeException("Unknown enum type %s", enumtype);
00656 }
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667 KatanaInterface::StopMessage::StopMessage() : Message("StopMessage")
00668 {
00669 data_size = sizeof(StopMessage_data_t);
00670 data_ptr = malloc(data_size);
00671 memset(data_ptr, 0, data_size);
00672 data = (StopMessage_data_t *)data_ptr;
00673 data_ts = (message_data_ts_t *)data_ptr;
00674 }
00675
00676
00677 KatanaInterface::StopMessage::~StopMessage()
00678 {
00679 free(data_ptr);
00680 }
00681
00682
00683
00684
00685 KatanaInterface::StopMessage::StopMessage(const StopMessage *m) : Message("StopMessage")
00686 {
00687 data_size = m->data_size;
00688 data_ptr = malloc(data_size);
00689 memcpy(data_ptr, m->data_ptr, data_size);
00690 data = (StopMessage_data_t *)data_ptr;
00691 data_ts = (message_data_ts_t *)data_ptr;
00692 }
00693
00694
00695
00696
00697
00698
00699
00700 Message *
00701 KatanaInterface::StopMessage::clone() const
00702 {
00703 return new KatanaInterface::StopMessage(this);
00704 }
00705
00706
00707
00708
00709
00710
00711
00712
00713 KatanaInterface::FlushMessage::FlushMessage() : Message("FlushMessage")
00714 {
00715 data_size = sizeof(FlushMessage_data_t);
00716 data_ptr = malloc(data_size);
00717 memset(data_ptr, 0, data_size);
00718 data = (FlushMessage_data_t *)data_ptr;
00719 data_ts = (message_data_ts_t *)data_ptr;
00720 }
00721
00722
00723 KatanaInterface::FlushMessage::~FlushMessage()
00724 {
00725 free(data_ptr);
00726 }
00727
00728
00729
00730
00731 KatanaInterface::FlushMessage::FlushMessage(const FlushMessage *m) : Message("FlushMessage")
00732 {
00733 data_size = m->data_size;
00734 data_ptr = malloc(data_size);
00735 memcpy(data_ptr, m->data_ptr, data_size);
00736 data = (FlushMessage_data_t *)data_ptr;
00737 data_ts = (message_data_ts_t *)data_ptr;
00738 }
00739
00740
00741
00742
00743
00744
00745
00746 Message *
00747 KatanaInterface::FlushMessage::clone() const
00748 {
00749 return new KatanaInterface::FlushMessage(this);
00750 }
00751
00752
00753
00754
00755
00756
00757
00758
00759 KatanaInterface::ParkMessage::ParkMessage() : Message("ParkMessage")
00760 {
00761 data_size = sizeof(ParkMessage_data_t);
00762 data_ptr = malloc(data_size);
00763 memset(data_ptr, 0, data_size);
00764 data = (ParkMessage_data_t *)data_ptr;
00765 data_ts = (message_data_ts_t *)data_ptr;
00766 }
00767
00768
00769 KatanaInterface::ParkMessage::~ParkMessage()
00770 {
00771 free(data_ptr);
00772 }
00773
00774
00775
00776
00777 KatanaInterface::ParkMessage::ParkMessage(const ParkMessage *m) : Message("ParkMessage")
00778 {
00779 data_size = m->data_size;
00780 data_ptr = malloc(data_size);
00781 memcpy(data_ptr, m->data_ptr, data_size);
00782 data = (ParkMessage_data_t *)data_ptr;
00783 data_ts = (message_data_ts_t *)data_ptr;
00784 }
00785
00786
00787
00788
00789
00790
00791
00792 Message *
00793 KatanaInterface::ParkMessage::clone() const
00794 {
00795 return new KatanaInterface::ParkMessage(this);
00796 }
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812 KatanaInterface::LinearGotoMessage::LinearGotoMessage(const float ini_x, const float ini_y, const float ini_z, const float ini_phi, const float ini_theta, const float ini_psi) : Message("LinearGotoMessage")
00813 {
00814 data_size = sizeof(LinearGotoMessage_data_t);
00815 data_ptr = malloc(data_size);
00816 memset(data_ptr, 0, data_size);
00817 data = (LinearGotoMessage_data_t *)data_ptr;
00818 data_ts = (message_data_ts_t *)data_ptr;
00819 data->x = ini_x;
00820 data->y = ini_y;
00821 data->z = ini_z;
00822 data->phi = ini_phi;
00823 data->theta = ini_theta;
00824 data->psi = ini_psi;
00825 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00826 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00827 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
00828 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
00829 add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
00830 add_fieldinfo(IFT_FLOAT, "psi", 1, &data->psi);
00831 }
00832
00833 KatanaInterface::LinearGotoMessage::LinearGotoMessage() : Message("LinearGotoMessage")
00834 {
00835 data_size = sizeof(LinearGotoMessage_data_t);
00836 data_ptr = malloc(data_size);
00837 memset(data_ptr, 0, data_size);
00838 data = (LinearGotoMessage_data_t *)data_ptr;
00839 data_ts = (message_data_ts_t *)data_ptr;
00840 add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00841 add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00842 add_fieldinfo(IFT_FLOAT, "z", 1, &data->z);
00843 add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
00844 add_fieldinfo(IFT_FLOAT, "theta", 1, &data->theta);
00845 add_fieldinfo(IFT_FLOAT, "psi", 1, &data->psi);
00846 }
00847
00848
00849 KatanaInterface::LinearGotoMessage::~LinearGotoMessage()
00850 {
00851 free(data_ptr);
00852 }
00853
00854
00855
00856
00857 KatanaInterface::LinearGotoMessage::LinearGotoMessage(const LinearGotoMessage *m) : Message("LinearGotoMessage")
00858 {
00859 data_size = m->data_size;
00860 data_ptr = malloc(data_size);
00861 memcpy(data_ptr, m->data_ptr, data_size);
00862 data = (LinearGotoMessage_data_t *)data_ptr;
00863 data_ts = (message_data_ts_t *)data_ptr;
00864 }
00865
00866
00867
00868
00869
00870
00871
00872 float
00873 KatanaInterface::LinearGotoMessage::x() const
00874 {
00875 return data->x;
00876 }
00877
00878
00879
00880
00881
00882 size_t
00883 KatanaInterface::LinearGotoMessage::maxlenof_x() const
00884 {
00885 return 1;
00886 }
00887
00888
00889
00890
00891
00892
00893 void
00894 KatanaInterface::LinearGotoMessage::set_x(const float new_x)
00895 {
00896 data->x = new_x;
00897 }
00898
00899
00900
00901
00902
00903
00904 float
00905 KatanaInterface::LinearGotoMessage::y() const
00906 {
00907 return data->y;
00908 }
00909
00910
00911
00912
00913
00914 size_t
00915 KatanaInterface::LinearGotoMessage::maxlenof_y() const
00916 {
00917 return 1;
00918 }
00919
00920
00921
00922
00923
00924
00925 void
00926 KatanaInterface::LinearGotoMessage::set_y(const float new_y)
00927 {
00928 data->y = new_y;
00929 }
00930
00931
00932
00933
00934
00935
00936 float
00937 KatanaInterface::LinearGotoMessage::z() const
00938 {
00939 return data->z;
00940 }
00941
00942
00943
00944
00945
00946 size_t
00947 KatanaInterface::LinearGotoMessage::maxlenof_z() const
00948 {
00949 return 1;
00950 }
00951
00952
00953
00954
00955
00956
00957 void
00958 KatanaInterface::LinearGotoMessage::set_z(const float new_z)
00959 {
00960 data->z = new_z;
00961 }
00962
00963
00964
00965
00966
00967 float
00968 KatanaInterface::LinearGotoMessage::phi() const
00969 {
00970 return data->phi;
00971 }
00972
00973
00974
00975
00976
00977 size_t
00978 KatanaInterface::LinearGotoMessage::maxlenof_phi() const
00979 {
00980 return 1;
00981 }
00982
00983
00984
00985
00986
00987 void
00988 KatanaInterface::LinearGotoMessage::set_phi(const float new_phi)
00989 {
00990 data->phi = new_phi;
00991 }
00992
00993
00994
00995
00996
00997 float
00998 KatanaInterface::LinearGotoMessage::theta() const
00999 {
01000 return data->theta;
01001 }
01002
01003
01004
01005
01006
01007 size_t
01008 KatanaInterface::LinearGotoMessage::maxlenof_theta() const
01009 {
01010 return 1;
01011 }
01012
01013
01014
01015
01016
01017 void
01018 KatanaInterface::LinearGotoMessage::set_theta(const float new_theta)
01019 {
01020 data->theta = new_theta;
01021 }
01022
01023
01024
01025
01026
01027 float
01028 KatanaInterface::LinearGotoMessage::psi() const
01029 {
01030 return data->psi;
01031 }
01032
01033
01034
01035
01036
01037 size_t
01038 KatanaInterface::LinearGotoMessage::maxlenof_psi() const
01039 {
01040 return 1;
01041 }
01042
01043
01044
01045
01046
01047 void
01048 KatanaInterface::LinearGotoMessage::set_psi(const float new_psi)
01049 {
01050 data->psi = new_psi;
01051 }
01052
01053
01054
01055
01056
01057
01058 Message *
01059 KatanaInterface::LinearGotoMessage::clone() const
01060 {
01061 return new KatanaInterface::LinearGotoMessage(this);
01062 }
01063
01064
01065
01066
01067
01068
01069
01070
01071 KatanaInterface::CalibrateMessage::CalibrateMessage() : Message("CalibrateMessage")
01072 {
01073 data_size = sizeof(CalibrateMessage_data_t);
01074 data_ptr = malloc(data_size);
01075 memset(data_ptr, 0, data_size);
01076 data = (CalibrateMessage_data_t *)data_ptr;
01077 data_ts = (message_data_ts_t *)data_ptr;
01078 }
01079
01080
01081 KatanaInterface::CalibrateMessage::~CalibrateMessage()
01082 {
01083 free(data_ptr);
01084 }
01085
01086
01087
01088
01089 KatanaInterface::CalibrateMessage::CalibrateMessage(const CalibrateMessage *m) : Message("CalibrateMessage")
01090 {
01091 data_size = m->data_size;
01092 data_ptr = malloc(data_size);
01093 memcpy(data_ptr, m->data_ptr, data_size);
01094 data = (CalibrateMessage_data_t *)data_ptr;
01095 data_ts = (message_data_ts_t *)data_ptr;
01096 }
01097
01098
01099
01100
01101
01102
01103
01104 Message *
01105 KatanaInterface::CalibrateMessage::clone() const
01106 {
01107 return new KatanaInterface::CalibrateMessage(this);
01108 }
01109
01110
01111
01112
01113
01114
01115
01116
01117 KatanaInterface::OpenGripperMessage::OpenGripperMessage() : Message("OpenGripperMessage")
01118 {
01119 data_size = sizeof(OpenGripperMessage_data_t);
01120 data_ptr = malloc(data_size);
01121 memset(data_ptr, 0, data_size);
01122 data = (OpenGripperMessage_data_t *)data_ptr;
01123 data_ts = (message_data_ts_t *)data_ptr;
01124 }
01125
01126
01127 KatanaInterface::OpenGripperMessage::~OpenGripperMessage()
01128 {
01129 free(data_ptr);
01130 }
01131
01132
01133
01134
01135 KatanaInterface::OpenGripperMessage::OpenGripperMessage(const OpenGripperMessage *m) : Message("OpenGripperMessage")
01136 {
01137 data_size = m->data_size;
01138 data_ptr = malloc(data_size);
01139 memcpy(data_ptr, m->data_ptr, data_size);
01140 data = (OpenGripperMessage_data_t *)data_ptr;
01141 data_ts = (message_data_ts_t *)data_ptr;
01142 }
01143
01144
01145
01146
01147
01148
01149
01150 Message *
01151 KatanaInterface::OpenGripperMessage::clone() const
01152 {
01153 return new KatanaInterface::OpenGripperMessage(this);
01154 }
01155
01156
01157
01158
01159
01160
01161
01162
01163 KatanaInterface::CloseGripperMessage::CloseGripperMessage() : Message("CloseGripperMessage")
01164 {
01165 data_size = sizeof(CloseGripperMessage_data_t);
01166 data_ptr = malloc(data_size);
01167 memset(data_ptr, 0, data_size);
01168 data = (CloseGripperMessage_data_t *)data_ptr;
01169 data_ts = (message_data_ts_t *)data_ptr;
01170 }
01171
01172
01173 KatanaInterface::CloseGripperMessage::~CloseGripperMessage()
01174 {
01175 free(data_ptr);
01176 }
01177
01178
01179
01180
01181 KatanaInterface::CloseGripperMessage::CloseGripperMessage(const CloseGripperMessage *m) : Message("CloseGripperMessage")
01182 {
01183 data_size = m->data_size;
01184 data_ptr = malloc(data_size);
01185 memcpy(data_ptr, m->data_ptr, data_size);
01186 data = (CloseGripperMessage_data_t *)data_ptr;
01187 data_ts = (message_data_ts_t *)data_ptr;
01188 }
01189
01190
01191
01192
01193
01194
01195
01196 Message *
01197 KatanaInterface::CloseGripperMessage::clone() const
01198 {
01199 return new KatanaInterface::CloseGripperMessage(this);
01200 }
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211 KatanaInterface::SetEnabledMessage::SetEnabledMessage(const bool ini_enabled) : Message("SetEnabledMessage")
01212 {
01213 data_size = sizeof(SetEnabledMessage_data_t);
01214 data_ptr = malloc(data_size);
01215 memset(data_ptr, 0, data_size);
01216 data = (SetEnabledMessage_data_t *)data_ptr;
01217 data_ts = (message_data_ts_t *)data_ptr;
01218 data->enabled = ini_enabled;
01219 add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
01220 }
01221
01222 KatanaInterface::SetEnabledMessage::SetEnabledMessage() : Message("SetEnabledMessage")
01223 {
01224 data_size = sizeof(SetEnabledMessage_data_t);
01225 data_ptr = malloc(data_size);
01226 memset(data_ptr, 0, data_size);
01227 data = (SetEnabledMessage_data_t *)data_ptr;
01228 data_ts = (message_data_ts_t *)data_ptr;
01229 add_fieldinfo(IFT_BOOL, "enabled", 1, &data->enabled);
01230 }
01231
01232
01233 KatanaInterface::SetEnabledMessage::~SetEnabledMessage()
01234 {
01235 free(data_ptr);
01236 }
01237
01238
01239
01240
01241 KatanaInterface::SetEnabledMessage::SetEnabledMessage(const SetEnabledMessage *m) : Message("SetEnabledMessage")
01242 {
01243 data_size = m->data_size;
01244 data_ptr = malloc(data_size);
01245 memcpy(data_ptr, m->data_ptr, data_size);
01246 data = (SetEnabledMessage_data_t *)data_ptr;
01247 data_ts = (message_data_ts_t *)data_ptr;
01248 }
01249
01250
01251
01252
01253
01254
01255 bool
01256 KatanaInterface::SetEnabledMessage::is_enabled() const
01257 {
01258 return data->enabled;
01259 }
01260
01261
01262
01263
01264
01265 size_t
01266 KatanaInterface::SetEnabledMessage::maxlenof_enabled() const
01267 {
01268 return 1;
01269 }
01270
01271
01272
01273
01274
01275 void
01276 KatanaInterface::SetEnabledMessage::set_enabled(const bool new_enabled)
01277 {
01278 data->enabled = new_enabled;
01279 }
01280
01281
01282
01283
01284
01285
01286 Message *
01287 KatanaInterface::SetEnabledMessage::clone() const
01288 {
01289 return new KatanaInterface::SetEnabledMessage(this);
01290 }
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301 KatanaInterface::SetMaxVelocityMessage::SetMaxVelocityMessage(const uint8_t ini_max_velocity) : Message("SetMaxVelocityMessage")
01302 {
01303 data_size = sizeof(SetMaxVelocityMessage_data_t);
01304 data_ptr = malloc(data_size);
01305 memset(data_ptr, 0, data_size);
01306 data = (SetMaxVelocityMessage_data_t *)data_ptr;
01307 data_ts = (message_data_ts_t *)data_ptr;
01308 data->max_velocity = ini_max_velocity;
01309 add_fieldinfo(IFT_BYTE, "max_velocity", 1, &data->max_velocity);
01310 }
01311
01312 KatanaInterface::SetMaxVelocityMessage::SetMaxVelocityMessage() : Message("SetMaxVelocityMessage")
01313 {
01314 data_size = sizeof(SetMaxVelocityMessage_data_t);
01315 data_ptr = malloc(data_size);
01316 memset(data_ptr, 0, data_size);
01317 data = (SetMaxVelocityMessage_data_t *)data_ptr;
01318 data_ts = (message_data_ts_t *)data_ptr;
01319 add_fieldinfo(IFT_BYTE, "max_velocity", 1, &data->max_velocity);
01320 }
01321
01322
01323 KatanaInterface::SetMaxVelocityMessage::~SetMaxVelocityMessage()
01324 {
01325 free(data_ptr);
01326 }
01327
01328
01329
01330
01331 KatanaInterface::SetMaxVelocityMessage::SetMaxVelocityMessage(const SetMaxVelocityMessage *m) : Message("SetMaxVelocityMessage")
01332 {
01333 data_size = m->data_size;
01334 data_ptr = malloc(data_size);
01335 memcpy(data_ptr, m->data_ptr, data_size);
01336 data = (SetMaxVelocityMessage_data_t *)data_ptr;
01337 data_ts = (message_data_ts_t *)data_ptr;
01338 }
01339
01340
01341
01342
01343
01344
01345 uint8_t
01346 KatanaInterface::SetMaxVelocityMessage::max_velocity() const
01347 {
01348 return data->max_velocity;
01349 }
01350
01351
01352
01353
01354
01355 size_t
01356 KatanaInterface::SetMaxVelocityMessage::maxlenof_max_velocity() const
01357 {
01358 return 1;
01359 }
01360
01361
01362
01363
01364
01365 void
01366 KatanaInterface::SetMaxVelocityMessage::set_max_velocity(const uint8_t new_max_velocity)
01367 {
01368 data->max_velocity = new_max_velocity;
01369 }
01370
01371
01372
01373
01374
01375
01376 Message *
01377 KatanaInterface::SetMaxVelocityMessage::clone() const
01378 {
01379 return new KatanaInterface::SetMaxVelocityMessage(this);
01380 }
01381
01382
01383
01384
01385 bool
01386 KatanaInterface::message_valid(const Message *message) const
01387 {
01388 const StopMessage *m0 = dynamic_cast<const StopMessage *>(message);
01389 if ( m0 != NULL ) {
01390 return true;
01391 }
01392 const FlushMessage *m1 = dynamic_cast<const FlushMessage *>(message);
01393 if ( m1 != NULL ) {
01394 return true;
01395 }
01396 const ParkMessage *m2 = dynamic_cast<const ParkMessage *>(message);
01397 if ( m2 != NULL ) {
01398 return true;
01399 }
01400 const LinearGotoMessage *m3 = dynamic_cast<const LinearGotoMessage *>(message);
01401 if ( m3 != NULL ) {
01402 return true;
01403 }
01404 const CalibrateMessage *m4 = dynamic_cast<const CalibrateMessage *>(message);
01405 if ( m4 != NULL ) {
01406 return true;
01407 }
01408 const OpenGripperMessage *m5 = dynamic_cast<const OpenGripperMessage *>(message);
01409 if ( m5 != NULL ) {
01410 return true;
01411 }
01412 const CloseGripperMessage *m6 = dynamic_cast<const CloseGripperMessage *>(message);
01413 if ( m6 != NULL ) {
01414 return true;
01415 }
01416 const SetEnabledMessage *m7 = dynamic_cast<const SetEnabledMessage *>(message);
01417 if ( m7 != NULL ) {
01418 return true;
01419 }
01420 const SetMaxVelocityMessage *m8 = dynamic_cast<const SetMaxVelocityMessage *>(message);
01421 if ( m8 != NULL ) {
01422 return true;
01423 }
01424 return false;
01425 }
01426
01427
01428 EXPORT_INTERFACE(KatanaInterface)
01429
01430
01431
01432 }