source: flair-src/trunk/lib/FlairCore/src/ImuData.h@ 397

Last change on this file since 397 was 252, checked in by Sanahuja Guillaume, 6 years ago

change io_data CopyDate to RawRead

File size: 4.5 KB
Line 
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 ImuData.h
7 * \brief Class defining IMU datas
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2014/01/15
10 * \version 4.0
11 */
12#ifndef IMUDATA_H
13#define IMUDATA_H
14
15#include <io_data.h>
16#include <IODataElement.h>
17#include <Vector3D.h>
18
19namespace flair {
20namespace core {
21
22/*! \class ImuData
23*
24* \brief Class defining IMU datas
25*
26* IMU (inertial measurement unit) datas consist of raw accelerometer values, raw
27*gyrometer values
28* and raw magnetometer values.
29*
30*/
31class ImuData : public io_data {
32public:
33 class Type : public DataType {
34 public:
35 Type(ScalarType const &_elementDataType)
36 : elementDataType(_elementDataType) {}
37 ScalarType const &GetElementDataType() const { return elementDataType; }
38 std::string GetDescription() const { return "imu data"; }
39 size_t GetSize() const {
40 size_t size = 0;
41 size += 3 * elementDataType.GetSize(); // RawAcc
42 size += 3 * elementDataType.GetSize(); // RawGyr
43 size += 3 * elementDataType.GetSize(); // RawMag
44 return size;
45 }
46
47 private:
48 ScalarType const &elementDataType;
49 };
50
51 /*!
52 \enum PlotableData_t
53 \brief Datas wich can be plotted in a DataPlot1D
54 */
55 typedef enum {
56 RawAx /*! x raw accelerometer */,
57 RawAy /*! y raw accelerometer */,
58 RawAz /*! z raw accelerometer */,
59 RawGx /*! x raw gyrometer */,
60 RawGy /*! y raw gyrometer */,
61 RawGz /*! z raw gyrometer */,
62 RawGxDeg /*! x raw gyrometer degree */,
63 RawGyDeg /*! y raw gyrometer degree */,
64 RawGzDeg /*! z raw gyrometer degree */,
65 RawMx /*! x raw magnetometer */,
66 RawMy /*! y raw magnetometer */,
67 RawMz /*! z raw magnetometer */
68 } PlotableData_t;
69
70 /*!
71 * \brief Constructor
72 *
73 * Construct an io_data representing IMU datas. \n
74 *
75 * \param parent parent
76 * \param name name
77 * \param n number of samples
78 */
79 ImuData(const Object *parent, std::string name = "", int n = 1);
80
81 /*!
82 * \brief Destructor
83 *
84 */
85 ~ImuData();
86
87 /*!
88 * \brief Element
89 *
90 * Get a pointer to a specific element. This pointer can be used for plotting.
91 *
92 * \param data_type data type
93 *
94 * \return pointer to the element
95 */
96 IODataElement *Element(PlotableData_t data_type) const;
97
98 /*!
99 * \brief Get raw accelerations
100 *
101 * This method is mutex protected.
102 *
103 * \return raw accelerations
104 *
105 */
106 Vector3Df GetRawAcc(void) const;
107
108 /*!
109 * \brief Get raw magnetometers
110 *
111 * This method is mutex protected.
112 *
113 * \return raw magnetometers
114 *
115 */
116 Vector3Df GetRawMag(void) const;
117
118 /*!
119 * \brief Get raw angular speed
120 *
121 * This method is mutex protected.
122 *
123 * \return raw angular speed
124 *
125 */
126 Vector3Df GetRawGyr(void) const;
127
128 /*!
129 * \brief Get raw accelerations, magnetometers and angular speeds
130 *
131 * This method is mutex protected.
132 *
133 * \param rawAcc raw accelerations
134 * \param rawMag raw magnetometers
135 * \param rawGyr raw angular speeds
136 *
137 */
138 void GetRawAccMagAndGyr(Vector3Df &rawAcc, Vector3Df &rawMag,
139 Vector3Df &rawGyr) const;
140
141 /*!
142 * \brief Set raw accelerations
143 *
144 * This method is mutex protected.
145 *
146 * \param raw accelerations
147 *
148 */
149 void SetRawAcc(const Vector3Df &rawAcc);
150
151 /*!
152 * \brief Set raw magnetometers
153 *
154 * This method is mutex protected.
155 *
156 * \param raw magnetometers
157 *
158 */
159 void SetRawMag(const Vector3Df &rawMag);
160
161 /*!
162 * \brief Set raw angular speed
163 *
164 * This method is mutex protected.
165 *
166 * \param raw angular speed
167 *
168 */
169 void SetRawGyr(const Vector3Df &rawGyr);
170
171 /*!
172 * \brief Set raw accelerations, magnetometers and angular speeds
173 *
174 * This method is mutex protected.
175 *
176 * \param rawAcc raw accelerations
177 * \param rawMag raw magnetometers
178 * \param rawGyr raw angular speeds
179 *
180 */
181 void SetRawAccMagAndGyr(const Vector3Df &rawAcc, const Vector3Df &rawMag,
182 const Vector3Df &rawGyr);
183
184 Type const &GetDataType() const { return dataType; }
185
186private:
187 /*!
188 * \brief Raw read datas
189 *
190 * Reimplemented from io_data. \n
191 * See io_data::RawRead.
192 *
193 * \param dst destination buffer
194 */
195 void RawRead(char *dst) const;
196
197 /*!
198 * \brief Raw accelerometer
199 *
200 */
201 Vector3Df rawAcc;
202
203 /*!
204 * \brief Raw gyrometer
205 *
206 */
207 Vector3Df rawGyr;
208
209 /*!
210 * \brief Raw magnetometer
211 *
212 */
213 Vector3Df rawMag;
214
215 void Queue(char **dst, const void *src, size_t size) const;
216 Type dataType;
217};
218
219} // end namespace core
220} // end namespace flair
221
222#endif // IMUDATA_H
Note: See TracBrowser for help on using the repository browser.