source: flair-dev/trunk/include/FlairCore/ImuData.h@ 12

Last change on this file since 12 was 2, checked in by Sanahuja Guillaume, 9 years ago

initial commit flaircore

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