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
54 //current_aircraft.fdm_state->set_Tank1Fuel(15.0);
55 //current_aircraft.fdm_state->set_Tank2Fuel(15.0);
60 FGLaRCsim::~FGLaRCsim(void) {
66 // Initialize the LaRCsim flight model, dt is the time increment for
67 // each subsequent iteration through the EOM
68 void FGLaRCsim::init() {
70 // Explicitly call the superclass's
74 speed_up = fgGetValue("/sim/speed-up", true);
76 ls_set_model_dt( get_delta_t() );
77 // Initialize our little engine that hopefully might
78 eng.init( get_delta_t() );
79 // dcl - in passing dt to init rather than update I am assuming
80 // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
82 // update the engines interface
86 // Fill the fuel tanks
87 // Hardwired to C172 full tanks for now - need to fix this sometime
88 // Also note that this is the max quantity - the usable quantity
93 // SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::init()" );
95 double save_alt = 0.0;
97 if ( get_Altitude() < -9000.0 ) {
98 save_alt = get_Altitude();
102 // translate FG to LaRCsim structure
105 // actual LaRCsim top level init
106 // ls_toplevel_init( dt, (char *)fgGetString("/sim/aircraft").c_str() );
108 SG_LOG( SG_FLIGHT, SG_INFO, "FG pos = " <<
111 // translate LaRCsim back to FG structure
114 // but lets restore our original bogus altitude when we are done
115 if ( save_alt < -9000.0 ) {
116 set_Altitude( save_alt );
121 // Run an iteration of the EOM (equations of motion)
122 bool FGLaRCsim::update( int multiloop ) {
124 if ( fgGetString("/sim/aircraft") == "c172" ) {
125 // set control inputs
126 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
127 eng.set_IAS( V_calibrated_kts );
128 eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
129 eng.set_Propeller_Lever_Pos( 100 );
130 eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 );
131 eng.set_p_amb( Static_pressure );
132 eng.set_T_amb( Static_temperature );
134 // update engine model
137 // copy engine state values onto "bus"
138 FGEngInterface *e = get_engine( 0 );
139 e->set_Throttle( controls.get_throttle( 0 ) * 100.0 );
140 e->set_Mixture( 80 );
141 e->set_Prop_Advance( 100 );
142 e->set_RPM( eng.get_RPM() );
143 e->set_Manifold_Pressure( eng.get_Manifold_Pressure() );
144 e->set_MaxHP( eng.get_MaxHP() );
145 e->set_Percentage_Power( eng.get_Percentage_Power() );
146 e->set_EGT( eng.get_EGT() );
147 e->set_CHT( eng.get_CHT() );
148 e->set_prop_thrust( eng.get_prop_thrust_SI() );
149 e->set_Fuel_Flow( eng.get_fuel_flow_gals_hr() );
151 //Assume we are using both tanks equally for now
152 reduce_Tank1Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
154 reduce_Tank2Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
158 SG_LOG( SG_FLIGHT, SG_INFO, "Throttle = "
159 << controls.get_throttle( 0 ) * 100.0);
160 SG_LOG( SG_FLIGHT, SG_INFO, " Mixture = " << 80);
161 SG_LOG( SG_FLIGHT, SG_INFO, " RPM = " << eng.get_RPM());
162 SG_LOG( SG_FLIGHT, SG_INFO, " MP = " << eng.get_Manifold_Pressure());
163 SG_LOG( SG_FLIGHT, SG_INFO, " HP = "
164 << ( eng.get_MaxHP() * eng.get_Percentage_Power()/ 100.0) );
165 SG_LOG( SG_FLIGHT, SG_INFO, " EGT = " << eng.get_EGT());
166 SG_LOG( SG_FLIGHT, SG_INFO, " Thrust (N) "
167 << eng.get_prop_thrust_SI()); // Thrust in Newtons
168 SG_LOG( SG_FLIGHT, SG_INFO, '\n');
170 F_X_engine = eng.get_prop_thrust_lbs();
171 // cout << "F_X_engine = " << F_X_engine << '\n';
174 double save_alt = 0.0;
176 // lets try to avoid really screwing up the LaRCsim model
177 if ( get_Altitude() < -9000.0 ) {
178 save_alt = get_Altitude();
182 // copy control positions into the LaRCsim structure
183 Lat_control = controls.get_aileron() /
184 speed_up->getIntValue();
185 Long_control = controls.get_elevator();
186 Long_trim = controls.get_elevator_trim();
187 Rudder_pedal = controls.get_rudder() /
188 speed_up->getIntValue();
189 Flap_handle = 30.0 * controls.get_flaps();
191 if ( fgGetString("/sim/aircraft") == "c172" ) {
192 Use_External_Engine = 1;
194 Use_External_Engine = 0;
197 Throttle_pct = controls.get_throttle( 0 ) * 1.0;
199 Brake_pct[0] = controls.get_brake( 1 );
200 Brake_pct[1] = controls.get_brake( 0 );
202 // Inform LaRCsim of the local terrain altitude
203 // Runway_altitude = get_Runway_altitude();
204 Runway_altitude = scenery.cur_elev * SG_METER_TO_FEET;
207 /* V_north_airmass = get_V_north_airmass();
208 V_east_airmass = get_V_east_airmass();
209 V_down_airmass = get_V_down_airmass(); */
212 // old -- FGInterface_2_LaRCsim() not needed except for Init()
213 // translate FG to LaRCsim structure
214 // FGInterface_2_LaRCsim(f);
215 // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
216 // printf("Altitude = %.2f\n", Altitude * 0.3048);
217 // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
219 ls_update(multiloop);
221 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
222 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
224 // translate LaRCsim back to FG structure so that the
225 // autopilot (and the rest of the sim can use the updated
229 // but lets restore our original bogus altitude when we are done
230 if ( save_alt < -9000.0 ) {
231 set_Altitude( save_alt );
238 // Convert from the FGInterface struct to the LaRCsim generic_ struct
239 bool FGLaRCsim::copy_to_LaRCsim () {
245 // Dx_pilot = get_Dx_pilot();
246 // Dy_pilot = get_Dy_pilot();
247 // Dz_pilot = get_Dz_pilot();
254 // F_north = get_F_north();
255 // F_east = get_F_east();
256 // F_down = get_F_down();
257 // F_X_aero = get_F_X_aero();
258 // F_Y_aero = get_F_Y_aero();
259 // F_Z_aero = get_F_Z_aero();
260 // F_X_engine = get_F_X_engine();
261 // F_Y_engine = get_F_Y_engine();
262 // F_Z_engine = get_F_Z_engine();
263 // F_X_gear = get_F_X_gear();
264 // F_Y_gear = get_F_Y_gear();
265 // F_Z_gear = get_F_Z_gear();
266 // M_l_rp = get_M_l_rp();
267 // M_m_rp = get_M_m_rp();
268 // M_n_rp = get_M_n_rp();
269 // M_l_cg = get_M_l_cg();
270 // M_m_cg = get_M_m_cg();
271 // M_n_cg = get_M_n_cg();
272 // M_l_aero = get_M_l_aero();
273 // M_m_aero = get_M_m_aero();
274 // M_n_aero = get_M_n_aero();
275 // M_l_engine = get_M_l_engine();
276 // M_m_engine = get_M_m_engine();
277 // M_n_engine = get_M_n_engine();
278 // M_l_gear = get_M_l_gear();
279 // M_m_gear = get_M_m_gear();
280 // M_n_gear = get_M_n_gear();
281 // V_dot_north = get_V_dot_north();
282 // V_dot_east = get_V_dot_east();
283 // V_dot_down = get_V_dot_down();
284 // U_dot_body = get_U_dot_body();
285 // V_dot_body = get_V_dot_body();
286 // W_dot_body = get_W_dot_body();
287 // A_X_cg = get_A_X_cg();
288 // A_Y_cg = get_A_Y_cg();
289 // A_Z_cg = get_A_Z_cg();
290 // A_X_pilot = get_A_X_pilot();
291 // A_Y_pilot = get_A_Y_pilot();
292 // A_Z_pilot = get_A_Z_pilot();
293 // N_X_cg = get_N_X_cg();
294 // N_Y_cg = get_N_Y_cg();
295 // N_Z_cg = get_N_Z_cg();
296 // N_X_pilot = get_N_X_pilot();
297 // N_Y_pilot = get_N_Y_pilot();
298 // N_Z_pilot = get_N_Z_pilot();
299 // P_dot_body = get_P_dot_body();
300 // Q_dot_body = get_Q_dot_body();
301 // R_dot_body = get_R_dot_body();
302 // V_north = get_V_north();
303 // V_east = get_V_east();
304 // V_down = get_V_down();
305 // V_north_rel_ground = get_V_north_rel_ground();
306 // V_east_rel_ground = get_V_east_rel_ground();
307 // V_down_rel_ground = get_V_down_rel_ground();
308 // V_north_airmass = get_V_north_airmass();
309 // V_east_airmass = get_V_east_airmass();
310 // V_down_airmass = get_V_down_airmass();
311 // V_north_rel_airmass = get_V_north_rel_airmass();
312 // V_east_rel_airmass = get_V_east_rel_airmass();
313 // V_down_rel_airmass = get_V_down_rel_airmass();
314 // U_gust = get_U_gust();
315 // V_gust = get_V_gust();
316 // W_gust = get_W_gust();
317 // U_body = get_U_body();
318 // V_body = get_V_body();
319 // W_body = get_W_body();
320 // V_rel_wind = get_V_rel_wind();
321 // V_true_kts = get_V_true_kts();
322 // V_rel_ground = get_V_rel_ground();
323 // V_inertial = get_V_inertial();
324 // V_ground_speed = get_V_ground_speed();
325 // V_equiv = get_V_equiv();
326 // V_equiv_kts = get_V_equiv_kts();
327 // V_calibrated = get_V_calibrated();
328 // V_calibrated_kts = get_V_calibrated_kts();
329 // P_body = get_P_body();
330 // Q_body = get_Q_body();
331 // R_body = get_R_body();
332 // P_local = get_P_local();
333 // Q_local = get_Q_local();
334 // R_local = get_R_local();
335 // P_total = get_P_total();
336 // Q_total = get_Q_total();
337 // R_total = get_R_total();
338 // Phi_dot = get_Phi_dot();
339 // Theta_dot = get_Theta_dot();
340 // Psi_dot = get_Psi_dot();
341 // Latitude_dot = get_Latitude_dot();
342 // Longitude_dot = get_Longitude_dot();
343 // Radius_dot = get_Radius_dot();
344 // Lat_geocentric = get_Lat_geocentric();
345 // Lon_geocentric = get_Lon_geocentric();
346 // Radius_to_vehicle = get_Radius_to_vehicle();
347 // Latitude = get_Latitude();
348 // Longitude = get_Longitude();
349 // Altitude = get_Altitude();
351 // Theta = get_Theta();
353 // T_local_to_body_11 = get_T_local_to_body_11();
354 // T_local_to_body_12 = get_T_local_to_body_12();
355 // T_local_to_body_13 = get_T_local_to_body_13();
356 // T_local_to_body_21 = get_T_local_to_body_21();
357 // T_local_to_body_22 = get_T_local_to_body_22();
358 // T_local_to_body_23 = get_T_local_to_body_23();
359 // T_local_to_body_31 = get_T_local_to_body_31();
360 // T_local_to_body_32 = get_T_local_to_body_32();
361 // T_local_to_body_33 = get_T_local_to_body_33();
362 // Gravity = get_Gravity();
363 // Centrifugal_relief = get_Centrifugal_relief();
364 // Alpha = get_Alpha();
365 // Beta = get_Beta();
366 // Alpha_dot = get_Alpha_dot();
367 // Beta_dot = get_Beta_dot();
368 // Cos_alpha = get_Cos_alpha();
369 // Sin_alpha = get_Sin_alpha();
370 // Cos_beta = get_Cos_beta();
371 // Sin_beta = get_Sin_beta();
372 // Cos_phi = get_Cos_phi();
373 // Sin_phi = get_Sin_phi();
374 // Cos_theta = get_Cos_theta();
375 // Sin_theta = get_Sin_theta();
376 // Cos_psi = get_Cos_psi();
377 // Sin_psi = get_Sin_psi();
378 // Gamma_vert_rad = get_Gamma_vert_rad();
379 // Gamma_horiz_rad = get_Gamma_horiz_rad();
380 // Sigma = get_Sigma();
381 // Density = get_Density();
382 // V_sound = get_V_sound();
383 // Mach_number = get_Mach_number();
384 // Static_pressure = get_Static_pressure();
385 // Total_pressure = get_Total_pressure();
386 // Impact_pressure = get_Impact_pressure();
387 // Dynamic_pressure = get_Dynamic_pressure();
388 // Static_temperature = get_Static_temperature();
389 // Total_temperature = get_Total_temperature();
390 // Sea_level_radius = get_Sea_level_radius();
391 // Earth_position_angle = get_Earth_position_angle();
392 // Runway_altitude = get_Runway_altitude();
393 // Runway_latitude = get_Runway_latitude();
394 // Runway_longitude = get_Runway_longitude();
395 // Runway_heading = get_Runway_heading();
396 // Radius_to_rwy = get_Radius_to_rwy();
397 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
398 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
399 // D_cg_above_rwy = get_D_cg_above_rwy();
400 // X_cg_rwy = get_X_cg_rwy();
401 // Y_cg_rwy = get_Y_cg_rwy();
402 // H_cg_rwy = get_H_cg_rwy();
403 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
404 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
405 // D_pilot_above_rwy = get_D_pilot_above_rwy();
406 // X_pilot_rwy = get_X_pilot_rwy();
407 // Y_pilot_rwy = get_Y_pilot_rwy();
408 // H_pilot_rwy = get_H_pilot_rwy();
414 // Convert from the LaRCsim generic_ struct to the FGInterface struct
415 bool FGLaRCsim::copy_from_LaRCsim() {
417 // Mass properties and geometry values
418 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
419 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
420 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
423 // set_Forces_Body_Total( F_X, F_Y, F_Z );
424 // set_Forces_Local_Total( F_north, F_east, F_down );
425 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
426 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
427 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
430 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
431 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
432 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
433 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
434 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
437 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
438 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
439 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
440 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
441 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
442 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
443 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
446 _set_Velocities_Local( V_north, V_east, V_down );
447 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
448 // V_down_rel_ground );
449 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
451 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
452 // V_east_rel_airmass, V_down_rel_airmass );
453 // set_Velocities_Gust( U_gust, V_gust, W_gust );
454 _set_Velocities_Wind_Body( U_body, V_body, W_body );
456 _set_V_rel_wind( V_rel_wind );
457 // set_V_true_kts( V_true_kts );
458 // set_V_rel_ground( V_rel_ground );
459 // set_V_inertial( V_inertial );
460 _set_V_ground_speed( V_ground_speed );
461 // set_V_equiv( V_equiv );
462 _set_V_equiv_kts( V_equiv_kts );
463 // set_V_calibrated( V_calibrated );
464 _set_V_calibrated_kts( V_calibrated_kts );
466 _set_Omega_Body( P_body, Q_body, R_body );
467 // set_Omega_Local( P_local, Q_local, R_local );
468 // set_Omega_Total( P_total, Q_total, R_total );
470 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
471 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
473 _set_Mach_number( Mach_number );
475 SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
476 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
477 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
478 << " radius_to_vehicle = " << Radius_to_vehicle );
480 double tmp_lon_geoc = Lon_geocentric;
481 while ( tmp_lon_geoc < -SGD_PI ) { tmp_lon_geoc += SGD_2PI; }
482 while ( tmp_lon_geoc > SGD_PI ) { tmp_lon_geoc -= SGD_2PI; }
484 double tmp_lon = Longitude;
485 while ( tmp_lon < -SGD_PI ) { tmp_lon += SGD_2PI; }
486 while ( tmp_lon > SGD_PI ) { tmp_lon -= SGD_2PI; }
489 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
491 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
492 _set_Euler_Angles( Phi, Theta, Psi );
494 _set_Altitude_AGL( Altitude-Runway_altitude );
496 // Miscellaneous quantities
497 _set_T_Local_to_Body(T_local_to_body_m);
498 // set_Gravity( Gravity );
499 // set_Centrifugal_relief( Centrifugal_relief );
503 // set_Alpha_dot( Alpha_dot );
504 // set_Beta_dot( Beta_dot );
506 // set_Cos_alpha( Cos_alpha );
507 // set_Sin_alpha( Sin_alpha );
508 // set_Cos_beta( Cos_beta );
509 // set_Sin_beta( Sin_beta );
511 _set_Cos_phi( Cos_phi );
512 // set_Sin_phi( Sin_phi );
513 _set_Cos_theta( Cos_theta );
514 // set_Sin_theta( Sin_theta );
515 // set_Cos_psi( Cos_psi );
516 // set_Sin_psi( Sin_psi );
518 _set_Gamma_vert_rad( Gamma_vert_rad );
519 // set_Gamma_horiz_rad( Gamma_horiz_rad );
521 // set_Sigma( Sigma );
522 _set_Density( Density );
523 // set_V_sound( V_sound );
524 // set_Mach_number( Mach_number );
526 _set_Static_pressure( Static_pressure );
527 // set_Total_pressure( Total_pressure );
528 // set_Impact_pressure( Impact_pressure );
529 // set_Dynamic_pressure( Dynamic_pressure );
531 _set_Static_temperature( Static_temperature );
532 // set_Total_temperature( Total_temperature );
534 _set_Sea_level_radius( Sea_level_radius );
535 _set_Earth_position_angle( Earth_position_angle );
537 _set_Runway_altitude( Runway_altitude );
538 // set_Runway_latitude( Runway_latitude );
539 // set_Runway_longitude( Runway_longitude );
540 // set_Runway_heading( Runway_heading );
541 // set_Radius_to_rwy( Radius_to_rwy );
543 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
544 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
545 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
546 // D_pilot_above_rwy );
547 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
549 _set_sin_lat_geocentric(Lat_geocentric);
550 _set_cos_lat_geocentric(Lat_geocentric);
551 _set_sin_cos_longitude(Longitude);
552 _set_sin_cos_latitude(Latitude);
554 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
555 // printf("sin_lat %f cos_lat %f\n",
556 // get_sin_latitude(), get_cos_latitude());
557 // printf("sin_lon %f cos_lon %f\n",
558 // get_sin_longitude(), get_cos_longitude());
560 _set_Climb_Rate( -1 * V_down );
566 void FGLaRCsim::set_ls(void) {
567 Phi=lsic->GetRollAngleRadIC();
568 Theta=lsic->GetPitchAngleRadIC();
569 Psi=lsic->GetHeadingRadIC();
570 V_north=lsic->GetVnorthFpsIC();
571 V_east=lsic->GetVeastFpsIC();
572 V_down=lsic->GetVdownFpsIC();
573 Altitude=lsic->GetAltitudeFtIC();
574 Latitude=lsic->GetLatitudeGDRadIC();
575 Longitude=lsic->GetLongitudeRadIC();
576 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
577 V_north_airmass = lsic->GetVnorthAirmassFpsIC();
578 V_east_airmass = lsic->GetVeastAirmassFpsIC();
579 V_down_airmass = lsic->GetVdownAirmassFpsIC();
582 SG_LOG( SG_FLIGHT, SG_INFO, " FGLaRCsim::set_ls(): " );
583 SG_LOG( SG_FLIGHT, SG_INFO, " Phi: " << Phi );
584 SG_LOG( SG_FLIGHT, SG_INFO, " Theta: " << Theta );
585 SG_LOG( SG_FLIGHT, SG_INFO, " Psi: " << Psi );
586 SG_LOG( SG_FLIGHT, SG_INFO, " V_north: " << V_north );
587 SG_LOG( SG_FLIGHT, SG_INFO, " V_east: " << V_east );
588 SG_LOG( SG_FLIGHT, SG_INFO, " V_down: " << V_down );
589 SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: " << Altitude );
590 SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: " << Latitude );
591 SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: " << Longitude );
592 SG_LOG( SG_FLIGHT, SG_INFO, " Runway_altitude: " << Runway_altitude );
593 SG_LOG( SG_FLIGHT, SG_INFO, " V_north_airmass: " << V_north_airmass );
594 SG_LOG( SG_FLIGHT, SG_INFO, " V_east_airmass: " << V_east_airmass );
595 SG_LOG( SG_FLIGHT, SG_INFO, " V_down_airmass: " << V_down_airmass );
598 void FGLaRCsim::snap_shot(void) {
599 lsic->SetLatitudeGDRadIC( get_Latitude() );
600 lsic->SetLongitudeRadIC( get_Longitude() );
601 lsic->SetAltitudeFtIC( get_Altitude() );
602 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
603 lsic->SetVtrueFpsIC( get_V_rel_wind() );
604 lsic->SetPitchAngleRadIC( get_Theta() );
605 lsic->SetRollAngleRadIC( get_Phi() );
606 lsic->SetHeadingRadIC( get_Psi() );
607 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
608 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
609 get_V_east_airmass(),
610 get_V_down_airmass() );
614 void FGLaRCsim::set_Latitude(double lat) {
615 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
617 lsic->SetLatitudeGDRadIC(lat);
619 copy_from_LaRCsim(); //update the bus
622 void FGLaRCsim::set_Longitude(double lon) {
623 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
625 lsic->SetLongitudeRadIC(lon);
627 copy_from_LaRCsim(); //update the bus
630 void FGLaRCsim::set_Altitude(double alt) {
631 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Altitude: " << alt );
633 lsic->SetAltitudeFtIC(alt);
635 copy_from_LaRCsim(); //update the bus
638 void FGLaRCsim::set_V_calibrated_kts(double vc) {
639 SG_LOG( SG_FLIGHT, SG_INFO,
640 "FGLaRCsim::set_V_calibrated_kts: " << vc );
642 lsic->SetVcalibratedKtsIC(vc);
644 copy_from_LaRCsim(); //update the bus
647 void FGLaRCsim::set_Mach_number(double mach) {
648 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
650 lsic->SetMachIC(mach);
652 copy_from_LaRCsim(); //update the bus
655 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
656 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_local: "
657 << north << " " << east << " " << down );
659 lsic->SetVNEDFpsIC(north, east, down);
661 copy_from_LaRCsim(); //update the bus
664 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
665 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
666 << u << " " << v << " " << w );
668 lsic->SetUVWFpsIC(u,v,w);
670 copy_from_LaRCsim(); //update the bus
674 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
675 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Euler_angles: "
676 << phi << " " << theta << " " << psi );
679 lsic->SetPitchAngleRadIC(theta);
680 lsic->SetRollAngleRadIC(phi);
681 lsic->SetHeadingRadIC(psi);
683 copy_from_LaRCsim(); //update the bus
687 void FGLaRCsim::set_Climb_Rate( double roc) {
688 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
690 lsic->SetClimbRateFpsIC(roc);
692 copy_from_LaRCsim(); //update the bus
695 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
696 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
698 lsic->SetFlightPathAngleRadIC(gamma);
700 copy_from_LaRCsim(); //update the bus
703 void FGLaRCsim::set_Runway_altitude(double ralt) {
704 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
706 lsic->SetRunwayAltitudeFtIC(ralt);
708 copy_from_LaRCsim(); //update the bus
711 void FGLaRCsim::set_AltitudeAGL(double altagl) {
712 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
714 lsic->SetAltitudeAGLFtIC(altagl);
719 void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
722 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
723 << wnorth << " " << weast << " " << wdown );
725 lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
730 void FGLaRCsim::set_Static_pressure(double p) {
731 SG_LOG( SG_FLIGHT, SG_INFO,
732 "FGLaRCsim::set_Static_pressure: " << p );
733 SG_LOG( SG_FLIGHT, SG_INFO,
734 "LaRCsim does not support externally supplied atmospheric data" );
737 void FGLaRCsim::set_Static_temperature(double T) {
738 SG_LOG( SG_FLIGHT, SG_INFO,
739 "FGLaRCsim::set_Static_temperature: " << T );
740 SG_LOG( SG_FLIGHT, SG_INFO,
741 "LaRCsim does not support externally supplied atmospheric data" );
745 void FGLaRCsim::set_Density(double rho) {
746 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Density: " << rho );
747 SG_LOG( SG_FLIGHT, SG_INFO,
748 "LaRCsim does not support externally supplied atmospheric data" );