[nps] fixedwings: no need for NPS_ACTUATOR_NAMES

If NPS_ACTUATOR_NAMES is not specified, use the standard throttle,roll,pitch and if used in airframe yaw commands
for throttle, aileron, elevator and rudder in JSBSim model.
This commit is contained in:
Felix Ruess
2015-03-09 15:30:54 +01:00
parent 9797c2998d
commit 73af245e1e
5 changed files with 39 additions and 11 deletions
+1 -3
View File
@@ -274,9 +274,7 @@
</section>
<section name="SIMULATOR" prefix="NPS_">
<!--define name="JSBSIM_MODEL" value="&quot;Malolo1&quot;"/-->
<define name="JSBSIM_MODEL" value="&quot;LisaAspirin2&quot;"/>
<define name="ACTUATOR_NAMES" value="{&quot;throttle-cmd-norm&quot;, &quot;aileron-cmd-norm&quot;, &quot;elevator-cmd-norm&quot;, &quot;rudder-cmd-norm&quot;}"/>
<define name="JSBSIM_MODEL" value="&quot;Malolo1&quot;"/>
<define name="SENSORS_PARAMS" value="&quot;nps_sensors_params_invariant.h&quot;"/>
<define name="JS_AXIS_MODE" value="4"/>
</section>
@@ -204,12 +204,8 @@
<section name="SIMULATOR" prefix="NPS_">
<define name="JSBSIM_MODEL" value="&quot;Malolo1&quot;"/>
<define name="JSBSIM_LAUNCHSPEED" value="20"/>
<define name="COMMANDS_NB" value="3"/>
<define name="ACTUATOR_NAMES" value="{&quot;throttle-cmd-norm&quot;, &quot;aileron-cmd-norm&quot;, &quot;elevator-cmd-norm&quot;}"/>
<define name="SENSORS_PARAMS" value="&quot;nps_sensors_params_default.h&quot;"/>
<define name="JS_AXIS_MODE" value="4"/>
<define name="BYPASS_AHRS" value="TRUE"/>
<define name="BYPASS_INS" value="TRUE"/>
</section>
</airframe>
+5
View File
@@ -15,7 +15,12 @@
#if defined MOTOR_MIXING_NB_MOTOR
#define NPS_COMMANDS_NB MOTOR_MIXING_NB_MOTOR
#else
#ifdef NPS_ACTUATOR_NAMES
#define NPS_COMMANDS_NB COMMANDS_NB
#else
/* not using explicitly set NPS_ACTUATOR_NAMES -> throttle,roll,pitch,yaw commands */
#define NPS_COMMANDS_NB 4
#endif
#endif
#endif
+22 -2
View File
@@ -64,8 +64,6 @@ bool_t nps_bypass_ins;
#define NPS_BYPASS_INS FALSE
#endif
PRINT_CONFIG_VAR(NPS_COMMANDS_NB)
#if !defined (FBW) || !defined (AP)
#error NPS does not currently support dual processor simulation for FBW and AP on fixedwing!
@@ -139,10 +137,32 @@ void nps_autopilot_run_step(double time) {
Ap(handle_periodic_tasks);
/* scale final motor commands to 0-1 for feeding the fdm */
#ifdef NPS_ACTUATOR_NAMES
PRINT_CONFIG_MSG("actuators for JSBSim explicitly set.")
PRINT_CONFIG_VAR(NPS_COMMANDS_NB)
//PRINT_CONFIG_VAR(NPS_ACTUATOR_NAMES)
for (uint8_t i=0; i < NPS_COMMANDS_NB; i++)
autopilot.commands[i] = (double)commands[i]/MAX_PPRZ;
// hack: invert pitch to fit most JSBSim models
autopilot.commands[COMMAND_PITCH] = -(double)commands[COMMAND_PITCH]/MAX_PPRZ;
#else
PRINT_CONFIG_MSG("Using throttle, roll, pitch, yaw commands instead of explicit actuators.")
PRINT_CONFIG_VAR(COMMAND_THROTTLE)
PRINT_CONFIG_VAR(COMMAND_ROLL)
PRINT_CONFIG_VAR(COMMAND_PITCH)
autopilot.commands[COMMAND_THROTTLE] = (double)commands[COMMAND_THROTTLE]/MAX_PPRZ;
autopilot.commands[COMMAND_ROLL] = (double)commands[COMMAND_ROLL]/MAX_PPRZ;
// hack: invert pitch to fit most JSBSim models
autopilot.commands[COMMAND_PITCH] = -(double)commands[COMMAND_PITCH]/MAX_PPRZ;
#ifdef COMMAND_YAW
PRINT_CONFIG_VAR(COMMAND_YAW)
autopilot.commands[COMMAND_YAW] = (double)commands[COMMAND_YAW]/MAX_PPRZ;
#else
autopilot.commands[3] = 0.;
#endif
#endif
// do the launch when clicking launch in GCS
autopilot.launch = launch && !kill_throttle;
+11 -2
View File
@@ -81,6 +81,7 @@ using namespace JSBSim;
using namespace std;
static void feed_jsbsim(double* commands, int commands_nb);
static void feed_jsbsim(double throttle, double aileron, double elevator, double rudder);
static void fetch_state(void);
static int check_for_nan(void);
@@ -222,7 +223,7 @@ void nps_fdm_set_wind(double speed, double dir, int turbulence_severity) {
* @param commands_nb Number of commands (length of array)
*/
static void feed_jsbsim(double* commands, int commands_nb) {
#ifdef NPS_ACTUATOR_NAMES
char buf[64];
const char* names[] = NPS_ACTUATOR_NAMES;
string property;
@@ -233,9 +234,17 @@ static void feed_jsbsim(double* commands, int commands_nb) {
property = string(buf);
FDMExec->GetPropertyManager()->GetNode(property)->SetDouble("", commands[i]);
}
#else
if (commands_nb != 4) {
cerr << "commands_nb must be 4!" << endl;
exit(-1);
}
/* call version that directly feeds throttle, aileron, elevator, rudder */
feed_jsbsim(commands[COMMAND_THROTTLE], commands[COMMAND_ROLL], commands[COMMAND_PITCH], commands[3]);
#endif
}
void feed_jsbsim(double throttle, double aileron, double elevator, double rudder)
static void feed_jsbsim(double throttle, double aileron, double elevator, double rudder)
{
FGFCS* FCS = FDMExec->GetFCS();
FCS->SetDaCmd(aileron);