Skip to content

Commit

Permalink
Use the defined commands number and name in NPS
Browse files Browse the repository at this point in the history
  • Loading branch information
tmldeponti committed Apr 15, 2024
1 parent c125242 commit 02517cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sw/simulator/nps/nps_autopilot.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ extern "C" {
#ifndef NPS_COMMANDS_NB
#if defined MOTOR_MIXING_NB_MOTOR
#define NPS_COMMANDS_NB MOTOR_MIXING_NB_MOTOR
#elif defined NPS_USE_COMMANDS
#define NPS_COMMANDS_NB COMMANDS_NB
#else
#define NPS_COMMANDS_NB ACTUATORS_NB // uses actuators_pprz[ACTUATORS_NB]
#endif /* #if defined MOTOR_MIXING_NB_MOTOR */
#endif /* #if defined MOTOR_MIXING_NB_MOTOR or NPS_USE_COMMANDS */
#endif /* #ifndef NPS_COMMANDS_NB */

struct NpsAutopilot {
Expand Down
12 changes: 12 additions & 0 deletions sw/simulator/nps/nps_fdm_jsbsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,18 @@ static void feed_jsbsim(double *commands, int commands_nb __attribute__((unused)
FDMExec->GetPropertyManager()->GetNode(property)->SetDouble("", commands[i]);
}
#else /* use COMMAND names */
#ifdef NPS_USE_COMMANDS /*Use generated command names*/
char buf[64];
const char *names[] = COMMAND_NAMES;
string property;

int i;
for (i = 0; i < commands_nb; i++) {
sprintf(buf, "fcs/%s", names[i]);
property = string(buf);
FDMExec->GetPropertyManager()->GetNode(property)->SetDouble("", commands[i]);
}
#else /*Use manually defined commands*/
// get FGFCS instance
FGFCS *FCS = FDMExec->GetFCS();

Expand Down Expand Up @@ -355,6 +366,7 @@ static void feed_jsbsim(double *commands, int commands_nb __attribute__((unused)
FCS->SetDfCmd(commands[COMMAND_FLAP]);
#endif /* COMMAND_FLAP */

#endif /* NPS_USE_COMMANDS */
#endif /* NPS_ACTUATOR_NAMES */
}

Expand Down

0 comments on commit 02517cf

Please sign in to comment.