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