Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Pages
libs
range_sensor
simple_samples
gdCaptureSample.cpp
1
11
#include "
UrgCtrl.h
"
12
#include <cstdlib>
13
14
using namespace
qrk;
15
using namespace
std;
16
17
19
int
main(
int
argc,
char
*argv[])
20
{
21
//const char device[] = "COM3";
22
const
char
device[] =
"/dev/ttyACM0"
;
23
24
UrgCtrl
urg;
25
if
(! urg.
connect
(device)) {
26
printf(
"UrgCtrl::connect: %s\n"
, urg.
what
());
27
exit(1);
28
}
29
30
// Scans for the number of times specified as in GD command and outputs the data.
31
enum
{ CaptureTimes = 1 };
32
for
(
int
i = 0; i < CaptureTimes; ++i) {
33
long
timestamp = 0;
34
vector<long> data;
35
36
// Get the data
37
int
n = urg.
capture
(data, ×tamp);
38
39
// Output
40
printf(
"timestamp: %ld\n"
, timestamp);
41
for
(
int
j = 0; j < n; ++j) {
42
// The distance data that are less than urg_minDistance() are shown as invalide values
43
printf(
"%d:%ld, "
, j, data[j]);
44
}
45
printf(
"\n"
);
46
}
47
return
0;
48
}
Generated on Tue Oct 30 2012 14:20:25 by
1.8.2-20120930