]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim.hxx
b) FDM - ada.cxx, ada.hxx have been updated with the faux, daux and iaux arrays that...
[flightgear.git] / src / FDM / 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 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  General Public License for more details.
19
20  You should have received a copy of the GNU 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 <Aircraft/aircraft.hxx>
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 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 #include <simgear/misc/props.hxx>
54
55 #include <FDM/JSBSim/FGFDMExec.h>
56
57 class FGState;
58 class FGAtmosphere;
59 class FGFCS;
60 class FGPropulsion;
61 class FGMassBalance;
62 class FGAerodynamics;
63 class FGInertial;
64 class FGAircraft;
65 class FGTranslation;
66 class FGRotation;
67 class FGPosition;
68 class FGAuxiliary;
69 class FGOutput;
70 class FGInitialCondition;
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 CLASS DOCUMENTATION
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79
80 /** FGFS / JSBSim interface (aka "The Bus").
81     This class provides for an interface between FlightGear and its data
82     structures and JSBSim and its data structures. This is the class which is
83     used to command JSBSim when integrated with FlightGear. See the
84     documentation for main for direction on running JSBSim apart from FlightGear.
85     @author Curtis L. Olson (original)
86     @author Tony Peden (Maintained and refined)
87     @version $Id$
88     @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
89 */
90
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 CLASS DECLARATION
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
94
95 class FGJSBsim: public FGInterface {
96
97 public:
98     /// Constructor
99     FGJSBsim::FGJSBsim( double dt );
100     /// Destructor
101     FGJSBsim::~FGJSBsim();
102
103     /// copy FDM state to LaRCsim structures
104     bool copy_to_JSBsim();
105
106     /// copy FDM state from LaRCsim structures
107     bool copy_from_JSBsim();
108
109     /// Reset flight params to a specific position
110     void init();
111
112     /// @name Position Parameter Set
113     //@{
114     /** Set geocentric latitude
115         @param lat latitude in radians measured from the 0 meridian where
116                          the westerly direction is positive and east is negative */
117     void set_Latitude(double lat);  // geocentric
118
119     /** Set longitude
120         @param lon longitude in radians measured from the equator where
121                          the northerly direction is positive and south is negative */
122     void set_Longitude(double lon);
123
124     /** Set altitude
125         Note: this triggers a recalculation of AGL altitude
126               @param alt altitude in feet */
127     void set_Altitude(double alt);        // triggers re-calc of AGL altitude
128     //@}
129
130     //void set_AltitudeAGL(double altagl); // and vice-versa
131
132     /// @name Velocity Parameter Set
133     //@{
134     /** Sets calibrated airspeed
135         Setting this will trigger a recalc of the other velocity terms.
136               @param vc Calibrated airspeed in ft/sec */
137     void set_V_calibrated_kts(double vc);
138
139     /** Sets Mach number.
140         Setting this will trigger a recalc of the other velocity terms.
141               @param mach Mach number */
142     void set_Mach_number(double mach);
143
144     /** Sets velocity in N-E-D coordinates.
145         Setting this will trigger a recalc of the other velocity terms.
146               @param north velocity northward in ft/sec
147               @param east velocity eastward in ft/sec
148               @param down velocity downward in ft/sec */
149     void set_Velocities_Local( double north, double east, double down );
150
151     /** Sets aircraft velocity in stability frame.
152         Setting this will trigger a recalc of the other velocity terms.
153               @param u X velocity in ft/sec
154               @param v Y velocity  in ft/sec
155               @param w Z velocity in ft/sec */
156     void set_Velocities_Wind_Body( double u, double v, double w);
157     //@}
158
159     /** Euler Angle Parameter Set
160         @param phi roll angle in radians
161               @param theta pitch angle in radians
162               @param psi heading angle in radians */
163     void set_Euler_Angles( double phi, double theta, double psi );
164
165     /// @name Flight Path Parameter Set
166     //@{
167     /** Sets rate of climb
168         @param roc Rate of climb in ft/sec */
169     void set_Climb_Rate( double roc);
170
171     /** Sets the flight path angle in radians
172         @param gamma flight path angle in radians. */
173     void set_Gamma_vert_rad( double gamma);
174     //@}
175
176     /// @name Earth Parameter Set
177     //@{
178     /** Sets the sea level radius in feet.
179         @param slr Sea Level Radius in feet */
180     void set_Sea_level_radius(double slr);
181
182     /** Sets the runway altitude in feet above sea level.
183         @param ralt Runway altitude in feet above sea level. */
184     void set_Runway_altitude(double ralt);
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     void set_Velocities_Local_Airmass (double wnorth,
206                                        double weast,
207                                        double wdown );
208     //@}
209
210     /** Update the position based on inputs, positions, velocities, etc.
211         @param multiloop number of times to loop through the FDM
212               @return true if successful */
213     bool update( int multiloop );
214     bool ToggleDataLogging(bool state);
215     bool ToggleDataLogging(void);
216
217 private:
218     FGFDMExec *fdmex;
219     FGInitialCondition *fgic;
220     bool needTrim;
221
222     FGState*        State;
223     FGAtmosphere*   Atmosphere;
224     FGFCS*          FCS;
225     FGPropulsion*   Propulsion;
226     FGMassBalance*  MassBalance;
227     FGAircraft*     Aircraft;
228     FGTranslation*  Translation;
229     FGRotation*     Rotation;
230     FGPosition*     Position;
231     FGAuxiliary*    Auxiliary;
232     FGAerodynamics* Aerodynamics;
233
234     int runcount;
235     float trim_elev;
236     float trim_throttle;
237     
238     SGPropertyNode *startup_trim;
239     SGPropertyNode *trimmed;
240     SGPropertyNode *pitch_trim;
241     SGPropertyNode *throttle_trim;
242     SGPropertyNode *aileron_trim;
243     SGPropertyNode *rudder_trim;
244     
245     void snap_shot(void);
246 };
247
248
249 #endif // _JSBSIM_HXX
250
251