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 )
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->GetAircraft()->GetNumGearUnits() <= 0 ) {
117 SG_LOG( SG_FLIGHT, SG_ALERT, "num gear units = "
118 << fdmex->GetAircraft()->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->GetAircraft()->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 e->set_Manifold_Pressure( eng->getManifoldPressure_inHg() );
271 e->set_RPM( thrust->GetRPM() );
272 e->set_EGT( eng->getExhaustGasTemp_degF() );
273 e->set_CHT( eng->getCylinderHeadTemp_degF() );
274 e->set_Oil_Temp( eng->getOilTemp_degF() );
275 e->set_Throttle( globals->get_controls()->get_throttle(i) );
278 for ( i=0; i < multiloop; i++ ) {
282 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
283 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
285 // translate JSBsim back to FG structure so that the
286 // autopilot (and the rest of the sim can use the updated values
292 /******************************************************************************/
294 // Convert from the FGInterface struct to the JSBsim generic_ struct
296 bool FGJSBsim::copy_to_JSBsim() {
297 // copy control positions into the JSBsim structure
299 FCS->SetDaCmd( globals->get_controls()->get_aileron());
300 FCS->SetDeCmd( globals->get_controls()->get_elevator());
301 FCS->SetPitchTrimCmd(globals->get_controls()->get_elevator_trim());
302 FCS->SetDrCmd( -globals->get_controls()->get_rudder());
303 FCS->SetDfCmd( globals->get_controls()->get_flaps() );
304 FCS->SetDsbCmd( 0.0 ); //speedbrakes
305 FCS->SetDspCmd( 0.0 ); //spoilers
306 FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) );
307 FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) );
308 FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) );
309 for (int i = 0; i < get_num_engines(); i++) {
310 FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i));
311 FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i));
314 Position->SetSeaLevelRadius( get_Sea_level_radius() );
315 Position->SetRunwayRadius( scenery.get_cur_elev()*SG_METER_TO_FEET
316 + get_Sea_level_radius() );
318 Atmosphere->SetExTemperature(get_Static_temperature());
319 Atmosphere->SetExPressure(get_Static_pressure());
320 Atmosphere->SetExDensity(get_Density());
321 Atmosphere->SetWindNED(get_V_north_airmass(),
322 get_V_east_airmass(),
323 get_V_down_airmass());
324 // SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
325 // << get_V_north_airmass() << ", "
326 // << get_V_east_airmass() << ", "
327 // << get_V_down_airmass() );
332 /******************************************************************************/
334 // Convert from the JSBsim generic_ struct to the FGInterface struct
336 bool FGJSBsim::copy_from_JSBsim() {
339 _set_Inertias( MassBalance->GetMass(),
340 MassBalance->GetIxx(),
341 MassBalance->GetIyy(),
342 MassBalance->GetIzz(),
343 MassBalance->GetIxz() );
345 _set_CG_Position( MassBalance->GetXYZcg(1),
346 MassBalance->GetXYZcg(2),
347 MassBalance->GetXYZcg(3) );
349 _set_Accels_Body( Translation->GetUVWdot(1),
350 Translation->GetUVWdot(2),
351 Translation->GetUVWdot(3) );
353 _set_Accels_CG_Body( Translation->GetUVWdot(1),
354 Translation->GetUVWdot(2),
355 Translation->GetUVWdot(3) );
357 //_set_Accels_CG_Body_N ( Translation->GetNcg(1),
358 // Translation->GetNcg(2),
359 // Translation->GetNcg(3) );
361 _set_Accels_Pilot_Body( Auxiliary->GetPilotAccel(1),
362 Auxiliary->GetPilotAccel(2),
363 Auxiliary->GetPilotAccel(3) );
365 //_set_Accels_Pilot_Body_N( Auxiliary->GetNpilot(1),
366 // Auxiliary->GetNpilot(2),
367 // Auxiliary->GetNpilot(3) );
369 _set_Nlf( Aerodynamics->GetNlf() );
373 _set_Velocities_Local( Position->GetVn(),
377 _set_Velocities_Wind_Body( Translation->GetUVW(1),
378 Translation->GetUVW(2),
379 Translation->GetUVW(3) );
381 _set_V_rel_wind( Translation->GetVt() );
383 _set_V_equiv_kts( Auxiliary->GetVequivalentKTS() );
385 // _set_V_calibrated( Auxiliary->GetVcalibratedFPS() );
387 _set_V_calibrated_kts( Auxiliary->GetVcalibratedKTS() );
389 _set_V_ground_speed( Position->GetVground() );
391 _set_Omega_Body( Rotation->GetPQR(1),
393 Rotation->GetPQR(3) );
395 _set_Euler_Rates( Rotation->GetEulerRates(1),
396 Rotation->GetEulerRates(2),
397 Rotation->GetEulerRates(3) );
399 _set_Geocentric_Rates(Position->GetLatitudeDot(),
400 Position->GetLongitudeDot(),
401 Position->Gethdot() );
403 _set_Mach_number( Translation->GetMach() );
406 _updatePosition( Position->GetLatitude(),
407 Position->GetLongitude(),
410 _set_Altitude_AGL( Position->GetDistanceAGL() );
412 _set_Euler_Angles( Rotation->Getphi(),
414 Rotation->Getpsi() );
416 _set_Alpha( Translation->Getalpha() );
417 _set_Beta( Translation->Getbeta() );
420 _set_Gamma_vert_rad( Position->GetGamma() );
421 // set_Gamma_horiz_rad( Gamma_horiz_rad );
423 _set_Earth_position_angle( Auxiliary->GetEarthPositionAngle() );
425 _set_Climb_Rate( Position->Gethdot() );
428 for ( i = 1; i <= 3; i++ ) {
429 for ( j = 1; j <= 3; j++ ) {
430 _set_T_Local_to_Body( i, j, State->GetTl2b(i,j) );
436 void FGJSBsim::snap_shot(void) {
437 fgic->SetLatitudeRadIC(get_Lat_geocentric() );
438 fgic->SetLongitudeRadIC( get_Longitude() );
439 fgic->SetAltitudeFtIC( get_Altitude() );
440 fgic->SetTerrainAltitudeFtIC( get_Runway_altitude() );
441 fgic->SetVtrueFpsIC( get_V_rel_wind() );
442 fgic->SetPitchAngleRadIC( get_Theta() );
443 fgic->SetRollAngleRadIC( get_Phi() );
444 fgic->SetTrueHeadingRadIC( get_Psi() );
445 fgic->SetClimbRateFpsIC( get_Climb_Rate() );
449 bool FGJSBsim::ToggleDataLogging(void) {
450 return fdmex->GetOutput()->Toggle();
454 bool FGJSBsim::ToggleDataLogging(bool state) {
456 fdmex->GetOutput()->Enable();
459 fdmex->GetOutput()->Disable();
466 void FGJSBsim::set_Latitude(double lat) {
467 static const SGPropertyNode *altitude
468 = fgGetNode("/position/altitude-ft");
470 if ( altitude->getDoubleValue() > -9990 ) {
471 alt = altitude->getDoubleValue();
476 double sea_level_radius_meters, lat_geoc;
478 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
479 SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt );
481 sgGeodToGeoc( lat, alt * SG_FEET_TO_METER,
482 &sea_level_radius_meters, &lat_geoc );
483 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
484 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
485 fgic->SetLatitudeRadIC( lat_geoc );
489 void FGJSBsim::set_Longitude(double lon) {
491 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon );
493 fgic->SetLongitudeRadIC( lon );
497 void FGJSBsim::set_Altitude(double alt) {
498 static const SGPropertyNode *latitude
499 = fgGetNode("/position/latitude-deg");
501 double sea_level_radius_meters,lat_geoc;
503 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt );
504 SG_LOG(SG_FLIGHT,SG_INFO, " lat (deg) = " << latitude->getDoubleValue() );
506 sgGeodToGeoc( latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, alt,
507 &sea_level_radius_meters, &lat_geoc);
508 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
509 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
510 fgic->SetLatitudeRadIC( lat_geoc );
511 fgic->SetAltitudeFtIC(alt);
515 void FGJSBsim::set_V_calibrated_kts(double vc) {
516 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " << vc );
518 fgic->SetVcalibratedKtsIC(vc);
522 void FGJSBsim::set_Mach_number(double mach) {
523 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " << mach );
525 fgic->SetMachIC(mach);
529 void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
530 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: "
531 << north << ", " << east << ", " << down );
533 fgic->SetVnorthFpsIC(north);
534 fgic->SetVeastFpsIC(east);
535 fgic->SetVdownFpsIC(down);
539 void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
540 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
541 << u << ", " << v << ", " << w );
543 fgic->SetUBodyFpsIC(u);
544 fgic->SetVBodyFpsIC(v);
545 fgic->SetWBodyFpsIC(w);
550 void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
551 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: "
552 << phi << ", " << theta << ", " << psi );
554 fgic->SetPitchAngleRadIC(theta);
555 fgic->SetRollAngleRadIC(phi);
556 fgic->SetTrueHeadingRadIC(psi);
561 void FGJSBsim::set_Climb_Rate( double roc) {
562 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
564 fgic->SetClimbRateFpsIC(roc);
568 void FGJSBsim::set_Gamma_vert_rad( double gamma) {
569 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
571 fgic->SetFlightPathAngleRadIC(gamma);
576 void FGJSBsim::set_Sea_level_radius(double slr) {
577 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
579 fgic->SetSeaLevelRadiusFtIC(slr);
583 void FGJSBsim::set_Runway_altitude(double ralt) {
584 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
586 _set_Runway_altitude( ralt );
587 fgic->SetTerrainAltitudeFtIC( ralt );
591 void FGJSBsim::set_Static_pressure(double p) {
592 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p );
594 Atmosphere->SetExPressure(p);
595 if(Atmosphere->External() == true)
599 void FGJSBsim::set_Static_temperature(double T) {
600 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_temperature: " << T );
602 Atmosphere->SetExTemperature(T);
603 if(Atmosphere->External() == true)
608 void FGJSBsim::set_Density(double rho) {
609 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Density: " << rho );
611 Atmosphere->SetExDensity(rho);
612 if(Atmosphere->External() == true)
617 void FGJSBsim::set_Velocities_Local_Airmass (double wnorth,
620 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: "
621 << wnorth << ", " << weast << ", " << wdown );
623 _set_Velocities_Local_Airmass( wnorth, weast, wdown );
624 Atmosphere->SetWindNED(wnorth, weast, wdown );
625 if(Atmosphere->External() == true)
631 void FGJSBsim::update_Latitude(double lat) {
632 double sea_level_radius_meters, lat_geoc;
634 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::update_Latitude: " << lat );
635 SG_LOG(SG_FLIGHT,SG_INFO," cur alt = " << get_Altitude() );
638 sgGeodToGeoc( lat, get_Altitude(), &sea_level_radius_meters, &lat_geoc);
639 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
640 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
641 fgic->SetLatitudeRadIC( lat_geoc );
642 fdmex->RunIC(fgic); //loop JSBSim once
643 copy_from_JSBsim(); //update the bus
647 void FGJSBsim::update_Longitude(double lon) {
649 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::update_Longitude: " << lon );
650 SG_LOG(SG_FLIGHT,SG_INFO," cur alt = " << get_Altitude() );
653 fgic->SetLongitudeRadIC(lon);
654 fdmex->RunIC(fgic); //loop JSBSim once
655 copy_from_JSBsim(); //update the bus
659 void FGJSBsim::update_Altitude(double alt) {
660 double sea_level_radius_meters,lat_geoc;
662 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Altitude: " << alt );
665 sgGeodToGeoc( get_Latitude(), alt , &sea_level_radius_meters, &lat_geoc);
666 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
667 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
668 fgic->SetLatitudeRadIC( lat_geoc );
669 fgic->SetAltitudeFtIC(alt);
670 fdmex->RunIC(fgic); //loop JSBSim once
671 copy_from_JSBsim(); //update the bus
675 void FGJSBsim::update_V_calibrated_kts(double vc) {
676 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_V_calibrated_kts: " << vc );
679 fgic->SetVcalibratedKtsIC(vc);
680 fdmex->RunIC(fgic); //loop JSBSim once
681 copy_from_JSBsim(); //update the bus
685 void FGJSBsim::update_Mach_number(double mach) {
686 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Mach_number: " << mach );
689 fgic->SetMachIC(mach);
690 fdmex->RunIC(fgic); //loop JSBSim once
691 copy_from_JSBsim(); //update the bus
695 void FGJSBsim::update_Velocities_Local( double north, double east, double down ){
696 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Local: "
697 << north << ", " << east << ", " << down );
700 fgic->SetVnorthFpsIC(north);
701 fgic->SetVeastFpsIC(east);
702 fgic->SetVdownFpsIC(down);
703 fdmex->RunIC(fgic); //loop JSBSim once
704 copy_from_JSBsim(); //update the bus
708 void FGJSBsim::update_Velocities_Wind_Body( double u, double v, double w){
709 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Wind_Body: "
710 << u << ", " << v << ", " << w );
713 fgic->SetUBodyFpsIC(u);
714 fgic->SetVBodyFpsIC(v);
715 fgic->SetWBodyFpsIC(w);
716 fdmex->RunIC(fgic); //loop JSBSim once
717 copy_from_JSBsim(); //update the bus
722 void FGJSBsim::update_Euler_Angles( double phi, double theta, double psi ) {
723 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Euler_Angles: "
724 << phi << ", " << theta << ", " << psi );
727 fgic->SetPitchAngleRadIC(theta);
728 fgic->SetRollAngleRadIC(phi);
729 fgic->SetTrueHeadingRadIC(psi);
730 fdmex->RunIC(fgic); //loop JSBSim once
731 copy_from_JSBsim(); //update the bus
736 void FGJSBsim::update_Climb_Rate( double roc) {
737 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Climb_Rate: " << roc );
740 fgic->SetClimbRateFpsIC(roc);
741 fdmex->RunIC(fgic); //loop JSBSim once
742 copy_from_JSBsim(); //update the bus
746 void FGJSBsim::update_Gamma_vert_rad( double gamma) {
747 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Gamma_vert_rad: " << gamma );
750 fgic->SetFlightPathAngleRadIC(gamma);
751 fdmex->RunIC(fgic); //loop JSBSim once
752 copy_from_JSBsim(); //update the bus
757 void FGJSBsim::update_Sea_level_radius(double slr) {
758 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Sea_level_radius: " << slr );
761 fgic->SetSeaLevelRadiusFtIC(slr);
762 fdmex->RunIC(fgic); //loop JSBSim once
763 copy_from_JSBsim(); //update the bus
767 void FGJSBsim::update_Runway_altitude(double ralt) {
768 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Runway_altitude: " << ralt );
771 _set_Runway_altitude( ralt );
772 fgic->SetTerrainAltitudeFtIC( ralt );
773 fdmex->RunIC(fgic); //loop JSBSim once
774 copy_from_JSBsim(); //update the bus
778 void FGJSBsim::update_Static_pressure(double p) {
779 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Static_pressure: " << p );
782 Atmosphere->SetExPressure(p);
783 if(Atmosphere->External() == true)
787 void FGJSBsim::update_Static_temperature(double T) {
788 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Static_temperature: " << T );
791 Atmosphere->SetExTemperature(T);
792 if(Atmosphere->External() == true)
797 void FGJSBsim::update_Density(double rho) {
798 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Density: " << rho );
801 Atmosphere->SetExDensity(rho);
802 if(Atmosphere->External() == true)
807 void FGJSBsim::update_Velocities_Local_Airmass (double wnorth,
810 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Local_Airmass: "
811 << wnorth << ", " << weast << ", " << wdown );
813 _set_Velocities_Local_Airmass( wnorth, weast, wdown );
815 Atmosphere->SetWindNED(wnorth, weast, wdown );
816 if(Atmosphere->External() == true)