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 #define METERS_TO_FEET 3.2808398950
50 #define RADTODEG 57.2957795
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56 #include <simgear/misc/props.hxx>
58 #include <FDM/JSBSim/FGFDMExec.h>
73 class FGInitialCondition;
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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)
91 @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
98 class FGJSBsim: public FGInterface {
102 FGJSBsim( double dt );
106 /// copy FDM state to LaRCsim structures
107 bool copy_to_JSBsim();
109 /// copy FDM state from LaRCsim structures
110 bool copy_from_JSBsim();
112 /// Reset flight params to a specific position
115 /// @name Position Parameter Set
117 /** Set geocentric latitude
118 @param lat latitude in radians measured from the 0 meridian where
119 the westerly direction is positive and east is negative */
120 void set_Latitude(double lat); // geocentric
123 @param lon longitude in radians measured from the equator where
124 the northerly direction is positive and south is negative */
125 void set_Longitude(double lon);
128 Note: this triggers a recalculation of AGL altitude
129 @param alt altitude in feet */
130 void set_Altitude(double alt); // triggers re-calc of AGL altitude
133 //void set_AltitudeAGL(double altagl); // and vice-versa
135 /// @name Velocity Parameter Set
137 /** Sets calibrated airspeed
138 Setting this will trigger a recalc of the other velocity terms.
139 @param vc Calibrated airspeed in ft/sec */
140 void set_V_calibrated_kts(double vc);
142 /** Sets Mach number.
143 Setting this will trigger a recalc of the other velocity terms.
144 @param mach Mach number */
145 void set_Mach_number(double mach);
147 /** Sets velocity in N-E-D coordinates.
148 Setting this will trigger a recalc of the other velocity terms.
149 @param north velocity northward in ft/sec
150 @param east velocity eastward in ft/sec
151 @param down velocity downward in ft/sec */
152 void set_Velocities_Local( double north, double east, double down );
154 /** Sets aircraft velocity in stability frame.
155 Setting this will trigger a recalc of the other velocity terms.
156 @param u X velocity in ft/sec
157 @param v Y velocity in ft/sec
158 @param w Z velocity in ft/sec */
159 void set_Velocities_Wind_Body( double u, double v, double w);
162 /** Euler Angle Parameter Set
163 @param phi roll angle in radians
164 @param theta pitch angle in radians
165 @param psi heading angle in radians */
166 void set_Euler_Angles( double phi, double theta, double psi );
168 /// @name Flight Path Parameter Set
170 /** Sets rate of climb
171 @param roc Rate of climb in ft/sec */
172 void set_Climb_Rate( double roc);
174 /** Sets the flight path angle in radians
175 @param gamma flight path angle in radians. */
176 void set_Gamma_vert_rad( double gamma);
180 /// @name Atmospheric Parameter Set
182 /** Sets the atmospheric static pressure
183 @param p pressure in psf */
184 void set_Static_pressure(double p);
186 /** Sets the atmospheric temperature
187 @param T temperature in degrees rankine */
188 void set_Static_temperature(double T);
190 /** Sets the atmospheric density.
191 @param rho air density slugs/cubic foot */
192 void set_Density(double rho);
194 /** Sets the velocity of the local airmass for wind modeling.
195 @param wnorth velocity north in fps
196 @param weast velocity east in fps
197 @param wdown velocity down in fps*/
198 void set_Velocities_Local_Airmass (double wnorth,
201 /// @name Position Parameter Update
205 /** Update the position based on inputs, positions, velocities, etc.
206 @param multiloop number of times to loop through the FDM
207 @return true if successful */
208 void update( int multiloop );
209 bool ToggleDataLogging(bool state);
210 bool ToggleDataLogging(void);
212 void update_ic(void);
216 FGInitialCondition *fgic;
220 FGAtmosphere* Atmosphere;
222 FGPropulsion* Propulsion;
223 FGMassBalance* MassBalance;
224 FGAircraft* Aircraft;
225 FGTranslation* Translation;
226 FGRotation* Rotation;
227 FGPosition* Position;
228 FGAuxiliary* Auxiliary;
229 FGAerodynamics* Aerodynamics;
230 FGGroundReactions *GroundReactions;
236 SGPropertyNode *startup_trim;
237 SGPropertyNode *trimmed;
238 SGPropertyNode *pitch_trim;
239 SGPropertyNode *throttle_trim;
240 SGPropertyNode *aileron_trim;
241 SGPropertyNode *rudder_trim;
242 SGPropertyNode *stall_warning;
244 /* SGPropertyNode *elevator_pos_deg;
245 SGPropertyNode *left_aileron_pos_deg;
246 SGPropertyNode *right_aileron_pos_deg;
247 SGPropertyNode *rudder_pos_deg;
248 SGPropertyNode *flap_pos_deg; */
251 SGPropertyNode *elevator_pos_pct;
252 SGPropertyNode *left_aileron_pos_pct;
253 SGPropertyNode *right_aileron_pos_pct;
254 SGPropertyNode *rudder_pos_pct;
255 SGPropertyNode *flap_pos_pct;
257 SGPropertyNode *gear_pos_pct;
259 void init_gear(void);
260 void update_gear(void);
265 #endif // _JSBSIM_HXX