mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 20:38:27 +08:00
Autopilot refactor (#2009)
* [autopilot] refactor autopilot API for both firmwares With this, fixedwing and rotorcraft are mostly using the same interface for the autopilot. Some specific code and messages handling are still firmware dependent. A large part of the autopilot logic of the fixedwing is moved from main_ap to autopilot_static. More getter/setter functions are provided. * [autopilot] update the rest of the system and the conf for using the refactored autopilot API * [autopilot] fix some errors from CI servers * [actuators] use dummy actuators module to prevent autoloading * Rename Bart_heliDD_INDI.xml to tudelft_bs_helidd_indi.xml * Rename Bart_heliDD_pid.xml to tudelft_bs_helidd_pid.xml * Delete tudelft_course2016_bebop_colorfilter.xml * Delete tudelft_course2016_bebop_avoider.xml * [actuators] don't autoload actuators when set to 'none' * [gcs] autodetect firmware for strip mode button
This commit is contained in:
committed by
Felix Ruess
parent
ded925a851
commit
363dec8693
@@ -24,7 +24,7 @@ struct NpsAutopilot {
|
||||
bool launch;
|
||||
};
|
||||
|
||||
extern struct NpsAutopilot autopilot;
|
||||
extern struct NpsAutopilot nps_autopilot;
|
||||
|
||||
extern bool nps_bypass_ahrs;
|
||||
extern bool nps_bypass_ins;
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "subsystems/abi.h"
|
||||
|
||||
// for launch
|
||||
#include "firmwares/fixedwing/autopilot.h"
|
||||
#include "autopilot.h"
|
||||
|
||||
// for datalink_time hack
|
||||
#include "subsystems/datalink/datalink.h"
|
||||
@@ -60,7 +60,7 @@
|
||||
#include "subsystems/datalink/downlink.h"
|
||||
#endif
|
||||
|
||||
struct NpsAutopilot autopilot;
|
||||
struct NpsAutopilot nps_autopilot;
|
||||
bool nps_bypass_ahrs;
|
||||
bool nps_bypass_ins;
|
||||
|
||||
@@ -80,7 +80,7 @@ bool nps_bypass_ins;
|
||||
void nps_autopilot_init(enum NpsRadioControlType type_rc, int num_rc_script, char *rc_dev)
|
||||
{
|
||||
|
||||
autopilot.launch = FALSE;
|
||||
nps_autopilot.launch = FALSE;
|
||||
|
||||
if (rc_dev != NULL) {
|
||||
nps_radio_control_init(type_rc, num_rc_script, rc_dev);
|
||||
@@ -183,30 +183,30 @@ void nps_autopilot_run_step(double time)
|
||||
//PRINT_CONFIG_VAR(NPS_ACTUATOR_NAMES)
|
||||
|
||||
for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) {
|
||||
autopilot.commands[i] = (double)commands[i] / MAX_PPRZ;
|
||||
nps_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;
|
||||
nps_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;
|
||||
nps_autopilot.commands[COMMAND_THROTTLE] = (double)commands[COMMAND_THROTTLE] / MAX_PPRZ;
|
||||
nps_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;
|
||||
nps_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;
|
||||
nps_autopilot.commands[COMMAND_YAW] = (double)commands[COMMAND_YAW] / MAX_PPRZ;
|
||||
#endif /* COMMAND_YAW */
|
||||
#endif /* NPS_ACTUATOR_NAMES */
|
||||
|
||||
// do the launch when clicking launch in GCS
|
||||
autopilot.launch = launch && !kill_throttle;
|
||||
if (!launch) {
|
||||
autopilot.commands[COMMAND_THROTTLE] = 0;
|
||||
nps_autopilot.launch = autopilot.launch && !autopilot.kill_throttle;
|
||||
if (!autopilot.launch) {
|
||||
nps_autopilot.commands[COMMAND_THROTTLE] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
// for datalink_time hack
|
||||
#include "subsystems/datalink/datalink.h"
|
||||
|
||||
struct NpsAutopilot autopilot;
|
||||
struct NpsAutopilot nps_autopilot;
|
||||
bool nps_bypass_ahrs;
|
||||
bool nps_bypass_ins;
|
||||
|
||||
@@ -63,7 +63,7 @@ bool nps_bypass_ins;
|
||||
|
||||
void nps_autopilot_init(enum NpsRadioControlType type_rc, int num_rc_script, char *rc_dev)
|
||||
{
|
||||
autopilot.launch = TRUE;
|
||||
nps_autopilot.launch = TRUE;
|
||||
|
||||
nps_radio_control_init(type_rc, num_rc_script, rc_dev);
|
||||
nps_electrical_init();
|
||||
@@ -152,7 +152,7 @@ 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++) {
|
||||
autopilot.commands[i] = (double)motor_mixing.commands[i] / MAX_PPRZ;
|
||||
nps_autopilot.commands[i] = (double)motor_mixing.commands[i] / MAX_PPRZ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ static void on_DL_SETTING(IvyClientPtr app __attribute__((unused)),
|
||||
printf("setting %d %f\n", index, value);
|
||||
|
||||
/*
|
||||
* In case of HITL, update autopilot.launch from DL_SETTINGS
|
||||
* In case of HITL, update nps_autopilot.launch from DL_SETTINGS
|
||||
* so the plane can be properly launched.
|
||||
*
|
||||
* In case of STIL nps_update_launch_from_dl() is an empty function
|
||||
|
||||
@@ -95,13 +95,13 @@ void nps_radio_and_autopilot_init(void)
|
||||
|
||||
void nps_update_launch_from_dl(uint8_t value)
|
||||
{
|
||||
autopilot.launch = value;
|
||||
nps_autopilot.launch = value;
|
||||
}
|
||||
|
||||
void nps_main_run_sim_step(void)
|
||||
{
|
||||
nps_atmosphere_update(SIM_DT);
|
||||
nps_fdm_run_step(autopilot.launch, autopilot.commands, NPS_COMMANDS_NB);
|
||||
nps_fdm_run_step(nps_autopilot.launch, nps_autopilot.commands, NPS_COMMANDS_NB);
|
||||
}
|
||||
|
||||
void *nps_ins_data_loop(void *data __attribute__((unused)))
|
||||
@@ -244,10 +244,10 @@ void *nps_ap_data_loop(void *data __attribute__((unused)))
|
||||
pthread_mutex_lock(&fdm_mutex);
|
||||
// update commands
|
||||
for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) {
|
||||
autopilot.commands[i] = (double)cmd_buf[i] / MAX_PPRZ;
|
||||
nps_autopilot.commands[i] = (double)cmd_buf[i] / MAX_PPRZ;
|
||||
}
|
||||
// hack: invert pitch to fit most JSBSim models
|
||||
autopilot.commands[COMMAND_PITCH] = -(double)cmd_buf[COMMAND_PITCH] / MAX_PPRZ;
|
||||
nps_autopilot.commands[COMMAND_PITCH] = -(double)cmd_buf[COMMAND_PITCH] / MAX_PPRZ;
|
||||
pthread_mutex_unlock(&fdm_mutex);
|
||||
break;
|
||||
case DL_MOTOR_MIXING:
|
||||
@@ -257,7 +257,7 @@ void *nps_ap_data_loop(void *data __attribute__((unused)))
|
||||
pthread_mutex_lock(&fdm_mutex);
|
||||
// update commands
|
||||
for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) {
|
||||
autopilot.commands[i] = (double)cmd_buf[i] / MAX_PPRZ;
|
||||
nps_autopilot.commands[i] = (double)cmd_buf[i] / MAX_PPRZ;
|
||||
}
|
||||
pthread_mutex_unlock(&fdm_mutex);
|
||||
break;
|
||||
|
||||
@@ -77,7 +77,7 @@ void nps_main_run_sim_step(void)
|
||||
|
||||
nps_autopilot_run_systime_step();
|
||||
|
||||
nps_fdm_run_step(autopilot.launch, autopilot.commands, NPS_COMMANDS_NB);
|
||||
nps_fdm_run_step(nps_autopilot.launch, nps_autopilot.commands, NPS_COMMANDS_NB);
|
||||
|
||||
nps_sensors_run_step(nps_main.sim_time);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user