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