Merge pull request #6132 from mikeller/fix_pid_loop_slowness

Remove GPS rescue update from PID loop.
This commit is contained in:
Michael Keller 2018-06-17 13:35:39 +12:00 committed by GitHub
commit 0dd43c92dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 92 deletions

View File

@ -923,10 +923,6 @@ static FAST_CODE_NOINLINE void subTaskMainSubprocesses(timeUs_t currentTimeUs)
} }
#endif #endif
#ifdef USE_GPS_RESCUE
updateGPSRescueState();
#endif
#ifdef USE_SDCARD #ifdef USE_SDCARD
afatfs_poll(); afatfs_poll();
#endif #endif
@ -977,6 +973,7 @@ static FAST_CODE void subTaskMotorUpdate(timeUs_t currentTimeUs)
static FAST_CODE_NOINLINE void subTaskRcCommand(timeUs_t currentTimeUs) static FAST_CODE_NOINLINE void subTaskRcCommand(timeUs_t currentTimeUs)
{ {
UNUSED(currentTimeUs);
// If we're armed, at minimum throttle, and we do arming via the // If we're armed, at minimum throttle, and we do arming via the
// sticks, do not process yaw input from the rx. We do this so the // sticks, do not process yaw input from the rx. We do this so the
@ -999,7 +996,12 @@ static FAST_CODE_NOINLINE void subTaskRcCommand(timeUs_t currentTimeUs)
} }
processRcCommand(); processRcCommand();
UNUSED(currentTimeUs);
#if defined(USE_GPS_RESCUE)
if (FLIGHT_MODE(GPS_RESCUE_MODE)) {
gpsRescueInjectRcCommands();
}
#endif
} }
// Function for loop trigger // Function for loop trigger

View File

@ -43,7 +43,6 @@
#include "flight/failsafe.h" #include "flight/failsafe.h"
#include "flight/imu.h" #include "flight/imu.h"
#include "flight/gps_rescue.h"
#include "flight/pid.h" #include "flight/pid.h"
#include "pg/rx.h" #include "pg/rx.h"
#include "rx/rx.h" #include "rx/rx.h"
@ -528,10 +527,6 @@ FAST_CODE FAST_CODE_NOINLINE void updateRcCommands(void)
rcCommand[YAW] = rcCommandBuff.Z; rcCommand[YAW] = rcCommandBuff.Z;
} }
} }
if (FLIGHT_MODE(GPS_RESCUE_MODE)) {
rcCommand[THROTTLE] = rescueThrottle;
}
} }
void resetYawAxis(void) void resetYawAxis(void)

View File

@ -71,6 +71,9 @@ PG_RESET_TEMPLATE(gpsRescueConfig_t, gpsRescueConfig,
.minSats = 8 .minSats = 8
); );
static uint16_t rescueThrottle;
static uint16_t rescueYaw;
int32_t gpsRescueAngle[ANGLE_INDEX_COUNT] = { 0, 0 }; int32_t gpsRescueAngle[ANGLE_INDEX_COUNT] = { 0, 0 };
uint16_t hoverThrottle = 0; uint16_t hoverThrottle = 0;
float averageThrottle = 0.0; float averageThrottle = 0.0;
@ -182,6 +185,8 @@ void updateGPSRescueState(void)
disarm(); disarm();
rescueStop(); rescueStop();
break; break;
default:
break;
} }
performSanityChecks(); performSanityChecks();
@ -396,7 +401,13 @@ void setBearing(int16_t deg)
dif *= -GET_DIRECTION(rcControlsConfig()->yaw_control_reversed); dif *= -GET_DIRECTION(rcControlsConfig()->yaw_control_reversed);
rcCommand[YAW] = - (dif * gpsRescueConfig()->yawP / 20); rescueYaw = - (dif * gpsRescueConfig()->yawP / 20);
}
void gpsRescueInjectRcCommands(void)
{
rcCommand[THROTTLE] = rescueThrottle;
rcCommand[YAW] = rescueYaw;
} }
#endif #endif

View File

@ -42,8 +42,6 @@ typedef struct gpsRescue_s {
PG_DECLARE(gpsRescueConfig_t, gpsRescueConfig); PG_DECLARE(gpsRescueConfig_t, gpsRescueConfig);
uint16_t rescueThrottle;
typedef enum { typedef enum {
RESCUE_IDLE, RESCUE_IDLE,
RESCUE_INITIALIZE, RESCUE_INITIALIZE,
@ -110,3 +108,5 @@ void performSanityChecks(void);
void sensorUpdate(void); void sensorUpdate(void);
void rescueAttainPosition(void); void rescueAttainPosition(void);
void gpsRescueInjectRcCommands(void);

View File

@ -531,6 +531,9 @@ void gpsUpdate(timeUs_t currentTimeUs)
if (sensors(SENSOR_GPS)) { if (sensors(SENSOR_GPS)) {
updateGpsIndicator(currentTimeUs); updateGpsIndicator(currentTimeUs);
} }
#if defined(USE_GPS_RESCUE)
updateGPSRescueState();
#endif
} }
static void gpsNewData(uint16_t c) static void gpsNewData(uint16_t c)