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