-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Expand file tree
/
Copy pathSensorBase.hpp
More file actions
87 lines (73 loc) · 2.08 KB
/
Copy pathSensorBase.hpp
File metadata and controls
87 lines (73 loc) · 2.08 KB
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
81
82
83
84
85
86
87
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef msr_airlib_SensorBase_hpp
#define msr_airlib_SensorBase_hpp
#include "common/Common.hpp"
#include "common/UpdatableObject.hpp"
#include "common/CommonStructs.hpp"
#include "physics/Environment.hpp"
#include "physics/Kinematics.hpp"
namespace msr
{
namespace airlib
{
/*
Derived classes should not do any work in constructor which requires ground truth.
After construction of the derived class an initialize(...) must be made which would
set the sensor in good-to-use state by call to reset.
*/
class SensorBase : public UpdatableObject
{
public:
enum class SensorType : uint
{
Barometer = 1,
Imu = 2,
Gps = 3,
Magnetometer = 4,
Distance = 5,
Lidar = 6
};
SensorBase(const std::string& sensor_name = "")
: name_(sensor_name)
{
}
protected:
struct GroundTruth
{
const Kinematics::State* kinematics;
const Environment* environment;
};
public:
virtual void initialize(const Kinematics::State* kinematics, const Environment* environment)
{
ground_truth_.kinematics = kinematics;
ground_truth_.environment = environment;
}
virtual void update() override
{
is_new_ = false;
}
const bool& checkIfNew() const
{
return is_new_;
}
const GroundTruth& getGroundTruth() const
{
return ground_truth_;
}
const std::string& getName() const
{
return name_;
}
virtual ~SensorBase() = default;
private:
//ground truth can be shared between many sensors
GroundTruth ground_truth_ = { nullptr, nullptr };
std::string name_ = "";
protected:
bool is_new_ = false;
};
}
} //namespace
#endif