-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
74 lines (61 loc) · 1.71 KB
/
main.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
#include <iostream>
#include <sstream>
#include <vector>
#include "Dense"
#include "measurement_package.h"
#include "tracking.h"
using Eigen::MatrixXd;
using Eigen::VectorXd;
using std::cout;
using std::endl;
using std::ifstream;
using std::istringstream;
using std::string;
using std::vector;
int main() {
vector<MeasurementPackage> measurement_pack_list;
// hardcoded input file with laser and radar measurements
string in_file_name_ = "obj_pose-laser-radar-synthetic-input.txt";
ifstream in_file(in_file_name_.c_str(), ifstream::in);
if (!in_file.is_open()) {
cout << "Cannot open input file: " << in_file_name_ << endl;
}
string line;
// setting i to get only first 3 measurements
int i = 0;
while (getline(in_file, line) && (i<=3)) {
MeasurementPackage meas_package;
istringstream iss(line);
string sensor_type;
iss >> sensor_type;
int64_t timestamp;
if (sensor_type.compare("L") == 0) {
// reading measurements
meas_package.sensor_type_ = MeasurementPackage::LASER;
meas_package.raw_measurements_ = VectorXd(2);
float x;
float y;
iss >> x;
iss >> y;
meas_package.raw_measurements_ << x,y;
iss >> timestamp;
meas_package.timestamp_ = timestamp;
measurement_pack_list.push_back(meas_package);
} else if (sensor_type.compare("R") == 0) {
// Skipping Radar measurements
continue;
}
++i;
}
// Creating a Tracking instance
Tracking tracking;
size_t N = measurement_pack_list.size();
// (the speed is unknown in the first frame)
for (size_t k = 0; k < N; ++k) {
tracking.ProcessMeasurement(measurement_pack_list[k]);
}
if (in_file.is_open()) {
in_file.close();
}
return 0;
}