Skip to content

Commit

Permalink
fixed some initialisation calls in JSBSim for fw
Browse files Browse the repository at this point in the history
  • Loading branch information
lamestllama committed Feb 18, 2011
1 parent a62e73f commit 75c7eb5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions sw/simulator/sim_ac_jsbsim.c
Expand Up @@ -32,6 +32,8 @@
#include <iostream>

#include <FGFDMExec.h>
//#include <SGGeod.hxx>
#include <math/FGLocation.h>
#include "sim_ac_flightgear.h"

using namespace std;
Expand All @@ -45,6 +47,7 @@ GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

bool run_model;
bool run_fg = false;

string ICName;
string AircraftName;
Expand Down Expand Up @@ -80,7 +83,7 @@ static gboolean sim_periodic(gpointer data __attribute__ ((unused))) {

/* read actuators positions and feed JSBSim inputs */
copy_inputs_to_jsbsim(FDMExec);

/* run JSBSim flight model */
bool result = true;
if (run_model) {
Expand All @@ -92,8 +95,9 @@ static gboolean sim_periodic(gpointer data __attribute__ ((unused))) {
/* read outputs from model state */
copy_outputs_from_jsbsim(FDMExec);

/* send outputs to flightgear for visualisation */
sim_ac_flightgear_send(FDMExec);
/* send outputs to flightgear for visualisation */
if (run_fg == true)
sim_ac_flightgear_send(FDMExec);

/* run the airborne code
with 60 Hz, even if JSBSim runs with a multiple of this */
Expand All @@ -115,7 +119,8 @@ int main ( int argc, char** argv) {

sim_init();

sim_ac_flightgear_init(fgAddress.c_str(), 5501);
if (run_fg == true)
sim_ac_flightgear_init(fgAddress.c_str(), 5501);

GMainLoop *ml = g_main_loop_new(NULL, FALSE);

Expand Down Expand Up @@ -171,6 +176,7 @@ static void sim_parse_options(int argc, char** argv) {
ivyBus = string(argv[++i]);
}
else if (argument == "-fg") {
run_fg = true;
fgAddress = string(argv[++i]);
}
else {
Expand Down Expand Up @@ -237,13 +243,21 @@ void jsbsim_init(void) {
}
}
else {

// FGInitialCondition::SetAltitudeASLFtIC
// requires this function to be called
// before itself
IC->SetVgroundFpsIC(0.);

// Use flight plan initial conditions
IC->SetLatitudeDegIC(NAV_LAT0 / 1e7);
IC->SetLongitudeDegIC(NAV_LON0 / 1e7);
IC->SetAltitudeAGLFtIC(0.0 / FT2M);

IC->SetAltitudeASLFtIC(GROUND_ALT / FT2M);
IC->SetTerrainElevationFtIC(GROUND_ALT / FT2M);
IC->SetPsiDegIC(QFU);
IC->SetVgroundFpsIC(0.);

//initRunning for all engines
FDMExec->GetPropulsion()->InitRunning(-1);
if (!FDMExec->RunIC()) {
Expand Down

0 comments on commit 75c7eb5

Please sign in to comment.