]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/flight_control/FGMagnetometer.h
Sync. with JSBSim (CVS) again
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGMagnetometer.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGMagnetometer.h
4  Author:       Matthew Chave
5  Date started: August 2009
6
7  ------------- Copyright (C) 2009 -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
17  details.
18
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33 #ifndef FGMAGNETOMETER_H
34 #define FGMAGNETOMETER_H
35
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40 #include "FGSensor.h"
41 #include <input_output/FGXMLElement.h>
42 #include "models/FGPropagate.h"
43 #include "models/FGMassBalance.h"
44 #include "models/FGInertial.h"
45 #include "math/FGColumnVector3.h"
46 #include "math/FGMatrix33.h"
47
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 DEFINITIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52 #define ID_MAGNETOMETER "$Id$"
53
54 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 FORWARD DECLARATIONS
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57
58 namespace JSBSim {
59
60 class FGFCS;
61
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 CLASS DOCUMENTATION
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65
66 /** Encapsulates a magnetometer component for the flight control system.
67
68 Syntax:
69
70 @code
71 <magnetometer name="name">
72   <input> property </input>
73   <lag> number </lag>
74   <noise variation="PERCENT|ABSOLUTE"> number </noise>
75   <quantization name="name">
76     <bits> number </bits>
77     <min> number </min>
78     <max> number </max>
79   </quantization>
80   <drift_rate> number </drift_rate>
81   <bias> number </bias>
82   <gain> number </gain>
83 </magnetometer>
84 @endcode
85
86 Example:
87
88 @code
89 <magnetometer name="aero/magnetometer/qbar">
90   <input> aero/qbar </input>
91   <lag> 0.5 </lag>
92   <noise variation="PERCENT"> 2 </noise>
93   <quantization name="aero/magnetometer/quantized/qbar">
94     <bits> 12 </bits>
95     <min> 0 </min>
96     <max> 400 </max>
97   </quantization>
98   <bias> 0.5 </bias>
99   <gain> 0.5 </gain>
100 </magnetometer>
101 @endcode
102
103 The only required element in the magnetometer definition is the input element. In that
104 case, no degradation would be modeled, and the output would simply be the input.
105
106 For noise, if the type is PERCENT, then the value supplied is understood to be a
107 percentage variance. That is, if the number given is 0.05, the the variance is
108 understood to be +/-0.05 percent maximum variance. So, the actual value for the magnetometer
109 will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any time -
110 even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the delta
111 time.
112
113 @author Jon S. Berndt
114 @version $Revision$
115 */
116
117 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 CLASS DECLARATION
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
120
121 class FGMagnetometer  : public FGSensor
122 {
123 public:
124   FGMagnetometer(FGFCS* fcs, Element* element);
125   ~FGMagnetometer();
126
127   bool Run (void);
128
129 private:
130   FGPropagate* Propagate;
131   FGMassBalance* MassBalance;
132   FGInertial* Inertial;
133   FGColumnVector3 vLocation;
134   FGColumnVector3 vOrient;
135   FGColumnVector3 vRadius;
136   FGColumnVector3 vMag;
137   FGMatrix33 mT;
138   void CalculateTransformMatrix(void);
139   void updateInertialMag(void);
140   int axis;
141   double field[6];
142   double usedLat;
143   double usedLon;
144   double usedAlt;
145   unsigned long int date;
146   int counter;
147   int INERTIAL_UPDATE_RATE;
148
149   void Debug(int from);
150 };
151 }
152 #endif