From 6026278b0921a7fb79f29971eadf448fce696adf Mon Sep 17 00:00:00 2001 From: Stephen Dwyer Date: Mon, 21 Feb 2011 17:42:57 -0700 Subject: [PATCH] modified JSBSim fw sim to easily use either defaults or an initialization file, launch velocity can now be specified in SIMU section, added example intialization file, modified jsbsim.xml example airframe to use init file and updated to include firmware section instead of old makefile section --- conf/airframes/jsbsim.xml | 44 +++++++++++++++++------- conf/simulator/Malolo1/Malolo1-IC.xml | 49 +++++++++++++++++++++++++++ sw/simulator/sim_ac_fw.c | 8 +++-- sw/simulator/sim_ac_jsbsim.c | 2 +- 4 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 conf/simulator/Malolo1/Malolo1-IC.xml diff --git a/conf/airframes/jsbsim.xml b/conf/airframes/jsbsim.xml index 67fe2f0a1a..18dc8cc3ca 100644 --- a/conf/airframes/jsbsim.xml +++ b/conf/airframes/jsbsim.xml @@ -191,25 +191,43 @@
+ +
- -#### Config for SITL simulation -include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile + + + + -sim.CFLAGS += -DBOARD_CONFIG=\"boards/tiny_sim.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -sim.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c + + + + + + + + + + + + + + + + + + + -#### Config for SITL simulation with JSBSim -SRC_FIRMWARE = firmwares/fixedwing -include $(PAPARAZZI_SRC)/conf/autopilot/sitl_jsbsim.makefile + + + + + + -jsbsim.CFLAGS += -DBOARD_CONFIG=\"boards/tiny_sim.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -jsbsim.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c -jsbsim.srcs += $(SIMDIR)/sim_ac_fw.c - - diff --git a/conf/simulator/Malolo1/Malolo1-IC.xml b/conf/simulator/Malolo1/Malolo1-IC.xml new file mode 100644 index 0000000000..89c46bef55 --- /dev/null +++ b/conf/simulator/Malolo1/Malolo1-IC.xml @@ -0,0 +1,49 @@ + + + + + + + 43.46223 + 1.27289 + 186.0 + 2.0 + + 0.0 + 0.0 + 0.0 + + 0.0 + 20.0 + + 0.0 + -1 + diff --git a/sw/simulator/sim_ac_fw.c b/sw/simulator/sim_ac_fw.c index fac1a433b5..e9dde43ab0 100644 --- a/sw/simulator/sim_ac_fw.c +++ b/sw/simulator/sim_ac_fw.c @@ -127,6 +127,9 @@ static inline double normalize_from_pprz(int command) { void copy_inputs_to_jsbsim(FGFDMExec* FDMExec) { static double throttle_slewed = 0.; static double th = 0.; +#ifndef JSBSIM_LAUNCHSPEED +#define JSBSIM_LAUNCHSPEED 20.0 //launch speed in m/s aligned with airframe body forward +#endif if (run_model) th += 0.01; if (th >= 1) th = 1; // detect launch @@ -134,8 +137,9 @@ void copy_inputs_to_jsbsim(FGFDMExec* FDMExec) { run_model = true; //set_value(FDMExec, "propulsion/set-running", 1); // set initial speed - FDMExec->GetIC()->SetAltitudeAGLFtIC(5.0 / FT2M); - FDMExec->GetIC()->SetVgroundFpsIC(20./FT2M); + //FDMExec->GetIC()->SetAltitudeAGLFtIC(5.0 / FT2M); + //FDMExec->GetIC()->SetVgroundFpsIC(20./FT2M); + FDMExec->GetIC()->SetUBodyFpsIC( JSBSIM_LAUNCHSPEED / FT2M); FDMExec->RunIC(); th = 0.; } diff --git a/sw/simulator/sim_ac_jsbsim.c b/sw/simulator/sim_ac_jsbsim.c index 3806af2909..55f66a17a8 100644 --- a/sw/simulator/sim_ac_jsbsim.c +++ b/sw/simulator/sim_ac_jsbsim.c @@ -253,7 +253,7 @@ void jsbsim_init(void) { IC->SetLatitudeDegIC(NAV_LAT0 / 1e7); IC->SetLongitudeDegIC(NAV_LON0 / 1e7); - IC->SetAltitudeASLFtIC(GROUND_ALT / FT2M); + IC->SetAltitudeASLFtIC((GROUND_ALT + 2.0) / FT2M); IC->SetTerrainElevationFtIC(GROUND_ALT / FT2M); IC->SetPsiDegIC(QFU); IC->SetVgroundFpsIC(0.);