-
Notifications
You must be signed in to change notification settings - Fork 0
/
LRF_test.cpp
80 lines (56 loc) · 2.24 KB
/
LRF_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// General / System includes
#include <stdio.h>
#include <iostream>
// LRF
#include "LRF.h"
using namespace std;
int main(int argc, char *argv[]){
const char *dev = "/dev/ttyUSB1";
LRF disto = LRF(dev);
/* disto.enablePointer(0); // enable pointer
cout << "Testing Sequential switching" << endl;
cout << " " << disto.disablePointer(0) << endl;
cout << " " << disto.enablePointer(0) << endl;
cout << " " << disto.enablePointer(1) << endl;
cout << " " << disto.enablePointer(1) << endl;
cout << " " << disto.enablePointer(0) << endl;
cout << " " << disto.enablePointer(0) << endl;
cout << " " << disto.disablePointer(0) << endl;
cout << " " << disto.disablePointer(1) << endl;
cout << " " << disto.disablePointer(1) << endl;
cout << " " << disto.disablePointer(0) << endl;
cout << " " << disto.enablePointer(0) << endl;
cout << " " << disto.disablePointer(1) << endl;
cout << " " << disto.enablePointer(1) << endl;
cout << " " << disto.disablePointer(1) << endl;
cout << " " << disto.enablePointer(0) << endl;
cout << " " << disto.disablePointer(0) << endl;
cout << " " << disto.enablePointer(1) << endl;
cout << " " << disto.disablePointer(1) << endl;
cout << " " << disto.enablePointer(0) << endl;
cout << " " << disto.disablePointer(0) << endl;
cout << " " << disto.enablePointer(0) << endl;
double measurement;
cout << "\nTesting Single Measurements\n";
measurement = disto.getMeasurement();
cout << "\nDistance: " << measurement << endl;
measurement = disto.getMeasurement();
cout << "\nDistance: " << measurement << endl;
measurement = disto.getMeasurement();
cout << "\nDistance: " << measurement << endl;
measurement = disto.getMeasurement();
cout << "\nDistance: " << measurement << endl;
measurement = disto.getMeasurement();
cout << "\nDistance: " << measurement << endl;
*/
double avg = 0.0;
double var = 0.0;
int max_rounds = 13;
cout << "Single Measurement: ";
cout << disto.getMeasurement() << endl;
cout << "\nTesting " << max_rounds << " continous measurements\n";
cout << disto.getMeasurements(&avg, &var, &max_rounds) << endl;
cout << "Rounds: " << max_rounds << " Average: " << avg << " Variance: " << var << endl;
cout << "Laser pointer State: " << disto.isON() << endl;
return 0;
}