| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGAccelerometer.h |
| 4 | Author: Jon Berndt |
| 5 | Date started: May 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 |
| 11 | Software Foundation; either version 2 of the License, or (at your option) any |
| 12 | later 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 |
| 20 | with this program; if not, write to the Free Software Foundation, Inc., 59 |
| 21 | Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | |
| 23 | Further information about the GNU Lesser General Public License can also be |
| 24 | found on the world wide web at http://www.gnu.org. |
| 25 | |
| 26 | HISTORY |
| 27 | -------------------------------------------------------------------------------- |
| 28 | |
| 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 30 | SENTRY |
| 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 32 | |
| 33 | #ifndef FGACCELEROMETER_H |
| 34 | #define FGACCELEROMETER_H |
| 35 | |
| 36 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 37 | INCLUDES |
| 38 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 39 | |
| 40 | #include "FGSensorOrientation.h" |
| 41 | |
| 42 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 43 | FORWARD DECLARATIONS |
| 44 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 45 | |
| 46 | namespace JSBSim { |
| 47 | |
| 48 | class FGFCS; |
| 49 | class FGPropagate; |
| 50 | class FGAccelerations; |
| 51 | class FGMassBalance; |
| 52 | |
| 53 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 54 | CLASS DOCUMENTATION |
| 55 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 56 | |
| 57 | /** Encapsulates a Accelerometer component for the flight control system. |
| 58 | |
| 59 | Syntax: |
| 60 | |
| 61 | @code |
| 62 | <accelerometer name="name"> |
| 63 | <location unit="{IN | M}"> |
| 64 | <x> number </x> |
| 65 | <y> number </y> |
| 66 | <z> number </z> |
| 67 | </location> |
| 68 | <orientation unit="{RAD | DEG}"> |
| 69 | <pitch> {number} </pitch> |
| 70 | <roll> {number} </roll> |
| 71 | <yaw> {number} </yaw> |
| 72 | </orientation> |
| 73 | <axis> {X | Y | Z} </axis> |
| 74 | <lag> number </lag> |
| 75 | <noise variation="PERCENT|ABSOLUTE"> number </noise> |
| 76 | <quantization name="name"> |
| 77 | <bits> number </bits> |
| 78 | <min> number </min> |
| 79 | <max> number </max> |
| 80 | </quantization> |
| 81 | <drift_rate> number </drift_rate> |
| 82 | <gain> number </gain> |
| 83 | <bias> number </bias> |
| 84 | <output> { output_property } </output> |
| 85 | </accelerometer> |
| 86 | @endcode |
| 87 | |
| 88 | Example: |
| 89 | |
| 90 | @code |
| 91 | <accelerometer name="aero/accelerometer/right_tip_wing"> |
| 92 | <location unit="IN"> |
| 93 | <x> 43.2 </x> |
| 94 | <y> 214. </y> |
| 95 | <z> 59.4 </z> |
| 96 | </location> |
| 97 | <axis> Z </axis> |
| 98 | <lag> 0.5 </lag> |
| 99 | <noise variation="PERCENT"> 2 </noise> |
| 100 | <quantization name="aero/accelerometer/quantized/right_tip_wing"> |
| 101 | <bits> 12 </bits> |
| 102 | <min> 0 </min> |
| 103 | <max> 400 </max> |
| 104 | </quantization> |
| 105 | <bias> 0.5 </bias> |
| 106 | <output> aero/accelerometer/right_tip_wing </output> |
| 107 | </accelerometer> |
| 108 | @endcode |
| 109 | |
| 110 | The only required element in the accelerometer definition is the input element. |
| 111 | In that case, no degradation would be modeled, and the output would simply be |
| 112 | the input. |
| 113 | |
| 114 | For noise, if the type is PERCENT, then the value supplied is understood to be a |
| 115 | percentage variance. That is, if the number given is 0.05, the variance is |
| 116 | understood to be +/-0.05 percent maximum variance. So, the actual value for the |
| 117 | accelerometer will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value |
| 118 | at any time - even varying all the way from 0.95 to 1.05 in adjacent frames - |
| 119 | whatever the delta time. |
| 120 | |
| 121 | @author Jon S. Berndt |
| 122 | @version $Revision: 1.9 $ |
| 123 | */ |
| 124 | |
| 125 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 126 | CLASS DECLARATION |
| 127 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 128 | |
| 129 | class FGAccelerometer : public FGSensor, public FGSensorOrientation |
| 130 | { |
| 131 | public: |
| 132 | FGAccelerometer(FGFCS* fcs, Element* element); |
| 133 | ~FGAccelerometer(); |
| 134 | |
| 135 | bool Run (void) override; |
| 136 | |
| 137 | private: |
| 138 | FGPropagate* Propagate; |
| 139 | FGAccelerations* Accelerations; |
| 140 | FGMassBalance* MassBalance; |
| 141 | FGColumnVector3 vLocation; |
| 142 | FGColumnVector3 vRadius; |
| 143 | FGColumnVector3 vAccel; |
| 144 | |
| 145 | void Debug(int from) override; |
| 146 | }; |
| 147 | } |
| 148 | #endif |