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