mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 21:07:40 +08:00
[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:
@@ -274,9 +274,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section name="SIMULATOR" prefix="NPS_">
|
<section name="SIMULATOR" prefix="NPS_">
|
||||||
<!--define name="JSBSIM_MODEL" value=""Malolo1""/-->
|
<define name="JSBSIM_MODEL" value=""Malolo1""/>
|
||||||
<define name="JSBSIM_MODEL" value=""LisaAspirin2""/>
|
|
||||||
<define name="ACTUATOR_NAMES" value="{"throttle-cmd-norm", "aileron-cmd-norm", "elevator-cmd-norm", "rudder-cmd-norm"}"/>
|
|
||||||
<define name="SENSORS_PARAMS" value=""nps_sensors_params_invariant.h""/>
|
<define name="SENSORS_PARAMS" value=""nps_sensors_params_invariant.h""/>
|
||||||
<define name="JS_AXIS_MODE" value="4"/>
|
<define name="JS_AXIS_MODE" value="4"/>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -204,12 +204,8 @@
|
|||||||
<section name="SIMULATOR" prefix="NPS_">
|
<section name="SIMULATOR" prefix="NPS_">
|
||||||
<define name="JSBSIM_MODEL" value=""Malolo1""/>
|
<define name="JSBSIM_MODEL" value=""Malolo1""/>
|
||||||
<define name="JSBSIM_LAUNCHSPEED" value="20"/>
|
<define name="JSBSIM_LAUNCHSPEED" value="20"/>
|
||||||
<define name="COMMANDS_NB" value="3"/>
|
|
||||||
<define name="ACTUATOR_NAMES" value="{"throttle-cmd-norm", "aileron-cmd-norm", "elevator-cmd-norm"}"/>
|
|
||||||
<define name="SENSORS_PARAMS" value=""nps_sensors_params_default.h""/>
|
<define name="SENSORS_PARAMS" value=""nps_sensors_params_default.h""/>
|
||||||
<define name="JS_AXIS_MODE" value="4"/>
|
<define name="JS_AXIS_MODE" value="4"/>
|
||||||
<define name="BYPASS_AHRS" value="TRUE"/>
|
|
||||||
<define name="BYPASS_INS" value="TRUE"/>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</airframe>
|
</airframe>
|
||||||
|
|||||||
@@ -15,7 +15,12 @@
|
|||||||
#if defined MOTOR_MIXING_NB_MOTOR
|
#if defined MOTOR_MIXING_NB_MOTOR
|
||||||
#define NPS_COMMANDS_NB MOTOR_MIXING_NB_MOTOR
|
#define NPS_COMMANDS_NB MOTOR_MIXING_NB_MOTOR
|
||||||
#else
|
#else
|
||||||
|
#ifdef NPS_ACTUATOR_NAMES
|
||||||
#define NPS_COMMANDS_NB COMMANDS_NB
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ bool_t nps_bypass_ins;
|
|||||||
#define NPS_BYPASS_INS FALSE
|
#define NPS_BYPASS_INS FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRINT_CONFIG_VAR(NPS_COMMANDS_NB)
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined (FBW) || !defined (AP)
|
#if !defined (FBW) || !defined (AP)
|
||||||
#error NPS does not currently support dual processor simulation for FBW and AP on fixedwing!
|
#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);
|
Ap(handle_periodic_tasks);
|
||||||
|
|
||||||
/* scale final motor commands to 0-1 for feeding the fdm */
|
/* 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++)
|
for (uint8_t i=0; i < NPS_COMMANDS_NB; i++)
|
||||||
autopilot.commands[i] = (double)commands[i]/MAX_PPRZ;
|
autopilot.commands[i] = (double)commands[i]/MAX_PPRZ;
|
||||||
// hack: invert pitch to fit most JSBSim models
|
// hack: invert pitch to fit most JSBSim models
|
||||||
autopilot.commands[COMMAND_PITCH] = -(double)commands[COMMAND_PITCH]/MAX_PPRZ;
|
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
|
// do the launch when clicking launch in GCS
|
||||||
autopilot.launch = launch && !kill_throttle;
|
autopilot.launch = launch && !kill_throttle;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ using namespace JSBSim;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static void feed_jsbsim(double* commands, int commands_nb);
|
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 void fetch_state(void);
|
||||||
static int check_for_nan(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)
|
* @param commands_nb Number of commands (length of array)
|
||||||
*/
|
*/
|
||||||
static void feed_jsbsim(double* commands, int commands_nb) {
|
static void feed_jsbsim(double* commands, int commands_nb) {
|
||||||
|
#ifdef NPS_ACTUATOR_NAMES
|
||||||
char buf[64];
|
char buf[64];
|
||||||
const char* names[] = NPS_ACTUATOR_NAMES;
|
const char* names[] = NPS_ACTUATOR_NAMES;
|
||||||
string property;
|
string property;
|
||||||
@@ -233,9 +234,17 @@ static void feed_jsbsim(double* commands, int commands_nb) {
|
|||||||
property = string(buf);
|
property = string(buf);
|
||||||
FDMExec->GetPropertyManager()->GetNode(property)->SetDouble("", commands[i]);
|
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();
|
FGFCS* FCS = FDMExec->GetFCS();
|
||||||
FCS->SetDaCmd(aileron);
|
FCS->SetDaCmd(aileron);
|
||||||
|
|||||||
Reference in New Issue
Block a user