QuadroCopter  0.1.4
orientation.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2017 Michael Brookes
3 
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef QUADRO_ORIENTATION_H
19 #define QUADRO_ORIENTATION_H
20 
21 #include <cstdio>
22 #include <pthread.h>
23 #include "../External/Kalman.h"
24 #include "../Timer/Timer.h"
25 #include "../I2C/Devices/L3GD20H/L3GD20H.h"
26 #include "../I2C/Devices/LSM303/Accelerometer/LSM303Accelerometer.h"
27 #include "../analog/devices/LVMaxSonarEZ/LVMaxSonarEZ.h"
28 #include "../I2C/Devices/LSM303/Magnetometer/LSM303Magnetometer.h"
29 #include "../external/PID.h"
30 
31 namespace quadro {
32  using namespace analog;
33  using namespace i2c;
34 
38  class orientation {
39 
40  public:
41 
45  const float DATA_RATE = 0.02;
46 
51  const float COMPLIMENTARY_FILTER_TUNING = 0.98;
52 
60  orientation( );
61 
65  ~orientation() noexcept;
66 
72  void setDataFilterSelection( int );
73 
74  float roll;
75  float pitch;
76  float yaw;
77  float baroHeight;
78  float sonicHeight;
79  float height;
80  float heading;
81 
82  int dataFilterSelection;
83 
87  enum dataFilter {
88  KALMAN = 1,
89  COMPLIMENTARY = 2
90  };
91 
96 
101 
102  private:
103 
109  static void* setValues( void* orientationInst );
110 
111  pthread_t orientationNotifyer;
112 
113  Kalman kalmanPitch;
114 
115  Kalman kalmanRoll;
116 
117  LVMaxSonarEZ* sonicSensor;
118 
119  LSM303Accelerometer* accelerometer;
120 
121  LSM303Magnetometer* magnetometer;
122 
123  L3GD20H* gyroscope;
124 
128  void runKalmanCalculations();
129 
133  void runComplimentaryCalculations();
134 
135  };
136 
137 }
138 
139 #endif //QUADRO_ORIENTATION_H
Definition: orientation.h:38
Definition: L3GD20H.h:51
Definition: LVMaxSonarEZ.h:28
Definition: LSM303Accelerometer.h:20
Definition: LSM303Magnetometer.h:31
Definition: aeronautics.h:23
PID * rollPID
Definition: orientation.h:100
Definition: PID.h:7
PID * pitchPID
Definition: orientation.h:95
dataFilter
Definition: orientation.h:87
Definition: Kalman.h:21