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") );
100 SG_LOG( SG_FLIGHT, SG_INFO, " loaded aircraft.");
102 SG_LOG( SG_FLIGHT, SG_INFO,
103 " aircraft does not exist (you may have mis-typed the name).");
107 int Neng = Propulsion->GetNumEngines();
108 SG_LOG(SG_FLIGHT,SG_INFO, "Neng: " << Neng );
110 for(int i=0;i<Neng;i++) {
111 add_engine( FGEngInterface() );
114 fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
115 fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0));
116 fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
117 fgSetDouble("/fdm/trim/rudder", FCS->GetDrCmd());
119 startup_trim = fgGetNode("/sim/startup/trim", true);
121 trimmed = fgGetNode("/fdm/trim/trimmed", true);
122 trimmed->setBoolValue(false);
124 pitch_trim = fgGetNode("/fdm/trim/pitch-trim", true );
125 throttle_trim = fgGetNode("/fdm/trim/throttle", true );
126 aileron_trim = fgGetNode("/fdm/trim/aileron", true );
127 rudder_trim = fgGetNode("/fdm/trim/rudder", true );
130 /******************************************************************************/
131 FGJSBsim::~FGJSBsim(void) {
133 delete fdmex; fdmex=NULL;
134 delete fgic; fgic=NULL;
138 /******************************************************************************/
140 // Initialize the JSBsim flight model, dt is the time increment for
141 // each subsequent iteration through the EOM
143 void FGJSBsim::init() {
145 SG_LOG( SG_FLIGHT, SG_INFO, "Starting and initializing JSBsim" );
147 // Explicitly call the superclass's
148 // init method first.
151 fdmex->GetState()->Initialize(fgic);
152 // fdmex->RunIC(fgic); //loop JSBSim once w/o integrating
153 fdmex->Run(); //loop JSBSim once
154 copy_from_JSBsim(); //update the bus
156 SG_LOG( SG_FLIGHT, SG_INFO, " Initialized JSBSim with:" );
158 switch(fgic->GetSpeedSet()) {
160 SG_LOG(SG_FLIGHT,SG_INFO, " Vn,Ve,Vd= "
161 << Position->GetVn() << ", "
162 << Position->GetVe() << ", "
163 << Position->GetVd() << " ft/s");
166 SG_LOG(SG_FLIGHT,SG_INFO, " U,V,W= "
167 << Translation->GetUVW(1) << ", "
168 << Translation->GetUVW(2) << ", "
169 << Translation->GetUVW(3) << " ft/s");
172 SG_LOG(SG_FLIGHT,SG_INFO, " Mach: "
173 << Translation->GetMach() );
177 SG_LOG(SG_FLIGHT,SG_INFO, " Indicated Airspeed: "
178 << Auxiliary->GetVcalibratedKTS() << " knots" );
182 SG_LOG( SG_FLIGHT, SG_INFO, " Bank Angle: "
183 << Rotation->Getphi()*RADTODEG << " deg" );
184 SG_LOG( SG_FLIGHT, SG_INFO, " Pitch Angle: "
185 << Rotation->Gettht()*RADTODEG << " deg" );
186 SG_LOG( SG_FLIGHT, SG_INFO, " True Heading: "
187 << Rotation->Getpsi()*RADTODEG << " deg" );
188 SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: "
189 << Position->GetLatitude() << " deg" );
190 SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: "
191 << Position->GetLongitude() << " deg" );
192 SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: "
193 << Position->Geth() << " feet" );
194 SG_LOG( SG_FLIGHT, SG_INFO, " loaded initial conditions" );
196 SG_LOG( SG_FLIGHT, SG_INFO, " set dt" );
198 SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing JSBSim" );
201 /******************************************************************************/
203 // Run an iteration of the EOM (equations of motion)
205 bool FGJSBsim::update( int multiloop ) {
209 double save_alt = 0.0;
213 trimmed->setBoolValue(false);
215 if ( needTrim && startup_trim->getBoolValue() ) {
217 //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
218 //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
221 if(fgic->GetVcalibratedKtsIC() < 10 ) {
222 fgic->SetVcalibratedKtsIC(0.0);
223 fgtrim=new FGTrim(fdmex,fgic,tGround);
225 fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
227 if(!fgtrim->DoTrim()) {
231 trimmed->setBoolValue(true);
233 fgtrim->ReportState();
238 pitch_trim->setDoubleValue( FCS->GetPitchTrimCmd() );
239 throttle_trim->setDoubleValue( FCS->GetThrottleCmd(0) );
240 aileron_trim->setDoubleValue( FCS->GetDaCmd() );
241 rudder_trim->setDoubleValue( FCS->GetDrCmd() );
243 globals->get_controls()->set_elevator_trim(FCS->GetPitchTrimCmd());
244 globals->get_controls()->set_elevator(FCS->GetDeCmd());
245 globals->get_controls()->set_throttle(FGControls::ALL_ENGINES,
246 FCS->GetThrottleCmd(0));
248 globals->get_controls()->set_aileron(FCS->GetDaCmd());
249 globals->get_controls()->set_rudder( FCS->GetDrCmd());
251 SG_LOG( SG_FLIGHT, SG_INFO, " Trim complete" );
254 for( i=0; i<get_num_engines(); i++ ) {
255 FGEngInterface * e = get_engine(i);
256 FGEngine * eng = Propulsion->GetEngine(i);
257 FGThruster * thrust = Propulsion->GetThruster(i);
258 e->set_Manifold_Pressure( eng->getManifoldPressure_inHg() );
259 e->set_RPM( thrust->GetRPM() );
260 e->set_EGT( eng->getExhaustGasTemp_degF() );
261 e->set_CHT( eng->getCylinderHeadTemp_degF() );
262 e->set_Oil_Temp( eng->getOilTemp_degF() );
263 e->set_Throttle( globals->get_controls()->get_throttle(i) );
266 for ( i=0; i < multiloop; i++ ) {
270 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
271 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
273 // translate JSBsim back to FG structure so that the
274 // autopilot (and the rest of the sim can use the updated values
280 /******************************************************************************/
282 // Convert from the FGInterface struct to the JSBsim generic_ struct
284 bool FGJSBsim::copy_to_JSBsim() {
285 // copy control positions into the JSBsim structure
287 FCS->SetDaCmd( globals->get_controls()->get_aileron());
288 FCS->SetDeCmd( globals->get_controls()->get_elevator());
289 FCS->SetPitchTrimCmd(globals->get_controls()->get_elevator_trim());
290 FCS->SetDrCmd( -globals->get_controls()->get_rudder());
291 FCS->SetDfCmd( globals->get_controls()->get_flaps() );
292 FCS->SetDsbCmd( 0.0 ); //speedbrakes
293 FCS->SetDspCmd( 0.0 ); //spoilers
294 FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) );
295 FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) );
296 FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) );
297 for (int i = 0; i < get_num_engines(); i++) {
298 FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i));
299 FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i));
302 Position->SetSeaLevelRadius( get_Sea_level_radius() );
303 Position->SetRunwayRadius( scenery.get_cur_elev()*SG_METER_TO_FEET
304 + get_Sea_level_radius() );
306 Atmosphere->SetExTemperature(get_Static_temperature());
307 Atmosphere->SetExPressure(get_Static_pressure());
308 Atmosphere->SetExDensity(get_Density());
309 Atmosphere->SetWindNED(get_V_north_airmass(),
310 get_V_east_airmass(),
311 get_V_down_airmass());
312 // SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
313 // << get_V_north_airmass() << ", "
314 // << get_V_east_airmass() << ", "
315 // << get_V_down_airmass() );
320 /******************************************************************************/
322 // Convert from the JSBsim generic_ struct to the FGInterface struct
324 bool FGJSBsim::copy_from_JSBsim() {
327 _set_Inertias( MassBalance->GetMass(),
328 MassBalance->GetIxx(),
329 MassBalance->GetIyy(),
330 MassBalance->GetIzz(),
331 MassBalance->GetIxz() );
333 _set_CG_Position( MassBalance->GetXYZcg(1),
334 MassBalance->GetXYZcg(2),
335 MassBalance->GetXYZcg(3) );
337 _set_Accels_Body( Translation->GetUVWdot(1),
338 Translation->GetUVWdot(2),
339 Translation->GetUVWdot(3) );
341 _set_Accels_CG_Body( Translation->GetUVWdot(1),
342 Translation->GetUVWdot(2),
343 Translation->GetUVWdot(3) );
345 //_set_Accels_CG_Body_N ( Translation->GetNcg(1),
346 // Translation->GetNcg(2),
347 // Translation->GetNcg(3) );
349 _set_Accels_Pilot_Body( Auxiliary->GetPilotAccel(1),
350 Auxiliary->GetPilotAccel(2),
351 Auxiliary->GetPilotAccel(3) );
353 //_set_Accels_Pilot_Body_N( Auxiliary->GetNpilot(1),
354 // Auxiliary->GetNpilot(2),
355 // Auxiliary->GetNpilot(3) );
357 _set_Nlf( Aerodynamics->GetNlf() );
361 _set_Velocities_Local( Position->GetVn(),
365 _set_Velocities_Wind_Body( Translation->GetUVW(1),
366 Translation->GetUVW(2),
367 Translation->GetUVW(3) );
369 _set_V_rel_wind( Translation->GetVt() );
371 _set_V_equiv_kts( Auxiliary->GetVequivalentKTS() );
373 // _set_V_calibrated( Auxiliary->GetVcalibratedFPS() );
375 _set_V_calibrated_kts( Auxiliary->GetVcalibratedKTS() );
377 _set_V_ground_speed( Position->GetVground() );
379 _set_Omega_Body( Rotation->GetPQR(1),
381 Rotation->GetPQR(3) );
383 _set_Euler_Rates( Rotation->GetEulerRates(1),
384 Rotation->GetEulerRates(2),
385 Rotation->GetEulerRates(3) );
387 _set_Geocentric_Rates(Position->GetLatitudeDot(),
388 Position->GetLongitudeDot(),
389 Position->Gethdot() );
391 _set_Mach_number( Translation->GetMach() );
394 _updatePosition( Position->GetLatitude() * SGD_DEGREES_TO_RADIANS,
395 Position->GetLongitude() * SGD_DEGREES_TO_RADIANS,
398 _set_Altitude_AGL( Position->GetDistanceAGL() );
400 _set_Euler_Angles( Rotation->Getphi(),
402 Rotation->Getpsi() );
404 _set_Alpha( Translation->Getalpha() );
405 _set_Beta( Translation->Getbeta() );
408 _set_Gamma_vert_rad( Position->GetGamma() );
409 // set_Gamma_horiz_rad( Gamma_horiz_rad );
411 _set_Earth_position_angle( Auxiliary->GetEarthPositionAngle() );
413 _set_Climb_Rate( Position->Gethdot() );
416 for ( i = 1; i <= 3; i++ ) {
417 for ( j = 1; j <= 3; j++ ) {
418 _set_T_Local_to_Body( i, j, State->GetTl2b(i,j) );
424 void FGJSBsim::snap_shot(void) {
425 fgic->SetLatitudeRadIC(get_Lat_geocentric() );
426 fgic->SetLongitudeRadIC( get_Longitude() );
427 fgic->SetAltitudeFtIC( get_Altitude() );
428 fgic->SetTerrainAltitudeFtIC( get_Runway_altitude() );
429 fgic->SetVtrueFpsIC( get_V_rel_wind() );
430 fgic->SetPitchAngleRadIC( get_Theta() );
431 fgic->SetRollAngleRadIC( get_Phi() );
432 fgic->SetTrueHeadingRadIC( get_Psi() );
433 fgic->SetClimbRateFpsIC( get_Climb_Rate() );
437 bool FGJSBsim::ToggleDataLogging(void) {
438 return fdmex->GetOutput()->Toggle();
442 bool FGJSBsim::ToggleDataLogging(bool state) {
444 fdmex->GetOutput()->Enable();
447 fdmex->GetOutput()->Disable();
454 void FGJSBsim::set_Latitude(double lat) {
455 static const SGPropertyNode *altitude
456 = fgGetNode("/position/altitude-ft");
458 if ( altitude->getDoubleValue() > -9990 ) {
459 alt = altitude->getDoubleValue();
464 double sea_level_radius_meters, lat_geoc;
466 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
467 SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt );
469 sgGeodToGeoc( lat, alt * SG_FEET_TO_METER,
470 &sea_level_radius_meters, &lat_geoc );
471 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
472 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
473 fgic->SetLatitudeRadIC( lat_geoc * SGD_RADIANS_TO_DEGREES );
477 void FGJSBsim::set_Longitude(double lon) {
479 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon );
481 fgic->SetLongitudeRadIC(lon * SGD_RADIANS_TO_DEGREES );
485 void FGJSBsim::set_Altitude(double alt) {
486 static const SGPropertyNode *latitude
487 = fgGetNode("/position/latitude-deg");
489 double sea_level_radius_meters,lat_geoc;
491 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt );
492 SG_LOG(SG_FLIGHT,SG_INFO, " lat (deg) = " << latitude->getDoubleValue() );
494 sgGeodToGeoc( latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, alt,
495 &sea_level_radius_meters, &lat_geoc);
496 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
497 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
498 fgic->SetLatitudeRadIC( lat_geoc * SGD_RADIANS_TO_DEGREES );
499 fgic->SetAltitudeFtIC(alt);
503 void FGJSBsim::set_V_calibrated_kts(double vc) {
504 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " << vc );
506 fgic->SetVcalibratedKtsIC(vc);
510 void FGJSBsim::set_Mach_number(double mach) {
511 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " << mach );
513 fgic->SetMachIC(mach);
517 void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
518 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: "
519 << north << ", " << east << ", " << down );
521 fgic->SetVnorthFpsIC(north);
522 fgic->SetVeastFpsIC(east);
523 fgic->SetVdownFpsIC(down);
527 void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
528 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
529 << u << ", " << v << ", " << w );
531 fgic->SetUBodyFpsIC(u);
532 fgic->SetVBodyFpsIC(v);
533 fgic->SetWBodyFpsIC(w);
538 void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
539 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: "
540 << phi << ", " << theta << ", " << psi );
542 fgic->SetPitchAngleRadIC(theta);
543 fgic->SetRollAngleRadIC(phi);
544 fgic->SetTrueHeadingRadIC(psi);
549 void FGJSBsim::set_Climb_Rate( double roc) {
550 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
552 fgic->SetClimbRateFpsIC(roc);
556 void FGJSBsim::set_Gamma_vert_rad( double gamma) {
557 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
559 fgic->SetFlightPathAngleRadIC(gamma);
564 void FGJSBsim::set_Sea_level_radius(double slr) {
565 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
567 fgic->SetSeaLevelRadiusFtIC(slr);
571 void FGJSBsim::set_Runway_altitude(double ralt) {
572 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
574 _set_Runway_altitude( ralt );
575 fgic->SetTerrainAltitudeFtIC( ralt );
579 void FGJSBsim::set_Static_pressure(double p) {
580 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p );
582 Atmosphere->SetExPressure(p);
583 if(Atmosphere->External() == true)
587 void FGJSBsim::set_Static_temperature(double T) {
588 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_temperature: " << T );
590 Atmosphere->SetExTemperature(T);
591 if(Atmosphere->External() == true)
596 void FGJSBsim::set_Density(double rho) {
597 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Density: " << rho );
599 Atmosphere->SetExDensity(rho);
600 if(Atmosphere->External() == true)
605 void FGJSBsim::set_Velocities_Local_Airmass (double wnorth,
608 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: "
609 << wnorth << ", " << weast << ", " << wdown );
611 _set_Velocities_Local_Airmass( wnorth, weast, wdown );
612 Atmosphere->SetWindNED(wnorth, weast, wdown );
613 if(Atmosphere->External() == true)
619 void FGJSBsim::update_Latitude(double lat) {
620 double sea_level_radius_meters, lat_geoc;
622 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::update_Latitude: " << lat );
623 SG_LOG(SG_FLIGHT,SG_INFO," cur alt = " << get_Altitude() );
626 sgGeodToGeoc( lat, get_Altitude(), &sea_level_radius_meters, &lat_geoc);
627 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
628 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
629 fgic->SetLatitudeRadIC( lat_geoc );
630 fdmex->RunIC(fgic); //loop JSBSim once
631 copy_from_JSBsim(); //update the bus
635 void FGJSBsim::update_Longitude(double lon) {
637 SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::update_Longitude: " << lon );
638 SG_LOG(SG_FLIGHT,SG_INFO," cur alt = " << get_Altitude() );
641 fgic->SetLongitudeRadIC(lon);
642 fdmex->RunIC(fgic); //loop JSBSim once
643 copy_from_JSBsim(); //update the bus
647 void FGJSBsim::update_Altitude(double alt) {
648 double sea_level_radius_meters,lat_geoc;
650 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Altitude: " << alt );
653 sgGeodToGeoc( get_Latitude(), alt , &sea_level_radius_meters, &lat_geoc);
654 _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
655 fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
656 fgic->SetLatitudeRadIC( lat_geoc );
657 fgic->SetAltitudeFtIC(alt);
658 fdmex->RunIC(fgic); //loop JSBSim once
659 copy_from_JSBsim(); //update the bus
663 void FGJSBsim::update_V_calibrated_kts(double vc) {
664 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_V_calibrated_kts: " << vc );
667 fgic->SetVcalibratedKtsIC(vc);
668 fdmex->RunIC(fgic); //loop JSBSim once
669 copy_from_JSBsim(); //update the bus
673 void FGJSBsim::update_Mach_number(double mach) {
674 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Mach_number: " << mach );
677 fgic->SetMachIC(mach);
678 fdmex->RunIC(fgic); //loop JSBSim once
679 copy_from_JSBsim(); //update the bus
683 void FGJSBsim::update_Velocities_Local( double north, double east, double down ){
684 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Local: "
685 << north << ", " << east << ", " << down );
688 fgic->SetVnorthFpsIC(north);
689 fgic->SetVeastFpsIC(east);
690 fgic->SetVdownFpsIC(down);
691 fdmex->RunIC(fgic); //loop JSBSim once
692 copy_from_JSBsim(); //update the bus
696 void FGJSBsim::update_Velocities_Wind_Body( double u, double v, double w){
697 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Wind_Body: "
698 << u << ", " << v << ", " << w );
701 fgic->SetUBodyFpsIC(u);
702 fgic->SetVBodyFpsIC(v);
703 fgic->SetWBodyFpsIC(w);
704 fdmex->RunIC(fgic); //loop JSBSim once
705 copy_from_JSBsim(); //update the bus
710 void FGJSBsim::update_Euler_Angles( double phi, double theta, double psi ) {
711 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Euler_Angles: "
712 << phi << ", " << theta << ", " << psi );
715 fgic->SetPitchAngleRadIC(theta);
716 fgic->SetRollAngleRadIC(phi);
717 fgic->SetTrueHeadingRadIC(psi);
718 fdmex->RunIC(fgic); //loop JSBSim once
719 copy_from_JSBsim(); //update the bus
724 void FGJSBsim::update_Climb_Rate( double roc) {
725 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Climb_Rate: " << roc );
728 fgic->SetClimbRateFpsIC(roc);
729 fdmex->RunIC(fgic); //loop JSBSim once
730 copy_from_JSBsim(); //update the bus
734 void FGJSBsim::update_Gamma_vert_rad( double gamma) {
735 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Gamma_vert_rad: " << gamma );
738 fgic->SetFlightPathAngleRadIC(gamma);
739 fdmex->RunIC(fgic); //loop JSBSim once
740 copy_from_JSBsim(); //update the bus
745 void FGJSBsim::update_Sea_level_radius(double slr) {
746 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Sea_level_radius: " << slr );
749 fgic->SetSeaLevelRadiusFtIC(slr);
750 fdmex->RunIC(fgic); //loop JSBSim once
751 copy_from_JSBsim(); //update the bus
755 void FGJSBsim::update_Runway_altitude(double ralt) {
756 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Runway_altitude: " << ralt );
759 _set_Runway_altitude( ralt );
760 fgic->SetTerrainAltitudeFtIC( ralt );
761 fdmex->RunIC(fgic); //loop JSBSim once
762 copy_from_JSBsim(); //update the bus
766 void FGJSBsim::update_Static_pressure(double p) {
767 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Static_pressure: " << p );
770 Atmosphere->SetExPressure(p);
771 if(Atmosphere->External() == true)
775 void FGJSBsim::update_Static_temperature(double T) {
776 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Static_temperature: " << T );
779 Atmosphere->SetExTemperature(T);
780 if(Atmosphere->External() == true)
785 void FGJSBsim::update_Density(double rho) {
786 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Density: " << rho );
789 Atmosphere->SetExDensity(rho);
790 if(Atmosphere->External() == true)
795 void FGJSBsim::update_Velocities_Local_Airmass (double wnorth,
798 SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::update_Velocities_Local_Airmass: "
799 << wnorth << ", " << weast << ", " << wdown );
801 _set_Velocities_Local_Airmass( wnorth, weast, wdown );
803 Atmosphere->SetWindNED(wnorth, weast, wdown );
804 if(Atmosphere->External() == true)