1 // JSBsim.cxx -- interface to the JSBsim flight model
3 // Written by Curtis Olson, started February 1999.
5 // Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <simgear/compiler.h>
26 #ifdef SG_MATH_EXCEPTION_CLASH
32 #include <simgear/constants.h>
33 #include <simgear/debug/logstream.hxx>
34 #include <simgear/math/sg_geodesy.hxx>
35 #include <simgear/misc/sg_path.hxx>
37 #include <Scenery/scenery.hxx>
39 #include <Aircraft/aircraft.hxx>
40 #include <Controls/controls.hxx>
41 #include <Main/globals.hxx>
42 #include <Main/fg_props.hxx>
44 #include <FDM/JSBSim/FGFDMExec.h>
45 #include <FDM/JSBSim/FGAircraft.h>
46 #include <FDM/JSBSim/FGFCS.h>
47 #include <FDM/JSBSim/FGPosition.h>
48 #include <FDM/JSBSim/FGRotation.h>
49 #include <FDM/JSBSim/FGState.h>
50 #include <FDM/JSBSim/FGTranslation.h>
51 #include <FDM/JSBSim/FGAuxiliary.h>
52 #include <FDM/JSBSim/FGDefs.h>
53 #include <FDM/JSBSim/FGInitialCondition.h>
54 #include <FDM/JSBSim/FGTrim.h>
55 #include <FDM/JSBSim/FGAtmosphere.h>
56 #include <FDM/JSBSim/FGMassBalance.h>
57 #include <FDM/JSBSim/FGAerodynamics.h>
60 /******************************************************************************/
62 FGJSBsim::FGJSBsim( double dt )
67 fdmex = new FGFDMExec;
69 State = fdmex->GetState();
70 Atmosphere = fdmex->GetAtmosphere();
71 FCS = fdmex->GetFCS();
72 MassBalance = fdmex->GetMassBalance();
73 Propulsion = fdmex->GetPropulsion();
74 Aircraft = fdmex->GetAircraft();
75 Translation = fdmex->GetTranslation();
76 Rotation = fdmex->GetRotation();
77 Position = fdmex->GetPosition();
78 Auxiliary = fdmex->GetAuxiliary();
79 Aerodynamics = fdmex->GetAerodynamics();
81 Atmosphere->UseInternal();
83 fgic=new FGInitialCondition(fdmex);
86 SGPath aircraft_path( globals->get_fg_root() );
87 aircraft_path.append( "Aircraft" );
89 SGPath engine_path( globals->get_fg_root() );
90 engine_path.append( "Engine" );
94 result = fdmex->LoadModel( aircraft_path.str(),
96 fgGetString("/sim/aircraft") );
99 SG_LOG( SG_FLIGHT, SG_INFO, " loaded aircraft.");
101 SG_LOG( SG_FLIGHT, SG_INFO,
102 " aircraft does not exist (you may have mis-typed the name).");
106 SG_LOG( SG_FLIGHT, SG_INFO, "" );
107 SG_LOG( SG_FLIGHT, SG_INFO, "" );
108 SG_LOG( SG_FLIGHT, SG_INFO, "After loading aircraft definition file ..." );
110 int Neng = Propulsion->GetNumEngines();
111 SG_LOG( SG_FLIGHT, SG_INFO, "num engines = " << Neng );
112 for(int i=0;i<Neng;i++) {
113 add_engine( FGEngInterface() );
116 if ( fdmex->GetGroundReactions()->GetNumGearUnits() <= 0 ) {
117 SG_LOG( SG_FLIGHT, SG_ALERT, "num gear units = "
118 << fdmex->GetGroundReactions()->GetNumGearUnits() );
119 SG_LOG( SG_FLIGHT, SG_ALERT, "This is a very bad thing because with 0 gear units, the ground trimming");
120 SG_LOG( SG_FLIGHT, SG_ALERT, "routine (coming up later in the code) will core dump.");
121 SG_LOG( SG_FLIGHT, SG_ALERT, "Halting the sim now, and hoping a solution will present itself soon!");
126 fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
127 fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0));
128 fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
129 fgSetDouble("/fdm/trim/rudder", FCS->GetDrCmd());
131 startup_trim = fgGetNode("/sim/startup/trim", true);
133 trimmed = fgGetNode("/fdm/trim/trimmed", true);
134 trimmed->setBoolValue(false);
136 pitch_trim = fgGetNode("/fdm/trim/pitch-trim", true );
137 throttle_trim = fgGetNode("/fdm/trim/throttle", true );
138 aileron_trim = fgGetNode("/fdm/trim/aileron", true );
139 rudder_trim = fgGetNode("/fdm/trim/rudder", true );
142 /******************************************************************************/
143 FGJSBsim::~FGJSBsim(void) {
145 delete fdmex; fdmex=NULL;
146 delete fgic; fgic=NULL;
150 /******************************************************************************/
152 // Initialize the JSBsim flight model, dt is the time increment for
153 // each subsequent iteration through the EOM
155 void FGJSBsim::init() {
157 SG_LOG( SG_FLIGHT, SG_INFO, "Starting and initializing JSBsim" );
159 // Explicitly call the superclass's
160 // init method first.
163 fdmex->GetState()->Initialize(fgic);
164 fdmex->RunIC(fgic); //loop JSBSim once w/o integrating
165 // fdmex->Run(); //loop JSBSim once
166 copy_from_JSBsim(); //update the bus
168 SG_LOG( SG_FLIGHT, SG_INFO, " Initialized JSBSim with:" );
170 switch(fgic->GetSpeedSet()) {
172 SG_LOG(SG_FLIGHT,SG_INFO, " Vn,Ve,Vd= "
173 << Position->GetVn() << ", "
174 << Position->GetVe() << ", "
175 << Position->GetVd() << " ft/s");
178 SG_LOG(SG_FLIGHT,SG_INFO, " U,V,W= "
179 << Translation->GetUVW(1) << ", "
180 << Translation->GetUVW(2) << ", "
181 << Translation->GetUVW(3) << " ft/s");
184 SG_LOG(SG_FLIGHT,SG_INFO, " Mach: "
185 << Translation->GetMach() );
189 SG_LOG(SG_FLIGHT,SG_INFO, " Indicated Airspeed: "
190 << Auxiliary->GetVcalibratedKTS() << " knots" );
194 SG_LOG( SG_FLIGHT, SG_INFO, " Bank Angle: "
195 << Rotation->Getphi()*RADTODEG << " deg" );
196 SG_LOG( SG_FLIGHT, SG_INFO, " Pitch Angle: "
197 << Rotation->Gettht()*RADTODEG << " deg" );
198 SG_LOG( SG_FLIGHT, SG_INFO, " True Heading: "
199 << Rotation->Getpsi()*RADTODEG << " deg" );
200 SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: "
201 << Position->GetLatitude() << " deg" );
202 SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: "
203 << Position->GetLongitude() << " deg" );
204 SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: "
205 << Position->Geth() << " feet" );
206 SG_LOG( SG_FLIGHT, SG_INFO, " loaded initial conditions" );
208 SG_LOG( SG_FLIGHT, SG_INFO, " set dt" );
210 SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing JSBSim" );
213 /******************************************************************************/
215 // Run an iteration of the EOM (equations of motion)
217 bool FGJSBsim::update( int multiloop ) {
221 double save_alt = 0.0;
225 trimmed->setBoolValue(false);
227 if ( needTrim && startup_trim->getBoolValue() ) {
228 cout << "num gear units = " << fdmex->GetGroundReactions()->GetNumGearUnits() << endl;
229 //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
230 //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
233 if(fgic->GetVcalibratedKtsIC() < 10 ) {
234 fgic->SetVcalibratedKtsIC(0.0);
235 fgtrim=new FGTrim(fdmex,fgic,tGround);
237 fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
239 if(!fgtrim->DoTrim()) {
243 trimmed->setBoolValue(true);
245 fgtrim->ReportState();
250 pitch_trim->setDoubleValue( FCS->GetPitchTrimCmd() );
251 throttle_trim->setDoubleValue( FCS->GetThrottleCmd(0) );
252 aileron_trim->setDoubleValue( FCS->GetDaCmd() );
253 rudder_trim->setDoubleValue( FCS->GetDrCmd() );
255 globals->get_controls()->set_elevator_trim(FCS->GetPitchTrimCmd());
256 globals->get_controls()->set_elevator(FCS->GetDeCmd());
257 globals->get_controls()->set_throttle(FGControls::ALL_ENGINES,
258 FCS->GetThrottleCmd(0));
260 globals->get_controls()->set_aileron(FCS->GetDaCmd());
261 globals->get_controls()->set_rudder( FCS->GetDrCmd());
263 SG_LOG( SG_FLIGHT, SG_INFO, " Trim complete" );
266 for( i=0; i<get_num_engines(); i++ ) {
267 FGEngInterface * e = get_engine(i);
268 FGEngine * eng = Propulsion->GetEngine(i);
269 FGThruster * thrust = Propulsion->GetThruster(i);
270 eng->SetMagnetos( globals->get_controls()->get_magnetos(i) );
271 eng->SetStarter( globals->get_controls()->get_starter(i) );
272 e->set_Manifold_Pressure( eng->getManifoldPressure_inHg() );
273 e->set_RPM( thrust->GetRPM() );
274 e->set_EGT( eng->getExhaustGasTemp_degF() );
275 e->set_CHT( eng->getCylinderHeadTemp_degF() );
276 e->set_Oil_Temp( eng->getOilTemp_degF() );
277 e->set_Running_Flag( eng->GetRunning() );
278 e->set_Cranking_Flag( eng->GetCranking() );
279 e->set_Throttle( globals->get_controls()->get_throttle(i) );
282 for ( i=0; i < multiloop; i++ ) {
286 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
287 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
289 // translate JSBsim back to FG structure so that the
290 // autopilot (and the rest of the sim can use the updated values
296 /******************************************************************************/
298 // Convert from the FGInterface struct to the JSBsim generic_ struct
300 bool FGJSBsim::copy_to_JSBsim() {
301 // copy control positions into the JSBsim structure
303 FCS->SetDaCmd( globals->get_controls()->get_aileron());
304 FCS->SetDeCmd( globals->get_controls()->get_elevator());
305 FCS->SetPitchTrimCmd(globals->get_controls()->get_elevator_trim());
306 FCS->SetDrCmd( -globals->get_controls()->get_rudder());
307 FCS->SetDfCmd( globals->get_controls()->get_flaps() );
308 FCS->SetDsbCmd( 0.0 ); //speedbrakes
309 FCS->SetDspCmd( 0.0 ); //spoilers
310 FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) );
311 FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) );
312 FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) );
313 for (int i = 0; i < get_num_engines(); i++) {
314 FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i));
315 FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i));
318 Position->SetSeaLevelRadius( get_Sea_level_radius() );
319 Position->SetRunwayRadius( scenery.get_cur_elev()*SG_METER_TO_FEET
320 + get_Sea_level_radius() );
322 Atmosphere->SetExTemperature(get_Static_temperature());
323 Atmosphere->SetExPressure(get_Static_pressure());
324 Atmosphere->SetExDensity(get_Density());
325 Atmosphere->SetWindNED(get_V_north_airmass(),
326 get_V_east_airmass(),
327 get_V_down_airmass());
328 // SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
329 // << get_V_north_airmass() << ", "
330 // << get_V_east_airmass() << ", "
331 // << get_V_down_airmass() );
336 /******************************************************************************/
338 // Convert from the JSBsim generic_ struct to the FGInterface struct
340 bool FGJSBsim::copy_from_JSBsim() {
343 _set_Inertias( MassBalance->GetMass(),
344 MassBalance->GetIxx(),
345 MassBalance->GetIyy(),
346 MassBalance->GetIzz(),
347 MassBalance->GetIxz() );
349 _set_CG_Position( MassBalance->GetXYZcg(1),
350 MassBalance->GetXYZcg(2),
351 MassBalance->GetXYZcg(3) );
353 _set_Accels_Body( Translation->GetUVWdot(1),
354 Translation->GetUVWdot(2),
355 Translation->GetUVWdot(3) );
357 _set_Accels_CG_Body( Translation->GetUVWdot(1),
358 Translation->GetUVWdot(2),
359 Translation->GetUVWdot(3) );
361 //_set_Accels_CG_Body_N ( Translation->GetNcg(1),
362 // Translation->GetNcg(2),
363 // Translation->GetNcg(3) );
365 _set_Accels_Pilot_Body( Auxiliary->GetPilotAccel(1),
366 Auxiliary->GetPilotAccel(2),
367 Auxiliary->GetPilotAccel(3) );
369 //_set_Accels_Pilot_Body_N( Auxiliary->GetNpilot(1),
370 // Auxiliary->GetNpilot(2),
371 // Auxiliary->GetNpilot(3) );
373 _set_Nlf( Aerodynamics->GetNlf() );
377 _set_Velocities_Local( Position->GetVn(),
381 _set_Velocities_Wind_Body( Translation->GetUVW(1),
382 Translation->GetUVW(2),
383 Translation->GetUVW(3) );
385 _set_V_rel_wind( Translation->GetVt() );
387 _set_V_equiv_kts( Auxiliary->GetVequivalentKTS() );
389 // _set_V_calibrated( Auxiliary->GetVcalibratedFPS() );
391 _set_V_calibrated_kts( Auxiliary->GetVcalibratedKTS() );
393 _set_V_ground_speed( Position->GetVground() );
395 _set_Omega_Body( Rotation->GetPQR(1),
397 Rotation->GetPQR(3) );
399 _set_Euler_Rates( Rotation->GetEulerRates(1),
400 Rotation->GetEulerRates(2),
401 Rotation->GetEulerRates(3) );
403 _set_Geocentric_Rates(Position->GetLatitudeDot(),
404 Position->GetLongitudeDot(),
405 Position->Gethdot() );
407 _set_Mach_number( Translation->GetMach() );
410 _updatePosition( Position->GetLatitude(),
411 Position->GetLongitude(),
414 _set_Altitude_AGL( Position->GetDistanceAGL() );
416 _set_Euler_Angles( Rotation->Getphi(),
418 Rotation->Getpsi() );
420 _set_Alpha( Translation->Getalpha() );
421 _set_Beta( Translation->Getbeta() );
424 _set_Gamma_vert_rad( Position->GetGamma() );
425 // set_Gamma_horiz_rad( Gamma_horiz_rad );
427 _set_Earth_position_angle( Auxiliary->GetEarthPositionAngle() );
429 _set_Climb_Rate( Position->Gethdot() );
432 for ( i = 1; i <= 3; i++ ) {
433 for ( j = 1; j <= 3; j++ ) {
434 _set_T_Local_to_Body( i, j, State->GetTl2b(i,j) );
440 void FGJSBsim::snap_shot(void) {
441 fgic->SetLatitudeRadIC(get_Lat_geocentric() );
442 fgic->SetLongitudeRadIC( get_Longitude() );
443 fgic->SetAltitudeFtIC( get_Altitude() );
444 fgic->SetTerrainAltitudeFtIC( get_Runway_altitude() );
445 fgic->SetVtrueFpsIC( get_V_rel_wind() );
446 fgic->SetPitchAngleRadIC( get_Theta() );
447 fgic->SetRollAngleRadIC( get_Phi() );
448 fgic->SetTrueHeadingRadIC( get_Psi() );
449 fgic->SetClimbRateFpsIC( get_Climb_Rate() );
453 bool FGJSBsim::ToggleDataLogging(void) {
454 return fdmex->GetOutput()->Toggle();
458 bool FGJSBsim::ToggleDataLogging(bool state) {
460 fdmex->GetOutput()->Enable();
463 fdmex->GetOutput()->Disable();
470 void FGJSBsim::set_Latitude(double lat) {
471 static const SGPropertyNode *altitude
472 = fgGetNode("/position/altitude-ft");
474 if ( altitude->getDoubleValue() > -9990 ) {
475 alt = altitude->getDoubleValue();
480 double sea_level_radius_meters, lat_geoc;
482 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
483 SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt );
485 sgGeodToGeoc( lat, alt * SG_FEET_TO_METER,
486 &sea_level_radius_meters, &lat_geoc );
487 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
488 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
489 fgic->SetLatitudeRadIC( lat_geoc );
493 void FGJSBsim::set_Longitude(double lon) {
495 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon );
497 fgic->SetLongitudeRadIC( lon );
501 void FGJSBsim::set_Altitude(double alt) {
502 static const SGPropertyNode *latitude
503 = fgGetNode("/position/latitude-deg");
505 double sea_level_radius_meters,lat_geoc;
507 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt );
508 SG_LOG(SG_FLIGHT,SG_INFO, " lat (deg) = " << latitude->getDoubleValue() );
510 sgGeodToGeoc( latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, alt,
511 &sea_level_radius_meters, &lat_geoc);
512 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
513 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
514 fgic->SetLatitudeRadIC( lat_geoc );
515 fgic->SetAltitudeFtIC(alt);
519 void FGJSBsim::set_V_calibrated_kts(double vc) {
520 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " << vc );
522 fgic->SetVcalibratedKtsIC(vc);
526 void FGJSBsim::set_Mach_number(double mach) {
527 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " << mach );
529 fgic->SetMachIC(mach);
533 void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
534 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: "
535 << north << ", " << east << ", " << down );
537 fgic->SetVnorthFpsIC(north);
538 fgic->SetVeastFpsIC(east);
539 fgic->SetVdownFpsIC(down);
543 void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
544 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
545 << u << ", " << v << ", " << w );
547 fgic->SetUBodyFpsIC(u);
548 fgic->SetVBodyFpsIC(v);
549 fgic->SetWBodyFpsIC(w);
554 void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
555 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: "
556 << phi << ", " << theta << ", " << psi );
558 fgic->SetPitchAngleRadIC(theta);
559 fgic->SetRollAngleRadIC(phi);
560 fgic->SetTrueHeadingRadIC(psi);
565 void FGJSBsim::set_Climb_Rate( double roc) {
566 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
568 fgic->SetClimbRateFpsIC(roc);
572 void FGJSBsim::set_Gamma_vert_rad( double gamma) {
573 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
575 fgic->SetFlightPathAngleRadIC(gamma);
580 void FGJSBsim::set_Sea_level_radius(double slr) {
581 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
583 fgic->SetSeaLevelRadiusFtIC(slr);
587 void FGJSBsim::set_Runway_altitude(double ralt) {
588 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
590 _set_Runway_altitude( ralt );
591 fgic->SetTerrainAltitudeFtIC( ralt );
595 void FGJSBsim::set_Static_pressure(double p) {
596 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p );
598 Atmosphere->SetExPressure(p);
599 if(Atmosphere->External() == true)
603 void FGJSBsim::set_Static_temperature(double T) {
604 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_temperature: " << T );
606 Atmosphere->SetExTemperature(T);
607 if(Atmosphere->External() == true)
612 void FGJSBsim::set_Density(double rho) {
613 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Density: " << rho );
615 Atmosphere->SetExDensity(rho);
616 if(Atmosphere->External() == true)
621 void FGJSBsim::set_Velocities_Local_Airmass (double wnorth,
624 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: "
625 << wnorth << ", " << weast << ", " << wdown );
627 _set_Velocities_Local_Airmass( wnorth, weast, wdown );
628 Atmosphere->SetWindNED(wnorth, weast, wdown );
629 if(Atmosphere->External() == true)
635 void FGJSBsim::update_Latitude(double lat) {
636 double sea_level_radius_meters, lat_geoc;
638 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::update_Latitude: " << lat );
639 SG_LOG(SG_FLIGHT,SG_INFO," cur alt = " << get_Altitude() );
642 sgGeodToGeoc( lat, get_Altitude(), &sea_level_radius_meters, &lat_geoc);
643 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
644 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
645 fgic->SetLatitudeRadIC( lat_geoc );
646 fdmex->RunIC(fgic); //loop JSBSim once
647 copy_from_JSBsim(); //update the bus
651 void FGJSBsim::update_Longitude(double lon) {
653 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::update_Longitude: " << lon );
654 SG_LOG(SG_FLIGHT,SG_INFO," cur alt = " << get_Altitude() );
657 fgic->SetLongitudeRadIC(lon);
658 fdmex->RunIC(fgic); //loop JSBSim once
659 copy_from_JSBsim(); //update the bus
663 void FGJSBsim::update_Altitude(double alt) {
664 double sea_level_radius_meters,lat_geoc;
666 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Altitude: " << alt );
669 sgGeodToGeoc( get_Latitude(), alt , &sea_level_radius_meters, &lat_geoc);
670 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
671 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
672 fgic->SetLatitudeRadIC( lat_geoc );
673 fgic->SetAltitudeFtIC(alt);
674 fdmex->RunIC(fgic); //loop JSBSim once
675 copy_from_JSBsim(); //update the bus
679 void FGJSBsim::update_V_calibrated_kts(double vc) {
680 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_V_calibrated_kts: " << vc );
683 fgic->SetVcalibratedKtsIC(vc);
684 fdmex->RunIC(fgic); //loop JSBSim once
685 copy_from_JSBsim(); //update the bus
689 void FGJSBsim::update_Mach_number(double mach) {
690 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Mach_number: " << mach );
693 fgic->SetMachIC(mach);
694 fdmex->RunIC(fgic); //loop JSBSim once
695 copy_from_JSBsim(); //update the bus
699 void FGJSBsim::update_Velocities_Local( double north, double east, double down ){
700 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Local: "
701 << north << ", " << east << ", " << down );
704 fgic->SetVnorthFpsIC(north);
705 fgic->SetVeastFpsIC(east);
706 fgic->SetVdownFpsIC(down);
707 fdmex->RunIC(fgic); //loop JSBSim once
708 copy_from_JSBsim(); //update the bus
712 void FGJSBsim::update_Velocities_Wind_Body( double u, double v, double w){
713 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Wind_Body: "
714 << u << ", " << v << ", " << w );
717 fgic->SetUBodyFpsIC(u);
718 fgic->SetVBodyFpsIC(v);
719 fgic->SetWBodyFpsIC(w);
720 fdmex->RunIC(fgic); //loop JSBSim once
721 copy_from_JSBsim(); //update the bus
726 void FGJSBsim::update_Euler_Angles( double phi, double theta, double psi ) {
727 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Euler_Angles: "
728 << phi << ", " << theta << ", " << psi );
731 fgic->SetPitchAngleRadIC(theta);
732 fgic->SetRollAngleRadIC(phi);
733 fgic->SetTrueHeadingRadIC(psi);
734 fdmex->RunIC(fgic); //loop JSBSim once
735 copy_from_JSBsim(); //update the bus
740 void FGJSBsim::update_Climb_Rate( double roc) {
741 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Climb_Rate: " << roc );
744 fgic->SetClimbRateFpsIC(roc);
745 fdmex->RunIC(fgic); //loop JSBSim once
746 copy_from_JSBsim(); //update the bus
750 void FGJSBsim::update_Gamma_vert_rad( double gamma) {
751 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Gamma_vert_rad: " << gamma );
754 fgic->SetFlightPathAngleRadIC(gamma);
755 fdmex->RunIC(fgic); //loop JSBSim once
756 copy_from_JSBsim(); //update the bus
761 void FGJSBsim::update_Sea_level_radius(double slr) {
762 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Sea_level_radius: " << slr );
765 fgic->SetSeaLevelRadiusFtIC(slr);
766 fdmex->RunIC(fgic); //loop JSBSim once
767 copy_from_JSBsim(); //update the bus
771 void FGJSBsim::update_Runway_altitude(double ralt) {
772 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Runway_altitude: " << ralt );
775 _set_Runway_altitude( ralt );
776 fgic->SetTerrainAltitudeFtIC( ralt );
777 fdmex->RunIC(fgic); //loop JSBSim once
778 copy_from_JSBsim(); //update the bus
782 void FGJSBsim::update_Static_pressure(double p) {
783 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Static_pressure: " << p );
786 Atmosphere->SetExPressure(p);
787 if(Atmosphere->External() == true)
791 void FGJSBsim::update_Static_temperature(double T) {
792 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Static_temperature: " << T );
795 Atmosphere->SetExTemperature(T);
796 if(Atmosphere->External() == true)
801 void FGJSBsim::update_Density(double rho) {
802 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Density: " << rho );
805 Atmosphere->SetExDensity(rho);
806 if(Atmosphere->External() == true)
811 void FGJSBsim::update_Velocities_Local_Airmass (double wnorth,
814 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Local_Airmass: "
815 << wnorth << ", " << weast << ", " << wdown );
817 _set_Velocities_Local_Airmass( wnorth, weast, wdown );
819 Atmosphere->SetWindNED(wnorth, weast, wdown );
820 if(Atmosphere->External() == true)