inav icon indicating copy to clipboard operation
inav copied to clipboard

[7.1 RC1] Autoland Fix

Open Scavanger opened this issue 11 months ago • 1 comments

Fix for #9731

Should now working correctly for Waypoints

Scavanger avatar Mar 01 '24 16:03 Scavanger

Having tested this it doesn't really work as I would expect. For starters it seemed to get stuck in what I assume was the flare phase, nothing you could do to regain control, stick abort didn't work, which wasn't good given it completely overshot the landing and climbed on flaring (HITL test only luckily). Not sure why it was in the Flare given there's no Lidar set up, maybe a HITL thing ? If it was in the Glide phase then the stick abort didn't work. Admittedly maybe it's not set up correctly to land on the spot but the loss of control isn't good.

I think that it must always be possible to abort any Auto flight mode by turning off the switch that initiated it. Getting stuck with no control should never happen whilst you still have a valid signal. The change in this PR locks out any ability for the mode switch to fully control the selected mode.

breadoven avatar Mar 02 '24 14:03 breadoven

Yes, that's right, I have changed the behaviour, now the flare can be aborted by switching to another flight mode, e.g. briefly RTH on/off. However, cancellation by stick movement is intentionally not possible in flare phase for safety reasons: Many people fly with aircraft without landing gear, if the engine then revs up again this can have bad consequences very close to the ground or even if there is already ground contact and the landing disarm has not yet been triggered.

If there is no lidar, there is no flare.

Scavanger avatar Mar 06 '24 14:03 Scavanger

Well I was definitely getting a Flare when I tested with HITL, based on BB log navState (=46) and there was no Lidar set up. Can't see what prevents a Flare without Lidar either based on this part of the code:

    if (getLandAltitude() <= posControl.fwLandState.landAltAgl + navFwAutolandConfig()->flareAltitude) {
        posControl.fwLandState.landState = FW_AUTOLAND_STATE_FLARE;
        return NAV_FSM_EVENT_SUCCESS;
    }

The above will return a result regardless of whether or not Lidar is used surely ?

Also, with the change I made in #9768 the change in this PR mentioned above is no longer required, the switch to Auto Landing from a WP Landing waypoint now works as expected. It also means that switching off WP mode will abort the Auto Landing regardless of landing phase. It shouldn't be necessary to switch to other modes, which would be confusing anyway, you just switch off the mode that initiated the Auto landing in the first place.

breadoven avatar Mar 06 '24 17:03 breadoven

Any reason why you closed this @Scavanger ? Are you still working on it ?

breadoven avatar Mar 11 '24 10:03 breadoven

Any reason why you closed this @Scavanger ? Are you still working on it ?

Yes, of course. I got bogged down with the rebase, Gita rebase and I will probably never be friends. There'll be a new version soon.

Scavanger avatar Mar 11 '24 10:03 Scavanger

OK. I tested the changes from this PR with some additional changes and it seems to work as expected now. Additional changes were:

  1. Last commit removed (https://github.com/iNavFlight/inav/pull/9754/commits/a66deda681238b89b86001e95096475ea15d5908) which breaks the recent change I made to fix WP RTH behaviour (#9768).
  2. Needs something in the FW landing detector to activate landing detection during Approach/Glide/Flare phase otherwise no landing is detected. https://github.com/iNavFlight/inav/blob/0d55d20bc8467ee2963e6cf54c6ef6c9ffacccfd/src/main/navigation/navigation_fixedwing.c#L728
  3. Needs something in isWaypointNavTrackingActive to make it active during Auto Landing Approach phase https://github.com/iNavFlight/inav/blob/0d55d20bc8467ee2963e6cf54c6ef6c9ffacccfd/src/main/navigation/navigation.c#L3971
  4. Needs something in calculateVirtualPositionTarget_FW and updatePositionHeadingController_FW to activate what is effectively course hold during the Glide and Flare. https://github.com/iNavFlight/inav/blob/0d55d20bc8467ee2963e6cf54c6ef6c9ffacccfd/src/main/navigation/navigation_fixedwing.c#L274 https://github.com/iNavFlight/inav/blob/0d55d20bc8467ee2963e6cf54c6ef6c9ffacccfd/src/main/navigation/navigation_fixedwing.c#L408
  5. No need to set idle value, this is handled by ENABLE_STATE(NAV_MOTOR_STOP_OR_IDLE) https://github.com/Scavanger/inav/blob/efe1ee55534ffb110e6f9b0342c2db474d8d6bad/src/main/navigation/navigation_fixedwing.c#L668
  6. Also removed the following since it's redundant. switching to RTH with WP mode switch active is handled by the change I made in https://github.com/iNavFlight/inav/pull/9768 (seems to work OK from testing and allows auto landing mode to always be cancelled by switching off mode switch):
#ifdef USE_FW_AUTOLAND
            if (FLIGHT_MODE(NAV_FW_AUTOLAND)) {
                return NAV_FSM_EVENT_SWITCH_TO_RTH;
            }
#endif

I think some of the changes above would be better handled by using additional stateFlags rather than relying on Flight Modes to control different control behaviour but that would require a separate change/refactor in its own right.

breadoven avatar Mar 11 '24 11:03 breadoven