-
Notifications
You must be signed in to change notification settings - Fork 0
/
InclinometerModule.h
91 lines (79 loc) · 2.25 KB
/
InclinometerModule.h
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
88
89
90
91
/**
* @file InclinometerModule.h
* @author Ryan Johnson ([email protected])
* @brief A module that encapsulates the mathematical model and the sensor for
* an Inclinometer.
* @version 0.1
* @date 2020-05-26
*
* @copyright Copyright (c) 2020
*
*/
#ifndef INCLINOMETER_MODULE_H
#define INCLINOMETER_MODULE_H
#include "InclinometerInterface.h"
#include "InclinometerModel.h"
namespace Inclinometer {
/**
* @brief Holds a model and a data source
*/
class Module {
public:
/**
* @brief Construct a new Module object
*
* @param src the sensor data source
* @param yaw the starting yaw offset, default 0
*/
Module(InclinometerDataSource *src, double yaw = 0.0) : sensor(src)
{
model.setBaseFrameAnglesRadians(Vector3d(0, 0, yaw));
};
/**
* @brief Initializes the contained sensor/data source
*
* @return true if the sensor successfully initialized
* @return false if the sensor did not successfully initialize
*/
bool begin() { return sensor->begin(); };
/**
* @brief Checks if the sensor has data
*
* @return true if the sensor has data that can be read
* @return false if the sensor does not have data that can be read
*/
bool hasData() { return sensor->hasData(); };
/**
* @brief Get the calculated angle measures if data is available
*
* @return Eigen::Vector2d roll, pitch
*/
Eigen::Vector2d getData() { return model.calculate(sensor->getData()); };
/**
* @brief zero the sensor and return the zero frame from the current
* measurement
*
* @return ModelZeropoint
*/
ModelZeropoint zero()
{
return model.setMeasurementAsZero(sensor->getData());
};
/**
* @brief import a zero frame and zero the sensor to it
*
* @param zero the zero frame to zero the sensor to
*/
void importZero(ModelZeropoint zero) { return model.importZero(zero); };
/**
* @brief Get the model contained in the module
*
* @return Model
*/
Model &getModel() { return model; };
private:
InclinometerDataSource *sensor;
Model model;
};
}; // namespace Inclinometer
#endif