JSBSim Flight Dynamics Model 1.2.3 (07 Jun 2025)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGSensor.h
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGSensor.h
4 Author: Jon Berndt
5 Date started: 9 July 2005
6
7 ------------- Copyright (C) 2005 -------------
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
26HISTORY
27--------------------------------------------------------------------------------
28
29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30SENTRY
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33#ifndef FGSENSOR_H
34#define FGSENSOR_H
35
36/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37INCLUDES
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#include "FGFCSComponent.h"
41#include <optional>
42
43/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44FORWARD DECLARATIONS
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47namespace JSBSim {
48
49class FGFCS;
50class Element;
51
52/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53CLASS DOCUMENTATION
54%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
129/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130CLASS DECLARATION
131%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
132
134{
135public:
136 FGSensor(FGFCS* fcs, Element* element);
137 virtual ~FGSensor();
138
139 void SetFailLow(double val) {if (val > 0.0) fail_low = true; else fail_low = false;}
140 void SetFailHigh(double val) {if (val > 0.0) fail_high = true; else fail_high = false;}
141 void SetFailStuck(double val) {if (val > 0.0) fail_stuck = true; else fail_stuck = false;}
142
143 double GetFailLow(void) const {if (fail_low) return 1.0; else return 0.0;}
144 double GetFailHigh(void) const {if (fail_high) return 1.0; else return 0.0;}
145 double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
146 int GetQuantized(void) const {return quantized;}
147
148 int GetNoiseRandomSeed(void) const;
149 void SetNoiseRandomSeed(int seed);
150
151 bool Run (void) override;
152 void ResetPastStates(void) override;
153
154protected:
155 enum eNoiseType {ePercent=0, eAbsolute} NoiseType;
156 enum eDistributionType {eUniform=0, eGaussian} DistributionType;
157 double min, max;
158 double span;
159 double bias;
160 double gain;
161 double drift_rate;
162 double drift;
163 double noise_variance;
164 double lag;
165 double granularity;
166 double ca;
167 double cb;
169 double PreviousInput;
170 int noise_type;
171 int bits;
172 int quantized;
173 int divisions;
174 bool fail_low;
175 bool fail_high;
176 bool fail_stuck;
177 std::string quant_property;
178
179 void ProcessSensorSignal(void);
180 void Noise(void);
181 void Bias(void);
182 void Drift(void);
183 void Quantize(void);
184 void Lag(void);
185 void Gain(void);
186
187 void bind(Element* el, FGPropertyManager* pm) override;
188
189private:
190 std::optional<unsigned int> RandomSeed;
191 std::shared_ptr<RandomNumberGenerator> generator;
192 void Debug(int from) override;
193};
194}
195#endif
Base class for JSBSim Flight Control System Components.
Encapsulates the Flight Control System (FCS) functionality.
Definition FGFCS.h:189
Class wrapper for property handling.
Encapsulates a Sensor component for the flight control system.
Definition FGSensor.h:134
double PreviousOutput
lag filter coefficient "b"
Definition FGSensor.h:168
double cb
lag filter coefficient "a"
Definition FGSensor.h:167