1 | // %flair:license{
|
---|
2 | // This file is part of the Flair framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %flair:license}
|
---|
5 | /*!
|
---|
6 | * \file Imu.h
|
---|
7 | * \brief Base class for Imu
|
---|
8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
9 | * \date 2014/01/16
|
---|
10 | * \version 4.0
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef IMU_H
|
---|
14 | #define IMU_H
|
---|
15 |
|
---|
16 | #include <IODevice.h>
|
---|
17 | #include <Vector3D.h>
|
---|
18 |
|
---|
19 | namespace flair {
|
---|
20 | namespace core {
|
---|
21 | class ImuData;
|
---|
22 | class OneAxisRotation;
|
---|
23 | }
|
---|
24 | namespace gui {
|
---|
25 | class Tab;
|
---|
26 | class TabWidget;
|
---|
27 | class GroupBox;
|
---|
28 | class Layout;
|
---|
29 | class DataPlot1D;
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | class Ahrs_impl;
|
---|
34 |
|
---|
35 | namespace flair {
|
---|
36 | namespace sensor {
|
---|
37 | /*! \class Imu
|
---|
38 | *
|
---|
39 | * \brief Base class for Imu
|
---|
40 | *
|
---|
41 | * Use this class to define a custom Imu.
|
---|
42 | *
|
---|
43 | */
|
---|
44 | class Imu : public core::IODevice {
|
---|
45 | friend class ::Ahrs_impl;
|
---|
46 |
|
---|
47 | public:
|
---|
48 | /*!
|
---|
49 | * \brief Constructor
|
---|
50 | *
|
---|
51 | * Construct an Imu.
|
---|
52 | * It will be child of the FrameworkManager.
|
---|
53 | *
|
---|
54 | * \param name name
|
---|
55 | * \param needRotation true will enable post rotation in GCS. Post rotation must be applied manually in reimplemented code
|
---|
56 | */
|
---|
57 | Imu(std::string name,bool needRotation=true);
|
---|
58 |
|
---|
59 | /*!
|
---|
60 | * \brief Destructor
|
---|
61 | *
|
---|
62 | */
|
---|
63 | ~Imu();
|
---|
64 |
|
---|
65 | /*!
|
---|
66 | * \brief Get IMU datas
|
---|
67 | *
|
---|
68 | * \return ImuData
|
---|
69 | */
|
---|
70 | const core::ImuData *GetDatas(void) const;
|
---|
71 |
|
---|
72 |
|
---|
73 | /*!
|
---|
74 | * \brief Setup Layout
|
---|
75 | *
|
---|
76 | * \return setup Layout
|
---|
77 | */
|
---|
78 | gui::Layout *GetLayout(void) const;
|
---|
79 |
|
---|
80 | /*!
|
---|
81 | * \brief Lock user interface
|
---|
82 | *
|
---|
83 | */
|
---|
84 | void LockUserInterface(void) const;
|
---|
85 |
|
---|
86 | /*!
|
---|
87 | * \brief Unlock user interface
|
---|
88 | *
|
---|
89 | */
|
---|
90 | void UnlockUserInterface(void) const;
|
---|
91 |
|
---|
92 | /*!
|
---|
93 | * \brief Use default plot
|
---|
94 | *
|
---|
95 | */
|
---|
96 | void UseDefaultPlot(void);
|
---|
97 |
|
---|
98 | /*!
|
---|
99 | * \brief Plot tab
|
---|
100 | *
|
---|
101 | * \return plot Tab
|
---|
102 | */
|
---|
103 | gui::Tab *GetPlotTab(void) const;
|
---|
104 |
|
---|
105 | /*!
|
---|
106 | * \brief Get OneAxisRotation
|
---|
107 | *
|
---|
108 | * \return fixed rotation of the imu
|
---|
109 | */
|
---|
110 | core::OneAxisRotation *GetOneAxisRotation(void) const;
|
---|
111 |
|
---|
112 |
|
---|
113 | protected:
|
---|
114 | /*!
|
---|
115 | * \brief Setup GroupBox
|
---|
116 | *
|
---|
117 | * \return setup GroupBox
|
---|
118 | */
|
---|
119 | gui::GroupBox *GetGroupBox(void) const;
|
---|
120 |
|
---|
121 | /*!
|
---|
122 | * \brief ApplyRotation
|
---|
123 | *
|
---|
124 | * The reimplemented class must call this function to rotate IMU datas, before filling the ImuData. \n
|
---|
125 | * It handles the data rotation if it was defined.
|
---|
126 | *
|
---|
127 | * \param vector vector to apply rotation to
|
---|
128 | */
|
---|
129 | void ApplyRotation(core::Vector3Df& vector);
|
---|
130 |
|
---|
131 | /*!
|
---|
132 | * \brief ApplyRotation
|
---|
133 | *
|
---|
134 | * The reimplemented class must call this function to rotate IMU datas, before filling the ImuData. \n
|
---|
135 | * It handles the data rotation if it was defined.
|
---|
136 | *
|
---|
137 | * \param quaternion quaternion to apply rotation to
|
---|
138 | */
|
---|
139 | void ApplyRotation(core::Quaternion& quaternion);
|
---|
140 |
|
---|
141 | /*!
|
---|
142 | * \brief Get imu datas
|
---|
143 | *
|
---|
144 | * Can be used by dervied class to fill core::ImuData
|
---|
145 | *
|
---|
146 | * \param imuData imu datas
|
---|
147 | */
|
---|
148 | void GetDatas(core::ImuData **imuData) const;
|
---|
149 |
|
---|
150 | /*!
|
---|
151 | * \brief Remove Offsets
|
---|
152 | *
|
---|
153 | * Remove the accelerometers and gyrometers offsets. During first 10s, returns 0 (gathering data to get offset)
|
---|
154 | * Then, returns the vectors without offset
|
---|
155 | *
|
---|
156 | * \param acc accelerometer vector to remove offset
|
---|
157 | * \param gyr gyrometer vector to remove offset
|
---|
158 | */
|
---|
159 | void RemoveOffsets(core::Vector3Df& acc,core::Vector3Df& gyr);
|
---|
160 |
|
---|
161 | private:
|
---|
162 | gui::Tab *mainTab, *sensorTab, *plotTab;
|
---|
163 | gui::TabWidget *tab;
|
---|
164 | gui::GroupBox *setupGroupbox;
|
---|
165 | core::OneAxisRotation *rotation;
|
---|
166 | core::ImuData *imuData;
|
---|
167 |
|
---|
168 | gui::DataPlot1D *axPlot, *ayPlot, *azPlot;
|
---|
169 | gui::DataPlot1D *gxPlot, *gyPlot, *gzPlot;
|
---|
170 | gui::DataPlot1D *mxPlot, *myPlot, *mzPlot;
|
---|
171 |
|
---|
172 | //for calibration:
|
---|
173 | core::Time startCalcOffset;
|
---|
174 | bool calibrationDone;
|
---|
175 | core::Vector3Df accOffset,gyrOffset,accMax,accMin;
|
---|
176 | uint16_t cptOffset;
|
---|
177 |
|
---|
178 | };
|
---|
179 | } // end namespace sensor
|
---|
180 | } // end namespace flair
|
---|
181 |
|
---|
182 | #endif // IMU_H
|
---|