This repository was archived by the owner on Jul 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathdatapoint.cpp
67 lines (46 loc) · 1.39 KB
/
datapoint.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
#include "datapoint.h"
using namespace std;
DataPoint::DataPoint(){
this->initialized = false;
}
DataPoint::DataPoint(const long long timestamp, const DataPointType data_type, const VectorXd raw){
this->set(timestamp, data_type, raw);
}
void DataPoint::set(const long timestamp, const DataPointType data_type, const VectorXd raw){
this->timestamp = timestamp;
this->data_type = data_type;
this->raw = raw;
this->initialized = true;
}
VectorXd DataPoint::get() const{
return this->raw;
}
VectorXd DataPoint::get_state() const{
VectorXd state(4);
if (this->data_type == DataPointType::LIDAR){
double x = this->raw(0);
double y = this->raw(1);
state << x, y, 0.0, 0.0;
} else if (this->data_type == DataPointType::RADAR){
state = convert_polar_to_cartesian(this->raw);
} else if (this->data_type == DataPointType::STATE){
state = this->raw;
}
return state;
}
long long DataPoint::get_timestamp() const{
return this->timestamp;
}
DataPointType DataPoint::get_type() const{
return this->data_type;
}
void DataPoint::print() const{
if (this->initialized){
cout << "Timestamp: " << this->timestamp << endl;
cout << "Sensor ID: " << static_cast<int>(this->data_type) << " (LIDAR = 0 | RADAR = 1 | STATE = 2)" << endl;
cout << "Raw Data: " << endl;
cout << this->raw << endl;
} else {
cout << "DataPoint is not initialized." << endl;
}
}