1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-19 06:15:14 +03:00

Refactor HDG controller usages

This commit is contained in:
Pawel Spychalski (DzikuVx) 2019-12-27 13:34:54 +01:00
parent c5bc1903f7
commit d234324cff
5 changed files with 25 additions and 9 deletions

View file

@ -123,6 +123,7 @@ typedef enum {
NAV_EXTRA_ARMING_SAFETY_BYPASSED = (1 << 14), // nav_extra_arming_safey was bypassed. Keep it until power cycle. NAV_EXTRA_ARMING_SAFETY_BYPASSED = (1 << 14), // nav_extra_arming_safey was bypassed. Keep it until power cycle.
AIRMODE_ACTIVE = (1 << 15), AIRMODE_ACTIVE = (1 << 15),
ESC_SENSOR_ENABLED = (1 << 16), ESC_SENSOR_ENABLED = (1 << 16),
FW_HEADING_USE_YAW = (1 << 17),
} stateFlags_t; } stateFlags_t;
#define DISABLE_STATE(mask) (stateFlags &= ~(mask)) #define DISABLE_STATE(mask) (stateFlags &= ~(mask))

View file

@ -140,11 +140,14 @@ bool mixerIsOutputSaturated(void)
void mixerUpdateStateFlags(void) void mixerUpdateStateFlags(void)
{ {
// set flag that we're on something with wings // set flag that we're on something with wings or a land/water vehicle
if (mixerConfig()->platformType == PLATFORM_AIRPLANE) { if (
ENABLE_STATE(FIXED_WING); mixerConfig()->platformType == PLATFORM_AIRPLANE ||
} else if (mixerConfig()->platformType == PLATFORM_HELICOPTER) { mixerConfig()->platformType == PLATFORM_ROVER ||
DISABLE_STATE(FIXED_WING); mixerConfig()->platformType == PLATFORM_BOAT ||
mixerConfig()->platformType == PLATFORM_OTHER
) {
ENABLE_STATE(FIXED_WING); //This is not entirely true, but much closer to reality than not using FIXED_WING mode
} else { } else {
DISABLE_STATE(FIXED_WING); DISABLE_STATE(FIXED_WING);
} }

View file

@ -1062,10 +1062,12 @@ void pidInit(void)
} }
if (pidProfile()->pidControllerType == PID_TYPE_AUTO) { if (pidProfile()->pidControllerType == PID_TYPE_AUTO) {
if (mixerConfig()->platformType == PLATFORM_AIRPLANE) { if (mixerConfig()->platformType == PLATFORM_MULTIROTOR ||
usedPidControllerType = PID_TYPE_PIFF; mixerConfig()->platformType == PLATFORM_TRICOPTER ||
} else { mixerConfig()->platformType == PLATFORM_HELICOPTER) {
usedPidControllerType = PID_TYPE_PID; usedPidControllerType = PID_TYPE_PID;
} else {
usedPidControllerType = PID_TYPE_PIFF;
} }
} else { } else {
usedPidControllerType = pidProfile()->pidControllerType; usedPidControllerType = pidProfile()->pidControllerType;

View file

@ -3250,6 +3250,16 @@ void navigationInit(void)
/* Use system config */ /* Use system config */
navigationUsePIDs(); navigationUsePIDs();
if (
mixerConfig()->platformType == PLATFORM_BOAT ||
mixerConfig()->platformType == PLATFORM_ROVER ||
navConfig()->fw.useFwNavYawControl
) {
ENABLE_STATE(FW_HEADING_USE_YAW);
} else {
DISABLE_STATE(FW_HEADING_USE_YAW);
}
} }
/*----------------------------------------------------------- /*-----------------------------------------------------------

View file

@ -346,7 +346,7 @@ static void updatePositionHeadingController_FW(timeUs_t currentTimeUs, timeDelta
* Yaw adjustment * Yaw adjustment
* It is working in relative mode and we aim to keep error at zero * It is working in relative mode and we aim to keep error at zero
*/ */
if (navConfig()->fw.useFwNavYawControl) { if (STATE(FW_HEADING_USE_YAW)) {
static float limit = 0.0f; static float limit = 0.0f;