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