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 speed_up = fgGetNode("/sim/speed-up", true);
45 aircraft = fgGetNode("/sim/aircraft", true);
47 ls_toplevel_init( 0.0, (char *)(aircraft->getStringValue().c_str()) );
49 lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
50 copy_to_LaRCsim(); // initialize all of LaRCsim's vars
52 //this should go away someday -- formerly done in fg_init.cxx
59 ls_set_model_dt( get_delta_t() );
61 // Initialize our little engine that hopefully might
62 eng.init( get_delta_t() );
63 // dcl - in passing dt to init rather than update I am assuming
64 // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
66 // update the engines interface
70 // Fill the fuel tanks
71 // Hardwired to C172 full tanks for now - need to fix this sometime
72 // Also note that this is the max quantity - the usable quantity
80 FGLaRCsim::~FGLaRCsim(void) {
87 // Initialize the LaRCsim flight model, dt is the time increment for
88 // each subsequent iteration through the EOM
89 void FGLaRCsim::init() {
91 // Explicitly call the superclass's
97 // Run an iteration of the EOM (equations of motion)
98 bool FGLaRCsim::update( int multiloop ) {
100 if ( aircraft->getStringValue() == "c172" ) {
101 // set control inputs
102 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
103 eng.set_IAS( V_calibrated_kts );
104 eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
106 eng.set_Propeller_Lever_Pos( 100 );
107 eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
109 eng.set_p_amb( Static_pressure );
110 eng.set_T_amb( Static_temperature );
112 // update engine model
115 // copy engine state values onto "bus"
116 FGEngInterface *e = get_engine( 0 );
117 e->set_Throttle( globals->get_controls()->get_throttle( 0 ) * 100.0 );
118 e->set_Mixture( 80 );
119 e->set_Prop_Advance( 100 );
120 e->set_RPM( eng.get_RPM() );
121 e->set_Manifold_Pressure( eng.get_Manifold_Pressure() );
122 e->set_MaxHP( eng.get_MaxHP() );
123 e->set_Percentage_Power( eng.get_Percentage_Power() );
124 e->set_EGT( eng.get_EGT() );
125 e->set_CHT( eng.get_CHT() );
126 e->set_prop_thrust( eng.get_prop_thrust_SI() );
127 e->set_Fuel_Flow( eng.get_fuel_flow_gals_hr() );
129 //Assume we are using both tanks equally for now
130 reduce_Tank1Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
132 reduce_Tank2Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
136 SG_LOG( SG_FLIGHT, SG_INFO, "Throttle = "
137 << globals->get_controls()->get_throttle( 0 ) * 100.0);
138 SG_LOG( SG_FLIGHT, SG_INFO, " Mixture = " << 80);
139 SG_LOG( SG_FLIGHT, SG_INFO, " RPM = " << eng.get_RPM());
140 SG_LOG( SG_FLIGHT, SG_INFO, " MP = " << eng.get_Manifold_Pressure());
141 SG_LOG( SG_FLIGHT, SG_INFO, " HP = "
142 << ( eng.get_MaxHP() * eng.get_Percentage_Power()/ 100.0) );
143 SG_LOG( SG_FLIGHT, SG_INFO, " EGT = " << eng.get_EGT());
144 SG_LOG( SG_FLIGHT, SG_INFO, " Thrust (N) "
145 << eng.get_prop_thrust_SI()); // Thrust in Newtons
146 SG_LOG( SG_FLIGHT, SG_INFO, '\n');
148 F_X_engine = eng.get_prop_thrust_lbs();
149 // cout << "F_X_engine = " << F_X_engine << '\n';
152 double save_alt = 0.0;
154 // lets try to avoid really screwing up the LaRCsim model
155 if ( get_Altitude() < -9000.0 ) {
156 save_alt = get_Altitude();
160 // copy control positions into the LaRCsim structure
161 Lat_control = globals->get_controls()->get_aileron() /
162 speed_up->getIntValue();
163 Long_control = globals->get_controls()->get_elevator();
164 Long_trim = globals->get_controls()->get_elevator_trim();
165 Rudder_pedal = globals->get_controls()->get_rudder() /
166 speed_up->getIntValue();
167 Flap_handle = 30.0 * globals->get_controls()->get_flaps();
169 if ( aircraft->getStringValue() == "c172" ) {
170 Use_External_Engine = 1;
172 Use_External_Engine = 0;
175 Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
177 Brake_pct[0] = globals->get_controls()->get_brake( 1 );
178 Brake_pct[1] = globals->get_controls()->get_brake( 0 );
180 // Inform LaRCsim of the local terrain altitude
181 // Runway_altitude = get_Runway_altitude();
182 Runway_altitude = scenery.cur_elev * SG_METER_TO_FEET;
185 /* V_north_airmass = get_V_north_airmass();
186 V_east_airmass = get_V_east_airmass();
187 V_down_airmass = get_V_down_airmass(); */
190 // old -- FGInterface_2_LaRCsim() not needed except for Init()
191 // translate FG to LaRCsim structure
192 // FGInterface_2_LaRCsim(f);
193 // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
194 // printf("Altitude = %.2f\n", Altitude * 0.3048);
195 // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
197 ls_update(multiloop);
199 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
200 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
202 // translate LaRCsim back to FG structure so that the
203 // autopilot (and the rest of the sim can use the updated
207 // but lets restore our original bogus altitude when we are done
208 if ( save_alt < -9000.0 ) {
209 set_Altitude( save_alt );
216 // Convert from the FGInterface struct to the LaRCsim generic_ struct
217 bool FGLaRCsim::copy_to_LaRCsim () {
223 // Dx_pilot = get_Dx_pilot();
224 // Dy_pilot = get_Dy_pilot();
225 // Dz_pilot = get_Dz_pilot();
232 // F_north = get_F_north();
233 // F_east = get_F_east();
234 // F_down = get_F_down();
235 // F_X_aero = get_F_X_aero();
236 // F_Y_aero = get_F_Y_aero();
237 // F_Z_aero = get_F_Z_aero();
238 // F_X_engine = get_F_X_engine();
239 // F_Y_engine = get_F_Y_engine();
240 // F_Z_engine = get_F_Z_engine();
241 // F_X_gear = get_F_X_gear();
242 // F_Y_gear = get_F_Y_gear();
243 // F_Z_gear = get_F_Z_gear();
244 // M_l_rp = get_M_l_rp();
245 // M_m_rp = get_M_m_rp();
246 // M_n_rp = get_M_n_rp();
247 // M_l_cg = get_M_l_cg();
248 // M_m_cg = get_M_m_cg();
249 // M_n_cg = get_M_n_cg();
250 // M_l_aero = get_M_l_aero();
251 // M_m_aero = get_M_m_aero();
252 // M_n_aero = get_M_n_aero();
253 // M_l_engine = get_M_l_engine();
254 // M_m_engine = get_M_m_engine();
255 // M_n_engine = get_M_n_engine();
256 // M_l_gear = get_M_l_gear();
257 // M_m_gear = get_M_m_gear();
258 // M_n_gear = get_M_n_gear();
259 // V_dot_north = get_V_dot_north();
260 // V_dot_east = get_V_dot_east();
261 // V_dot_down = get_V_dot_down();
262 // U_dot_body = get_U_dot_body();
263 // V_dot_body = get_V_dot_body();
264 // W_dot_body = get_W_dot_body();
265 // A_X_cg = get_A_X_cg();
266 // A_Y_cg = get_A_Y_cg();
267 // A_Z_cg = get_A_Z_cg();
268 // A_X_pilot = get_A_X_pilot();
269 // A_Y_pilot = get_A_Y_pilot();
270 // A_Z_pilot = get_A_Z_pilot();
271 // N_X_cg = get_N_X_cg();
272 // N_Y_cg = get_N_Y_cg();
273 // N_Z_cg = get_N_Z_cg();
274 // N_X_pilot = get_N_X_pilot();
275 // N_Y_pilot = get_N_Y_pilot();
276 // N_Z_pilot = get_N_Z_pilot();
277 // P_dot_body = get_P_dot_body();
278 // Q_dot_body = get_Q_dot_body();
279 // R_dot_body = get_R_dot_body();
280 // V_north = get_V_north();
281 // V_east = get_V_east();
282 // V_down = get_V_down();
283 // V_north_rel_ground = get_V_north_rel_ground();
284 // V_east_rel_ground = get_V_east_rel_ground();
285 // V_down_rel_ground = get_V_down_rel_ground();
286 // V_north_airmass = get_V_north_airmass();
287 // V_east_airmass = get_V_east_airmass();
288 // V_down_airmass = get_V_down_airmass();
289 // V_north_rel_airmass = get_V_north_rel_airmass();
290 // V_east_rel_airmass = get_V_east_rel_airmass();
291 // V_down_rel_airmass = get_V_down_rel_airmass();
292 // U_gust = get_U_gust();
293 // V_gust = get_V_gust();
294 // W_gust = get_W_gust();
295 // U_body = get_U_body();
296 // V_body = get_V_body();
297 // W_body = get_W_body();
298 // V_rel_wind = get_V_rel_wind();
299 // V_true_kts = get_V_true_kts();
300 // V_rel_ground = get_V_rel_ground();
301 // V_inertial = get_V_inertial();
302 // V_ground_speed = get_V_ground_speed();
303 // V_equiv = get_V_equiv();
304 // V_equiv_kts = get_V_equiv_kts();
305 // V_calibrated = get_V_calibrated();
306 // V_calibrated_kts = get_V_calibrated_kts();
307 // P_body = get_P_body();
308 // Q_body = get_Q_body();
309 // R_body = get_R_body();
310 // P_local = get_P_local();
311 // Q_local = get_Q_local();
312 // R_local = get_R_local();
313 // P_total = get_P_total();
314 // Q_total = get_Q_total();
315 // R_total = get_R_total();
316 // Phi_dot = get_Phi_dot();
317 // Theta_dot = get_Theta_dot();
318 // Psi_dot = get_Psi_dot();
319 // Latitude_dot = get_Latitude_dot();
320 // Longitude_dot = get_Longitude_dot();
321 // Radius_dot = get_Radius_dot();
322 // Lat_geocentric = get_Lat_geocentric();
323 // Lon_geocentric = get_Lon_geocentric();
324 // Radius_to_vehicle = get_Radius_to_vehicle();
325 // Latitude = get_Latitude();
326 // Longitude = get_Longitude();
327 // Altitude = get_Altitude();
329 // Theta = get_Theta();
331 // T_local_to_body_11 = get_T_local_to_body_11();
332 // T_local_to_body_12 = get_T_local_to_body_12();
333 // T_local_to_body_13 = get_T_local_to_body_13();
334 // T_local_to_body_21 = get_T_local_to_body_21();
335 // T_local_to_body_22 = get_T_local_to_body_22();
336 // T_local_to_body_23 = get_T_local_to_body_23();
337 // T_local_to_body_31 = get_T_local_to_body_31();
338 // T_local_to_body_32 = get_T_local_to_body_32();
339 // T_local_to_body_33 = get_T_local_to_body_33();
340 // Gravity = get_Gravity();
341 // Centrifugal_relief = get_Centrifugal_relief();
342 // Alpha = get_Alpha();
343 // Beta = get_Beta();
344 // Alpha_dot = get_Alpha_dot();
345 // Beta_dot = get_Beta_dot();
346 // Cos_alpha = get_Cos_alpha();
347 // Sin_alpha = get_Sin_alpha();
348 // Cos_beta = get_Cos_beta();
349 // Sin_beta = get_Sin_beta();
350 // Cos_phi = get_Cos_phi();
351 // Sin_phi = get_Sin_phi();
352 // Cos_theta = get_Cos_theta();
353 // Sin_theta = get_Sin_theta();
354 // Cos_psi = get_Cos_psi();
355 // Sin_psi = get_Sin_psi();
356 // Gamma_vert_rad = get_Gamma_vert_rad();
357 // Gamma_horiz_rad = get_Gamma_horiz_rad();
358 // Sigma = get_Sigma();
359 // Density = get_Density();
360 // V_sound = get_V_sound();
361 // Mach_number = get_Mach_number();
362 // Static_pressure = get_Static_pressure();
363 // Total_pressure = get_Total_pressure();
364 // Impact_pressure = get_Impact_pressure();
365 // Dynamic_pressure = get_Dynamic_pressure();
366 // Static_temperature = get_Static_temperature();
367 // Total_temperature = get_Total_temperature();
368 // Sea_level_radius = get_Sea_level_radius();
369 // Earth_position_angle = get_Earth_position_angle();
370 // Runway_altitude = get_Runway_altitude();
371 // Runway_latitude = get_Runway_latitude();
372 // Runway_longitude = get_Runway_longitude();
373 // Runway_heading = get_Runway_heading();
374 // Radius_to_rwy = get_Radius_to_rwy();
375 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
376 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
377 // D_cg_above_rwy = get_D_cg_above_rwy();
378 // X_cg_rwy = get_X_cg_rwy();
379 // Y_cg_rwy = get_Y_cg_rwy();
380 // H_cg_rwy = get_H_cg_rwy();
381 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
382 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
383 // D_pilot_above_rwy = get_D_pilot_above_rwy();
384 // X_pilot_rwy = get_X_pilot_rwy();
385 // Y_pilot_rwy = get_Y_pilot_rwy();
386 // H_pilot_rwy = get_H_pilot_rwy();
392 // Convert from the LaRCsim generic_ struct to the FGInterface struct
393 bool FGLaRCsim::copy_from_LaRCsim() {
395 // Mass properties and geometry values
396 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
397 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
398 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
401 // set_Forces_Body_Total( F_X, F_Y, F_Z );
402 // set_Forces_Local_Total( F_north, F_east, F_down );
403 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
404 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
405 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
408 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
409 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
410 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
411 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
412 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
415 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
416 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
417 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
418 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
419 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
420 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
421 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
424 _set_Velocities_Local( V_north, V_east, V_down );
425 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
426 // V_down_rel_ground );
427 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
429 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
430 // V_east_rel_airmass, V_down_rel_airmass );
431 // set_Velocities_Gust( U_gust, V_gust, W_gust );
432 _set_Velocities_Wind_Body( U_body, V_body, W_body );
434 _set_V_rel_wind( V_rel_wind );
435 // set_V_true_kts( V_true_kts );
436 // set_V_rel_ground( V_rel_ground );
437 // set_V_inertial( V_inertial );
438 _set_V_ground_speed( V_ground_speed );
439 // set_V_equiv( V_equiv );
440 _set_V_equiv_kts( V_equiv_kts );
441 // set_V_calibrated( V_calibrated );
442 _set_V_calibrated_kts( V_calibrated_kts );
444 _set_Omega_Body( P_body, Q_body, R_body );
445 // set_Omega_Local( P_local, Q_local, R_local );
446 // set_Omega_Total( P_total, Q_total, R_total );
448 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
449 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
451 _set_Mach_number( Mach_number );
453 SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
454 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
455 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
456 << " radius_to_vehicle = " << Radius_to_vehicle );
458 double tmp_lon_geoc = Lon_geocentric;
459 while ( tmp_lon_geoc < -SGD_PI ) { tmp_lon_geoc += SGD_2PI; }
460 while ( tmp_lon_geoc > SGD_PI ) { tmp_lon_geoc -= SGD_2PI; }
462 double tmp_lon = Longitude;
463 while ( tmp_lon < -SGD_PI ) { tmp_lon += SGD_2PI; }
464 while ( tmp_lon > SGD_PI ) { tmp_lon -= SGD_2PI; }
467 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
469 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
470 _set_Euler_Angles( Phi, Theta, Psi );
472 _set_Altitude_AGL( Altitude - Runway_altitude );
474 // Miscellaneous quantities
475 _set_T_Local_to_Body(T_local_to_body_m);
476 // set_Gravity( Gravity );
477 // set_Centrifugal_relief( Centrifugal_relief );
481 // set_Alpha_dot( Alpha_dot );
482 // set_Beta_dot( Beta_dot );
484 // set_Cos_alpha( Cos_alpha );
485 // set_Sin_alpha( Sin_alpha );
486 // set_Cos_beta( Cos_beta );
487 // set_Sin_beta( Sin_beta );
489 _set_Cos_phi( Cos_phi );
490 // set_Sin_phi( Sin_phi );
491 _set_Cos_theta( Cos_theta );
492 // set_Sin_theta( Sin_theta );
493 // set_Cos_psi( Cos_psi );
494 // set_Sin_psi( Sin_psi );
496 _set_Gamma_vert_rad( Gamma_vert_rad );
497 // set_Gamma_horiz_rad( Gamma_horiz_rad );
499 // set_Sigma( Sigma );
500 _set_Density( Density );
501 // set_V_sound( V_sound );
502 // set_Mach_number( Mach_number );
504 _set_Static_pressure( Static_pressure );
505 // set_Total_pressure( Total_pressure );
506 // set_Impact_pressure( Impact_pressure );
507 // set_Dynamic_pressure( Dynamic_pressure );
509 _set_Static_temperature( Static_temperature );
510 // set_Total_temperature( Total_temperature );
512 _set_Sea_level_radius( Sea_level_radius );
513 _set_Earth_position_angle( Earth_position_angle );
515 _set_Runway_altitude( Runway_altitude );
516 // set_Runway_latitude( Runway_latitude );
517 // set_Runway_longitude( Runway_longitude );
518 // set_Runway_heading( Runway_heading );
519 // set_Radius_to_rwy( Radius_to_rwy );
521 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
522 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
523 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
524 // D_pilot_above_rwy );
525 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
527 _set_sin_lat_geocentric(Lat_geocentric);
528 _set_cos_lat_geocentric(Lat_geocentric);
529 _set_sin_cos_longitude(Longitude);
530 _set_sin_cos_latitude(Latitude);
532 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
533 // printf("sin_lat %f cos_lat %f\n",
534 // get_sin_latitude(), get_cos_latitude());
535 // printf("sin_lon %f cos_lon %f\n",
536 // get_sin_longitude(), get_cos_longitude());
538 _set_Climb_Rate( -1 * V_down );
539 // cout << "climb rate = " << -V_down * 60 << endl;
544 void FGLaRCsim::set_ls(void) {
545 Phi=lsic->GetRollAngleRadIC();
546 Theta=lsic->GetPitchAngleRadIC();
547 Psi=lsic->GetHeadingRadIC();
548 V_north=lsic->GetVnorthFpsIC();
549 V_east=lsic->GetVeastFpsIC();
550 V_down=lsic->GetVdownFpsIC();
551 Altitude=lsic->GetAltitudeFtIC();
552 Latitude=lsic->GetLatitudeGDRadIC();
553 Longitude=lsic->GetLongitudeRadIC();
554 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
555 V_north_airmass = lsic->GetVnorthAirmassFpsIC();
556 V_east_airmass = lsic->GetVeastAirmassFpsIC();
557 V_down_airmass = lsic->GetVdownAirmassFpsIC();
560 SG_LOG( SG_FLIGHT, SG_INFO, " FGLaRCsim::set_ls(): " );
561 SG_LOG( SG_FLIGHT, SG_INFO, " Phi: " << Phi );
562 SG_LOG( SG_FLIGHT, SG_INFO, " Theta: " << Theta );
563 SG_LOG( SG_FLIGHT, SG_INFO, " Psi: " << Psi );
564 SG_LOG( SG_FLIGHT, SG_INFO, " V_north: " << V_north );
565 SG_LOG( SG_FLIGHT, SG_INFO, " V_east: " << V_east );
566 SG_LOG( SG_FLIGHT, SG_INFO, " V_down: " << V_down );
567 SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: " << Altitude );
568 SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: " << Latitude );
569 SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: " << Longitude );
570 SG_LOG( SG_FLIGHT, SG_INFO, " Runway_altitude: " << Runway_altitude );
571 SG_LOG( SG_FLIGHT, SG_INFO, " V_north_airmass: " << V_north_airmass );
572 SG_LOG( SG_FLIGHT, SG_INFO, " V_east_airmass: " << V_east_airmass );
573 SG_LOG( SG_FLIGHT, SG_INFO, " V_down_airmass: " << V_down_airmass );
576 void FGLaRCsim::snap_shot(void) {
577 lsic->SetLatitudeGDRadIC( get_Latitude() );
578 lsic->SetLongitudeRadIC( get_Longitude() );
579 lsic->SetAltitudeFtIC( get_Altitude() );
580 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
581 lsic->SetVtrueFpsIC( get_V_rel_wind() );
582 lsic->SetPitchAngleRadIC( get_Theta() );
583 lsic->SetRollAngleRadIC( get_Phi() );
584 lsic->SetHeadingRadIC( get_Psi() );
585 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
586 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
587 get_V_east_airmass(),
588 get_V_down_airmass() );
592 void FGLaRCsim::set_Latitude(double lat) {
593 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
595 lsic->SetLatitudeGDRadIC(lat);
597 copy_from_LaRCsim(); //update the bus
600 void FGLaRCsim::set_Longitude(double lon) {
601 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
603 lsic->SetLongitudeRadIC(lon);
605 copy_from_LaRCsim(); //update the bus
608 void FGLaRCsim::set_Altitude(double alt) {
609 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Altitude: " << alt );
611 lsic->SetAltitudeFtIC(alt);
613 copy_from_LaRCsim(); //update the bus
616 void FGLaRCsim::set_V_calibrated_kts(double vc) {
617 SG_LOG( SG_FLIGHT, SG_INFO,
618 "FGLaRCsim::set_V_calibrated_kts: " << vc );
620 lsic->SetVcalibratedKtsIC(vc);
622 copy_from_LaRCsim(); //update the bus
625 void FGLaRCsim::set_Mach_number(double mach) {
626 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
628 lsic->SetMachIC(mach);
630 copy_from_LaRCsim(); //update the bus
633 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
634 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_local: "
635 << north << " " << east << " " << down );
637 lsic->SetVNEDFpsIC(north, east, down);
639 copy_from_LaRCsim(); //update the bus
642 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
643 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
644 << u << " " << v << " " << w );
646 lsic->SetUVWFpsIC(u,v,w);
648 copy_from_LaRCsim(); //update the bus
652 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
653 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Euler_angles: "
654 << phi << " " << theta << " " << psi );
657 lsic->SetPitchAngleRadIC(theta);
658 lsic->SetRollAngleRadIC(phi);
659 lsic->SetHeadingRadIC(psi);
661 copy_from_LaRCsim(); //update the bus
665 void FGLaRCsim::set_Climb_Rate( double roc) {
666 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
668 lsic->SetClimbRateFpsIC(roc);
670 copy_from_LaRCsim(); //update the bus
673 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
674 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
676 lsic->SetFlightPathAngleRadIC(gamma);
678 copy_from_LaRCsim(); //update the bus
681 void FGLaRCsim::set_Runway_altitude(double ralt) {
682 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
684 lsic->SetRunwayAltitudeFtIC(ralt);
686 copy_from_LaRCsim(); //update the bus
689 void FGLaRCsim::set_AltitudeAGL(double altagl) {
690 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
692 lsic->SetAltitudeAGLFtIC(altagl);
697 void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
700 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
701 << wnorth << " " << weast << " " << wdown );
703 lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
708 void FGLaRCsim::set_Static_pressure(double p) {
709 SG_LOG( SG_FLIGHT, SG_INFO,
710 "FGLaRCsim::set_Static_pressure: " << p );
711 SG_LOG( SG_FLIGHT, SG_INFO,
712 "LaRCsim does not support externally supplied atmospheric data" );
715 void FGLaRCsim::set_Static_temperature(double T) {
716 SG_LOG( SG_FLIGHT, SG_INFO,
717 "FGLaRCsim::set_Static_temperature: " << T );
718 SG_LOG( SG_FLIGHT, SG_INFO,
719 "LaRCsim does not support externally supplied atmospheric data" );
723 void FGLaRCsim::set_Density(double rho) {
724 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Density: " << rho );
725 SG_LOG( SG_FLIGHT, SG_INFO,
726 "LaRCsim does not support externally supplied atmospheric data" );