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>
37 #include <FDM/UIUCModel/uiuc_aircraft.h>
40 #include "LaRCsim.hxx"
42 FGLaRCsim::FGLaRCsim( double dt ) {
45 speed_up = fgGetNode("/sim/speed-up", true);
46 aero = fgGetNode("/sim/aero", true);
48 ls_toplevel_init( 0.0, (char *)(aero->getStringValue().c_str()) );
50 lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
51 if ( aero->getStringValue() == "c172" ) {
52 copy_to_LaRCsim(); // initialize all of LaRCsim's vars
54 //this should go away someday -- formerly done in fg_init.cxx
62 ls_set_model_dt( get_delta_t() );
64 // Initialize our little engine that hopefully might
65 eng.init( get_delta_t() );
66 // dcl - in passing dt to init rather than update I am assuming
67 // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
70 FGLaRCsim::~FGLaRCsim(void) {
77 // Initialize the LaRCsim flight model, dt is the time increment for
78 // each subsequent iteration through the EOM
79 void FGLaRCsim::init() {
80 //do init common to all FDM's
83 //now do any specific to LaRCsim
87 // Run an iteration of the EOM (equations of motion)
88 void FGLaRCsim::update( int multiloop ) {
90 if ( aero->getStringValue() == "c172" ) {
92 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
93 eng.set_IAS( V_calibrated_kts );
94 eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
96 eng.set_Propeller_Lever_Pos( 100 );
97 eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
99 eng.set_Magneto_Switch_Pos( globals->get_controls()->get_magnetos(0) );
100 eng.setStarterFlag( globals->get_controls()->get_starter(0) );
101 eng.set_p_amb( Static_pressure );
102 eng.set_T_amb( Static_temperature );
104 // update engine model
107 // copy engine state values onto "bus"
108 fgSetDouble("/engines/engine/rpm", eng.get_RPM());
109 fgSetDouble("/engines/engine/mp-osi", eng.get_Manifold_Pressure());
110 fgSetDouble("/engines/engine/max-hp", eng.get_MaxHP());
111 fgSetDouble("/engines/engine/power-pct", eng.get_Percentage_Power());
112 fgSetDouble("/engines/engine/egt-degf", eng.get_EGT());
113 fgSetDouble("/engines/engine/cht-degf", eng.get_CHT());
114 fgSetDouble("/engines/engine/prop-thrust", eng.get_prop_thrust_SI());
115 fgSetDouble("/engines/engine/fuel-flow-gph",
116 eng.get_fuel_flow_gals_hr());
117 fgSetDouble("/engines/engine/oil-temperature-degf",
119 fgSetDouble("/engines/engine/running", eng.getRunningFlag());
120 fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
122 static const SGPropertyNode *fuel_freeze
123 = fgGetNode("/sim/freeze/fuel");
125 if ( ! fuel_freeze->getBoolValue() ) {
126 //Assume we are using both tanks equally for now
127 fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
128 fgGetDouble("/consumables/fuel/tank[0]/level-gal_us")
129 - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
131 fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
132 fgGetDouble("/consumables/fuel/tank[1]/level-gal_us")
133 - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
137 F_X_engine = eng.get_prop_thrust_lbs();
138 // cout << "F_X_engine = " << F_X_engine << '\n';
141 double save_alt = 0.0;
143 // lets try to avoid really screwing up the LaRCsim model
144 if ( get_Altitude() < -9000.0 ) {
145 save_alt = get_Altitude();
149 // copy control positions into the LaRCsim structure
150 Lat_control = globals->get_controls()->get_aileron() /
151 speed_up->getIntValue();
152 Long_control = globals->get_controls()->get_elevator();
153 Long_trim = globals->get_controls()->get_elevator_trim();
154 Rudder_pedal = globals->get_controls()->get_rudder() /
155 speed_up->getIntValue();
156 Flap_handle = 30.0 * globals->get_controls()->get_flaps();
158 if ( aero->getStringValue() == "c172" ) {
159 Use_External_Engine = 1;
161 Use_External_Engine = 0;
164 Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
166 Brake_pct[0] = globals->get_controls()->get_brake( 1 );
167 Brake_pct[1] = globals->get_controls()->get_brake( 0 );
169 // Inform LaRCsim of the local terrain altitude
170 // Runway_altitude = get_Runway_altitude();
171 Runway_altitude = scenery.get_cur_elev() * SG_METER_TO_FEET;
174 /* V_north_airmass = get_V_north_airmass();
175 V_east_airmass = get_V_east_airmass();
176 V_down_airmass = get_V_down_airmass(); */
179 // old -- FGInterface_2_LaRCsim() not needed except for Init()
180 // translate FG to LaRCsim structure
181 // FGInterface_2_LaRCsim(f);
182 // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
183 // printf("Altitude = %.2f\n", Altitude * 0.3048);
184 // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
186 ls_update(multiloop);
188 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
189 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
191 // translate LaRCsim back to FG structure so that the
192 // autopilot (and the rest of the sim can use the updated
196 // but lets restore our original bogus altitude when we are done
197 if ( save_alt < -9000.0 ) {
198 set_Altitude( save_alt );
203 // Convert from the FGInterface struct to the LaRCsim generic_ struct
204 bool FGLaRCsim::copy_to_LaRCsim () {
210 // Dx_pilot = get_Dx_pilot();
211 // Dy_pilot = get_Dy_pilot();
212 // Dz_pilot = get_Dz_pilot();
219 // F_north = get_F_north();
220 // F_east = get_F_east();
221 // F_down = get_F_down();
222 // F_X_aero = get_F_X_aero();
223 // F_Y_aero = get_F_Y_aero();
224 // F_Z_aero = get_F_Z_aero();
225 // F_X_engine = get_F_X_engine();
226 // F_Y_engine = get_F_Y_engine();
227 // F_Z_engine = get_F_Z_engine();
228 // F_X_gear = get_F_X_gear();
229 // F_Y_gear = get_F_Y_gear();
230 // F_Z_gear = get_F_Z_gear();
231 // M_l_rp = get_M_l_rp();
232 // M_m_rp = get_M_m_rp();
233 // M_n_rp = get_M_n_rp();
234 // M_l_cg = get_M_l_cg();
235 // M_m_cg = get_M_m_cg();
236 // M_n_cg = get_M_n_cg();
237 // M_l_aero = get_M_l_aero();
238 // M_m_aero = get_M_m_aero();
239 // M_n_aero = get_M_n_aero();
240 // M_l_engine = get_M_l_engine();
241 // M_m_engine = get_M_m_engine();
242 // M_n_engine = get_M_n_engine();
243 // M_l_gear = get_M_l_gear();
244 // M_m_gear = get_M_m_gear();
245 // M_n_gear = get_M_n_gear();
246 // V_dot_north = get_V_dot_north();
247 // V_dot_east = get_V_dot_east();
248 // V_dot_down = get_V_dot_down();
249 // U_dot_body = get_U_dot_body();
250 // V_dot_body = get_V_dot_body();
251 // W_dot_body = get_W_dot_body();
252 // A_X_cg = get_A_X_cg();
253 // A_Y_cg = get_A_Y_cg();
254 // A_Z_cg = get_A_Z_cg();
255 // A_X_pilot = get_A_X_pilot();
256 // A_Y_pilot = get_A_Y_pilot();
257 // A_Z_pilot = get_A_Z_pilot();
258 // N_X_cg = get_N_X_cg();
259 // N_Y_cg = get_N_Y_cg();
260 // N_Z_cg = get_N_Z_cg();
261 // N_X_pilot = get_N_X_pilot();
262 // N_Y_pilot = get_N_Y_pilot();
263 // N_Z_pilot = get_N_Z_pilot();
264 // P_dot_body = get_P_dot_body();
265 // Q_dot_body = get_Q_dot_body();
266 // R_dot_body = get_R_dot_body();
267 // V_north = get_V_north();
268 // V_east = get_V_east();
269 // V_down = get_V_down();
270 // V_north_rel_ground = get_V_north_rel_ground();
271 // V_east_rel_ground = get_V_east_rel_ground();
272 // V_down_rel_ground = get_V_down_rel_ground();
273 // V_north_airmass = get_V_north_airmass();
274 // V_east_airmass = get_V_east_airmass();
275 // V_down_airmass = get_V_down_airmass();
276 // V_north_rel_airmass = get_V_north_rel_airmass();
277 // V_east_rel_airmass = get_V_east_rel_airmass();
278 // V_down_rel_airmass = get_V_down_rel_airmass();
279 // U_gust = get_U_gust();
280 // V_gust = get_V_gust();
281 // W_gust = get_W_gust();
282 // U_body = get_U_body();
283 // V_body = get_V_body();
284 // W_body = get_W_body();
285 // V_rel_wind = get_V_rel_wind();
286 // V_true_kts = get_V_true_kts();
287 // V_rel_ground = get_V_rel_ground();
288 // V_inertial = get_V_inertial();
289 // V_ground_speed = get_V_ground_speed();
290 // V_equiv = get_V_equiv();
291 // V_equiv_kts = get_V_equiv_kts();
292 // V_calibrated = get_V_calibrated();
293 // V_calibrated_kts = get_V_calibrated_kts();
294 // P_body = get_P_body();
295 // Q_body = get_Q_body();
296 // R_body = get_R_body();
297 // P_local = get_P_local();
298 // Q_local = get_Q_local();
299 // R_local = get_R_local();
300 // P_total = get_P_total();
301 // Q_total = get_Q_total();
302 // R_total = get_R_total();
303 // Phi_dot = get_Phi_dot();
304 // Theta_dot = get_Theta_dot();
305 // Psi_dot = get_Psi_dot();
306 // Latitude_dot = get_Latitude_dot();
307 // Longitude_dot = get_Longitude_dot();
308 // Radius_dot = get_Radius_dot();
309 // Lat_geocentric = get_Lat_geocentric();
310 // Lon_geocentric = get_Lon_geocentric();
311 // Radius_to_vehicle = get_Radius_to_vehicle();
312 // Latitude = get_Latitude();
313 // Longitude = get_Longitude();
314 // Altitude = get_Altitude();
316 // Theta = get_Theta();
318 // T_local_to_body_11 = get_T_local_to_body_11();
319 // T_local_to_body_12 = get_T_local_to_body_12();
320 // T_local_to_body_13 = get_T_local_to_body_13();
321 // T_local_to_body_21 = get_T_local_to_body_21();
322 // T_local_to_body_22 = get_T_local_to_body_22();
323 // T_local_to_body_23 = get_T_local_to_body_23();
324 // T_local_to_body_31 = get_T_local_to_body_31();
325 // T_local_to_body_32 = get_T_local_to_body_32();
326 // T_local_to_body_33 = get_T_local_to_body_33();
327 // Gravity = get_Gravity();
328 // Centrifugal_relief = get_Centrifugal_relief();
329 // Alpha = get_Alpha();
330 // Beta = get_Beta();
331 // Alpha_dot = get_Alpha_dot();
332 // Beta_dot = get_Beta_dot();
333 // Cos_alpha = get_Cos_alpha();
334 // Sin_alpha = get_Sin_alpha();
335 // Cos_beta = get_Cos_beta();
336 // Sin_beta = get_Sin_beta();
337 // Cos_phi = get_Cos_phi();
338 // Sin_phi = get_Sin_phi();
339 // Cos_theta = get_Cos_theta();
340 // Sin_theta = get_Sin_theta();
341 // Cos_psi = get_Cos_psi();
342 // Sin_psi = get_Sin_psi();
343 // Gamma_vert_rad = get_Gamma_vert_rad();
344 // Gamma_horiz_rad = get_Gamma_horiz_rad();
345 // Sigma = get_Sigma();
346 // Density = get_Density();
347 // V_sound = get_V_sound();
348 // Mach_number = get_Mach_number();
349 // Static_pressure = get_Static_pressure();
350 // Total_pressure = get_Total_pressure();
351 // Impact_pressure = get_Impact_pressure();
352 // Dynamic_pressure = get_Dynamic_pressure();
353 // Static_temperature = get_Static_temperature();
354 // Total_temperature = get_Total_temperature();
355 // Sea_level_radius = get_Sea_level_radius();
356 // Earth_position_angle = get_Earth_position_angle();
357 // Runway_altitude = get_Runway_altitude();
358 // Runway_latitude = get_Runway_latitude();
359 // Runway_longitude = get_Runway_longitude();
360 // Runway_heading = get_Runway_heading();
361 // Radius_to_rwy = get_Radius_to_rwy();
362 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
363 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
364 // D_cg_above_rwy = get_D_cg_above_rwy();
365 // X_cg_rwy = get_X_cg_rwy();
366 // Y_cg_rwy = get_Y_cg_rwy();
367 // H_cg_rwy = get_H_cg_rwy();
368 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
369 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
370 // D_pilot_above_rwy = get_D_pilot_above_rwy();
371 // X_pilot_rwy = get_X_pilot_rwy();
372 // Y_pilot_rwy = get_Y_pilot_rwy();
373 // H_pilot_rwy = get_H_pilot_rwy();
379 // Convert from the LaRCsim generic_ struct to the FGInterface struct
380 bool FGLaRCsim::copy_from_LaRCsim() {
382 // Mass properties and geometry values
383 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
384 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
385 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
388 // set_Forces_Body_Total( F_X, F_Y, F_Z );
389 // set_Forces_Local_Total( F_north, F_east, F_down );
390 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
391 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
392 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
395 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
396 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
397 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
398 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
399 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
402 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
403 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
404 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
405 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
406 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
407 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
408 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
411 _set_Velocities_Local( V_north, V_east, V_down );
412 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
413 // V_down_rel_ground );
414 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
416 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
417 // V_east_rel_airmass, V_down_rel_airmass );
418 // set_Velocities_Gust( U_gust, V_gust, W_gust );
419 _set_Velocities_Wind_Body( U_body, V_body, W_body );
421 _set_V_rel_wind( V_rel_wind );
422 // set_V_true_kts( V_true_kts );
423 // set_V_rel_ground( V_rel_ground );
424 // set_V_inertial( V_inertial );
425 _set_V_ground_speed( V_ground_speed );
426 // set_V_equiv( V_equiv );
427 _set_V_equiv_kts( V_equiv_kts );
428 // set_V_calibrated( V_calibrated );
429 _set_V_calibrated_kts( V_calibrated_kts );
431 _set_Omega_Body( P_body, Q_body, R_body );
432 // set_Omega_Local( P_local, Q_local, R_local );
433 // set_Omega_Total( P_total, Q_total, R_total );
435 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
436 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
438 _set_Mach_number( Mach_number );
440 SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
441 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
442 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
443 << " radius_to_vehicle = " << Radius_to_vehicle );
445 double tmp_lon_geoc = Lon_geocentric;
446 while ( tmp_lon_geoc < -SGD_PI ) { tmp_lon_geoc += SGD_2PI; }
447 while ( tmp_lon_geoc > SGD_PI ) { tmp_lon_geoc -= SGD_2PI; }
449 double tmp_lon = Longitude;
450 while ( tmp_lon < -SGD_PI ) { tmp_lon += SGD_2PI; }
451 while ( tmp_lon > SGD_PI ) { tmp_lon -= SGD_2PI; }
454 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
456 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
457 _set_Euler_Angles( Phi, Theta, Psi );
459 _set_Altitude_AGL( Altitude - Runway_altitude );
461 // Miscellaneous quantities
462 _set_T_Local_to_Body(T_local_to_body_m);
463 // set_Gravity( Gravity );
464 // set_Centrifugal_relief( Centrifugal_relief );
468 // set_Alpha_dot( Alpha_dot );
469 // set_Beta_dot( Beta_dot );
471 // set_Cos_alpha( Cos_alpha );
472 // set_Sin_alpha( Sin_alpha );
473 // set_Cos_beta( Cos_beta );
474 // set_Sin_beta( Sin_beta );
476 _set_Cos_phi( Cos_phi );
477 // set_Sin_phi( Sin_phi );
478 _set_Cos_theta( Cos_theta );
479 // set_Sin_theta( Sin_theta );
480 // set_Cos_psi( Cos_psi );
481 // set_Sin_psi( Sin_psi );
483 _set_Gamma_vert_rad( Gamma_vert_rad );
484 // set_Gamma_horiz_rad( Gamma_horiz_rad );
486 // set_Sigma( Sigma );
487 _set_Density( Density );
488 // set_V_sound( V_sound );
489 // set_Mach_number( Mach_number );
491 _set_Static_pressure( Static_pressure );
492 // set_Total_pressure( Total_pressure );
493 // set_Impact_pressure( Impact_pressure );
494 // set_Dynamic_pressure( Dynamic_pressure );
496 _set_Static_temperature( Static_temperature );
497 // set_Total_temperature( Total_temperature );
499 _set_Sea_level_radius( Sea_level_radius );
500 _set_Earth_position_angle( Earth_position_angle );
502 _set_Runway_altitude( Runway_altitude );
503 // set_Runway_latitude( Runway_latitude );
504 // set_Runway_longitude( Runway_longitude );
505 // set_Runway_heading( Runway_heading );
506 // set_Radius_to_rwy( Radius_to_rwy );
508 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
509 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
510 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
511 // D_pilot_above_rwy );
512 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
514 _set_sin_lat_geocentric(Lat_geocentric);
515 _set_cos_lat_geocentric(Lat_geocentric);
516 _set_sin_cos_longitude(Longitude);
517 _set_sin_cos_latitude(Latitude);
519 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
520 // printf("sin_lat %f cos_lat %f\n",
521 // get_sin_latitude(), get_cos_latitude());
522 // printf("sin_lon %f cos_lon %f\n",
523 // get_sin_longitude(), get_cos_longitude());
525 _set_Climb_Rate( -1 * V_down );
526 // cout << "climb rate = " << -V_down * 60 << endl;
528 if ( aero->getStringValue() == "uiuc" ) {
530 globals->get_controls()->set_elevator(Long_control);
531 globals->get_controls()->set_elevator_trim(Long_trim);
532 // controls.set_elevator(Long_control);
533 // controls.set_elevator_trim(Long_trim);
536 globals->get_controls()->set_aileron(Lat_control);
537 // controls.set_aileron(Lat_control);
540 globals->get_controls()->set_rudder(Rudder_pedal);
541 // controls.set_rudder(Rudder_pedal);
543 if (Throttle_pct_input) {
544 globals->get_controls()->set_throttle(0,Throttle_pct);
545 // controls.set_throttle(0,Throttle_pct);
553 void FGLaRCsim::set_ls(void) {
554 Phi=lsic->GetRollAngleRadIC();
555 Theta=lsic->GetPitchAngleRadIC();
556 Psi=lsic->GetHeadingRadIC();
557 V_north=lsic->GetVnorthFpsIC();
558 V_east=lsic->GetVeastFpsIC();
559 V_down=lsic->GetVdownFpsIC();
560 Altitude=lsic->GetAltitudeFtIC();
561 Latitude=lsic->GetLatitudeGDRadIC();
562 Longitude=lsic->GetLongitudeRadIC();
563 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
564 V_north_airmass = lsic->GetVnorthAirmassFpsIC();
565 V_east_airmass = lsic->GetVeastAirmassFpsIC();
566 V_down_airmass = lsic->GetVdownAirmassFpsIC();
569 SG_LOG( SG_FLIGHT, SG_INFO, " FGLaRCsim::set_ls(): " );
570 SG_LOG( SG_FLIGHT, SG_INFO, " Phi: " << Phi );
571 SG_LOG( SG_FLIGHT, SG_INFO, " Theta: " << Theta );
572 SG_LOG( SG_FLIGHT, SG_INFO, " Psi: " << Psi );
573 SG_LOG( SG_FLIGHT, SG_INFO, " V_north: " << V_north );
574 SG_LOG( SG_FLIGHT, SG_INFO, " V_east: " << V_east );
575 SG_LOG( SG_FLIGHT, SG_INFO, " V_down: " << V_down );
576 SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: " << Altitude );
577 SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: " << Latitude );
578 SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: " << Longitude );
579 SG_LOG( SG_FLIGHT, SG_INFO, " Runway_altitude: " << Runway_altitude );
580 SG_LOG( SG_FLIGHT, SG_INFO, " V_north_airmass: " << V_north_airmass );
581 SG_LOG( SG_FLIGHT, SG_INFO, " V_east_airmass: " << V_east_airmass );
582 SG_LOG( SG_FLIGHT, SG_INFO, " V_down_airmass: " << V_down_airmass );
585 void FGLaRCsim::snap_shot(void) {
586 lsic->SetLatitudeGDRadIC( get_Latitude() );
587 lsic->SetLongitudeRadIC( get_Longitude() );
588 lsic->SetAltitudeFtIC( get_Altitude() );
589 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
590 lsic->SetVtrueFpsIC( get_V_rel_wind() );
591 lsic->SetPitchAngleRadIC( get_Theta() );
592 lsic->SetRollAngleRadIC( get_Phi() );
593 lsic->SetHeadingRadIC( get_Psi() );
594 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
595 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
596 get_V_east_airmass(),
597 get_V_down_airmass() );
601 void FGLaRCsim::set_Latitude(double lat) {
602 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
604 lsic->SetLatitudeGDRadIC(lat);
606 copy_from_LaRCsim(); //update the bus
609 void FGLaRCsim::set_Longitude(double lon) {
610 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
612 lsic->SetLongitudeRadIC(lon);
614 copy_from_LaRCsim(); //update the bus
617 void FGLaRCsim::set_Altitude(double alt) {
618 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Altitude: " << alt );
620 lsic->SetAltitudeFtIC(alt);
622 copy_from_LaRCsim(); //update the bus
625 void FGLaRCsim::set_V_calibrated_kts(double vc) {
626 SG_LOG( SG_FLIGHT, SG_INFO,
627 "FGLaRCsim::set_V_calibrated_kts: " << vc );
629 lsic->SetVcalibratedKtsIC(vc);
631 copy_from_LaRCsim(); //update the bus
634 void FGLaRCsim::set_Mach_number(double mach) {
635 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
637 lsic->SetMachIC(mach);
639 copy_from_LaRCsim(); //update the bus
642 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
643 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_local: "
644 << north << " " << east << " " << down );
646 lsic->SetVNEDFpsIC(north, east, down);
648 copy_from_LaRCsim(); //update the bus
651 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
652 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
653 << u << " " << v << " " << w );
655 lsic->SetUVWFpsIC(u,v,w);
657 copy_from_LaRCsim(); //update the bus
661 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
662 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Euler_angles: "
663 << phi << " " << theta << " " << psi );
666 lsic->SetPitchAngleRadIC(theta);
667 lsic->SetRollAngleRadIC(phi);
668 lsic->SetHeadingRadIC(psi);
670 copy_from_LaRCsim(); //update the bus
674 void FGLaRCsim::set_Climb_Rate( double roc) {
675 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
677 lsic->SetClimbRateFpsIC(roc);
679 copy_from_LaRCsim(); //update the bus
682 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
683 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
685 lsic->SetFlightPathAngleRadIC(gamma);
687 copy_from_LaRCsim(); //update the bus
690 void FGLaRCsim::set_Runway_altitude(double ralt) {
691 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
693 lsic->SetRunwayAltitudeFtIC(ralt);
695 copy_from_LaRCsim(); //update the bus
698 void FGLaRCsim::set_AltitudeAGL(double altagl) {
699 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
701 lsic->SetAltitudeAGLFtIC(altagl);
706 void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
709 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
710 << wnorth << " " << weast << " " << wdown );
712 lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
717 void FGLaRCsim::set_Static_pressure(double p) {
718 SG_LOG( SG_FLIGHT, SG_INFO,
719 "FGLaRCsim::set_Static_pressure: " << p );
720 SG_LOG( SG_FLIGHT, SG_INFO,
721 "LaRCsim does not support externally supplied atmospheric data" );
724 void FGLaRCsim::set_Static_temperature(double T) {
725 SG_LOG( SG_FLIGHT, SG_INFO,
726 "FGLaRCsim::set_Static_temperature: " << T );
727 SG_LOG( SG_FLIGHT, SG_INFO,
728 "LaRCsim does not support externally supplied atmospheric data" );
732 void FGLaRCsim::set_Density(double rho) {
733 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Density: " << rho );
734 SG_LOG( SG_FLIGHT, SG_INFO,
735 "LaRCsim does not support externally supplied atmospheric data" );