]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim.hxx
Fixes to vor/ils/adf range pickup.
[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 #include <FDM/JSBSim/FGFDMExec.h>
41 #include <FDM/JSBSim/FGInitialCondition.h>
42 #undef MAX_ENGINES
43 #include <Aircraft/aircraft.hxx>
44
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 DEFINITIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 #define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 FORWARD DECLARATIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /** FGFS / JSBSim interface (aka "The Bus").
64     This class provides for an interface between FlightGear and its data
65     structures and JSBSim and its data structures. This is the class which is
66     used to command JSBSim when integrated with FlightGear. See the
67     documentation for main for direction on running JSBSim apart from FlightGear.
68     @author Curtis L. Olson (original)
69     @author Tony Peden (Maintained and refined)
70     @version $Id$
71     @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
72 */
73
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 CLASS DECLARATION
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78 class FGJSBsim: public FGInterface {
79
80 public:
81     /// Constructor
82     FGJSBsim::FGJSBsim( double dt );
83     /// Destructor
84     FGJSBsim::~FGJSBsim();
85
86     /// copy FDM state to LaRCsim structures
87     bool copy_to_JSBsim();
88
89     /// copy FDM state from LaRCsim structures
90     bool copy_from_JSBsim();
91
92     /// Reset flight params to a specific position
93     void init();
94
95     /// @name Position Parameter Set
96     //@{
97     /** Set geocentric latitude
98         @param lat latitude in radians measured from the 0 meridian where
99                          the westerly direction is positive and east is negative */
100     void set_Latitude(double lat);  // geocentric
101
102     /** Set longitude
103         @param lon longitude in radians measured from the equator where
104                          the northerly direction is positive and south is negative */
105     void set_Longitude(double lon);
106
107     /** Set altitude
108         Note: this triggers a recalculation of AGL altitude
109               @param alt altitude in feet */
110     void set_Altitude(double alt);        // triggers re-calc of AGL altitude
111     //@}
112
113     //void set_AltitudeAGL(double altagl); // and vice-versa
114
115     /// @name Velocity Parameter Set
116     //@{
117     /** Sets calibrated airspeed
118         Setting this will trigger a recalc of the other velocity terms.
119               @param vc Calibrated airspeed in ft/sec */
120     void set_V_calibrated_kts(double vc);
121
122     /** Sets Mach number.
123         Setting this will trigger a recalc of the other velocity terms.
124               @param mach Mach number */
125     void set_Mach_number(double mach);
126
127     /** Sets velocity in N-E-D coordinates.
128         Setting this will trigger a recalc of the other velocity terms.
129               @param north velocity northward in ft/sec
130               @param east velocity eastward in ft/sec
131               @param down velocity downward in ft/sec */
132     void set_Velocities_Local( double north, double east, double down );
133
134     /** Sets aircraft velocity in stability frame.
135         Setting this will trigger a recalc of the other velocity terms.
136               @param u X velocity in ft/sec
137               @param v Y velocity  in ft/sec
138               @param w Z velocity in ft/sec */
139     void set_Velocities_Wind_Body( double u, double v, double w);
140     //@}
141
142     /** Euler Angle Parameter Set
143         @param phi roll angle in radians
144               @param theta pitch angle in radians
145               @param psi heading angle in radians */
146     void set_Euler_Angles( double phi, double theta, double psi );
147
148     /// @name Flight Path Parameter Set
149     //@{
150     /** Sets rate of climb
151         @param roc Rate of climb in ft/sec */
152     void set_Climb_Rate( double roc);
153
154     /** Sets the flight path angle in radians
155         @param gamma flight path angle in radians. */
156     void set_Gamma_vert_rad( double gamma);
157     //@}
158
159     /// @name Earth Parameter Set
160     //@{
161     /** Sets the sea level radius in feet.
162         @param slr Sea Level Radius in feet */
163     void set_Sea_level_radius(double slr);
164
165     /** Sets the runway altitude in feet above sea level.
166         @param ralt Runway altitude in feet above sea level. */
167     void set_Runway_altitude(double ralt);
168     //@}
169
170     /// @name Atmospheric Parameter Set
171     //@{
172     /** Sets the atmospheric static pressure
173         @param p pressure in psf */
174     void set_Static_pressure(double p);
175
176     /** Sets the atmospheric temperature
177         @param T temperature in degrees rankine */
178     void set_Static_temperature(double T);
179
180     /** Sets the atmospheric density.
181         @param rho air density slugs/cubic foot */
182     void set_Density(double rho);
183
184     /** Sets the velocity of the local airmass for wind modeling.
185         @param wnorth velocity north in fps
186         @param weast velocity east in fps
187         @param wdown velocity down in fps*/
188     void set_Velocities_Local_Airmass (double wnorth,
189                                        double weast,
190                                        double wdown );
191     //@}
192
193     /** Update the position based on inputs, positions, velocities, etc.
194         @param multiloop number of times to loop through the FDM
195               @return true if successful */
196     bool update( int multiloop );
197
198 private:
199     FGFDMExec *fdmex;
200     FGInitialCondition *fgic;
201     bool needTrim;
202
203     int runcount;
204     bool trimmed;
205     float trim_elev;
206     float trim_throttle;
207     
208     void snap_shot(void);
209 };
210
211
212 #endif // _JSBSIM_HXX
213
214