1 // LaRCsim.cxx -- interface to the LaRCsim flight model
3 // Written by Curtis Olson, started October 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
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.
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.
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.
24 #include <simgear/constants.h>
25 #include <simgear/debug/logstream.hxx>
27 #include <Scenery/scenery.hxx>
29 #include <Main/fg_props.hxx>
30 #include <Aircraft/aircraft.hxx>
31 #include <Controls/controls.hxx>
32 #include <FDM/flight.hxx>
33 #include <FDM/LaRCsim/ls_cockpit.h>
34 #include <FDM/LaRCsim/ls_generic.h>
35 #include <FDM/LaRCsim/ls_interface.h>
36 #include <FDM/LaRCsimIC.hxx>
39 #include "LaRCsim.hxx"
41 FGLaRCsim::FGLaRCsim( double dt ) {
44 ls_toplevel_init( 0.0,
45 (char *)fgGetString("/sim/aircraft").c_str() );
46 lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
47 copy_to_LaRCsim(); // initialize all of LaRCsim's vars
48 //this should go away someday -- formerly done in fg_init.cxx
56 FGLaRCsim::~FGLaRCsim(void) {
62 // Initialize the LaRCsim flight model, dt is the time increment for
63 // each subsequent iteration through the EOM
64 void FGLaRCsim::init() {
66 speed_up = fgGetValue("/sim/speed-up", true);
68 ls_set_model_dt( get_delta_t() );
69 // Initialize our little engine that hopefully might
70 eng.init( get_delta_t() );
71 // dcl - in passing dt to init rather than update I am assuming
72 // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
74 // update the engines interface
79 // FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::init()" );
81 double save_alt = 0.0;
83 if ( get_Altitude() < -9000.0 ) {
84 save_alt = get_Altitude();
88 // translate FG to LaRCsim structure
91 // actual LaRCsim top level init
92 // ls_toplevel_init( dt, (char *)fgGetString("/sim/aircraft").c_str() );
94 FG_LOG( FG_FLIGHT, FG_INFO, "FG pos = " <<
97 // translate LaRCsim back to FG structure
100 // but lets restore our original bogus altitude when we are done
101 if ( save_alt < -9000.0 ) {
102 set_Altitude( save_alt );
107 // Run an iteration of the EOM (equations of motion)
108 bool FGLaRCsim::update( int multiloop ) {
110 if ( fgGetString("/sim/aircraft") == "c172" ) {
111 // set control inputs
112 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
113 eng.set_IAS( V_calibrated_kts );
114 eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
115 eng.set_Propeller_Lever_Pos( 100 );
116 if ( controls.get_mixture( 0 ) > 0.60 ) {
117 eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 );
119 eng.set_Mixture_Lever_Pos( 60.0 );
122 // update engine model
125 // copy engine state values onto "bus"
126 FGEngInterface *e = get_engine( 0 );
127 e->set_Throttle( controls.get_throttle( 0 ) * 100.0 );
128 e->set_Mixture( 80 );
129 e->set_Prop_Advance( 100 );
130 e->set_RPM( eng.get_RPM() );
131 e->set_Manifold_Pressure( eng.get_Manifold_Pressure() );
132 e->set_MaxHP( eng.get_MaxHP() );
133 e->set_Percentage_Power( eng.get_Percentage_Power() );
134 e->set_EGT( eng.get_EGT() );
135 e->set_CHT( eng.get_CHT() );
136 e->set_prop_thrust( eng.get_prop_thrust_SI() );
139 FG_LOG( FG_FLIGHT, FG_INFO, "Throttle = "
140 << controls.get_throttle( 0 ) * 100.0);
141 FG_LOG( FG_FLIGHT, FG_INFO, " Mixture = " << 80);
142 FG_LOG( FG_FLIGHT, FG_INFO, " RPM = " << eng.get_RPM());
143 FG_LOG( FG_FLIGHT, FG_INFO, " MP = " << eng.get_Manifold_Pressure());
144 FG_LOG( FG_FLIGHT, FG_INFO, " HP = "
145 << ( eng.get_MaxHP() * eng.get_Percentage_Power()/ 100.0) );
146 FG_LOG( FG_FLIGHT, FG_INFO, " EGT = " << eng.get_EGT());
147 FG_LOG( FG_FLIGHT, FG_INFO, " Thrust (N) "
148 << eng.get_prop_thrust_SI()); // Thrust in Newtons
149 FG_LOG( FG_FLIGHT, FG_INFO, '\n');
151 F_X_engine = eng.get_prop_thrust_lbs();
152 // cout << "F_X_engine = " << F_X_engine << '\n';
155 double save_alt = 0.0;
157 // lets try to avoid really screwing up the LaRCsim model
158 if ( get_Altitude() < -9000.0 ) {
159 save_alt = get_Altitude();
163 // copy control positions into the LaRCsim structure
164 Lat_control = controls.get_aileron() /
165 speed_up->getIntValue();
166 Long_control = controls.get_elevator();
167 Long_trim = controls.get_elevator_trim();
168 Rudder_pedal = controls.get_rudder() /
169 speed_up->getIntValue();
170 Flap_handle = 30.0 * controls.get_flaps();
172 if ( fgGetString("/sim/aircraft") == "c172" ) {
173 Use_External_Engine = 1;
175 Use_External_Engine = 0;
178 Throttle_pct = controls.get_throttle( 0 ) * 1.0;
180 Brake_pct[0] = controls.get_brake( 1 );
181 Brake_pct[1] = controls.get_brake( 0 );
183 // Inform LaRCsim of the local terrain altitude
184 // Runway_altitude = get_Runway_altitude();
185 Runway_altitude = scenery.cur_elev * METER_TO_FEET;
188 /* V_north_airmass = get_V_north_airmass();
189 V_east_airmass = get_V_east_airmass();
190 V_down_airmass = get_V_down_airmass(); */
193 // old -- FGInterface_2_LaRCsim() not needed except for Init()
194 // translate FG to LaRCsim structure
195 // FGInterface_2_LaRCsim(f);
196 // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
197 // printf("Altitude = %.2f\n", Altitude * 0.3048);
198 // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
200 ls_update(multiloop);
202 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
203 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
205 // translate LaRCsim back to FG structure so that the
206 // autopilot (and the rest of the sim can use the updated
210 // but lets restore our original bogus altitude when we are done
211 if ( save_alt < -9000.0 ) {
212 set_Altitude( save_alt );
219 // Convert from the FGInterface struct to the LaRCsim generic_ struct
220 bool FGLaRCsim::copy_to_LaRCsim () {
226 // Dx_pilot = get_Dx_pilot();
227 // Dy_pilot = get_Dy_pilot();
228 // Dz_pilot = get_Dz_pilot();
235 // F_north = get_F_north();
236 // F_east = get_F_east();
237 // F_down = get_F_down();
238 // F_X_aero = get_F_X_aero();
239 // F_Y_aero = get_F_Y_aero();
240 // F_Z_aero = get_F_Z_aero();
241 // F_X_engine = get_F_X_engine();
242 // F_Y_engine = get_F_Y_engine();
243 // F_Z_engine = get_F_Z_engine();
244 // F_X_gear = get_F_X_gear();
245 // F_Y_gear = get_F_Y_gear();
246 // F_Z_gear = get_F_Z_gear();
247 // M_l_rp = get_M_l_rp();
248 // M_m_rp = get_M_m_rp();
249 // M_n_rp = get_M_n_rp();
250 // M_l_cg = get_M_l_cg();
251 // M_m_cg = get_M_m_cg();
252 // M_n_cg = get_M_n_cg();
253 // M_l_aero = get_M_l_aero();
254 // M_m_aero = get_M_m_aero();
255 // M_n_aero = get_M_n_aero();
256 // M_l_engine = get_M_l_engine();
257 // M_m_engine = get_M_m_engine();
258 // M_n_engine = get_M_n_engine();
259 // M_l_gear = get_M_l_gear();
260 // M_m_gear = get_M_m_gear();
261 // M_n_gear = get_M_n_gear();
262 // V_dot_north = get_V_dot_north();
263 // V_dot_east = get_V_dot_east();
264 // V_dot_down = get_V_dot_down();
265 // U_dot_body = get_U_dot_body();
266 // V_dot_body = get_V_dot_body();
267 // W_dot_body = get_W_dot_body();
268 // A_X_cg = get_A_X_cg();
269 // A_Y_cg = get_A_Y_cg();
270 // A_Z_cg = get_A_Z_cg();
271 // A_X_pilot = get_A_X_pilot();
272 // A_Y_pilot = get_A_Y_pilot();
273 // A_Z_pilot = get_A_Z_pilot();
274 // N_X_cg = get_N_X_cg();
275 // N_Y_cg = get_N_Y_cg();
276 // N_Z_cg = get_N_Z_cg();
277 // N_X_pilot = get_N_X_pilot();
278 // N_Y_pilot = get_N_Y_pilot();
279 // N_Z_pilot = get_N_Z_pilot();
280 // P_dot_body = get_P_dot_body();
281 // Q_dot_body = get_Q_dot_body();
282 // R_dot_body = get_R_dot_body();
283 // V_north = get_V_north();
284 // V_east = get_V_east();
285 // V_down = get_V_down();
286 // V_north_rel_ground = get_V_north_rel_ground();
287 // V_east_rel_ground = get_V_east_rel_ground();
288 // V_down_rel_ground = get_V_down_rel_ground();
289 // V_north_airmass = get_V_north_airmass();
290 // V_east_airmass = get_V_east_airmass();
291 // V_down_airmass = get_V_down_airmass();
292 // V_north_rel_airmass = get_V_north_rel_airmass();
293 // V_east_rel_airmass = get_V_east_rel_airmass();
294 // V_down_rel_airmass = get_V_down_rel_airmass();
295 // U_gust = get_U_gust();
296 // V_gust = get_V_gust();
297 // W_gust = get_W_gust();
298 // U_body = get_U_body();
299 // V_body = get_V_body();
300 // W_body = get_W_body();
301 // V_rel_wind = get_V_rel_wind();
302 // V_true_kts = get_V_true_kts();
303 // V_rel_ground = get_V_rel_ground();
304 // V_inertial = get_V_inertial();
305 // V_ground_speed = get_V_ground_speed();
306 // V_equiv = get_V_equiv();
307 // V_equiv_kts = get_V_equiv_kts();
308 // V_calibrated = get_V_calibrated();
309 // V_calibrated_kts = get_V_calibrated_kts();
310 // P_body = get_P_body();
311 // Q_body = get_Q_body();
312 // R_body = get_R_body();
313 // P_local = get_P_local();
314 // Q_local = get_Q_local();
315 // R_local = get_R_local();
316 // P_total = get_P_total();
317 // Q_total = get_Q_total();
318 // R_total = get_R_total();
319 // Phi_dot = get_Phi_dot();
320 // Theta_dot = get_Theta_dot();
321 // Psi_dot = get_Psi_dot();
322 // Latitude_dot = get_Latitude_dot();
323 // Longitude_dot = get_Longitude_dot();
324 // Radius_dot = get_Radius_dot();
325 // Lat_geocentric = get_Lat_geocentric();
326 // Lon_geocentric = get_Lon_geocentric();
327 // Radius_to_vehicle = get_Radius_to_vehicle();
328 // Latitude = get_Latitude();
329 // Longitude = get_Longitude();
330 // Altitude = get_Altitude();
332 // Theta = get_Theta();
334 // T_local_to_body_11 = get_T_local_to_body_11();
335 // T_local_to_body_12 = get_T_local_to_body_12();
336 // T_local_to_body_13 = get_T_local_to_body_13();
337 // T_local_to_body_21 = get_T_local_to_body_21();
338 // T_local_to_body_22 = get_T_local_to_body_22();
339 // T_local_to_body_23 = get_T_local_to_body_23();
340 // T_local_to_body_31 = get_T_local_to_body_31();
341 // T_local_to_body_32 = get_T_local_to_body_32();
342 // T_local_to_body_33 = get_T_local_to_body_33();
343 // Gravity = get_Gravity();
344 // Centrifugal_relief = get_Centrifugal_relief();
345 // Alpha = get_Alpha();
346 // Beta = get_Beta();
347 // Alpha_dot = get_Alpha_dot();
348 // Beta_dot = get_Beta_dot();
349 // Cos_alpha = get_Cos_alpha();
350 // Sin_alpha = get_Sin_alpha();
351 // Cos_beta = get_Cos_beta();
352 // Sin_beta = get_Sin_beta();
353 // Cos_phi = get_Cos_phi();
354 // Sin_phi = get_Sin_phi();
355 // Cos_theta = get_Cos_theta();
356 // Sin_theta = get_Sin_theta();
357 // Cos_psi = get_Cos_psi();
358 // Sin_psi = get_Sin_psi();
359 // Gamma_vert_rad = get_Gamma_vert_rad();
360 // Gamma_horiz_rad = get_Gamma_horiz_rad();
361 // Sigma = get_Sigma();
362 // Density = get_Density();
363 // V_sound = get_V_sound();
364 // Mach_number = get_Mach_number();
365 // Static_pressure = get_Static_pressure();
366 // Total_pressure = get_Total_pressure();
367 // Impact_pressure = get_Impact_pressure();
368 // Dynamic_pressure = get_Dynamic_pressure();
369 // Static_temperature = get_Static_temperature();
370 // Total_temperature = get_Total_temperature();
371 // Sea_level_radius = get_Sea_level_radius();
372 // Earth_position_angle = get_Earth_position_angle();
373 // Runway_altitude = get_Runway_altitude();
374 // Runway_latitude = get_Runway_latitude();
375 // Runway_longitude = get_Runway_longitude();
376 // Runway_heading = get_Runway_heading();
377 // Radius_to_rwy = get_Radius_to_rwy();
378 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
379 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
380 // D_cg_above_rwy = get_D_cg_above_rwy();
381 // X_cg_rwy = get_X_cg_rwy();
382 // Y_cg_rwy = get_Y_cg_rwy();
383 // H_cg_rwy = get_H_cg_rwy();
384 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
385 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
386 // D_pilot_above_rwy = get_D_pilot_above_rwy();
387 // X_pilot_rwy = get_X_pilot_rwy();
388 // Y_pilot_rwy = get_Y_pilot_rwy();
389 // H_pilot_rwy = get_H_pilot_rwy();
395 // Convert from the LaRCsim generic_ struct to the FGInterface struct
396 bool FGLaRCsim::copy_from_LaRCsim() {
398 // Mass properties and geometry values
399 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
400 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
401 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
404 // set_Forces_Body_Total( F_X, F_Y, F_Z );
405 // set_Forces_Local_Total( F_north, F_east, F_down );
406 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
407 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
408 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
411 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
412 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
413 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
414 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
415 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
418 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
419 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
420 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
421 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
422 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
423 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
424 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
427 _set_Velocities_Local( V_north, V_east, V_down );
428 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
429 // V_down_rel_ground );
430 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
432 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
433 // V_east_rel_airmass, V_down_rel_airmass );
434 // set_Velocities_Gust( U_gust, V_gust, W_gust );
435 _set_Velocities_Wind_Body( U_body, V_body, W_body );
437 _set_V_rel_wind( V_rel_wind );
438 // set_V_true_kts( V_true_kts );
439 // set_V_rel_ground( V_rel_ground );
440 // set_V_inertial( V_inertial );
441 _set_V_ground_speed( V_ground_speed );
442 // set_V_equiv( V_equiv );
443 _set_V_equiv_kts( V_equiv_kts );
444 // set_V_calibrated( V_calibrated );
445 _set_V_calibrated_kts( V_calibrated_kts );
447 _set_Omega_Body( P_body, Q_body, R_body );
448 // set_Omega_Local( P_local, Q_local, R_local );
449 // set_Omega_Total( P_total, Q_total, R_total );
451 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
452 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
454 _set_Mach_number( Mach_number );
456 FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << Longitude
457 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
458 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
459 << " radius_to_vehicle = " << Radius_to_vehicle );
461 double tmp_lon_geoc = Lon_geocentric;
462 while ( tmp_lon_geoc < -FG_PI ) { tmp_lon_geoc += FG_2PI; }
463 while ( tmp_lon_geoc > FG_PI ) { tmp_lon_geoc -= FG_2PI; }
465 double tmp_lon = Longitude;
466 while ( tmp_lon < -FG_PI ) { tmp_lon += FG_2PI; }
467 while ( tmp_lon > FG_PI ) { tmp_lon -= FG_2PI; }
470 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
472 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
473 _set_Euler_Angles( Phi, Theta, Psi );
475 _set_Altitude_AGL( Altitude-Runway_altitude );
477 // Miscellaneous quantities
478 _set_T_Local_to_Body(T_local_to_body_m);
479 // set_Gravity( Gravity );
480 // set_Centrifugal_relief( Centrifugal_relief );
484 // set_Alpha_dot( Alpha_dot );
485 // set_Beta_dot( Beta_dot );
487 // set_Cos_alpha( Cos_alpha );
488 // set_Sin_alpha( Sin_alpha );
489 // set_Cos_beta( Cos_beta );
490 // set_Sin_beta( Sin_beta );
492 _set_Cos_phi( Cos_phi );
493 // set_Sin_phi( Sin_phi );
494 _set_Cos_theta( Cos_theta );
495 // set_Sin_theta( Sin_theta );
496 // set_Cos_psi( Cos_psi );
497 // set_Sin_psi( Sin_psi );
499 _set_Gamma_vert_rad( Gamma_vert_rad );
500 // set_Gamma_horiz_rad( Gamma_horiz_rad );
502 // set_Sigma( Sigma );
503 _set_Density( Density );
504 // set_V_sound( V_sound );
505 // set_Mach_number( Mach_number );
507 _set_Static_pressure( Static_pressure );
508 // set_Total_pressure( Total_pressure );
509 // set_Impact_pressure( Impact_pressure );
510 // set_Dynamic_pressure( Dynamic_pressure );
512 _set_Static_temperature( Static_temperature );
513 // set_Total_temperature( Total_temperature );
515 _set_Sea_level_radius( Sea_level_radius );
516 _set_Earth_position_angle( Earth_position_angle );
518 _set_Runway_altitude( Runway_altitude );
519 // set_Runway_latitude( Runway_latitude );
520 // set_Runway_longitude( Runway_longitude );
521 // set_Runway_heading( Runway_heading );
522 // set_Radius_to_rwy( Radius_to_rwy );
524 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
525 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
526 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
527 // D_pilot_above_rwy );
528 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
530 _set_sin_lat_geocentric(Lat_geocentric);
531 _set_cos_lat_geocentric(Lat_geocentric);
532 _set_sin_cos_longitude(Longitude);
533 _set_sin_cos_latitude(Latitude);
535 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
536 // printf("sin_lat %f cos_lat %f\n",
537 // get_sin_latitude(), get_cos_latitude());
538 // printf("sin_lon %f cos_lon %f\n",
539 // get_sin_longitude(), get_cos_longitude());
541 _set_Climb_Rate( -1 * V_down );
547 void FGLaRCsim::set_ls(void) {
548 Phi=lsic->GetRollAngleRadIC();
549 Theta=lsic->GetPitchAngleRadIC();
550 Psi=lsic->GetHeadingRadIC();
551 V_north=lsic->GetVnorthFpsIC();
552 V_east=lsic->GetVeastFpsIC();
553 V_down=lsic->GetVdownFpsIC();
554 Altitude=lsic->GetAltitudeFtIC();
555 Latitude=lsic->GetLatitudeGDRadIC();
556 Longitude=lsic->GetLongitudeRadIC();
557 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
558 V_north_airmass = lsic->GetVnorthAirmassFpsIC();
559 V_east_airmass = lsic->GetVeastAirmassFpsIC();
560 V_down_airmass = lsic->GetVdownAirmassFpsIC();
563 FG_LOG( FG_FLIGHT, FG_INFO, " FGLaRCsim::set_ls(): " );
564 FG_LOG( FG_FLIGHT, FG_INFO, " Phi: " << Phi );
565 FG_LOG( FG_FLIGHT, FG_INFO, " Theta: " << Theta );
566 FG_LOG( FG_FLIGHT, FG_INFO, " Psi: " << Psi );
567 FG_LOG( FG_FLIGHT, FG_INFO, " V_north: " << V_north );
568 FG_LOG( FG_FLIGHT, FG_INFO, " V_east: " << V_east );
569 FG_LOG( FG_FLIGHT, FG_INFO, " V_down: " << V_down );
570 FG_LOG( FG_FLIGHT, FG_INFO, " Altitude: " << Altitude );
571 FG_LOG( FG_FLIGHT, FG_INFO, " Latitude: " << Latitude );
572 FG_LOG( FG_FLIGHT, FG_INFO, " Longitude: " << Longitude );
573 FG_LOG( FG_FLIGHT, FG_INFO, " Runway_altitude: " << Runway_altitude );
574 FG_LOG( FG_FLIGHT, FG_INFO, " V_north_airmass: " << V_north_airmass );
575 FG_LOG( FG_FLIGHT, FG_INFO, " V_east_airmass: " << V_east_airmass );
576 FG_LOG( FG_FLIGHT, FG_INFO, " V_down_airmass: " << V_down_airmass );
579 void FGLaRCsim::snap_shot(void) {
580 lsic->SetLatitudeGDRadIC( get_Latitude() );
581 lsic->SetLongitudeRadIC( get_Longitude() );
582 lsic->SetAltitudeFtIC( get_Altitude() );
583 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
584 lsic->SetVtrueFpsIC( get_V_rel_wind() );
585 lsic->SetPitchAngleRadIC( get_Theta() );
586 lsic->SetRollAngleRadIC( get_Phi() );
587 lsic->SetHeadingRadIC( get_Psi() );
588 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
589 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
590 get_V_east_airmass(),
591 get_V_down_airmass() );
595 void FGLaRCsim::set_Latitude(double lat) {
596 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Latitude: " << lat );
598 lsic->SetLatitudeGDRadIC(lat);
600 copy_from_LaRCsim(); //update the bus
603 void FGLaRCsim::set_Longitude(double lon) {
604 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Longitude: " << lon );
606 lsic->SetLongitudeRadIC(lon);
608 copy_from_LaRCsim(); //update the bus
611 void FGLaRCsim::set_Altitude(double alt) {
612 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Altitude: " << alt );
614 lsic->SetAltitudeFtIC(alt);
616 copy_from_LaRCsim(); //update the bus
619 void FGLaRCsim::set_V_calibrated_kts(double vc) {
620 FG_LOG( FG_FLIGHT, FG_INFO,
621 "FGLaRCsim::set_V_calibrated_kts: " << vc );
623 lsic->SetVcalibratedKtsIC(vc);
625 copy_from_LaRCsim(); //update the bus
628 void FGLaRCsim::set_Mach_number(double mach) {
629 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
631 lsic->SetMachIC(mach);
633 copy_from_LaRCsim(); //update the bus
636 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
637 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_local: "
638 << north << " " << east << " " << down );
640 lsic->SetVNEDFpsIC(north, east, down);
642 copy_from_LaRCsim(); //update the bus
645 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
646 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
647 << u << " " << v << " " << w );
649 lsic->SetUVWFpsIC(u,v,w);
651 copy_from_LaRCsim(); //update the bus
655 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
656 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Euler_angles: "
657 << phi << " " << theta << " " << psi );
660 lsic->SetPitchAngleRadIC(theta);
661 lsic->SetRollAngleRadIC(phi);
662 lsic->SetHeadingRadIC(psi);
664 copy_from_LaRCsim(); //update the bus
668 void FGLaRCsim::set_Climb_Rate( double roc) {
669 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
671 lsic->SetClimbRateFpsIC(roc);
673 copy_from_LaRCsim(); //update the bus
676 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
677 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
679 lsic->SetFlightPathAngleRadIC(gamma);
681 copy_from_LaRCsim(); //update the bus
684 void FGLaRCsim::set_Runway_altitude(double ralt) {
685 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
687 lsic->SetRunwayAltitudeFtIC(ralt);
689 copy_from_LaRCsim(); //update the bus
692 void FGLaRCsim::set_AltitudeAGL(double altagl) {
693 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
695 lsic->SetAltitudeAGLFtIC(altagl);
700 void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
703 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
704 << wnorth << " " << weast << " " << wdown );
706 lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
711 void FGLaRCsim::set_Static_pressure(double p) {
712 FG_LOG( FG_FLIGHT, FG_INFO,
713 "FGLaRCsim::set_Static_pressure: " << p );
714 FG_LOG( FG_FLIGHT, FG_INFO,
715 "LaRCsim does not support externally supplied atmospheric data" );
718 void FGLaRCsim::set_Static_temperature(double T) {
719 FG_LOG( FG_FLIGHT, FG_INFO,
720 "FGLaRCsim::set_Static_temperature: " << T );
721 FG_LOG( FG_FLIGHT, FG_INFO,
722 "LaRCsim does not support externally supplied atmospheric data" );
726 void FGLaRCsim::set_Density(double rho) {
727 FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Density: " << rho );
728 FG_LOG( FG_FLIGHT, FG_INFO,
729 "LaRCsim does not support externally supplied atmospheric data" );