diff --git a/libraries/SITL/SIM_JSBSim.cpp b/libraries/SITL/SIM_JSBSim.cpp index 14ced10d6e..aee85e9120 100644 --- a/libraries/SITL/SIM_JSBSim.cpp +++ b/libraries/SITL/SIM_JSBSim.cpp @@ -58,6 +58,10 @@ JSBSim::JSBSim(const char *home_str, const char *frame_str) : } else { frame = FRAME_NORMAL; } + const char *model_name = strchr(frame_str, ':'); + if (model_name != NULL) { + jsbsim_model = model_name + 1; + } } /* @@ -76,20 +80,20 @@ bool JSBSim::create_templates(void) FILE *f = fopen(jsbsim_script, "w"); if (f == NULL) { - hal.scheduler->panic("Unable to create jsbsim script"); + hal.scheduler->panic("Unable to create jsbsim script %s", jsbsim_script); } fprintf(f, "\n" "\n" "\n" +" name=\"Testing %s\">\n" "\n" " \n" -" test ArduPlane using Rascal110 and JSBSim\n" +" test ArduPlane using %s and JSBSim\n" " \n" "\n" -" \n" +" \n" "\n" " \n" @@ -112,12 +116,16 @@ bool JSBSim::create_templates(void) " \n" "\n" "\n" -"", control_port); +"", + jsbsim_model, + jsbsim_model, + jsbsim_model, + control_port); fclose(f); f = fopen(jsbsim_fgout, "w"); if (f == NULL) { - hal.scheduler->panic("Unable to create jsbsim fgout script"); + hal.scheduler->panic("Unable to create jsbsim fgout script %s", jsbsim_fgout); } fprintf(f, "\n" "\n", @@ -125,10 +133,10 @@ bool JSBSim::create_templates(void) fclose(f); char *jsbsim_reset; - asprintf(&jsbsim_reset, "%s/aircraft/Rascal/reset.xml", autotest_dir); + asprintf(&jsbsim_reset, "%s/aircraft/%s/reset.xml", autotest_dir, jsbsim_model); f = fopen(jsbsim_reset, "w"); if (f == NULL) { - hal.scheduler->panic("Unable to create jsbsim Rascal reset script"); + hal.scheduler->panic("Unable to create jsbsim reset script %s", jsbsim_reset); } float r, p, y; dcm.to_euler(&r, &p, &y); diff --git a/libraries/SITL/SIM_JSBSim.h b/libraries/SITL/SIM_JSBSim.h index e369434dfc..2bc6611803 100644 --- a/libraries/SITL/SIM_JSBSim.h +++ b/libraries/SITL/SIM_JSBSim.h @@ -55,6 +55,9 @@ private: char *jsbsim_fgout; int jsbsim_stdout; + // default JSBSim model + const char *jsbsim_model = "Rascal"; + bool created_templates; bool started_jsbsim; bool opened_control_socket;