mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-02 21:37:24 +08:00
Additional changes to use commands instead of actuator_pprz (#3330)
* first push * Remove redundant logic
This commit is contained in:
committed by
GitHub
parent
5f18e784b6
commit
6c8c6f118b
@@ -1601,13 +1601,13 @@ void oneloop_andi_run(bool in_flight, bool half_loop, struct FloatVect3 PSA_des,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Commit the actuator command*/
|
/*Commit the actuator command*/
|
||||||
stabilization.cmd[COMMAND_THRUST] = 0;
|
|
||||||
for (i = 0; i < ANDI_NUM_ACT; i++) {
|
for (i = 0; i < ANDI_NUM_ACT; i++) {
|
||||||
//actuators_pprz[i] = (int16_t) andi_u[i];
|
//actuators_pprz[i] = (int16_t) andi_u[i];
|
||||||
commands[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;
|
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];
|
autopilot.throttle = commands[COMMAND_THRUST];
|
||||||
|
stabilization.cmd[COMMAND_THRUST] = commands[COMMAND_THRUST];
|
||||||
if(autopilot.mode==AP_MODE_ATTITUDE_DIRECT){
|
if(autopilot.mode==AP_MODE_ATTITUDE_DIRECT){
|
||||||
eulers_zxy_des.phi = andi_u[COMMAND_ROLL];
|
eulers_zxy_des.phi = andi_u[COMMAND_ROLL];
|
||||||
eulers_zxy_des.theta = andi_u[COMMAND_PITCH];
|
eulers_zxy_des.theta = andi_u[COMMAND_PITCH];
|
||||||
|
|||||||
@@ -35,9 +35,13 @@
|
|||||||
#include "modules/ins/ins.h"
|
#include "modules/ins/ins.h"
|
||||||
#include "math/pprz_algebra.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
|
#ifndef NPS_NO_MOTOR_MIXING
|
||||||
#include "modules/actuators/motor_mixing.h"
|
#include "modules/actuators/motor_mixing.h"
|
||||||
|
|
||||||
#if NPS_COMMANDS_NB != MOTOR_MIXING_NB_MOTOR
|
#if NPS_COMMANDS_NB != MOTOR_MIXING_NB_MOTOR
|
||||||
#warning "NPS_COMMANDS_NB does not match MOTOR_MIXING_NB_MOTOR!"
|
#warning "NPS_COMMANDS_NB does not match MOTOR_MIXING_NB_MOTOR!"
|
||||||
#endif
|
#endif
|
||||||
@@ -169,8 +173,13 @@ void nps_autopilot_run_step(double time)
|
|||||||
/* scale final motor commands to 0-1 for feeding the fdm */
|
/* scale final motor commands to 0-1 for feeding the fdm */
|
||||||
for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) {
|
for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) {
|
||||||
#if NPS_NO_MOTOR_MIXING
|
#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;
|
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
|
#else
|
||||||
nps_autopilot.commands[i] = (double)motor_mixing.commands[i] / MAX_PPRZ;
|
nps_autopilot.commands[i] = (double)motor_mixing.commands[i] / MAX_PPRZ;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user