[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 AhrsData.h |
---|
| 7 | * \brief Class defining AHRS datas |
---|
| 8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253 |
---|
| 9 | * \date 2016/03/01 |
---|
| 10 | * \version 4.0 |
---|
| 11 | */ |
---|
| 12 | #ifndef AHRSDATA_H |
---|
| 13 | #define AHRSDATA_H |
---|
| 14 | |
---|
| 15 | #include <io_data.h> |
---|
| 16 | #include <IODataElement.h> |
---|
| 17 | #include <Vector3D.h> |
---|
| 18 | #include <Quaternion.h> |
---|
| 19 | |
---|
[13] | 20 | namespace flair { |
---|
| 21 | namespace core { |
---|
[2] | 22 | |
---|
[13] | 23 | /*! \class AhrsData |
---|
| 24 | * |
---|
| 25 | * \brief Class defining AHRS datas |
---|
| 26 | * |
---|
| 27 | * AHRS datas consist of quaternion and rotational angles values. \n |
---|
| 28 | * |
---|
| 29 | */ |
---|
| 30 | class AhrsData : public io_data { |
---|
| 31 | public: |
---|
| 32 | class Type : public DataType { |
---|
| 33 | public: |
---|
| 34 | Type(const ScalarType &inElementDataType) |
---|
| 35 | : elementDataType(inElementDataType) {} |
---|
| 36 | const ScalarType &GetElementDataType() const { return elementDataType; } |
---|
| 37 | std::string GetDescription() const { return "ahrs data"; } |
---|
| 38 | size_t GetSize() const { return 7 * elementDataType.GetSize(); } |
---|
[2] | 39 | |
---|
[13] | 40 | private: |
---|
| 41 | const ScalarType &elementDataType; |
---|
| 42 | }; |
---|
[2] | 43 | |
---|
[13] | 44 | /*! |
---|
| 45 | \enum PlotableData_t |
---|
| 46 | \brief Datas wich can be plotted in a DataPlot1D |
---|
| 47 | */ |
---|
| 48 | typedef enum { |
---|
| 49 | Roll /*! roll */, |
---|
| 50 | Pitch /*! pitch */, |
---|
| 51 | Yaw /*! yaw */, |
---|
| 52 | RollDeg /*! roll degree*/, |
---|
| 53 | PitchDeg /*! pitch degree */, |
---|
| 54 | YawDeg /*! yaw degree */, |
---|
| 55 | Q0 /*! quaternion 0 */, |
---|
| 56 | Q1 /*! quaternion 1 */, |
---|
| 57 | Q2 /*! quaternion 2 */, |
---|
| 58 | Q3 /*! quaternion 3 */, |
---|
| 59 | Wx /*! x filtered angular rate */, |
---|
| 60 | Wy /*! y filtered angular rate */, |
---|
| 61 | Wz /*! z filtered angular rate */, |
---|
| 62 | WxDeg /*! x filtered angular rate degree*/, |
---|
| 63 | WyDeg /*! y filtered angular rate degree*/, |
---|
| 64 | WzDeg /*! z filtered angular rate degree*/, |
---|
| 65 | } PlotableData_t; |
---|
[2] | 66 | |
---|
[13] | 67 | /*! |
---|
| 68 | * \brief Constructor |
---|
| 69 | * |
---|
| 70 | * Construct an io_data representing AHRS datas. \n |
---|
| 71 | * |
---|
| 72 | * \param parent parent |
---|
| 73 | * \param name name |
---|
| 74 | * \param n number of samples |
---|
| 75 | */ |
---|
| 76 | AhrsData(const Object *parent, std::string name = "", int n = 1); |
---|
[2] | 77 | |
---|
[13] | 78 | /*! |
---|
| 79 | * \brief Destructor |
---|
| 80 | * |
---|
| 81 | */ |
---|
| 82 | ~AhrsData(); |
---|
[2] | 83 | |
---|
[13] | 84 | /*! |
---|
| 85 | * \brief Element |
---|
| 86 | * |
---|
| 87 | * Get a pointer to a specific element. This pointer can be used for plotting. |
---|
| 88 | * |
---|
| 89 | * \param plotableData data type |
---|
| 90 | * |
---|
| 91 | * \return pointer to the element |
---|
| 92 | */ |
---|
| 93 | IODataElement *Element(PlotableData_t plotableData) const; |
---|
[2] | 94 | |
---|
[13] | 95 | /*! |
---|
| 96 | * \brief Set quaternion |
---|
| 97 | * |
---|
| 98 | * This method is mutex protected. |
---|
| 99 | * |
---|
| 100 | * \param quaternion quaternion |
---|
| 101 | * |
---|
| 102 | */ |
---|
| 103 | void SetQuaternion(const Quaternion &quaternion); |
---|
[2] | 104 | |
---|
[13] | 105 | /*! |
---|
| 106 | * \brief Get quaternion |
---|
| 107 | * |
---|
| 108 | * This method is mutex protected. |
---|
| 109 | * |
---|
| 110 | * \return quaternion |
---|
| 111 | * |
---|
| 112 | */ |
---|
| 113 | Quaternion GetQuaternion(void) const; |
---|
[2] | 114 | |
---|
[13] | 115 | /*! |
---|
| 116 | * \brief Set angular rates |
---|
| 117 | * |
---|
| 118 | * This method is mutex protected. |
---|
| 119 | * |
---|
| 120 | * \param angularRates angular rates |
---|
| 121 | * |
---|
| 122 | */ |
---|
[50] | 123 | void SetAngularRates(const Vector3Df &angularRates); |
---|
[2] | 124 | |
---|
[13] | 125 | /*! |
---|
| 126 | * \brief Get angular rates |
---|
| 127 | * |
---|
| 128 | * This method is mutex protected. |
---|
| 129 | * |
---|
| 130 | * \return angular rates |
---|
| 131 | * |
---|
| 132 | */ |
---|
[50] | 133 | Vector3Df GetAngularRates(void) const; |
---|
[2] | 134 | |
---|
[13] | 135 | /*! |
---|
| 136 | * \brief Get both quaternion and angular rates |
---|
| 137 | * |
---|
| 138 | * This method is mutex protected. |
---|
| 139 | * |
---|
| 140 | * \param quaternion quaternion |
---|
| 141 | * \param angularRates angular rates |
---|
| 142 | * |
---|
| 143 | */ |
---|
| 144 | void GetQuaternionAndAngularRates(Quaternion &quaternion, |
---|
[50] | 145 | Vector3Df &angularRates) const; |
---|
[2] | 146 | |
---|
[13] | 147 | /*! |
---|
| 148 | * \brief Set both quaternion and angular rates |
---|
| 149 | * |
---|
| 150 | * This method is mutex protected. |
---|
| 151 | * |
---|
| 152 | * \param quaternion quaternion |
---|
| 153 | * \param angularRates angular rates |
---|
| 154 | * |
---|
| 155 | */ |
---|
| 156 | void SetQuaternionAndAngularRates(const Quaternion &quaternion, |
---|
[50] | 157 | const Vector3Df &angularRates); |
---|
[2] | 158 | |
---|
[13] | 159 | const Type &GetDataType() const { return dataType; } |
---|
[2] | 160 | |
---|
[13] | 161 | private: |
---|
| 162 | /*! |
---|
| 163 | * \brief Copy datas |
---|
| 164 | * |
---|
| 165 | * Reimplemented from io_data. \n |
---|
| 166 | * See io_data::CopyDatas. |
---|
| 167 | * |
---|
| 168 | * \param dst destination buffer |
---|
| 169 | */ |
---|
| 170 | void CopyDatas(char *dst) const; |
---|
[2] | 171 | |
---|
[13] | 172 | void Queue(char **dst, const void *src, size_t size) const; |
---|
[2] | 173 | |
---|
[13] | 174 | /*! |
---|
| 175 | * \brief %Quaternion |
---|
| 176 | * |
---|
| 177 | */ |
---|
| 178 | Quaternion quaternion; |
---|
[2] | 179 | |
---|
[13] | 180 | /*! |
---|
| 181 | * \brief Angular rates |
---|
| 182 | * |
---|
| 183 | */ |
---|
[50] | 184 | Vector3Df angularRates; |
---|
[13] | 185 | |
---|
| 186 | Type dataType; |
---|
| 187 | }; |
---|
| 188 | |
---|
[2] | 189 | } // end namespace core |
---|
| 190 | } // end namespace flair |
---|
| 191 | |
---|
| 192 | #endif // AHRSDATA_H |
---|