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