autoCapture.cpp

Autoモードと Manualモードの違いを示すプログラム

実行結果例 (USB接続時)

% ./autoCapture
manual
1:(133 +133), 769
2:(252 +119), 769
3:(352 +100), 769
4:(451 +99), 769
5:(551 +100), 769
6:(650 +99), 769
7:(750 +100), 769
8:(850 +100), 769
9:(949 +99), 769
10:(1049 +100), 769

auto
1:(162 +162), 769
1:(181 +19), 769
1:(201 +20), 769
1:(221 +20), 769
1:(241 +20), 769
2:(261 +20), 769
2:(282 +21), 769
2:(301 +19), 769
2:(321 +20), 769
2:(342 +21), 769 

/*
  受信データのダブルバッファ化
  Satofumi KAMIMURA
  $Id$
*/

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


static void capture(int argc, char *argv[], bool autoCapture) {
  URGCtrl urg;
  if (urg.connect(argc, argv, autoCapture) < 0) {
    printf("URG::connect: %s\n", urg.what());
    exit(1);
  }
  unsigned long begin = VXV::GetTicks();
  unsigned long pre_ticks = 0;
  for (int i = 0; i < 10; ++i) {
    VXV::Delay(20);
    int n = urg.capture();
    int times = urg.getCaptureTimes();
    unsigned long ticks = VXV::GetTicks() - begin;
    unsigned long diff = ticks - pre_ticks;
    printf("%d:(%lu +%lu), %d\n", times, ticks, diff, n);
    pre_ticks = ticks;
  }
}


int main(int argc, char *argv[]) {
  try {
    printf("manual\n");
    capture(argc, argv, URG::ManualCapture);
    
    printf("\nauto\n");
    capture(argc, argv, URG::AutoCapture);
    
  } 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