Skip to content
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

Two Stage Climb First RTH #7323

Merged
merged 15 commits into from
Nov 8, 2021
Merged

Conversation

MrD-RC
Copy link
Collaborator

@MrD-RC MrD-RC commented Aug 1, 2021

Overview

Climb first can be a pretty inefficient part of the RTH sequence. The problem is that you are using energy spiralling up to altitude, or worse, flying away from home while gaining height. However, turning off climb first may not be a valid option, depending on the flying environment. This setting gives pilots more options with climb first.

So, what I'm adding, a two stage climb first. It's a really simple concept, and something that I think will be really useful. There are two new CLI commands:

  • nav_rth_climb_first_stage_mode: This setting is similar to nav_rth_mode, in that it lets you decide how you want to use the first climb stage altitude. Settings are AT_LEAST and EXTRA.
  • nav_rth_climb_first_stage_altitude: Allows you to set an altitude for the first climb stage. The default, 0, means the feature is disabled.

Why do we need this?

Other than the obvious energy benefits from turning towards home sooner. This also means that there should be no worries with nav_rth_abort_threshold when using a linear climb. Climb first is usually used because you're flying in an environment with obstacles. The two stage setting means that you can set the first stage to clear obstacles, before heading up to your chosen RTH Altitude.

So how does it work?

To be honest, pretty much as you expect it to. Once you select RTH, the model will start climbing (linear or spiral) up until the first stage target is met. Then it turns towards home and flies in that direction. If more altitude is needed to reach your target RTH altitude, it will climb on the way home. If the target altitude is met during the first climb stage, it will just fly home. Nice and simple, and much more energy efficient.

RTH Climb modes - climb first = on with stage

RTH Climb modes - climb first = spiral with stage

nav_rth_climb_first_stage_mode = AT_LEAST

This setting works in the same vein as the main RTH modes. Your target altitude for the first stage climb will be what you have set in nav_rth_climb_first_stage_altitude. If you are below the first climb stage altitude, it will climb to it. If not, it will turn to home and either fly home, or climb on the way home if your main RTH altitude target has not been reached. If the RTH Altitude is reached in the first stage, it will immediately turn towards home.

nav_rth_climb_first_stage_mode = EXTRA

Again, this setting works just like the main RTH modes. The target altitude for the first stage climb will be your current altitude plus the value you have set in nav_rth_climb_first_stage_altitude. If you are below the first climb stage altitude, it will climb to it. If not, it will turn to home and either fly home, or climb on the way home if your main RTH altitude target has not been reached. If the RTH Altitude is reached in the first stage, it will immediately turn towards home.

Here is a video showing regular RTHs, RTHs using two stage climb first and the AT_LEAST setting, and RTHs using two stage climb first and the EXTRA setting. The only difference between AT_LEAST and EXTRA in the code is the altitude number. So I split testing between the two modes. With AT_LEAST, I tested activating below the RTH Altitude and above. With EXTRA I tested activating well below the RTH Altitude, and just below, so that it would pass the RTH Altitude during the first stage.

https://youtu.be/yIO6CDxu1uM

Other notes

I have created more of those images. So will update the Wiki (if I can) to demonstrate the different climb first options, as that's not really covered in any documentation.

This feature adds two CLI commands:
- nav_rth_climb_first_stage_mode
- nav_rth_climb_first_stage_altitude

nav_rth_climb_first_stage_altitude sets an altitude to transition from climb first to turn first. 0 is disabled.

nav_rth_climb_first_stage_mode determines how nav_rth_climb_first_stage_altitude is used. Currently either as an at least altitude or adding to the current altitude.

Initial coding.
Initial testing went pretty well. Using the RTH climb stage worked perfectly with the AT_LEAST method. However the EXTRA method didn't work. After reviewing the code, I can see why, and have implemented a fix. This should now work as expected. I'll test ASAP.
Climb stage altitude is now set when RTH is initiated. this saves on calculations in each loop.
Clarified descriptions
@avsaase
Copy link
Member

avsaase commented Aug 1, 2021

Great idea! And I love the images.

How does this work on quads?

@MrD-RC
Copy link
Collaborator Author

MrD-RC commented Aug 1, 2021

@avsaase it has no effect on quads. It’s fixed wing only.

I imagine a quad with climb first would just go vertically up to the RTH altitude.

Alex, is this something that a quad could find useful? If so, it's just a case of changing the if statement in navigation.c:2473 to remove (STATE(FIXED_WING_LEGACY) || STATE(AIRPLANE)) &&

@JulioCesarMatias
Copy link
Collaborator

I liked that! And I also liked the pictures, so cute.

@MrD-RC
Copy link
Collaborator Author

MrD-RC commented Aug 8, 2021

I’ve updated the WiKi to cover the climb first modes. I’ve left stuff from this PR out until it gets merged.

@MrD-RC MrD-RC added this to the 4.0 milestone Oct 13, 2021
@MrD-RC MrD-RC added Ready to merge Release Notes Add this when a PR needs to be mentioned in the release notes labels Oct 15, 2021
@MrD-RC MrD-RC requested a review from DzikuVx October 16, 2021 10:36
@MrD-RC
Copy link
Collaborator Author

MrD-RC commented Nov 3, 2021

Updated from current master and resolved conflicts.

@MrD-RC
Copy link
Collaborator Author

MrD-RC commented Nov 6, 2021

Another update to resolve conflicts. @DzikuVx can we merge it, I know three times is the charm 🤣

@DzikuVx DzikuVx merged commit 00716f7 into iNavFlight:master Nov 8, 2021
breadoven added a commit to breadoven/inav that referenced this pull request Nov 8, 2021
commit ddbf3dd
Merge: 6df55cb 3c4df22
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 10:30:44 2021 +0100

    Merge pull request iNavFlight#7578 from breadoven/abo_mission_planner_fix

    Mission planner fix

commit 6df55cb
Merge: 00716f7 896f2da
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 09:06:29 2021 +0100

    Merge pull request iNavFlight#7250 from breadoven/abo_fixed_wing_soaring_mode

    Fixed wing soaring mode

commit 00716f7
Merge: b0aa8ee 6091443
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 09:03:43 2021 +0100

    Merge pull request iNavFlight#7323 from MrD-RC/nav_rth_climb_first_stage

    Two Stage Climb First RTH

commit b0aa8ee
Merge: 3b77031 f7b4e75
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 08:58:30 2021 +0100

    Merge pull request iNavFlight#7573 from iNavFlight/dzikuvx-fix-f7-h7-msc-on-windows

    Fix MSC on windows with F7 and H7

commit 3b77031
Merge: c4ecdd7 ed4d232
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 08:58:08 2021 +0100

    Merge pull request iNavFlight#7574 from sdellava/Add-pinio-to-FLYVOOF457

    Added PINIO and USER1 mode to FLYWOOF745 and FLYWOOF745

commit c4ecdd7
Merge: 7a71263 65514af
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 08:57:49 2021 +0100

    Merge pull request iNavFlight#7572 from bkleiner/bkleiner-h7-usb-msc

    h7: usb msc support for sdio

commit 7a71263
Merge: d5b7a2c 0a14236
Author: Paweł Spychalski <pspychalski@gmail.com>
Date:   Mon Nov 8 08:55:29 2021 +0100

    Merge pull request iNavFlight#7577 from iNavFlight/dzikuvx-fix-ci

    Temporary fix for CI

commit 0a14236
Author: Pawel Spychalski (DzikuVx) <pspychalski@gmail.com>
Date:   Mon Nov 8 08:35:54 2021 +0100

    Temporary fix for CI

commit 3c4df22
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Mon Nov 8 00:08:18 2021 +0000

    Update navigation.c

commit 896f2da
Merge: aa1f6c2 d5b7a2c
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Sun Nov 7 16:40:19 2021 +0000

    Merge remote-tracking branch 'upstream/master' into abo_fixed_wing_soaring_mode

commit aa1f6c2
Merge: 9ce4e27 264955b
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Sun Nov 7 15:51:49 2021 +0000

    Merge remote-tracking branch 'upstream/master' into abo_fixed_wing_soaring_mode

commit ed4d232
Author: Stefano Della Valle <stefano.dellavalle@thingslab.email>
Date:   Sun Nov 7 15:23:13 2021 +0100

    Added pinio

commit f7b4e75
Author: Pawel Spychalski (DzikuVx) <pspychalski@gmail.com>
Date:   Sun Nov 7 14:20:18 2021 +0100

    Fix MSC on windows with F7 and H7

commit 65514af
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 19:49:36 2021 +0100

    h7: hide all the unused parameters in usbd_msc_scsi

commit 4463d3f
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 19:37:25 2021 +0100

    h7: use idma for msc sdio

commit 6855c33
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 19:37:01 2021 +0100

    h7: enable usb msc and fix middleware compliation

commit b4ba470
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 18:36:57 2021 +0100

    h7: drop SDCARD_SDIO_DMA as IDMA is used

commit 6091443
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Nov 6 16:45:42 2021 +0000

    Updated Navigation.md - Made doc clearer

    Made doc clearer.

commit 98731cc
Merge: 155eaf7 3dad1d2
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Nov 6 16:17:02 2021 +0000

    Merge branch 'master' into nav_rth_climb_first_stage

commit 9965eb8
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 15:27:40 2021 +0100

    h7: move afatfs_cache to for alignment

commit 364b5be
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 14:37:00 2021 +0100

    h7: init sdio pins in fc_init

commit 24f2fb7
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 14:36:47 2021 +0100

    h7: skip SDIO_CFG_TO_DEV conversion as we hardcode enum entries

commit e440b64
Author: bkleiner <b.kleiner@str8labs.com>
Date:   Sat Nov 6 13:30:32 2021 +0100

    h7: fix sdio src file extension

commit fee2394
Author: Pawel Spychalski (DzikuVx) <pspychalski@gmail.com>
Date:   Mon Jul 26 11:59:53 2021 +0200

    Initial cut on H7 SD card. No idea if works. Compiles

commit 155eaf7
Merge: cce14d6 f8c9c3e
Author: Darren Lines <darren@darrenlines.uk>
Date:   Wed Nov 3 19:18:20 2021 +0000

    Merge branch 'iNavFlight:master' into nav_rth_climb_first_stage

commit cce14d6
Merge: 2762f25 73a1325
Author: Darren Lines <darren@darrenlines.uk>
Date:   Wed Nov 3 19:17:12 2021 +0000

    Merge branch 'master' into nav_rth_climb_first_stage

commit 9ce4e27
Merge: 6f6371b 312d038
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Thu Oct 28 20:31:47 2021 +0100

    Merge remote-tracking branch 'upstream/master' into abo_fixed_wing_soaring_mode

commit 2762f25
Merge: 7db8605 d3a95d8
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Oct 9 14:24:22 2021 +0100

    Merge branch 'iNavFlight:master' into nav_rth_climb_first_stage

commit 7db8605
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sun Aug 1 17:11:44 2021 +0100

    Update navigation.h

    Clarified descriptions

commit b6f8ff9
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sun Aug 1 11:39:29 2021 +0100

    Corrected heading and based off home position

commit 4e5f86f
Author: Darren Lines <darren@darrenlines.uk>
Date:   Mon Jul 26 21:50:53 2021 +0100

    Added CMS settings to make testing at the field easier

commit f06288c
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sun Jul 25 13:17:59 2021 +0100

    Changed method to set climb stage altitude

    Climb stage altitude is now set when RTH is initiated. this saves on calculations in each loop.

commit 9ed0b1d
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Jul 24 19:55:24 2021 +0100

    Changes to fix EXTRA mode

    Initial testing went pretty well. Using the RTH climb stage worked perfectly with the AT_LEAST method. However the EXTRA method didn't work. After reviewing the code, I can see why, and have implemented a fix. This should now work as expected. I'll test ASAP.

commit a1c05be
Author: Darren Lines <darren@darrenlines.uk>
Date:   Tue Jul 13 20:23:29 2021 +0100

    Typo fixed. Compiled docs.

commit 7d92451
Author: Darren Lines <darren@darrenlines.uk>
Date:   Tue Jul 13 16:12:42 2021 +0100

    typo fix

commit 10931fe
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Jun 19 17:36:02 2021 +0100

    Fixed compile errors

commit 4b2095f
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Jun 19 10:41:44 2021 +0100

    Update Settings.md

commit 05199ad
Author: Darren Lines <darren@darrenlines.uk>
Date:   Sat Jun 19 10:23:34 2021 +0100

    Allow setting an altitude limit for climb first

    This feature adds two CLI commands:
    - nav_rth_climb_first_stage_mode
    - nav_rth_climb_first_stage_altitude

    nav_rth_climb_first_stage_altitude sets an altitude to transition from climb first to turn first. 0 is disabled.

    nav_rth_climb_first_stage_mode determines how nav_rth_climb_first_stage_altitude is used. Currently either as an at least altitude or adding to the current altitude.

    Initial coding.

commit 6f6371b
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Mon Jul 12 10:18:14 2021 +0100

    Update fc_msp_box.c

commit 1d64e0a
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Mon Jul 12 09:44:04 2021 +0100

    Update fc_msp_box.c

commit 64a3ef6
Author: breadoven <56191411+breadoven@users.noreply.github.com>
Date:   Sun Jul 11 21:49:54 2021 +0100

    Initial build
@MrD-RC MrD-RC deleted the nav_rth_climb_first_stage branch November 9, 2021 13:16
@MrD-RC MrD-RC added Release Notes Add this when a PR needs to be mentioned in the release notes and removed Release Notes Add this when a PR needs to be mentioned in the release notes labels Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge Release Notes Add this when a PR needs to be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants