autoCapture.cpp

00001 /*
00002   受信データのダブルバッファ化
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #include <urgCtrl.h>
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 
00011 
00012 static void capture(int argc, char *argv[], bool autoCapture) {
00013   URGCtrl urg;
00014   if (urg.connect(argc, argv, autoCapture) < 0) {
00015     printf("URG::connect: %s\n", urg.what());
00016     exit(1);
00017   }
00018   unsigned long begin = VXV::GetTicks();
00019   unsigned long pre_ticks = 0;
00020   for (int i = 0; i < 10; ++i) {
00021     VXV::Delay(20);
00022     int n = urg.capture();
00023     int times = urg.getCaptureTimes();
00024     unsigned long ticks = VXV::GetTicks() - begin;
00025     unsigned long diff = ticks - pre_ticks;
00026     printf("%d:(%lu +%lu), %d\n", times, ticks, diff, n);
00027     pre_ticks = ticks;
00028   }
00029 }
00030 
00031 
00032 int main(int argc, char *argv[]) {
00033   try {
00034     printf("manual\n");
00035     capture(argc, argv, URG::ManualCapture);
00036     
00037     printf("\nauto\n");
00038     capture(argc, argv, URG::AutoCapture);
00039     
00040   } catch (std::exception& e) {
00041     printf("exception: %s\n", e.what());
00042   }
00043   return 0;
00044 }
00045 

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