]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim.cxx
This set of changes touches a *lot* of files. The main goal here is to
[flightgear.git] / src / FDM / JSBSim.cxx
1 // JSBsim.cxx -- interface to the JSBsim flight model
2 //
3 // Written by Curtis Olson, started February 1999.
4 //
5 // Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #include <simgear/compiler.h>
25
26 #ifdef SG_MATH_EXCEPTION_CLASH
27 #  include <math.h>
28 #endif
29
30 #include STL_STRING
31
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>
36
37 #include <Scenery/scenery.hxx>
38
39 #include <Aircraft/aircraft.hxx>
40 #include <Controls/controls.hxx>
41 #include <Main/globals.hxx>
42 #include <Main/fg_props.hxx>
43
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>
58 #include "JSBSim.hxx"
59
60 /******************************************************************************/
61
62 FGJSBsim::FGJSBsim( double dt ) 
63   : FGInterface(dt)
64 {
65     bool result;
66    
67     fdmex=new FGFDMExec;
68     
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();
80     
81     Atmosphere->UseInternal();
82     
83     fgic=new FGInitialCondition(fdmex);
84     needTrim=true;
85   
86     SGPath aircraft_path( globals->get_fg_root() );
87     aircraft_path.append( "Aircraft" );
88
89     SGPath engine_path( globals->get_fg_root() );
90     engine_path.append( "Engine" );
91     set_delta_t( dt );
92     State->Setdt( dt );
93
94     result = fdmex->LoadModel( aircraft_path.str(),
95                                engine_path.str(),
96                                fgGetString("/sim/aircraft") );
97     
98
99     if (result) {
100       SG_LOG( SG_FLIGHT, SG_INFO, "  loaded aircraft.");
101     } else {
102       SG_LOG( SG_FLIGHT, SG_INFO,
103               "  aircraft does not exist (you may have mis-typed the name).");
104       throw(-1);
105     }
106
107     int Neng = Propulsion->GetNumEngines();
108     SG_LOG(SG_FLIGHT,SG_INFO, "Neng: " << Neng );
109     
110     for(int i=0;i<Neng;i++) {
111         add_engine( FGEngInterface() );
112     }  
113     
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());
118
119     startup_trim = fgGetNode("/sim/startup/trim", true);
120
121     trimmed = fgGetNode("/fdm/trim/trimmed", true);
122     trimmed->setBoolValue(false);
123
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 );
128 }
129
130 /******************************************************************************/
131 FGJSBsim::~FGJSBsim(void) {
132     if (fdmex != NULL) {
133         delete fdmex; fdmex=NULL;
134         delete fgic; fgic=NULL;
135     }  
136 }
137
138 /******************************************************************************/
139
140 // Initialize the JSBsim flight model, dt is the time increment for
141 // each subsequent iteration through the EOM
142
143 void FGJSBsim::init() {
144     
145     SG_LOG( SG_FLIGHT, SG_INFO, "Starting and initializing JSBsim" );
146    
147     // Explicitly call the superclass's
148     // init method first.
149     FGInterface::init();
150
151     SG_LOG( SG_FLIGHT, SG_INFO, "  Initializing JSBSim with:" );
152
153     switch(fgic->GetSpeedSet()) {
154     case setned:
155         SG_LOG(SG_FLIGHT,SG_INFO, "  Vn,Ve,Vd= "
156                << Position->GetVn() << ", "
157                << Position->GetVe() << ", "
158                << Position->GetVd() << " ft/s");
159     break;
160     case setuvw:
161         SG_LOG(SG_FLIGHT,SG_INFO, "  U,V,W= "
162                << Translation->GetUVW(1) << ", "
163                << Translation->GetUVW(2) << ", "
164                << Translation->GetUVW(3) << " ft/s");
165     break;
166     case setmach:
167         SG_LOG(SG_FLIGHT,SG_INFO, "  Mach: "
168                << Translation->GetMach() );
169     break;
170     case setvc:
171     default:
172         SG_LOG(SG_FLIGHT,SG_INFO, "  Indicated Airspeed: "
173                << Auxiliary->GetVcalibratedKTS() << " knots" );
174     break;
175     }
176
177     SG_LOG( SG_FLIGHT, SG_INFO, "  Bank Angle: "
178             <<  Rotation->Getphi()*RADTODEG << " deg");
179     SG_LOG( SG_FLIGHT, SG_INFO, "  Pitch Angle: "
180             << Rotation->Gettht()*RADTODEG << " deg"  );
181     SG_LOG( SG_FLIGHT, SG_INFO, "  True Heading: "
182             << Rotation->Getpsi()*RADTODEG << " deg"  );
183     SG_LOG( SG_FLIGHT, SG_INFO, "  Latitude: "
184             <<  Position->GetLatitude() << " deg" );
185     SG_LOG( SG_FLIGHT, SG_INFO, "  Longitude: "
186             <<  Position->GetLongitude() << " deg"  );
187
188     SG_LOG( SG_FLIGHT, SG_INFO, "  loaded initial conditions" );
189
190     SG_LOG( SG_FLIGHT, SG_INFO, "  set dt" );
191
192     SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing JSBSim" );
193 }
194
195 /******************************************************************************/
196
197 // Run an iteration of the EOM (equations of motion)
198
199 bool FGJSBsim::update( int multiloop ) {
200
201     int i;
202
203     double save_alt = 0.0;
204
205     copy_to_JSBsim();
206
207     trimmed->setBoolValue(false);
208
209     if ( needTrim && startup_trim->getBoolValue() ) {
210
211         //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
212         //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
213
214         FGTrim *fgtrim;
215         if(fgic->GetVcalibratedKtsIC() < 10 ) {
216             fgic->SetVcalibratedKtsIC(0.0);
217             fgtrim=new FGTrim(fdmex,fgic,tGround);
218         } else {
219             fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
220         }
221         if(!fgtrim->DoTrim()) {
222             fgtrim->Report();
223             fgtrim->TrimStats();
224         } else {
225             trimmed->setBoolValue(true);
226         }
227         fgtrim->ReportState();
228         delete fgtrim;
229
230         needTrim=false;
231
232         pitch_trim->setDoubleValue( FCS->GetPitchTrimCmd() );
233         throttle_trim->setDoubleValue( FCS->GetThrottleCmd(0) );
234         aileron_trim->setDoubleValue( FCS->GetDaCmd() );
235         rudder_trim->setDoubleValue( FCS->GetDrCmd() );
236
237         globals->get_controls()->set_elevator_trim(FCS->GetPitchTrimCmd());
238         globals->get_controls()->set_elevator(FCS->GetDeCmd());
239         globals->get_controls()->set_throttle(FGControls::ALL_ENGINES,
240                                               FCS->GetThrottleCmd(0));
241
242         globals->get_controls()->set_aileron(FCS->GetDaCmd());
243         globals->get_controls()->set_rudder( FCS->GetDrCmd());
244     
245         SG_LOG( SG_FLIGHT, SG_INFO, "  Trim complete" );
246     }
247   
248     for( i=0; i<get_num_engines(); i++ ) {
249       FGEngInterface * e = get_engine(i);
250       FGEngine * eng = Propulsion->GetEngine(i);
251       FGThruster * thrust = Propulsion->GetThruster(i);
252       e->set_Manifold_Pressure( eng->getManifoldPressure_inHg() );
253       e->set_RPM( thrust->GetRPM() );
254       e->set_EGT( eng->getExhaustGasTemp_degF() );
255       e->set_CHT( eng->getCylinderHeadTemp_degF() );
256       e->set_Oil_Temp( eng->getOilTemp_degF() );
257       e->set_Throttle( globals->get_controls()->get_throttle(i) );
258     }
259
260     for ( i=0; i < multiloop; i++ ) {
261         fdmex->Run();
262     }
263
264     // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
265     // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
266
267     // translate JSBsim back to FG structure so that the
268     // autopilot (and the rest of the sim can use the updated values
269
270     copy_from_JSBsim();
271     return true;
272 }
273
274 /******************************************************************************/
275
276 // Convert from the FGInterface struct to the JSBsim generic_ struct
277
278 bool FGJSBsim::copy_to_JSBsim() {
279     // copy control positions into the JSBsim structure
280
281     FCS->SetDaCmd( globals->get_controls()->get_aileron());
282     FCS->SetDeCmd( globals->get_controls()->get_elevator());
283     FCS->SetPitchTrimCmd(globals->get_controls()->get_elevator_trim());
284     FCS->SetDrCmd( -globals->get_controls()->get_rudder());
285     FCS->SetDfCmd(  globals->get_controls()->get_flaps() );
286     FCS->SetDsbCmd( 0.0 ); //speedbrakes
287     FCS->SetDspCmd( 0.0 ); //spoilers
288     FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) );
289     FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) );
290     FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) );
291     for (int i = 0; i < get_num_engines(); i++) {
292       FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i));
293       FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i));
294     }
295
296     Position->SetSeaLevelRadius( get_Sea_level_radius() );
297     Position->SetRunwayRadius( scenery.get_cur_elev()*SG_METER_TO_FEET
298                                + get_Sea_level_radius() );
299
300     Atmosphere->SetExTemperature(get_Static_temperature());
301     Atmosphere->SetExPressure(get_Static_pressure());
302     Atmosphere->SetExDensity(get_Density());
303     Atmosphere->SetWindNED(get_V_north_airmass(),
304                            get_V_east_airmass(),
305                            get_V_down_airmass());
306 //    SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
307 //                  << get_V_north_airmass() << ", "
308 //                  << get_V_east_airmass()  << ", "
309 //                  << get_V_down_airmass() );
310
311     return true;
312 }
313
314 /******************************************************************************/
315
316 // Convert from the JSBsim generic_ struct to the FGInterface struct
317
318 bool FGJSBsim::copy_from_JSBsim() {
319     unsigned int i, j;
320
321     _set_Inertias( MassBalance->GetMass(),
322                    MassBalance->GetIxx(),
323                    MassBalance->GetIyy(),
324                    MassBalance->GetIzz(),
325                    MassBalance->GetIxz() );
326
327     _set_CG_Position( MassBalance->GetXYZcg(1),
328                       MassBalance->GetXYZcg(2),
329                       MassBalance->GetXYZcg(3) );
330
331     _set_Accels_Body( Translation->GetUVWdot(1),
332                       Translation->GetUVWdot(2),
333                       Translation->GetUVWdot(3) );
334
335     _set_Accels_CG_Body( Translation->GetUVWdot(1),
336                          Translation->GetUVWdot(2),
337                          Translation->GetUVWdot(3) );
338
339     //_set_Accels_CG_Body_N ( Translation->GetNcg(1),
340     //                       Translation->GetNcg(2),
341     //                       Translation->GetNcg(3) );
342     //
343     _set_Accels_Pilot_Body( Auxiliary->GetPilotAccel(1),
344                             Auxiliary->GetPilotAccel(2),
345                             Auxiliary->GetPilotAccel(3) );
346
347     //_set_Accels_Pilot_Body_N( Auxiliary->GetNpilot(1),
348     //                         Auxiliary->GetNpilot(2),
349     //                         Auxiliary->GetNpilot(3) );
350
351     _set_Nlf( Aerodynamics->GetNlf() );
352
353     // Velocities
354
355     _set_Velocities_Local( Position->GetVn(),
356                            Position->GetVe(),
357                            Position->GetVd() );
358
359     _set_Velocities_Wind_Body( Translation->GetUVW(1),
360                                Translation->GetUVW(2),
361                                Translation->GetUVW(3) );
362
363     _set_V_rel_wind( Translation->GetVt() );
364
365     _set_V_equiv_kts( Auxiliary->GetVequivalentKTS() );
366
367     // _set_V_calibrated( Auxiliary->GetVcalibratedFPS() );
368
369     _set_V_calibrated_kts( Auxiliary->GetVcalibratedKTS() );
370
371     _set_V_ground_speed( Position->GetVground() );
372
373     _set_Omega_Body( Rotation->GetPQR(1),
374                      Rotation->GetPQR(2),
375                      Rotation->GetPQR(3) );
376
377     _set_Euler_Rates( Rotation->GetEulerRates(1),
378                       Rotation->GetEulerRates(2),
379                       Rotation->GetEulerRates(3) );
380
381     _set_Geocentric_Rates(Position->GetLatitudeDot(),
382                           Position->GetLongitudeDot(),
383                           Position->Gethdot() );
384
385     _set_Mach_number( Translation->GetMach() );
386
387     // Positions
388     _updatePosition( Position->GetLatitude(),
389                      Position->GetLongitude(),
390                      Position->Geth() );
391
392     _set_Altitude_AGL( Position->GetDistanceAGL() );
393
394     _set_Euler_Angles( Rotation->Getphi(),
395                        Rotation->Gettht(),
396                        Rotation->Getpsi() );
397
398     _set_Alpha( Translation->Getalpha() );
399     _set_Beta( Translation->Getbeta() );
400
401
402     _set_Gamma_vert_rad( Position->GetGamma() );
403     // set_Gamma_horiz_rad( Gamma_horiz_rad );
404
405     _set_Earth_position_angle( Auxiliary->GetEarthPositionAngle() );
406
407     _set_Climb_Rate( Position->Gethdot() );
408
409
410     for ( i = 1; i <= 3; i++ ) {
411         for ( j = 1; j <= 3; j++ ) {
412             _set_T_Local_to_Body( i, j, State->GetTl2b(i,j) );
413         }
414     }
415     return true;
416 }
417
418 void FGJSBsim::snap_shot(void) {
419     fgic->SetLatitudeRadIC(get_Lat_geocentric() );
420     fgic->SetLongitudeRadIC( get_Longitude() );
421     fgic->SetAltitudeFtIC( get_Altitude() );
422     fgic->SetTerrainAltitudeFtIC( get_Runway_altitude() );
423     fgic->SetVtrueFpsIC( get_V_rel_wind() );
424     fgic->SetPitchAngleRadIC( get_Theta() );
425     fgic->SetRollAngleRadIC( get_Phi() );
426     fgic->SetTrueHeadingRadIC( get_Psi() );
427     fgic->SetClimbRateFpsIC( get_Climb_Rate() );
428 }
429
430
431 bool FGJSBsim::ToggleDataLogging(void) {
432     return fdmex->GetOutput()->Toggle();
433 }
434
435
436 bool FGJSBsim::ToggleDataLogging(bool state) {
437     if (state) {
438       fdmex->GetOutput()->Enable();
439       return true;
440     } else {
441       fdmex->GetOutput()->Disable();
442       return false;
443     }
444 }
445
446
447 //Positions
448 void FGJSBsim::set_Latitude(double lat) {
449     double sea_level_radius_meters,lat_geoc;
450
451     SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
452
453     snap_shot();
454     sgGeodToGeoc( lat, get_Altitude() , &sea_level_radius_meters, &lat_geoc);
455     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
456     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET  );
457     fgic->SetLatitudeRadIC( lat_geoc );
458     fdmex->RunIC(fgic); //loop JSBSim once
459     copy_from_JSBsim(); //update the bus
460     needTrim=true;
461 }
462
463 void FGJSBsim::set_Longitude(double lon) {
464
465     SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon );
466
467     snap_shot();
468     fgic->SetLongitudeRadIC(lon);
469     fdmex->RunIC(fgic); //loop JSBSim once
470     copy_from_JSBsim(); //update the bus
471     needTrim=true;
472 }
473
474 void FGJSBsim::set_Altitude(double alt) {
475     double sea_level_radius_meters,lat_geoc;
476
477     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt );
478
479     snap_shot();
480     sgGeodToGeoc( get_Latitude(), alt , &sea_level_radius_meters, &lat_geoc);
481     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
482     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
483     fgic->SetLatitudeRadIC( lat_geoc );
484     fgic->SetAltitudeFtIC(alt);
485     fdmex->RunIC(fgic); //loop JSBSim once
486     copy_from_JSBsim(); //update the bus
487     needTrim=true;
488 }
489
490 void FGJSBsim::set_V_calibrated_kts(double vc) {
491     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " <<  vc );
492
493     snap_shot();
494     fgic->SetVcalibratedKtsIC(vc);
495     fdmex->RunIC(fgic); //loop JSBSim once
496     copy_from_JSBsim(); //update the bus
497     needTrim=true;
498 }
499
500 void FGJSBsim::set_Mach_number(double mach) {
501     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " <<  mach );
502
503     snap_shot();
504     fgic->SetMachIC(mach);
505     fdmex->RunIC(fgic); //loop JSBSim once
506     copy_from_JSBsim(); //update the bus
507     needTrim=true;
508 }
509
510 void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
511     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: "
512        << north << ", " <<  east << ", " << down );
513
514     snap_shot();
515     fgic->SetVnorthFpsIC(north);
516     fgic->SetVeastFpsIC(east);
517     fgic->SetVdownFpsIC(down);
518     fdmex->RunIC(fgic); //loop JSBSim once
519     copy_from_JSBsim(); //update the bus
520     needTrim=true;
521 }
522
523 void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
524     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
525        << u << ", " <<  v << ", " <<  w );
526
527     snap_shot();
528     fgic->SetUBodyFpsIC(u);
529     fgic->SetVBodyFpsIC(v);
530     fgic->SetWBodyFpsIC(w);
531     fdmex->RunIC(fgic); //loop JSBSim once
532     copy_from_JSBsim(); //update the bus
533     needTrim=true;
534 }
535
536 //Euler angles
537 void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
538     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: "
539        << phi << ", " << theta << ", " << psi );
540
541     snap_shot();
542     fgic->SetPitchAngleRadIC(theta);
543     fgic->SetRollAngleRadIC(phi);
544     fgic->SetTrueHeadingRadIC(psi);
545     fdmex->RunIC(fgic); //loop JSBSim once
546     copy_from_JSBsim(); //update the bus
547     needTrim=true;
548 }
549
550 //Flight Path
551 void FGJSBsim::set_Climb_Rate( double roc) {
552     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
553
554     snap_shot();
555     fgic->SetClimbRateFpsIC(roc);
556     fdmex->RunIC(fgic); //loop JSBSim once
557     copy_from_JSBsim(); //update the bus
558     needTrim=true;
559 }
560
561 void FGJSBsim::set_Gamma_vert_rad( double gamma) {
562     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
563
564     snap_shot();
565     fgic->SetFlightPathAngleRadIC(gamma);
566     fdmex->RunIC(fgic); //loop JSBSim once
567     copy_from_JSBsim(); //update the bus
568     needTrim=true;
569 }
570
571 //Earth
572 void FGJSBsim::set_Sea_level_radius(double slr) {
573     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
574
575     snap_shot();
576     fgic->SetSeaLevelRadiusFtIC(slr);
577     fdmex->RunIC(fgic); //loop JSBSim once
578     copy_from_JSBsim(); //update the bus
579     needTrim=true;
580 }
581
582 void FGJSBsim::set_Runway_altitude(double ralt) {
583     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
584
585     snap_shot();
586     _set_Runway_altitude( ralt );
587     fgic->SetTerrainAltitudeFtIC( ralt );
588     fdmex->RunIC(fgic); //loop JSBSim once
589     copy_from_JSBsim(); //update the bus
590     needTrim=true;
591 }
592
593 void FGJSBsim::set_Static_pressure(double p) {
594     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p );
595
596     snap_shot();
597     Atmosphere->SetExPressure(p);
598     if(Atmosphere->External() == true)
599     needTrim=true;
600 }
601
602 void FGJSBsim::set_Static_temperature(double T) {
603     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_temperature: " << T );
604     
605     snap_shot();
606     Atmosphere->SetExTemperature(T);
607     if(Atmosphere->External() == true)
608     needTrim=true;
609 }
610  
611
612 void FGJSBsim::set_Density(double rho) {
613     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Density: " << rho );
614     
615     snap_shot();
616     Atmosphere->SetExDensity(rho);
617     if(Atmosphere->External() == true)
618     needTrim=true;
619 }
620   
621
622 void FGJSBsim::set_Velocities_Local_Airmass (double wnorth, 
623                          double weast, 
624                          double wdown ) {
625     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: " 
626        << wnorth << ", " << weast << ", " << wdown );
627     
628     _set_Velocities_Local_Airmass( wnorth, weast, wdown );
629     snap_shot();
630     Atmosphere->SetWindNED(wnorth, weast, wdown );
631     if(Atmosphere->External() == true)
632         needTrim=true;
633 }     
634