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.
AIRMODE_ACTIVE = (1 << 15),
ESC_SENSOR_ENABLED = (1 << 16),
FW_HEADING_USE_YAW = (1 << 17),
} stateFlags_t;
#define DISABLE_STATE(mask) (stateFlags &= ~(mask))

View file

@ -140,11 +140,14 @@ bool mixerIsOutputSaturated(void)
void mixerUpdateStateFlags(void)
{
// set flag that we're on something with wings
if (mixerConfig()->platformType == PLATFORM_AIRPLANE) {
ENABLE_STATE(FIXED_WING);
} else if (mixerConfig()->platformType == PLATFORM_HELICOPTER) {
DISABLE_STATE(FIXED_WING);
// set flag that we're on something with wings or a land/water vehicle
if (
mixerConfig()->platformType == PLATFORM_AIRPLANE ||
mixerConfig()->platformType == PLATFORM_ROVER ||
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 {
DISABLE_STATE(FIXED_WING);
}

View file

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

View file

@ -3250,6 +3250,16 @@ void navigationInit(void)
/* Use system config */
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
* 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;