FlightGear next
JSBSim.hxx
Go to the documentation of this file.
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: JSBSim.hxx
4 Author: Curtis L. Olson
5 Maintained by: Tony Peden, Curt Olson
6 Date started: 02/01/1999
7
8------ Copyright (C) 1999 - 2000 Curtis L. Olson (curt@flightgear.org) ------
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23
24HISTORY
25--------------------------------------------------------------------------------
2602/01/1999 CLO Created
27Additional log messages stored in CVS
28
29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30SENTRY
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33#ifndef _JSBSIM_HXX
34#define _JSBSIM_HXX
35
36/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37INCLUDES
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#undef MAX_ENGINES
41
42/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43DEFINITIONS
44%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46#define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
47
48#define METERS_TO_FEET 3.2808398950
49#define RADTODEG 57.2957795
50
51/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52FORWARD DECLARATIONS
53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55#include <simgear/props/props.hxx>
56
59
60namespace JSBSim {
61class FGAtmosphere;
62class FGWinds;
63class FGFCS;
64class FGPropulsion;
65class FGMassBalance;
66class FGAerodynamics;
67class FGInertial;
68class FGAircraft;
69class FGPropagate;
70class FGAuxiliary;
71class FGOutput;
72class FGInitialCondition;
73class FGLocation;
74class FGAccelerations;
75class FGPropertyManager;
76class FGColumnVector3;
77}
78
79// Adding it here will cause a namespace clash in FlightGear -EMH-
80// using namespace JSBSim;
81
82/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83CLASS DOCUMENTATION
84%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
85
96
97/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98CLASS DECLARATION
99%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
100
101class FGJSBsim : public FGInterface
102{
103public:
105 FGJSBsim( double dt );
106
108 ~FGJSBsim();
109
110 // Subsystem API.
111 void init() override;
112 void resume() override;
113 void suspend() override;
114 void unbind() override;
115 void update(double dt) override;
116
117 // Subsystem identification.
118 static const char* staticSubsystemClassId() { return "jsb"; }
119
121 bool copy_to_JSBsim();
122
124 bool copy_from_JSBsim();
125
127
128
131 void set_Latitude(double lat); // geocentric
132
136 void set_Longitude(double lon);
137
141 void set_Altitude(double alt); // triggers re-calc of AGL altitude
143
144 //void set_AltitudeAGL(double altagl); // and vice-versa
145
147
148
151 void set_V_calibrated_kts(double vc);
152
156 void set_Mach_number(double mach);
157
163 void set_Velocities_Local( double north, double east, double down );
164
170 void set_Velocities_Body( double u, double v, double w);
172
177 void set_Euler_Angles( double phi, double theta, double psi );
178
180
181
183 void set_Climb_Rate( double roc);
184
187 void set_Gamma_vert_rad( double gamma);
189
190
192
193
195// void set_Static_pressure(double p);
196
199// void set_Static_temperature(double T);
200
203// void set_Density(double rho);
204
210
211
212 bool ToggleDataLogging(bool state);
213 bool ToggleDataLogging(void);
214
215 double get_agl_ft(double t, const JSBSim::FGColumnVector3& loc,
216 double alt_off, double contact[3], double normal[3],
217 double vel[3], double angularVel[3]);
218
219private:
220 JSBSim::FGFDMExec *fdmex;
222 bool needTrim;
223
224 JSBSim::FGAtmosphere* Atmosphere;
225 JSBSim::FGWinds* Winds;
226 JSBSim::FGFCS* FCS;
227 JSBSim::FGPropulsion* Propulsion;
228 JSBSim::FGMassBalance* MassBalance;
229 JSBSim::FGAircraft* Aircraft;
230 JSBSim::FGPropagate* Propagate;
231 JSBSim::FGAuxiliary* Auxiliary;
232 JSBSim::FGAerodynamics* Aerodynamics;
234 JSBSim::FGInertial* Inertial;
235 JSBSim::FGAccelerations* Accelerations;
236 JSBSim::FGPropertyManager* PropertyManager;
237
238 // disabling unused members
239 /*
240 int runcount;
241 double trim_elev;
242 double trim_throttle;
243 */
244
245 SGPropertyNode_ptr startup_trim;
246 SGPropertyNode_ptr trimmed;
247 SGPropertyNode_ptr pitch_trim;
248 SGPropertyNode_ptr throttle_trim;
249 SGPropertyNode_ptr aileron_trim;
250 SGPropertyNode_ptr rudder_trim;
251 SGPropertyNode_ptr stall_warning;
252
253 /* SGPropertyNode_ptr elevator_pos_deg;
254 SGPropertyNode_ptr left_aileron_pos_deg;
255 SGPropertyNode_ptr right_aileron_pos_deg;
256 SGPropertyNode_ptr rudder_pos_deg;
257 SGPropertyNode_ptr flap_pos_deg; */
258
259
260 SGPropertyNode_ptr elevator_pos_pct;
261 SGPropertyNode_ptr left_aileron_pos_pct;
262 SGPropertyNode_ptr right_aileron_pos_pct;
263 SGPropertyNode_ptr rudder_pos_pct;
264 SGPropertyNode_ptr flap_pos_pct;
265 SGPropertyNode_ptr speedbrake_pos_pct;
266 SGPropertyNode_ptr spoilers_pos_pct;
267
268 SGPropertyNode_ptr override_fg_brake_prop;
269 SGPropertyNode_ptr ab_brake_engaged;
270 SGPropertyNode_ptr ab_brake_left_pct;
271 SGPropertyNode_ptr ab_brake_right_pct;
272
273 SGPropertyNode_ptr gear_pos_pct;
274 SGPropertyNode_ptr wing_fold_pos_pct;
275 SGPropertyNode_ptr tailhook_pos_pct;
276
277 SGConstPropertyNode_ptr altitude;
278 SGPropertyNode_ptr precipitation;
279 SGPropertyNode_ptr temperature;
280 SGPropertyNode_ptr pressure;
281 SGPropertyNode_ptr pressureSL;
282 SGPropertyNode_ptr dew_point;
283 SGPropertyNode_ptr ground_wind;
284 SGPropertyNode_ptr turbulence_gain;
285 SGPropertyNode_ptr turbulence_rate;
286 SGPropertyNode_ptr turbulence_model;
287
288 SGPropertyNode_ptr wind_from_north;
289 SGPropertyNode_ptr wind_from_east;
290 SGPropertyNode_ptr wind_from_down;
291
292 SGPropertyNode_ptr arrestor_wire_engaged_hook;
293 SGPropertyNode_ptr release_hook;
294
295 SGPropertyNode_ptr slaved;
296
297 SGPropertyNode_ptr terrain;
298
299 static std::map<std::string,int> TURBULENCE_TYPE_NAMES;
300
301 double last_hook_tip[3];
302 double last_hook_root[3];
303 JSBSim::FGColumnVector3 hook_root_struct;
304 double hook_length;
305
306 bool crashed;
307
308 AircraftMesh_ptr mesh;
309 SGPropertyNode_ptr _ai_wake_enabled;
310 SGPropertyNode_ptr _fmag{nullptr}, _mmag{nullptr};
311 SGPropertyNode_ptr _fbx{nullptr}, _fby{nullptr}, _fbz{nullptr};
312 SGPropertyNode_ptr _mbx{nullptr}, _mby{nullptr}, _mbz{nullptr};
313
314 void do_trim(void);
315
316 bool update_ground_cache(const JSBSim::FGLocation& cart, double dt);
317 void init_gear(void);
318 void update_gear(void);
319
320 void update_external_forces(double t_off);
321};
322
323#endif // _JSBSIM_HXX
double altitude
Definition ADA.cxx:46
SGSharedPtr< AircraftMesh > AircraftMesh_ptr
static const char * staticSubsystemClassId()
Definition JSBSim.hxx:118
void set_Velocities_Local(double north, double east, double down)
Sets velocity in N-E-D coordinates.
Definition JSBSim.cxx:1123
FGJSBsim(double dt)
Constructor.
Definition JSBSim.cxx:124
void set_Longitude(double lon)
Set longitude.
Definition JSBSim.cxx:1056
void set_V_calibrated_kts(double vc)
Sets calibrated airspeed Setting this will trigger a recalc of the other velocity terms.
Definition JSBSim.cxx:1081
void set_Latitude(double lat)
Set geocentric latitude.
Definition JSBSim.cxx:1030
void set_Climb_Rate(double roc)
Sets rate of climb.
Definition JSBSim.cxx:1186
bool copy_to_JSBsim()
copy FDM state to LaRCsim structures
Definition JSBSim.cxx:598
void unbind() override
Definition JSBSim.cxx:508
void update(double dt) override
Definition JSBSim.cxx:517
void set_Altitude(double alt)
Set altitude Note: this triggers a recalculation of AGL altitude.
Definition JSBSim.cxx:1069
void init() override
Definition JSBSim.cxx:380
void set_Mach_number(double mach)
Sets Mach number.
Definition JSBSim.cxx:1103
~FGJSBsim()
Destructor.
Definition JSBSim.cxx:369
void set_Euler_Angles(double phi, double theta, double psi)
Euler Angle Parameter Set.
Definition JSBSim.cxx:1164
bool copy_from_JSBsim()
copy FDM state from LaRCsim structures
Definition JSBSim.cxx:748
void suspend() override
Definition JSBSim.cxx:580
void set_Velocities_Body(double u, double v, double w)
Sets aircraft velocity in stability frame.
Definition JSBSim.cxx:1144
double get_agl_ft(double t, const JSBSim::FGColumnVector3 &loc, double alt_off, double contact[3], double normal[3], double vel[3], double angularVel[3])
Definition JSBSim.cxx:1369
bool ToggleDataLogging(void)
Definition JSBSim.cxx:1009
void set_Gamma_vert_rad(double gamma)
Sets the flight path angle in radians.
Definition JSBSim.cxx:1209
void resume() override
Definition JSBSim.cxx:588
Encapsulates the aerodynamic calculations.
Encapsulates an Aircraft and its systems.
Definition FGAircraft.h:102
Encapsulates various uncategorized scheduled functions.
This class implements a 3 element column vector.
Manages ground reactions modeling.
Models inertial forces (e.g.
Definition FGInertial.h:65
Models weight, balance and moment of inertia information.
Models the EOM and integration/propagation of state.
Definition FGPropagate.h:93
Propulsion management class.
Models atmospheric disturbances: winds, gusts, turbulence, downbursts, etc.
Definition FGWinds.h:166