]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/JSBSim.hxx
04a10b29934c7e481ec84d21a2dbc656a890bb87
[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 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 #define METERS_TO_FEET 3.2808398950
50 #define RADTODEG 57.2957795
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 #include <simgear/misc/props.hxx>
57
58 #include <FDM/JSBSim/FGFDMExec.h>
59
60 namespace JSBSim {
61 class FGState;
62 class FGAtmosphere;
63 class FGFCS;
64 class FGPropulsion;
65 class FGMassBalance;
66 class FGAerodynamics;
67 class FGInertial;
68 class FGAircraft;
69 class FGTranslation;
70 class FGRotation;
71 class FGPosition;
72 class FGAuxiliary;
73 class FGOutput;
74 class FGInitialCondition;
75 }
76
77 using namespace JSBSim;
78
79 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
82
83 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 CLASS DOCUMENTATION
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
86
87 /** FGFS / JSBSim interface (aka "The Bus").
88     This class provides for an interface between FlightGear and its data
89     structures and JSBSim and its data structures. This is the class which is
90     used to command JSBSim when integrated with FlightGear. See the
91     documentation for main for direction on running JSBSim apart from FlightGear.
92     @author Curtis L. Olson (original)
93     @author Tony Peden (Maintained and refined)
94     @version $Id$
95     @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
96     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/JSBSim.hxx?rev=HEAD&content-type=text/vnd.viewcvs-markup">
97          Header File </a>
98     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/JSBSim.cxx?rev=HEAD&content-type=text/vnd.viewcvs-markup">
99          Source File </a>
100 */
101
102 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 CLASS DECLARATION
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
105
106 class FGJSBsim: public FGInterface {
107
108 public:
109     /// Constructor
110     FGJSBsim( double dt );
111     /// Destructor
112     ~FGJSBsim();
113
114     /// copy FDM state to LaRCsim structures
115     bool copy_to_JSBsim();
116
117     /// copy FDM state from LaRCsim structures
118     bool copy_from_JSBsim();
119
120     /// Reset flight params to a specific position
121     void init();
122
123     /// @name Position Parameter Set
124     //@{
125     /** Set geocentric latitude
126         @param lat latitude in radians measured from the 0 meridian where
127                          the westerly direction is positive and east is negative */
128     void set_Latitude(double lat);  // geocentric
129
130     /** Set longitude
131         @param lon longitude in radians measured from the equator where
132                          the northerly direction is positive and south is negative */
133     void set_Longitude(double lon);
134
135     /** Set altitude
136         Note: this triggers a recalculation of AGL altitude
137               @param alt altitude in feet */
138     void set_Altitude(double alt);        // triggers re-calc of AGL altitude
139     //@}
140
141     //void set_AltitudeAGL(double altagl); // and vice-versa
142
143     /// @name Velocity Parameter Set
144     //@{
145     /** Sets calibrated airspeed
146         Setting this will trigger a recalc of the other velocity terms.
147               @param vc Calibrated airspeed in ft/sec */
148     void set_V_calibrated_kts(double vc);
149
150     /** Sets Mach number.
151         Setting this will trigger a recalc of the other velocity terms.
152               @param mach Mach number */
153     void set_Mach_number(double mach);
154
155     /** Sets velocity in N-E-D coordinates.
156         Setting this will trigger a recalc of the other velocity terms.
157               @param north velocity northward in ft/sec
158               @param east velocity eastward in ft/sec
159               @param down velocity downward in ft/sec */
160     void set_Velocities_Local( double north, double east, double down );
161
162     /** Sets aircraft velocity in stability frame.
163         Setting this will trigger a recalc of the other velocity terms.
164               @param u X velocity in ft/sec
165               @param v Y velocity  in ft/sec
166               @param w Z velocity in ft/sec */
167     void set_Velocities_Wind_Body( double u, double v, double w);
168     //@}
169
170     /** Euler Angle Parameter Set
171         @param phi roll angle in radians
172               @param theta pitch angle in radians
173               @param psi heading angle in radians */
174     void set_Euler_Angles( double phi, double theta, double psi );
175
176     /// @name Flight Path Parameter Set
177     //@{
178     /** Sets rate of climb
179         @param roc Rate of climb in ft/sec */
180     void set_Climb_Rate( double roc);
181
182     /** Sets the flight path angle in radians
183         @param gamma flight path angle in radians. */
184     void set_Gamma_vert_rad( double gamma);
185     //@}
186
187
188     /// @name Atmospheric Parameter Set
189     //@{
190     /** Sets the atmospheric static pressure
191         @param p pressure in psf */
192 //     void set_Static_pressure(double p);
193
194     /** Sets the atmospheric temperature
195         @param T temperature in degrees rankine */
196 //     void set_Static_temperature(double T);
197
198     /** Sets the atmospheric density.
199         @param rho air density slugs/cubic foot */
200 //     void set_Density(double rho);
201
202     /** Sets the velocity of the local airmass for wind modeling.
203         @param wnorth velocity north in fps
204         @param weast velocity east in fps
205         @param wdown velocity down in fps*/
206     /// @name Position Parameter Update
207     //@{
208
209
210     /** Update the position based on inputs, positions, velocities, etc.
211         @param dt delta time in seconds. */
212     void update(double dt);
213     bool ToggleDataLogging(bool state);
214     bool ToggleDataLogging(void);
215     void do_trim(void);
216     void update_ic(void);
217
218 private:
219     FGFDMExec *fdmex;
220     FGInitialCondition *fgic;
221     bool needTrim;
222
223     FGState*        State;
224     FGAtmosphere*   Atmosphere;
225     FGFCS*          FCS;
226     FGPropulsion*   Propulsion;
227     FGMassBalance*  MassBalance;
228     FGAircraft*     Aircraft;
229     FGTranslation*  Translation;
230     FGRotation*     Rotation;
231     FGPosition*     Position;
232     FGAuxiliary*    Auxiliary;
233     FGAerodynamics* Aerodynamics;
234     FGGroundReactions *GroundReactions;
235
236     int runcount;
237     float trim_elev;
238     float trim_throttle;
239     
240     SGPropertyNode *startup_trim;
241     SGPropertyNode *trimmed;
242     SGPropertyNode *pitch_trim;
243     SGPropertyNode *throttle_trim;
244     SGPropertyNode *aileron_trim;
245     SGPropertyNode *rudder_trim;
246     SGPropertyNode *stall_warning;
247     
248     /* SGPropertyNode *elevator_pos_deg;
249     SGPropertyNode *left_aileron_pos_deg;
250     SGPropertyNode *right_aileron_pos_deg;
251     SGPropertyNode *rudder_pos_deg;
252     SGPropertyNode *flap_pos_deg; */
253
254     
255     SGPropertyNode *elevator_pos_pct;
256     SGPropertyNode *left_aileron_pos_pct;
257     SGPropertyNode *right_aileron_pos_pct;
258     SGPropertyNode *rudder_pos_pct;
259     SGPropertyNode *flap_pos_pct;
260     SGPropertyNode *speedbrake_pos_pct;
261     SGPropertyNode *spoilers_pos_pct;
262     
263     SGPropertyNode *gear_pos_pct;
264     
265     SGPropertyNode *temperature;
266     SGPropertyNode *pressure;
267     SGPropertyNode *density;
268     SGPropertyNode *turbulence;
269     
270     SGPropertyNode *wind_from_north;
271     SGPropertyNode *wind_from_east;
272     SGPropertyNode *wind_from_down;
273     
274     void init_gear(void);
275     void update_gear(void);
276     
277 };
278
279
280 #endif // _JSBSIM_HXX
281
282