]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/JSBSim.hxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / FDM / JSBSim / JSBSim.hxx
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 HISTORY
25 --------------------------------------------------------------------------------
26 02/01/1999   CLO   Created
27 Additional log messages stored in CVS
28
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33 #ifndef _JSBSIM_HXX
34 #define _JSBSIM_HXX
35
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40 #undef MAX_ENGINES
41 #include "math/FGColumnVector3.h"
42
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 DEFINITIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47 #define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
48
49 #define METERS_TO_FEET 3.2808398950
50 #define RADTODEG 57.2957795
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 #include <simgear/props/props.hxx>
57
58 #include <FDM/JSBSim/FGFDMExec.h>
59
60 namespace JSBSim {
61 class FGAtmosphere;
62 class FGFCS;
63 class FGPropulsion;
64 class FGMassBalance;
65 class FGAerodynamics;
66 class FGInertial;
67 class FGAircraft;
68 class FGPropagate;
69 class FGAuxiliary;
70 class FGOutput;
71 class FGInitialCondition;
72 }
73
74 // Adding it here will cause a namespace clash in FlightGear -EMH-
75 // using namespace JSBSim;
76
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CLASS DOCUMENTATION
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80
81 /** FGFS / JSBSim interface (aka "The Bus").
82     This class provides for an interface between FlightGear and its data
83     structures and JSBSim and its data structures. This is the class which is
84     used to command JSBSim when integrated with FlightGear. See the
85     documentation for main for direction on running JSBSim apart from FlightGear.
86     @author Curtis L. Olson (original)
87     @author Tony Peden (Maintained and refined)
88     @version $Id: JSBSim.hxx,v 1.15 2010/10/07 03:45:40 jberndt Exp $
89     @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
90 */
91
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 CLASS DECLARATION
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95
96 class FGJSBsim: public FGInterface {
97
98 public:
99     /// Constructor
100     FGJSBsim( double dt );
101     /// Destructor
102     ~FGJSBsim();
103
104     /// copy FDM state to LaRCsim structures
105     bool copy_to_JSBsim();
106
107     /// copy FDM state from LaRCsim structures
108     bool copy_from_JSBsim();
109
110     /// Reset flight params to a specific position
111     void init();
112
113     /// Unbind properties
114     void unbind();
115
116     /// Suspend integration
117     void suspend();
118
119     /// Resume integration
120     void resume();
121
122     /// @name Position Parameter Set
123     //@{
124     /** Set geocentric latitude
125         @param lat latitude in radians measured from the 0 meridian where
126                    the westerly direction is positive and east is negative */
127     void set_Latitude(double lat);  // geocentric
128
129     /** Set longitude
130         @param lon longitude in radians measured from the equator where
131                    the northerly direction is positive and south is negative */
132     void set_Longitude(double lon);
133
134     /** Set altitude
135         Note: this triggers a recalculation of AGL altitude
136         @param alt altitude in feet */
137     void set_Altitude(double alt);        // triggers re-calc of AGL altitude
138     //@}
139
140     //void set_AltitudeAGL(double altagl); // and vice-versa
141
142     /// @name Velocity Parameter Set
143     //@{
144     /** Sets calibrated airspeed
145         Setting this will trigger a recalc of the other velocity terms.
146         @param vc Calibrated airspeed in ft/sec */
147     void set_V_calibrated_kts(double vc);
148
149     /** Sets Mach number.
150         Setting this will trigger a recalc of the other velocity terms.
151         @param mach Mach number */
152     void set_Mach_number(double mach);
153
154     /** Sets velocity in N-E-D coordinates.
155         Setting this will trigger a recalc of the other velocity terms.
156         @param north velocity northward in ft/sec
157         @param east velocity eastward in ft/sec
158         @param down velocity downward in ft/sec */
159     void set_Velocities_Local( double north, double east, double down );
160
161     /** Sets aircraft velocity in stability frame.
162         Setting this will trigger a recalc of the other velocity terms.
163         @param u X velocity in ft/sec
164         @param v Y velocity  in ft/sec
165         @param w Z velocity in ft/sec */
166     void set_Velocities_Wind_Body( double u, double v, double w);
167     //@}
168
169     /** Euler Angle Parameter Set
170         @param phi roll angle in radians
171         @param theta pitch angle in radians
172         @param psi heading angle in radians */
173     void set_Euler_Angles( double phi, double theta, double psi );
174
175     /// @name Flight Path Parameter Set
176     //@{
177     /** Sets rate of climb
178         @param roc Rate of climb in ft/sec */
179     void set_Climb_Rate( double roc);
180
181     /** Sets the flight path angle in radians
182         @param gamma flight path angle in radians. */
183     void set_Gamma_vert_rad( double gamma);
184     //@}
185
186
187     /// @name Atmospheric Parameter Set
188     //@{
189     /** Sets the atmospheric static pressure
190         @param p pressure in psf */
191 //     void set_Static_pressure(double p);
192
193     /** Sets the atmospheric temperature
194         @param T temperature in degrees rankine */
195 //     void set_Static_temperature(double T);
196
197     /** Sets the atmospheric density.
198         @param rho air density slugs/cubic foot */
199 //     void set_Density(double rho);
200
201     /** Sets the velocity of the local airmass for wind modeling.
202         @param wnorth velocity north in fps
203         @param weast velocity east in fps
204         @param wdown velocity down in fps*/
205     /// @name Position Parameter Update
206     //@{
207
208
209     /** Update the position based on inputs, positions, velocities, etc.
210         @param dt delta time in seconds. */
211     void update(double dt);
212     bool ToggleDataLogging(bool state);
213     bool ToggleDataLogging(void);
214     void do_trim(void);
215     void update_ic(void);
216
217     bool get_agl_ft(double t, const double pt[3], double alt_off,
218                     double contact[3], double normal[3], double vel[3],
219                     double angularVel[3], double *agl);
220 private:
221     JSBSim::FGFDMExec *fdmex;
222     JSBSim::FGInitialCondition *fgic;
223     bool needTrim;
224
225     JSBSim::FGAtmosphere*   Atmosphere;
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;
233     JSBSim::FGGroundReactions* GroundReactions;
234     JSBSim::FGInertial*     Inertial;
235
236     int runcount;
237     double trim_elev;
238     double trim_throttle;
239
240     SGPropertyNode_ptr startup_trim;
241     SGPropertyNode_ptr trimmed;
242     SGPropertyNode_ptr pitch_trim;
243     SGPropertyNode_ptr throttle_trim;
244     SGPropertyNode_ptr aileron_trim;
245     SGPropertyNode_ptr rudder_trim;
246     SGPropertyNode_ptr stall_warning;
247
248     /* SGPropertyNode_ptr elevator_pos_deg;
249     SGPropertyNode_ptr left_aileron_pos_deg;
250     SGPropertyNode_ptr right_aileron_pos_deg;
251     SGPropertyNode_ptr rudder_pos_deg;
252     SGPropertyNode_ptr flap_pos_deg; */
253
254
255     SGPropertyNode_ptr elevator_pos_pct;
256     SGPropertyNode_ptr left_aileron_pos_pct;
257     SGPropertyNode_ptr right_aileron_pos_pct;
258     SGPropertyNode_ptr rudder_pos_pct;
259     SGPropertyNode_ptr flap_pos_pct;
260     SGPropertyNode_ptr speedbrake_pos_pct;
261     SGPropertyNode_ptr spoilers_pos_pct;
262
263     SGPropertyNode_ptr ab_brake_engaged;
264     SGPropertyNode_ptr ab_brake_left_pct;
265     SGPropertyNode_ptr ab_brake_right_pct;
266     
267     SGPropertyNode_ptr gear_pos_pct;
268     SGPropertyNode_ptr wing_fold_pos_pct;
269     SGPropertyNode_ptr tailhook_pos_pct;
270
271     SGPropertyNode_ptr temperature;
272     SGPropertyNode_ptr pressure;
273     SGPropertyNode_ptr density;
274     SGPropertyNode_ptr turbulence_gain;
275     SGPropertyNode_ptr turbulence_rate;
276
277     SGPropertyNode_ptr wind_from_north;
278     SGPropertyNode_ptr wind_from_east;
279     SGPropertyNode_ptr wind_from_down;
280
281     SGPropertyNode_ptr slaved;
282
283     double last_hook_tip[3];
284     double last_hook_root[3];
285     JSBSim::FGColumnVector3 hook_root_struct;
286     double hook_length;
287     bool got_wire;
288
289     bool crashed;
290
291     void init_gear(void);
292     void update_gear(void);
293
294     void update_external_forces(double t_off);
295 };
296
297
298 #endif // _JSBSIM_HXX
299
300