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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 #include <FDM/JSBSim/FGFDMExec.h>
41 #include <FDM/JSBSim/FGInitialCondition.h>
43 #include <Aircraft/aircraft.hxx>
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 #define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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)
71 @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78 class FGJSBsim: public FGInterface {
82 FGJSBsim::FGJSBsim( double dt );
84 FGJSBsim::~FGJSBsim();
86 /// copy FDM state to LaRCsim structures
87 bool copy_to_JSBsim();
89 /// copy FDM state from LaRCsim structures
90 bool copy_from_JSBsim();
92 /// Reset flight params to a specific position
95 /// @name Position Parameter Set
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
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);
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
113 //void set_AltitudeAGL(double altagl); // and vice-versa
115 /// @name Velocity Parameter Set
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);
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);
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 );
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);
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 );
148 /// @name Flight Path Parameter Set
150 /** Sets rate of climb
151 @param roc Rate of climb in ft/sec */
152 void set_Climb_Rate( double roc);
154 /** Sets the flight path angle in radians
155 @param gamma flight path angle in radians. */
156 void set_Gamma_vert_rad( double gamma);
159 /// @name Earth Parameter Set
161 /** Sets the sea level radius in feet.
162 @param slr Sea Level Radius in feet */
163 void set_Sea_level_radius(double slr);
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);
170 /// @name Atmospheric Parameter Set
172 /** Sets the atmospheric static pressure
173 @param p pressure in psf */
174 void set_Static_pressure(double p);
176 /** Sets the atmospheric temperature
177 @param T temperature in degrees rankine */
178 void set_Static_temperature(double T);
180 /** Sets the atmospheric density.
181 @param rho air density slugs/cubic foot */
182 void set_Density(double rho);
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,
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 bool ToggleDataLogging(bool state);
198 bool ToggleDataLogging(void);
202 FGInitialCondition *fgic;
211 void snap_shot(void);
215 #endif // _JSBSIM_HXX