Skip to content

Improve behaviour when GPS Rescue is initiated close to home #12715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 25, 2023

Conversation

ctzsnooze
Copy link
Member

@ctzsnooze ctzsnooze commented Apr 23, 2023

When GPS Rescues are initiated within the minimum start distance, this PR makes the following changes:

  • the minimum start distance now defaults to 15m (from 30m), with an allowed configuration range of 10-30m

  • the descent distance is set to half the configured minimum start distance

  • the quad climbs by the `rescueAltitudeBufferM' height (default is 5m), typically with some overshoot

  • the quad flies out to at least the minimum start distance, by pitching forward 15 degrees while climbing, and waiting at the top of the climb until it is outside the minimum start distance. The rescue then proceeds normally.

  • the gain factor that controls how quickly the IMU yaw heading adapts to the GPS course over ground heading is dynamically modulated, as described in Increase IMU yaw CoG gain at higher positive pitch angles #12791, which is as follows:

  • the IMU yaw Cog gain is set to zero when climbing, rotating, or 'doing nothing', so that the IMU will not change or become disoriented from wind drift in these phases

  • the IMU yaw Cog gain will be enhanced by up to 6 times during the fly home phase, if the quad is pitched forward and if there is a discrepancy between the groundspeed and the velocity to home. This leads to a more rapid correction in the yaw heading in the event of a significant IMU error when starting to fly home, minimising any possible flyaway distance.

In a normal rescue, ie one commenced outside the minimum start distance:

  • the descent distance cannot be more than half the distance when the rescue was initiated

  • the IMU yaw Cog gain modified as above

Most rescues, no matter how close, or how extreme the IMU error, including initiating rescues while fully inverted, should now be successful.

Users should expect more aggressive yaw corrections at the start of the rescue than previously.

Here is a video of the typical behaviour.

If the IMU is not disoriented at the start, because the pre-rescue flight pattern was mostly nose-forward and at reasonable speed, the initial rotation return should be smooth, even for initiations close to, or within, the minimum rescue distance.

When the IMU is badly disoriented, eg from prior drift, or from flying backwards immediately before the rescue, it must have a period of time in clean forward flight before it can correctly re-orient its heading to match the GPS-measured course over ground. While doing this, the quad may initially fly away in whatever direction the IMU tells it to, but should quickly realise that it is going the wrong way, and rapidly try to correct itself. These corrections can involve quite extreme yaw and roll movements, including yaw overshoot corrections, as the IMU tries to correct itself at the same time as the heading itself is changing. As the quad gets better oriented, points more directly to home, and picks up clean speed towards home, the IMU errors should resolve, and the rest of the flight home should be uneventful.

When a rescue is initiated close to home, especially within the minimum rescue distance, there won't be much time in forward flight for the IMU to correct itself. Additionally, there may be little forward velocity, and an uncorrected IMU error cannot be resolved until the forward speed is greater than 2m/s, and a near-home initiation would require a near vertical descent with little or no forward speed, giving the IMU no chance to correct itself. This is why in previous versions, an initiation within the minimum start distance was managed by disarming the quad; the risk of flyaway was too high.

With this PR, an initiation within the minimum start distance of 15m, and above the landing height, will cause the quad to climb, then fly out to at least the minimum start distance, and then perform a normal rescue. Note that if the IMU is in error, the flight out to 15m from home could be in any direction at all, including overhead or behind the takeoff point. Sufficient climb height should be configured to ensure clearing any trees that could be within 50-60m of the takeoff point.

BE AWARE that for all rescues initiated inside the minimum start distance, the craft will:

  • always fly out to AT LEAST the minimum start distance before turning towards home, and
  • in cases of extreme IMU disorientation, having attained that distance, rotate to point in ANY DIRECTION AT ALL, including further way from home, once the craft reaches the minimum start distance.

The default minimum start distance is 15m, with a descent distance starting at half that value, or 7.5m. Generally it is best to avoid initiating a rescue so close to home. We only provide a rescue functionality in this situation to handle unexpected situations, eg while learning to fly LOS, or accidental initiation. The return can be quite hectic and involve circling behaviours and rough landings. The intent is for the pilot to recover manual control as soon as practical.

If flying in a large open area, and if you really wants the ability to make the rescue work at any point in the sky, including directly above the take-off point, please take off from a point that has plenty of clear space all around.

A slightly increased minimum start distance will give a less hectic recovery, but will allow a greater potential fly-away distance, when initiated within the minimum start distance. If the minimum distance is set too close, the quad may not get enough forward speed to correct the IMU, and will show multiple rapid yaw/roll adjustments that do not resolve fully before landing, leading to circling around the home point during descent, and a rough landing. However, the quad will get home.

NOTE: extreme IMU disorientation happens in the following situations:

  • after power up, the quad is flown straight up, or very slowly. The IMU never experiences any forward flight > 2/ms before the rescue is initiated. It therefore never orients itself to the course over ground, and has no idea which way the nose is pointing.
  • The quad is fully inverted and has been drifting when the rescue is initiated
  • the quad has been drifting backwards, or nearly backwards, for more than 6-8 seconds before the rescue is initiated
  • the quad has been drifting in the wind at speeds >2m/s for 5-8 seconds or more
  • any combinations of the above.

NB: As before, if a rescue is initiated:

  • within 5m of home, and
  • below the landing height of 5m
    the quad just disarms, to prevent injury caused by accidentally initiating a Rescue while the pilot and the quad are in close proximity, or when the quad is on the ground.

@github-actions

This comment has been minimized.

@blckmn
Copy link
Member

blckmn commented Apr 23, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> FAIL
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> PASS
  • assigned to an approver -> PASS
  • approver count at least three -> FAIL

@ctzsnooze ctzsnooze force-pushed the Fly-home-if-GPS-Rescue-too-close branch from 4f8f31d to d089384 Compare April 23, 2023 23:25
@github-actions

This comment has been minimized.

@ctzsnooze ctzsnooze force-pushed the Fly-home-if-GPS-Rescue-too-close branch 2 times, most recently from ff41abd to b55c087 Compare May 1, 2023 02:41
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@ctzsnooze ctzsnooze changed the title When GPS Rescue initiated close to home, descend then land; restore 50 degree max angle When GPS Rescue initiated close to home, descend then land; restore 45 degree max angle May 10, 2023
@ctzsnooze ctzsnooze force-pushed the Fly-home-if-GPS-Rescue-too-close branch from a3ceae6 to e1e6f83 Compare May 10, 2023 01:24
@github-actions

This comment has been minimized.

@ctzsnooze
Copy link
Member Author

@KarateBrot @sugaarK @haslinghuis please review so this can be merged, I am confident that the behaviour will be an improvement over the current situation.
It should be merged after #12738 to avoid conflicts; #12738 is more important.

@ctzsnooze ctzsnooze force-pushed the Fly-home-if-GPS-Rescue-too-close branch from f11e5c2 to 0c11405 Compare May 11, 2023 12:01
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@ctzsnooze ctzsnooze force-pushed the Fly-home-if-GPS-Rescue-too-close branch 3 times, most recently from eda044a to f8d21de Compare May 23, 2023 03:21
@github-actions

This comment has been minimized.

@ctzsnooze ctzsnooze changed the title When GPS Rescue initiated close to home, descend then land; restore 45 degree max angle Improve behaviour when GPS Rescue is initiated close to home May 23, 2023
@ctzsnooze
Copy link
Member Author

ctzsnooze commented May 23, 2023

This has been tested in last few days quite carefully by Sek101 and myself.
Further testing would be appreciated.
Behaviour is somewhat aggressive but rescues are reliable.

@ctzsnooze ctzsnooze requested a review from ledvinap May 23, 2023 04:13
@ctzsnooze ctzsnooze force-pushed the Fly-home-if-GPS-Rescue-too-close branch from f8d21de to 3f25c5d Compare May 23, 2023 06:31
@github-actions
Copy link

Do you want to test this code? Here you have an automated build:
Assets

  • See: https://www.youtube.com/watch?v=I1uN9CN30gw for instructions about installing this unified targets!
  • An easier way to test this, using the Configurator cloud build, is simply put #12715 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

Copy link
Member

@sugaarK sugaarK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this today it works well. I think we should put this into the 4.4.2 build @haslinghuis

sugaarK

This comment was marked as duplicate.

@sugaarK sugaarK merged commit f69fedd into betaflight:master May 25, 2023
@bede
Copy link

bede commented May 25, 2023

Unfortunately in my testing I observed repeated failed rescues while deliberately confusing the IMU by flying backwards in a 10mph crosswind. After several complete yaw revolutions, the quad started losing altitude far away from the home point as if to land, at which point I took over each time. I will share DVR with @ctzsnooze shortly.

When initiating rescue in forward flight I experienced no problems.

@ledvinap
Copy link
Contributor

@ctzsnooze: I thing that implementing IMU align phase (immediately/after short height stabilization for close rescue; after climb phase in normal rescue is necessary ...

@bede
Copy link

bede commented May 25, 2023

I will retest later today with the default max angle of 45 rather than 35 which I used initially

@bede
Copy link

bede commented May 25, 2023

Ok, 45 and 55 degrees (suggested by @ctzsnooze) perform better at recovering from disorientation (e.g. after long rescue climb). Summary of my testing with various max angles on a lightweight 5" craft with a 4S LiPo.

4.5.0 PR #12715 flashed today to an MAMBAF722_2022A

Wind: ~10mph, gusty

Protocol

  • Power cycle battery
  • Check >10 satellites locked
  • Take off, fly backwards downwind until home arrow points in opposite direction (180 degrees out)
  • Activate rescue on a switch
  • Success means rescue beginning its descend phase near home point
  • Failure means rescue entering 'panic' mode where it slowly descends after starting 20s countdown to disarm. At this point the craft was flown home manually.

Results

35 degrees: approx 10 trials, majority failures
45 degrees (default): 10 trials; 8 successes; 1 failure; 1 probable failure (aborted)
55 degrees: 12 trials; 2 failures; 2 probable failures (aborted)

Notes

  • Some trials were aborted due to substantial drift towards tall trees during rescue. These would probably have become failures
  • Failures involved at least one full yaw rotation

Thoughts

  • If configured correctly, the chances of successful IMU reorientation seem much improved over 4.4.
  • While my results were worse for 55 than 45, I consider their performance very similar.
  • Rescue parameters safe for 4.4 could well cause complete rescue failure with this PR – care needs to be taken here
  • With optimisation reorientation reliability could be increased further
  • If the first yaw sweep fails, perhaps a second, slower yaw sweep using more pitch could save reorientation?

AkankshaJjw pushed a commit to AkankshaJjw/betaflight that referenced this pull request May 29, 2023
…ght#12715)

* When initiated close to home, descend then land, 50 deg max

* restore divisions thanks -ffast-math

* fix typo in comment

* refactoring, improving flight behaviour

* modify comments, add a constraint

* refactor throttle D Multiplier and velocity iterm, improve comments

* move out if too close, boost IMU gain in fly home
davidbitton pushed a commit to davidbitton/betaflight that referenced this pull request Feb 5, 2024
…ght#12715)

* When initiated close to home, descend then land, 50 deg max

* restore divisions thanks -ffast-math

* fix typo in comment

* refactoring, improving flight behaviour

* modify comments, add a constraint

* refactor throttle D Multiplier and velocity iterm, improve comments

* move out if too close, boost IMU gain in fly home
@ctzsnooze ctzsnooze deleted the Fly-home-if-GPS-Rescue-too-close branch April 3, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

8 participants