[3] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[3] | 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>
|
---|
[173] | 17 | #include <Vector3D.h>
|
---|
[3] | 18 |
|
---|
| 19 | namespace flair {
|
---|
[51] | 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 | }
|
---|
[3] | 31 | }
|
---|
| 32 |
|
---|
| 33 | class Ahrs_impl;
|
---|
| 34 |
|
---|
[15] | 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;
|
---|
[3] | 46 |
|
---|
[15] | 47 | public:
|
---|
| 48 | /*!
|
---|
| 49 | * \brief Constructor
|
---|
| 50 | *
|
---|
| 51 | * Construct an Imu.
|
---|
[137] | 52 | * It will be child of the FrameworkManager.
|
---|
[15] | 53 | *
|
---|
| 54 | * \param name name
|
---|
[198] | 55 | * \param needRotation true will enable post rotation in GCS. Post rotation must be applied manually in reimplemented code
|
---|
[15] | 56 | */
|
---|
[198] | 57 | Imu(std::string name,bool needRotation=true);
|
---|
[3] | 58 |
|
---|
[15] | 59 | /*!
|
---|
| 60 | * \brief Destructor
|
---|
| 61 | *
|
---|
| 62 | */
|
---|
| 63 | ~Imu();
|
---|
[179] | 64 |
|
---|
| 65 | /*!
|
---|
| 66 | * \brief Get IMU datas
|
---|
| 67 | *
|
---|
| 68 | * \return ImuData
|
---|
| 69 | */
|
---|
| 70 | const core::ImuData *GetDatas(void) const;
|
---|
[3] | 71 |
|
---|
[179] | 72 |
|
---|
[15] | 73 | /*!
|
---|
| 74 | * \brief Setup Layout
|
---|
| 75 | *
|
---|
| 76 | * \return setup Layout
|
---|
| 77 | */
|
---|
| 78 | gui::Layout *GetLayout(void) const;
|
---|
[3] | 79 |
|
---|
[15] | 80 | /*!
|
---|
| 81 | * \brief Lock user interface
|
---|
| 82 | *
|
---|
| 83 | */
|
---|
| 84 | void LockUserInterface(void) const;
|
---|
[3] | 85 |
|
---|
[15] | 86 | /*!
|
---|
| 87 | * \brief Unlock user interface
|
---|
| 88 | *
|
---|
| 89 | */
|
---|
| 90 | void UnlockUserInterface(void) const;
|
---|
[3] | 91 |
|
---|
[15] | 92 | /*!
|
---|
| 93 | * \brief Use default plot
|
---|
| 94 | *
|
---|
| 95 | */
|
---|
| 96 | void UseDefaultPlot(void);
|
---|
[3] | 97 |
|
---|
[15] | 98 | /*!
|
---|
| 99 | * \brief Plot tab
|
---|
| 100 | *
|
---|
| 101 | * \return plot Tab
|
---|
| 102 | */
|
---|
| 103 | gui::Tab *GetPlotTab(void) const;
|
---|
[3] | 104 |
|
---|
[99] | 105 | /*!
|
---|
| 106 | * \brief Get OneAxisRotation
|
---|
| 107 | *
|
---|
| 108 | * \return fixed rotation of the imu
|
---|
| 109 | */
|
---|
| 110 | core::OneAxisRotation *GetOneAxisRotation(void) const;
|
---|
| 111 |
|
---|
| 112 |
|
---|
[15] | 113 | protected:
|
---|
| 114 | /*!
|
---|
| 115 | * \brief Setup GroupBox
|
---|
| 116 | *
|
---|
| 117 | * \return setup GroupBox
|
---|
| 118 | */
|
---|
| 119 | gui::GroupBox *GetGroupBox(void) const;
|
---|
[3] | 120 |
|
---|
[15] | 121 | /*!
|
---|
[173] | 122 | * \brief ApplyRotation
|
---|
[15] | 123 | *
|
---|
[173] | 124 | * The reimplemented class must call this function to rotate IMU datas, before filling the ImuData. \n
|
---|
[15] | 125 | * It handles the data rotation if it was defined.
|
---|
| 126 | *
|
---|
[173] | 127 | * \param vector vector to apply rotation to
|
---|
[15] | 128 | */
|
---|
[173] | 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);
|
---|
[3] | 140 |
|
---|
[15] | 141 | /*!
|
---|
| 142 | * \brief Get imu datas
|
---|
| 143 | *
|
---|
[179] | 144 | * Can be used by dervied class to fill core::ImuData
|
---|
| 145 | *
|
---|
[15] | 146 | * \param imuData imu datas
|
---|
| 147 | */
|
---|
| 148 | void GetDatas(core::ImuData **imuData) const;
|
---|
[343] | 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);
|
---|
[3] | 160 |
|
---|
[15] | 161 | private:
|
---|
| 162 | gui::Tab *mainTab, *sensorTab, *plotTab;
|
---|
| 163 | gui::TabWidget *tab;
|
---|
| 164 | gui::GroupBox *setupGroupbox;
|
---|
| 165 | core::OneAxisRotation *rotation;
|
---|
| 166 | core::ImuData *imuData;
|
---|
[3] | 167 |
|
---|
[15] | 168 | gui::DataPlot1D *axPlot, *ayPlot, *azPlot;
|
---|
| 169 | gui::DataPlot1D *gxPlot, *gyPlot, *gzPlot;
|
---|
| 170 | gui::DataPlot1D *mxPlot, *myPlot, *mzPlot;
|
---|
[343] | 171 |
|
---|
[344] | 172 | //for calibration:
|
---|
[343] | 173 | core::Time startCalcOffset;
|
---|
| 174 | bool calibrationDone;
|
---|
[344] | 175 | core::Vector3Df accOffset,gyrOffset,accMax,accMin;
|
---|
[343] | 176 | uint16_t cptOffset;
|
---|
| 177 |
|
---|
[15] | 178 | };
|
---|
[3] | 179 | } // end namespace sensor
|
---|
| 180 | } // end namespace flair
|
---|
| 181 |
|
---|
| 182 | #endif // IMU_H
|
---|