[2] | 1 | // %flair:license{
|
---|
[13] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 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 |
|
---|
[13] | 19 | namespace flair {
|
---|
| 20 | namespace core {
|
---|
[2] | 21 |
|
---|
[13] | 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 | */
|
---|
| 31 | class ImuData : public io_data {
|
---|
| 32 | public:
|
---|
| 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 | }
|
---|
[2] | 46 |
|
---|
[13] | 47 | private:
|
---|
| 48 | ScalarType const &elementDataType;
|
---|
| 49 | };
|
---|
[2] | 50 |
|
---|
[13] | 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;
|
---|
[2] | 69 |
|
---|
[13] | 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);
|
---|
[2] | 80 |
|
---|
[13] | 81 | /*!
|
---|
| 82 | * \brief Destructor
|
---|
| 83 | *
|
---|
| 84 | */
|
---|
| 85 | ~ImuData();
|
---|
[2] | 86 |
|
---|
[13] | 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;
|
---|
[2] | 97 |
|
---|
[13] | 98 | /*!
|
---|
| 99 | * \brief Get raw accelerations
|
---|
| 100 | *
|
---|
| 101 | * This method is mutex protected.
|
---|
| 102 | *
|
---|
| 103 | * \return raw accelerations
|
---|
| 104 | *
|
---|
| 105 | */
|
---|
[50] | 106 | Vector3Df GetRawAcc(void) const;
|
---|
[2] | 107 |
|
---|
[13] | 108 | /*!
|
---|
| 109 | * \brief Get raw magnetometers
|
---|
| 110 | *
|
---|
| 111 | * This method is mutex protected.
|
---|
| 112 | *
|
---|
| 113 | * \return raw magnetometers
|
---|
| 114 | *
|
---|
| 115 | */
|
---|
[50] | 116 | Vector3Df GetRawMag(void) const;
|
---|
[2] | 117 |
|
---|
[13] | 118 | /*!
|
---|
| 119 | * \brief Get raw angular speed
|
---|
| 120 | *
|
---|
| 121 | * This method is mutex protected.
|
---|
| 122 | *
|
---|
| 123 | * \return raw angular speed
|
---|
| 124 | *
|
---|
| 125 | */
|
---|
[50] | 126 | Vector3Df GetRawGyr(void) const;
|
---|
[2] | 127 |
|
---|
[13] | 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 | */
|
---|
[50] | 138 | void GetRawAccMagAndGyr(Vector3Df &rawAcc, Vector3Df &rawMag,
|
---|
| 139 | Vector3Df &rawGyr) const;
|
---|
[2] | 140 |
|
---|
[13] | 141 | /*!
|
---|
| 142 | * \brief Set raw accelerations
|
---|
| 143 | *
|
---|
| 144 | * This method is mutex protected.
|
---|
| 145 | *
|
---|
| 146 | * \param raw accelerations
|
---|
| 147 | *
|
---|
| 148 | */
|
---|
[50] | 149 | void SetRawAcc(const Vector3Df &rawAcc);
|
---|
[2] | 150 |
|
---|
[13] | 151 | /*!
|
---|
| 152 | * \brief Set raw magnetometers
|
---|
| 153 | *
|
---|
| 154 | * This method is mutex protected.
|
---|
| 155 | *
|
---|
| 156 | * \param raw magnetometers
|
---|
| 157 | *
|
---|
| 158 | */
|
---|
[50] | 159 | void SetRawMag(const Vector3Df &rawMag);
|
---|
[2] | 160 |
|
---|
[13] | 161 | /*!
|
---|
| 162 | * \brief Set raw angular speed
|
---|
| 163 | *
|
---|
| 164 | * This method is mutex protected.
|
---|
| 165 | *
|
---|
| 166 | * \param raw angular speed
|
---|
| 167 | *
|
---|
| 168 | */
|
---|
[50] | 169 | void SetRawGyr(const Vector3Df &rawGyr);
|
---|
[2] | 170 |
|
---|
[13] | 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 | */
|
---|
[50] | 181 | void SetRawAccMagAndGyr(const Vector3Df &rawAcc, const Vector3Df &rawMag,
|
---|
| 182 | const Vector3Df &rawGyr);
|
---|
[2] | 183 |
|
---|
[13] | 184 | Type const &GetDataType() const { return dataType; }
|
---|
[2] | 185 |
|
---|
[13] | 186 | private:
|
---|
| 187 | /*!
|
---|
| 188 | * \brief Copy datas
|
---|
| 189 | *
|
---|
| 190 | * Reimplemented from io_data. \n
|
---|
| 191 | * See io_data::CopyDatas.
|
---|
| 192 | *
|
---|
| 193 | * \param dst destination buffer
|
---|
| 194 | */
|
---|
| 195 | void CopyDatas(char *dst) const;
|
---|
[2] | 196 |
|
---|
[13] | 197 | /*!
|
---|
| 198 | * \brief Raw accelerometer
|
---|
| 199 | *
|
---|
| 200 | */
|
---|
[50] | 201 | Vector3Df rawAcc;
|
---|
[2] | 202 |
|
---|
[13] | 203 | /*!
|
---|
| 204 | * \brief Raw gyrometer
|
---|
| 205 | *
|
---|
| 206 | */
|
---|
[50] | 207 | Vector3Df rawGyr;
|
---|
[2] | 208 |
|
---|
[13] | 209 | /*!
|
---|
| 210 | * \brief Raw magnetometer
|
---|
| 211 | *
|
---|
| 212 | */
|
---|
[50] | 213 | Vector3Df rawMag;
|
---|
[2] | 214 |
|
---|
[13] | 215 | void Queue(char **dst, const void *src, size_t size) const;
|
---|
| 216 | Type dataType;
|
---|
| 217 | };
|
---|
| 218 |
|
---|
[2] | 219 | } // end namespace core
|
---|
| 220 | } // end namespace flair
|
---|
| 221 |
|
---|
| 222 | #endif // IMUDATA_H
|
---|