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