5
0
mirror of https://github.com/ArduPilot/ardupilot synced 2025-02-20 14:54:09 -04:00

SITL: support multiple jsbsim aircraft types

use -f jsbsim:ModelName
This commit is contained in:
Andrew Tridgell 2015-10-27 10:01:34 +11:00
parent da3961e4a6
commit 724f5511aa
2 changed files with 19 additions and 8 deletions

View File

@ -58,6 +58,10 @@ JSBSim::JSBSim(const char *home_str, const char *frame_str) :
} else { } else {
frame = FRAME_NORMAL; 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"); FILE *f = fopen(jsbsim_script, "w");
if (f == NULL) { if (f == NULL) {
hal.scheduler->panic("Unable to create jsbsim script"); hal.scheduler->panic("Unable to create jsbsim script %s", jsbsim_script);
} }
fprintf(f, fprintf(f,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<?xml-stylesheet type=\"text/xsl\" href=\"http://jsbsim.sf.net/JSBSimScript.xsl\"?>\n" "<?xml-stylesheet type=\"text/xsl\" href=\"http://jsbsim.sf.net/JSBSimScript.xsl\"?>\n"
"<runscript xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" "<runscript xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
" xsi:noNamespaceSchemaLocation=\"http://jsbsim.sf.net/JSBSimScript.xsd\"\n" " xsi:noNamespaceSchemaLocation=\"http://jsbsim.sf.net/JSBSimScript.xsd\"\n"
" name=\"Testing Rascal110\">\n" " name=\"Testing %s\">\n"
"\n" "\n"
" <description>\n" " <description>\n"
" test ArduPlane using Rascal110 and JSBSim\n" " test ArduPlane using %s and JSBSim\n"
" </description>\n" " </description>\n"
"\n" "\n"
" <use aircraft=\"Rascal\" initialize=\"reset\"/>\n" " <use aircraft=\"%s\" initialize=\"reset\"/>\n"
"\n" "\n"
" <!-- we control the servos via the jsbsim console\n" " <!-- we control the servos via the jsbsim console\n"
" interface on TCP 5124 -->\n" " interface on TCP 5124 -->\n"
@ -112,12 +116,16 @@ bool JSBSim::create_templates(void)
" </run>\n" " </run>\n"
"\n" "\n"
"</runscript>\n" "</runscript>\n"
"", control_port); "",
jsbsim_model,
jsbsim_model,
jsbsim_model,
control_port);
fclose(f); fclose(f);
f = fopen(jsbsim_fgout, "w"); f = fopen(jsbsim_fgout, "w");
if (f == NULL) { 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, "<?xml version=\"1.0\"?>\n" fprintf(f, "<?xml version=\"1.0\"?>\n"
"<output name=\"127.0.0.1\" type=\"FLIGHTGEAR\" port=\"%u\" protocol=\"udp\" rate=\"1000\"/>\n", "<output name=\"127.0.0.1\" type=\"FLIGHTGEAR\" port=\"%u\" protocol=\"udp\" rate=\"1000\"/>\n",
@ -125,10 +133,10 @@ bool JSBSim::create_templates(void)
fclose(f); fclose(f);
char *jsbsim_reset; 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"); f = fopen(jsbsim_reset, "w");
if (f == NULL) { 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; float r, p, y;
dcm.to_euler(&r, &p, &y); dcm.to_euler(&r, &p, &y);

View File

@ -55,6 +55,9 @@ private:
char *jsbsim_fgout; char *jsbsim_fgout;
int jsbsim_stdout; int jsbsim_stdout;
// default JSBSim model
const char *jsbsim_model = "Rascal";
bool created_templates; bool created_templates;
bool started_jsbsim; bool started_jsbsim;
bool opened_control_socket; bool opened_control_socket;