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