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