dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
levellingutil.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  *
29  * Additional note on redistribution: The copyright and license notices above
30  * must be maintained in each individual source file that is a derivative work
31  * of this source file; otherwise redistribution is prohibited.
32  */
33 
34 #ifndef LEVELLINGUTIL_H
35 #define LEVELLINGUTIL_H
36 
37 #include <QObject>
38 #include <QTimer>
39 
40 #include "uavobjects/uavobject.h"
42 
43 class LevellingUtil : public QObject
44 {
45  Q_OBJECT
46 public:
47  explicit LevellingUtil(long measurementCount, long measurementRate);
48  explicit LevellingUtil(long accelMeasurementCount, long accelMeasurementRate,
49  long gyroMeasurementCount, long gyroMeasurementRate);
50 
51 signals:
52  void progress(long current, long total);
53  void done(accelGyroBias measuredBias);
54  void timeout(QString message);
55 
56 public slots:
57  void start();
58  void abort();
59 
60 private slots:
61  void gyroMeasurementsUpdated(UAVObject *obj);
62  void accelMeasurementsUpdated(UAVObject *obj);
63  void timeout();
64 
65 private:
66  static const float G = 9.81f;
67  static const float ACCELERATION_SCALE = 0.004f * 9.81f;
68 
69  QTimer m_timeoutTimer;
70 
71  bool m_isMeasuring;
72  long m_receivedAccelUpdates;
73  long m_receivedGyroUpdates;
74 
75  long m_accelMeasurementCount;
76  long m_gyroMeasurementCount;
77  long m_accelMeasurementRate;
78  long m_gyroMeasurementRate;
79 
80  UAVObject::Metadata m_previousGyroMetaData;
81  UAVObject::Metadata m_previousAccelMetaData;
82 
83  double m_accelerometerX;
84  double m_accelerometerY;
85  double m_accelerometerZ;
86  double m_gyroX;
87  double m_gyroY;
88  double m_gyroZ;
89 
90  void stop();
91  void startMeasurement();
92  void stopMeasurement();
93  accelGyroBias calculateLevellingData();
94 };
95 
96 #endif // LEVELLINGUTIL_H
LevellingUtil(long measurementCount, long measurementRate)
void timeout(QString message)
void done(accelGyroBias measuredBias)
void progress(long current, long total)