]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/flight_control/FGMagnetometer.h
Merge branch 'next' of gitorious.org:fg/flightgear into next
[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 #include "FGSensorOrientation.h"
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 DEFINITIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 #define ID_MAGNETOMETER "$Id: FGMagnetometer.h,v 1.4 2009/12/11 06:03:06 jberndt Exp $"
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 FORWARD DECLARATIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 namespace JSBSim {
60
61 class FGFCS;
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 CLASS DOCUMENTATION
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 /** Encapsulates a magnetometer component for the flight control system.
68
69 Syntax:
70
71 @code
72 <magnetometer name="name">
73   <axis> {X|Y|Z} </axis>
74   <lag> number </lag>
75   <orientation unit=DEG">
76     <x> number </x>
77     <y> number </y>
78     <z> number </z>
79   </orientation>
80   <noise variation="PERCENT|ABSOLUTE"> number </noise>
81   <quantization name="name">
82     <bits> number </bits>
83     <min> number </min>
84     <max> number </max>
85   </quantization>
86   <drift_rate> number </drift_rate>
87   <bias> number </bias>
88   <gain> number </gain>
89 </magnetometer>
90 @endcode
91
92 Example:
93
94 @code
95 <magnetometer name="aero/magnetometer/X">
96   <axis> X </axis>
97   <lag> 0.5 </lag>
98   <noise variation="PERCENT"> 2 </noise>
99   <quantization name="aero/magnetometer/quantized/qbar">
100     <bits> 12 </bits>
101     <min> 0 </min>
102     <max> 400 </max>
103   </quantization>
104   <bias> 0.5 </bias>
105   <gain> 0.5 </gain>
106 </magnetometer>
107 @endcode
108
109 The only required element in the magnetometer definition is the axis element. In
110 the default case, no degradation would be modeled, and the output would simply be
111 the input.
112
113 For noise, if the type is PERCENT, then the value supplied is understood to be a
114 percentage variance. That is, if the number given is 0.05, the the variance is
115 understood to be +/-0.05 percent maximum variance. So, the actual value for the magnetometer
116 will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any time -
117 even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the delta
118 time.
119
120 @author Jon S. Berndt
121 @version $Revision: 1.4 $
122 */
123
124 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 CLASS DECLARATION
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
127
128 class FGMagnetometer  : public FGSensor, public FGSensorOrientation
129 {
130 public:
131   FGMagnetometer(FGFCS* fcs, Element* element);
132   ~FGMagnetometer();
133
134   bool Run (void);
135
136 private:
137   FGPropagate* Propagate;
138   FGMassBalance* MassBalance;
139   FGInertial* Inertial;
140   FGColumnVector3 vLocation;
141   FGColumnVector3 vRadius;
142   FGColumnVector3 vMag;
143   void updateInertialMag(void);
144   double field[6];
145   double usedLat;
146   double usedLon;
147   double usedAlt;
148   unsigned long int date;
149   int counter;
150   int INERTIAL_UPDATE_RATE;
151
152   void Debug(int from);
153 };
154 }
155 #endif