diff --git a/sw/airborne/firmwares/rotorcraft/oneloop/oneloop_andi.c b/sw/airborne/firmwares/rotorcraft/oneloop/oneloop_andi.c index 055c145e07..ccc53dc25b 100644 --- a/sw/airborne/firmwares/rotorcraft/oneloop/oneloop_andi.c +++ b/sw/airborne/firmwares/rotorcraft/oneloop/oneloop_andi.c @@ -1601,13 +1601,13 @@ void oneloop_andi_run(bool in_flight, bool half_loop, struct FloatVect3 PSA_des, } /*Commit the actuator command*/ - stabilization.cmd[COMMAND_THRUST] = 0; for (i = 0; i < ANDI_NUM_ACT; i++) { //actuators_pprz[i] = (int16_t) andi_u[i]; commands[i] = (int16_t) andi_u[i]; } commands[COMMAND_THRUST] = (commands[COMMAND_MOTOR_FRONT] + commands[COMMAND_MOTOR_RIGHT] + commands[COMMAND_MOTOR_BACK] + commands[COMMAND_MOTOR_LEFT])/num_thrusters_oneloop; autopilot.throttle = commands[COMMAND_THRUST]; + stabilization.cmd[COMMAND_THRUST] = commands[COMMAND_THRUST]; if(autopilot.mode==AP_MODE_ATTITUDE_DIRECT){ eulers_zxy_des.phi = andi_u[COMMAND_ROLL]; eulers_zxy_des.theta = andi_u[COMMAND_PITCH]; diff --git a/sw/simulator/nps/nps_autopilot_rotorcraft.c b/sw/simulator/nps/nps_autopilot_rotorcraft.c index e74a31a650..c71d58126d 100644 --- a/sw/simulator/nps/nps_autopilot_rotorcraft.c +++ b/sw/simulator/nps/nps_autopilot_rotorcraft.c @@ -35,9 +35,13 @@ #include "modules/ins/ins.h" #include "math/pprz_algebra.h" +#ifdef NPS_USE_COMMANDS +#include "modules/core/commands.h" +#define NPS_NO_MOTOR_MIXING TRUE +#endif + #ifndef NPS_NO_MOTOR_MIXING #include "modules/actuators/motor_mixing.h" - #if NPS_COMMANDS_NB != MOTOR_MIXING_NB_MOTOR #warning "NPS_COMMANDS_NB does not match MOTOR_MIXING_NB_MOTOR!" #endif @@ -169,8 +173,13 @@ void nps_autopilot_run_step(double time) /* scale final motor commands to 0-1 for feeding the fdm */ for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) { #if NPS_NO_MOTOR_MIXING + #if NPS_USE_COMMANDS + commands[i] = autopilot_get_motors_on() ? commands[i] : 0; + nps_autopilot.commands[i] = (double)commands[i] / MAX_PPRZ; + #else actuators_pprz[i] = autopilot_get_motors_on() ? actuators_pprz[i] : 0; - nps_autopilot.commands[i] = (double)actuators_pprz[i] / MAX_PPRZ; + nps_autopilot.commands[i] = (double)actuators_pprz[i] / MAX_PPRZ; + #endif #else nps_autopilot.commands[i] = (double)motor_mixing.commands[i] / MAX_PPRZ; #endif