1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 Author: Curtis L. Olson
5 Maintained by: Tony Peden, Curt Olson
6 Date started: 02/01/1999
8 ------ Copyright (C) 1999 - 2000 Curtis L. Olson (curt@flightgear.org) ------
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.
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.
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.
25 --------------------------------------------------------------------------------
26 02/01/1999 CLO Created
27 Additional log messages stored in CVS
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 #include <Aircraft/aircraft.hxx>
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 #include <simgear/misc/props.hxx>
55 #include <FDM/JSBSim/FGFDMExec.h>
70 class FGInitialCondition;
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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)
88 @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95 class FGJSBsim: public FGInterface {
99 FGJSBsim::FGJSBsim( double dt );
101 FGJSBsim::~FGJSBsim();
103 /// copy FDM state to LaRCsim structures
104 bool copy_to_JSBsim();
106 /// copy FDM state from LaRCsim structures
107 bool copy_from_JSBsim();
109 /// Reset flight params to a specific position
112 /// @name Position Parameter Set
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
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);
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
130 //void set_AltitudeAGL(double altagl); // and vice-versa
132 /// @name Velocity Parameter Set
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);
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);
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 );
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);
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 );
165 /// @name Flight Path Parameter Set
167 /** Sets rate of climb
168 @param roc Rate of climb in ft/sec */
169 void set_Climb_Rate( double roc);
171 /** Sets the flight path angle in radians
172 @param gamma flight path angle in radians. */
173 void set_Gamma_vert_rad( double gamma);
176 /// @name Earth Parameter Set
178 /** Sets the sea level radius in feet.
179 @param slr Sea Level Radius in feet */
180 void set_Sea_level_radius(double slr);
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);
187 /// @name Atmospheric Parameter Set
189 /** Sets the atmospheric static pressure
190 @param p pressure in psf */
191 void set_Static_pressure(double p);
193 /** Sets the atmospheric temperature
194 @param T temperature in degrees rankine */
195 void set_Static_temperature(double T);
197 /** Sets the atmospheric density.
198 @param rho air density slugs/cubic foot */
199 void set_Density(double rho);
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,
208 /// @name Position Parameter Update
210 /** Update geocentric latitude
211 @param lat latitude in radians measured from the 0 meridian where
212 the westerly direction is positive and east is negative */
213 void update_Latitude(double lat); // geocentric
216 @param lon longitude in radians measured from the equator where
217 the northerly direction is positive and south is negative */
218 void update_Longitude(double lon);
221 Note: this triggers a recalculation of AGL altitude
222 @param alt altitude in feet */
223 void update_Altitude(double alt); // triggers re-calc of AGL altitude
226 //void update_AltitudeAGL(double altagl); // and vice-versa
228 /// @name Velocity Parameter Update
230 /** Updates calibrated airspeed
231 Updateting this will trigger a recalc of the other velocity terms.
232 @param vc Calibrated airspeed in ft/sec */
233 void update_V_calibrated_kts(double vc);
235 /** Updates Mach number.
236 Updateting this will trigger a recalc of the other velocity terms.
237 @param mach Mach number */
238 void update_Mach_number(double mach);
240 /** Updates velocity in N-E-D coordinates.
241 Updateting this will trigger a recalc of the other velocity terms.
242 @param north velocity northward in ft/sec
243 @param east velocity eastward in ft/sec
244 @param down velocity downward in ft/sec */
245 void update_Velocities_Local( double north, double east, double down );
247 /** Updates aircraft velocity in stability frame.
248 Updateting this will trigger a recalc of the other velocity terms.
249 @param u X velocity in ft/sec
250 @param v Y velocity in ft/sec
251 @param w Z velocity in ft/sec */
252 void update_Velocities_Wind_Body( double u, double v, double w);
255 /** Euler Angle Parameter Update
256 @param phi roll angle in radians
257 @param theta pitch angle in radians
258 @param psi heading angle in radians */
259 void update_Euler_Angles( double phi, double theta, double psi );
261 /// @name Flight Path Parameter Update
263 /** Updates rate of climb
264 @param roc Rate of climb in ft/sec */
265 void update_Climb_Rate( double roc);
267 /** Updates the flight path angle in radians
268 @param gamma flight path angle in radians. */
269 void update_Gamma_vert_rad( double gamma);
272 /// @name Earth Parameter Update
274 /** Updates the sea level radius in feet.
275 @param slr Sea Level Radius in feet */
276 void update_Sea_level_radius(double slr);
278 /** Updates the runway altitude in feet above sea level.
279 @param ralt Runway altitude in feet above sea level. */
280 void update_Runway_altitude(double ralt);
283 /// @name Atmospheric Parameter Update
285 /** Updates the atmospheric static pressure
286 @param p pressure in psf */
287 void update_Static_pressure(double p);
289 /** Updates the atmospheric temperature
290 @param T temperature in degrees rankine */
291 void update_Static_temperature(double T);
293 /** Updates the atmospheric density.
294 @param rho air density slugs/cubic foot */
295 void update_Density(double rho);
297 /** Updates the velocity of the local airmass for wind modeling.
298 @param wnorth velocity north in fps
299 @param weast velocity east in fps
300 @param wdown velocity down in fps*/
301 void update_Velocities_Local_Airmass (double wnorth,
306 /** Update the position based on inputs, positions, velocities, etc.
307 @param multiloop number of times to loop through the FDM
308 @return true if successful */
309 bool update( int multiloop );
310 bool ToggleDataLogging(bool state);
311 bool ToggleDataLogging(void);
315 FGInitialCondition *fgic;
319 FGAtmosphere* Atmosphere;
321 FGPropulsion* Propulsion;
322 FGMassBalance* MassBalance;
323 FGAircraft* Aircraft;
324 FGTranslation* Translation;
325 FGRotation* Rotation;
326 FGPosition* Position;
327 FGAuxiliary* Auxiliary;
328 FGAerodynamics* Aerodynamics;
334 SGPropertyNode *startup_trim;
335 SGPropertyNode *trimmed;
336 SGPropertyNode *pitch_trim;
337 SGPropertyNode *throttle_trim;
338 SGPropertyNode *aileron_trim;
339 SGPropertyNode *rudder_trim;
341 void snap_shot(void);
345 #endif // _JSBSIM_HXX