All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
captureIntensitySample.cpp
1 
11 #include "UrgCtrl.h"
12 #include "delay.h"
13 #include <cstdlib>
14 
15 using namespace qrk;
16 using namespace std;
17 
18 
20 int main(int argc, char *argv[])
21 {
22  UrgCtrl urg;
23  if (! urg.connect("/dev/ttyACM0")) {
24  printf("UrgCtrl::connect: %s\n", urg.what());
25  exit(1);
26  }
27  int scan_msec = urg.scanMsec();
29 
30  enum {
31  CaptureTimes = 10,
32  };
33 
34  vector<long> data;
35  vector<long> intensity_data;
36 
37  for (int i = 0; i < CaptureTimes; ++i) {
38  long timestamp = 0;
39 
40  // Get data with intensity information
41  int data_n = urg.captureWithIntensity(data, intensity_data, &timestamp);
42 
43  if (data_n > 0) {
44  int front_index = urg.rad2index(0.0);
45 
46  // Display
47  // The distance data that are less than urg_minDistance() are shown as invalid value.
48  printf("%d: %ld [mm] (%ld), %ld [msec]\n",
49  i, data[front_index], intensity_data[front_index], timestamp);
50  }
51  delay(scan_msec);
52  }
53 
54  return 0;
55 }