]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/JSBSim.hxx
remove unused files
[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
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 DEFINITIONS
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46 #define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
47
48 #define METERS_TO_FEET 3.2808398950
49 #define RADTODEG 57.2957795
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 FORWARD DECLARATIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 #include <simgear/props/props.hxx>
56
57 #include <FDM/JSBSim/FGFDMExec.h>
58
59 namespace JSBSim {
60 class FGAtmosphere;
61 class FGWinds;
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 class FGLocation;
73 class FGAccelerations;
74 }
75
76 // Adding it here will cause a namespace clash in FlightGear -EMH-
77 // using namespace JSBSim;
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: JSBSim.hxx,v 1.15 2010/10/07 03:45:40 jberndt Exp $
91     @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
92 */
93
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CLASS DECLARATION
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
98 class FGJSBsim: public FGInterface {
99
100 public:
101     /// Constructor
102     FGJSBsim( double dt );
103     /// Destructor
104     ~FGJSBsim();
105
106     /// copy FDM state to LaRCsim structures
107     bool copy_to_JSBsim();
108
109     /// copy FDM state from LaRCsim structures
110     bool copy_from_JSBsim();
111
112     /// Reset flight params to a specific position
113     void init();
114
115     /// Unbind properties
116     void unbind();
117
118     /// Suspend integration
119     void suspend();
120
121     /// Resume integration
122     void resume();
123
124     /// @name Position Parameter Set
125     //@{
126     /** Set geocentric latitude
127         @param lat latitude in radians measured from the 0 meridian where
128                    the westerly direction is positive and east is negative */
129     void set_Latitude(double lat);  // geocentric
130
131     /** Set longitude
132         @param lon longitude in radians measured from the equator where
133                    the northerly direction is positive and south is negative */
134     void set_Longitude(double lon);
135
136     /** Set altitude
137         Note: this triggers a recalculation of AGL altitude
138         @param alt altitude in feet */
139     void set_Altitude(double alt);        // triggers re-calc of AGL altitude
140     //@}
141
142     //void set_AltitudeAGL(double altagl); // and vice-versa
143
144     /// @name Velocity Parameter Set
145     //@{
146     /** Sets calibrated airspeed
147         Setting this will trigger a recalc of the other velocity terms.
148         @param vc Calibrated airspeed in ft/sec */
149     void set_V_calibrated_kts(double vc);
150
151     /** Sets Mach number.
152         Setting this will trigger a recalc of the other velocity terms.
153         @param mach Mach number */
154     void set_Mach_number(double mach);
155
156     /** Sets velocity in N-E-D coordinates.
157         Setting this will trigger a recalc of the other velocity terms.
158         @param north velocity northward in ft/sec
159         @param east velocity eastward in ft/sec
160         @param down velocity downward in ft/sec */
161     void set_Velocities_Local( double north, double east, double down );
162
163     /** Sets aircraft velocity in stability frame.
164         Setting this will trigger a recalc of the other velocity terms.
165         @param u X velocity in ft/sec
166         @param v Y velocity  in ft/sec
167         @param w Z velocity in ft/sec */
168     void set_Velocities_Wind_Body( double u, double v, double w);
169     //@}
170
171     /** Euler Angle Parameter Set
172         @param phi roll angle in radians
173         @param theta pitch angle in radians
174         @param psi heading angle in radians */
175     void set_Euler_Angles( double phi, double theta, double psi );
176
177     /// @name Flight Path Parameter Set
178     //@{
179     /** Sets rate of climb
180         @param roc Rate of climb in ft/sec */
181     void set_Climb_Rate( double roc);
182
183     /** Sets the flight path angle in radians
184         @param gamma flight path angle in radians. */
185     void set_Gamma_vert_rad( double gamma);
186     //@}
187
188
189     /// @name Atmospheric Parameter Set
190     //@{
191     /** Sets the atmospheric static pressure
192         @param p pressure in psf */
193 //     void set_Static_pressure(double p);
194
195     /** Sets the atmospheric temperature
196         @param T temperature in degrees rankine */
197 //     void set_Static_temperature(double T);
198
199     /** Sets the atmospheric density.
200         @param rho air density slugs/cubic foot */
201 //     void set_Density(double rho);
202
203     /** Sets the velocity of the local airmass for wind modeling.
204         @param wnorth velocity north in fps
205         @param weast velocity east in fps
206         @param wdown velocity down in fps*/
207     /// @name Position Parameter Update
208     //@{
209
210
211     /** Update the position based on inputs, positions, velocities, etc.
212         @param dt delta time in seconds. */
213     void update(double dt);
214
215     bool ToggleDataLogging(bool state);
216     bool ToggleDataLogging(void);
217
218     bool get_agl_ft(double t, const double pt[3], double alt_off,
219                     double contact[3], double normal[3], double vel[3],
220                     double angularVel[3], double *agl);
221 private:
222     JSBSim::FGFDMExec *fdmex;
223     JSBSim::FGInitialCondition *fgic;
224     bool needTrim;
225
226     JSBSim::FGAtmosphere*      Atmosphere;
227     JSBSim::FGWinds*           Winds;
228     JSBSim::FGFCS*             FCS;
229     JSBSim::FGPropulsion*      Propulsion;
230     JSBSim::FGMassBalance*     MassBalance;
231     JSBSim::FGAircraft*        Aircraft;
232     JSBSim::FGPropagate*       Propagate;
233     JSBSim::FGAuxiliary*       Auxiliary;
234     JSBSim::FGAerodynamics*    Aerodynamics;
235     JSBSim::FGGroundReactions* GroundReactions;
236     JSBSim::FGInertial*        Inertial;
237     JSBSim::FGAccelerations*   Accelerations;
238
239     int runcount;
240     double trim_elev;
241     double trim_throttle;
242
243     SGPropertyNode_ptr startup_trim;
244     SGPropertyNode_ptr trimmed;
245     SGPropertyNode_ptr pitch_trim;
246     SGPropertyNode_ptr throttle_trim;
247     SGPropertyNode_ptr aileron_trim;
248     SGPropertyNode_ptr rudder_trim;
249     SGPropertyNode_ptr stall_warning;
250
251     /* SGPropertyNode_ptr elevator_pos_deg;
252     SGPropertyNode_ptr left_aileron_pos_deg;
253     SGPropertyNode_ptr right_aileron_pos_deg;
254     SGPropertyNode_ptr rudder_pos_deg;
255     SGPropertyNode_ptr flap_pos_deg; */
256
257
258     SGPropertyNode_ptr elevator_pos_pct;
259     SGPropertyNode_ptr left_aileron_pos_pct;
260     SGPropertyNode_ptr right_aileron_pos_pct;
261     SGPropertyNode_ptr rudder_pos_pct;
262     SGPropertyNode_ptr flap_pos_pct;
263     SGPropertyNode_ptr speedbrake_pos_pct;
264     SGPropertyNode_ptr spoilers_pos_pct;
265
266     SGPropertyNode_ptr ab_brake_engaged;
267     SGPropertyNode_ptr ab_brake_left_pct;
268     SGPropertyNode_ptr ab_brake_right_pct;
269     
270     SGPropertyNode_ptr gear_pos_pct;
271     SGPropertyNode_ptr wing_fold_pos_pct;
272     SGPropertyNode_ptr tailhook_pos_pct;
273
274     SGPropertyNode_ptr temperature;
275     SGPropertyNode_ptr pressure;
276     SGPropertyNode_ptr pressureSL;
277     SGPropertyNode_ptr density;
278     SGPropertyNode_ptr ground_wind;
279     SGPropertyNode_ptr turbulence_gain;
280     SGPropertyNode_ptr turbulence_rate;
281     SGPropertyNode_ptr turbulence_model;
282
283     SGPropertyNode_ptr wind_from_north;
284     SGPropertyNode_ptr wind_from_east;
285     SGPropertyNode_ptr wind_from_down;
286
287     SGPropertyNode_ptr slaved;
288
289     static std::map<std::string,int> TURBULENCE_TYPE_NAMES;
290
291     double last_hook_tip[3];
292     double last_hook_root[3];
293     JSBSim::FGColumnVector3 hook_root_struct;
294     double hook_length;
295     bool got_wire;
296
297     bool crashed;
298
299     void do_trim(void);
300
301     double getMachFromVcas(double vcas);
302     bool update_ground_cache(JSBSim::FGLocation cart, double* cart_pos, double dt);
303     void init_gear(void);
304     void update_gear(void);
305
306     void update_external_forces(double t_off);
307 };
308
309
310 #endif // _JSBSIM_HXX
311
312