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