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