2
\example mdCaptureSample.cpp
4
\brief Sample to get data using MD command
6
\author Satofumi KAMIMURA
8
$Id: mdCaptureSample.cpp 1683 2010-02-10 10:28:05Z satofumi $
22
int main(int argc, char *argv[])
25
const char device[] = "COM3";
27
const char device[] = "/dev/ttyACM0";
31
if (! urg.connect(device)) {
32
printf("UrgCtrl::connect: %s\n", urg.what());
37
// Set to MD mode to acquire data
38
urg.setCaptureMode(AutoCapture);
41
// Mode to get distance data and intensity data
42
urg.setCaptureMode(IntensityCapture);
43
urg.setCaptureSkipLines(2);
45
int scan_msec = urg.scanMsec();
48
// Set range of acquisition from the center to left 90 degree.
49
// Set range of acquistion from center to right to 90 degree.
50
// So In total it will be 180 degree.
51
const double rad90 = 90.0 * M_PI / 180.0;
52
urg.setCaptureRange(urg.rad2index(-rad90), urg.rad2index(rad90));
55
int pre_timestamp = ticks();
57
// Data is acquired continuously using MD command
58
// but outputs data of specified number of times.
59
enum { CaptureTimes = 10};
60
urg.setCaptureTimes(CaptureTimes);
61
for (int i = 0; i < CaptureTimes;) {
66
int n = urg.capture(data, ×tamp);
73
printf("timestamp: %ld, (%d), %ld\n",
74
timestamp, ticks(), timestamp - pre_timestamp);
75
pre_timestamp = timestamp;
77
for (int j = 0; j < n; ++j) {
78
// The distance data that are less than urg_minDistance() are shown
80
printf("%d:%ld, ", j, data[j]);