oneScan.cpp

センサデータの取得を行うプログラム

実行結果例

% ./oneScan
0: 19, 1: 19, 2: 19, 3: 19, 4: 19, 5: 19, 6: 19, 7: 19, 8: 19, 
9: 19, 10: 19, 11: 19, 12: 19, 13: 19, 14: 19, 15: 19, 16: 19, 
17: 19, 18: 19, 19: 19, 20: 19, 21: 19, 22: 19, 23: 19, 24: 19, 
25: 19, 26: 19, 27: 19, 28: 19, 29: 19, 30: 19, 31: 19, 32: 19, 
33: 19, 34: 19, 35: 19, 36: 19, 37: 19, 38: 19, 39: 19, 40: 19, 
41: 19, 42: 19, 43: 19, 44: 19, 45: 291, 46: 290, 47: 290, 48: 290, 
49: 288, 50: 288, 51: 290, 52: 290, 53: 290, 54: 290, 55: 291, 56: 291, 
57: 292, 58: 292, 59: 292, 60: 297, 61: 294, 62: 294, 63: 299, 64: 301, 
65: 302, 66: 302, 67: 302, 68: 302, 69: 303, 70: 305, 71: 306, 72: 308, 
73: 309, 74: 310, 75: 310, 76: 310, 77: 310, 78: 311, 79: 312, 80: 312, 
81: 315, 82: 315, 83: 317, 84: 318, 85: 320, 86: 319, 87: 319, 88: 320, 
89: 320, 90: 323, 91: 323, 92: 326, 93: 325, 94: 325, 95: 326, 96: 325, 
97: 325, 98: 330, 99: 330, 100: 331, 101: 332, 102: 332, 103: 335, 104: 336, 
105: 335, 106: 336, 107: 336, 108: 336, 109: 337, 110: 339, 111: 339, 112: 340, 
113: 342, 114: 342, 115: 341, 116: 341, 117: 341, 118: 341, 119: 342, 120: 343, 
121: 349, 122: 349, 123: 349, 124: 350, 125: 351, 126: 352, 127: 352, 128: 352, 
129: 353, 130: 353, 131: 354, 132: 356, 133: 354, 134: 353, 135: 356, 136: 356, 
137: 357, 138: 357, 139: 358, 140: 357, 141: 357, 142: 355, 143: 357, 144: 356, 
145: 357, 146: 357, 147: 357, 148: 357, 149: 360, 150: 360, 151: 362, 152: 360, 
153: 362, 154: 362, 155: 362, 156: 362, 157: 362, 158: 366, 159: 366, 160: 361, 
161: 361, 162: 361, 163: 361, 164: 361, 165: 367, 166: 368, 167: 370, 168: 371, 
169: 371, 170: 372, 171: 376, 172: 378, 173: 377, 174: 377, 175: 378, 176: 381, 
177: 382, 178: 384, 179: 385, 180: 385, 181: 386, 182: 388, 183: 390, 184: 391, 
185: 391, 186: 393, 187: 393, 188: 394, 189: 396, 190: 399, 191: 406, 192: 409, 
193: 409, 194: 409, 195: 409, 196: 410, 197: 411, 198: 412, 199: 414, 200: 415, 
201: 417, 202: 419, 203: 419, 204: 419, 205: 418, 206: 418, 207: 417, 208: 417, 
209: 418, 210: 418, 211: 417, 212: 412, 213: 411, 214: 409, 215: 409, 216: 409, 
217: 414, 218: 440, 219: 440, 220: 442, 221: 442, 222: 438, 223: 438, 224: 442, 
225: 442, 226: 452, 227: 452, 228: 461, 229: 478, 230: 487, 231: 489, 232: 493, 
233: 507, 234: 517, 235: 522, 236: 532, 237: 543, 238: 559, 239: 566, 240: 573, 
241: 593, 242: 607, 243: 617, 244: 629, 245: 645, 246: 672, 247: 684, 248: 692, 
249: 694, 250: 694, 251: 697, 252: 697, 253: 694, 254: 692, 255: 696, 256: 696, 
257: 690, 258: 689, 259: 689, 260: 689, 261: 689, 262: 689, 263: 690, 264: 690, 
265: 689, 266: 689, 267: 689, 268: 688, 269: 687, 270: 686, 271: 686, 272: 686, 
273: 684, 274: 687, 275: 687, 276: 687, 277: 687, 278: 687, 279: 687, 280: 687, 
281: 687, 282: 684, 283: 682, 284: 682, 285: 682, 286: 684, 287: 687, 288: 687, 
289: 687, 290: 687, 291: 688, 292: 690, 293: 688, 294: 688, 295: 688, 296: 688, 
297: 686, 298: 686, 299: 686, 300: 688, 301: 686, 302: 686, 303: 686, 304: 686, 
305: 686, 306: 688, 307: 690, 308: 692, 309: 690, 310: 690, 311: 692, 312: 692, 
313: 692, 314: 693, 315: 693, 316: 696, 317: 693, 318: 692, 319: 692, 320: 696, 
321: 692, 322: 693, 323: 698, 324: 698, 325: 697, 326: 698, 327: 698, 328: 701, 
329: 701, 330: 707, 331: 707, 332: 708, 333: 708, 334: 709, 335: 710, 336: 711, 
337: 711, 338: 713, 339: 715, 340: 719, 341: 715, 342: 715, 343: 715, 344: 703, 
345: 689, 346: 680, 347: 659, 348: 647, 349: 640, 350: 634, 351: 619, 352: 609, 
353: 588, 354: 588, 355: 573, 356: 564, 357: 561, 358: 555, 359: 536, 360: 532, 
361: 521, 362: 519, 363: 511, 364: 505, 365: 498, 366: 490, 367: 487, 368: 482, 
369: 477, 370: 477, 371: 477, 372: 481, 373: 481, 374: 779, 375: 782, 376: 794, 
377: 791, 378: 792, 379: 794, 380: 797, 381: 800, 382: 800, 383: 807, 384: 811, 
385: 817, 386: 818, 387: 820, 388: 826, 389: 826, 390: 830, 391: 831, 392: 836, 
393: 846, 394: 846, 395: 847, 396: 848, 397: 857, 398: 861, 399: 862, 400: 863, 
401: 870, 402: 875, 403: 879, 404: 881, 405: 883, 406: 890, 407: 892, 408: 896, 
409: 907, 410: 911, 411: 913, 412: 914, 413: 925, 414: 925, 415: 925, 416: 914, 
417: 905, 418: 892, 419: 887, 420: 882, 421: 879, 422: 879, 423: 870, 424: 868, 
425: 867, 426: 866, 427: 850, 428: 846, 429: 844, 430: 840, 431: 837, 432: 832, 
433: 830, 434: 827, 435: 819, 436: 811, 437: 808, 438: 808, 439: 796, 440: 796, 
441: 786, 442: 785, 443: 780, 444: 776, 445: 776, 446: 776, 447: 772, 448: 767, 
449: 759, 450: 755, 451: 753, 452: 755, 453: 755, 454: 761, 455: 801, 456: 801, 
457: 801, 458: 789, 459: 768, 460: 729, 461: 715, 462: 712, 463: 704, 464: 697, 
465: 694, 466: 683, 467: 678, 468: 664, 469: 654, 470: 647, 471: 629, 472: 622, 
473: 616, 474: 613, 475: 603, 476: 596, 477: 584, 478: 583, 479: 573, 480: 568, 
481: 560, 482: 555, 483: 549, 484: 546, 485: 534, 486: 532, 487: 523, 488: 521, 
489: 516, 490: 515, 491: 509, 492: 503, 493: 495, 494: 494, 495: 486, 496: 484, 
497: 481, 498: 481, 499: 481, 500: 479, 501: 479, 502: 471, 503: 464, 504: 459, 
505: 459, 506: 456, 507: 456, 508: 455, 509: 456, 510: 456, 511: 458, 512: 471, 
513: 471, 514: 471, 515: 471, 516: 472, 517: 472, 518: 480, 519: 483, 520: 496, 
521: 502, 522: 515, 523: 529, 524: 536, 525: 553, 526: 578, 527: 578, 528: 631, 
529: 631, 530: 633, 531: 633, 532: 642, 533: 642, 534: 642, 535: 638, 536: 634, 
537: 629, 538: 628, 539: 620, 540: 620, 541: 617, 542: 617, 543: 606, 544: 597, 
545: 591, 546: 589, 547: 585, 548: 585, 549: 584, 550: 575, 551: 473, 552: 459, 
553: 452, 554: 450, 555: 440, 556: 439, 557: 436, 558: 432, 559: 429, 560: 427, 
561: 427, 562: 425, 563: 421, 564: 417, 565: 414, 566: 414, 567: 412, 568: 412, 
569: 409, 570: 407, 571: 407, 572: 407, 573: 405, 574: 403, 575: 399, 576: 397, 
577: 396, 578: 396, 579: 392, 580: 392, 581: 392, 582: 392, 583: 392, 584: 390, 
585: 387, 586: 385, 587: 383, 588: 379, 589: 377, 590: 376, 591: 375, 592: 376, 
593: 375, 594: 375, 595: 373, 596: 375, 597: 372, 598: 370, 599: 369, 600: 368, 
601: 365, 602: 363, 603: 363, 604: 363, 605: 363, 606: 363, 607: 363, 608: 363, 
609: 362, 610: 360, 611: 358, 612: 358, 613: 358, 614: 358, 615: 356, 616: 354, 
617: 353, 618: 353, 619: 353, 620: 353, 621: 353, 622: 351, 623: 351, 624: 351, 
625: 348, 626: 348, 627: 348, 628: 350, 629: 348, 630: 350, 631: 350, 632: 350, 
633: 348, 634: 350, 635: 348, 636: 348, 637: 347, 638: 347, 639: 346, 640: 346, 
641: 344, 642: 344, 643: 345, 644: 345, 645: 345, 646: 345, 647: 345, 648: 344, 
649: 343, 650: 340, 651: 340, 652: 335, 653: 333, 654: 331, 655: 333, 656: 333, 
657: 333, 658: 333, 659: 333, 660: 333, 661: 332, 662: 331, 663: 329, 664: 331, 
665: 329, 666: 326, 667: 326, 668: 326, 669: 326, 670: 325, 671: 325, 672: 320, 
673: 319, 674: 319, 675: 320, 676: 323, 677: 324, 678: 324, 679: 325, 680: 325, 
681: 325, 682: 325, 683: 326, 684: 333, 685: 333, 686: 333, 687: 334, 688: 335, 
689: 338, 690: 338, 691: 338, 692: 338, 693: 338, 694: 340, 695: 340, 696: 343, 
697: 340, 698: 341, 699: 341, 700: 344, 701: 342, 702: 344, 703: 348, 704: 350, 
705: 348, 706: 348, 707: 346, 708: 345, 709: 345, 710: 345, 711: 346, 712: 347, 
713: 352, 714: 352, 715: 353, 716: 355, 717: 357, 718: 358, 719: 361, 720: 365, 
721: 365, 722: 365, 723: 365, 724: 361, 725: 361, 726: 19, 727: 19, 728: 19, 
729: 19, 730: 19, 731: 19, 732: 19, 733: 19, 734: 19, 735: 19, 736: 19, 
737: 19, 738: 19, 739: 19, 740: 19, 741: 19, 742: 19, 743: 19, 744: 19, 
745: 19, 746: 19, 747: 19, 748: 19, 749: 19, 750: 19, 751: 19, 752: 19, 
753: 19, 754: 19, 755: 19, 756: 19, 757: 19, 758: 19, 759: 19, 760: 19, 
761: 19, 762: 19, 763: 19, 764: 19, 765: 19, 766: 19, 767: 19, 768: 19, 

n = 769 

/*
  センサデータの取得
  Satofumi KAMIMURA
  $Id$
*/

#include <urgCtrl.h>
#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[]) {
  try {
    // センサへの接続
    URGCtrl urg;
    if (urg.connect(argc, argv) < 0) {
      printf("URG::connect: %s\n", urg.what());
      exit(1);
    }

    // センサデータの取得
    int n = urg.capture();

    // 取得データの表示
    for (int i = 0; i < n; ++i) {
      printf("%d: %ld, ", i, urg.length[i]);
      if ((i > 0) && (i % 8 == 0)) {
        printf("\n");
      }
    }
    printf("\nn = %d\n", n);

  } catch (std::exception& e) {
    printf("exception: %s\n", e.what());
  }
  return 0;
}


Generated on Mon Apr 13 22:52:01 2009 by  doxygen 1.5.7.1