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

[WIP] Smart RTL from @samuelsadok #7363

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[WIP] Smart RTL from @samuelsadok #7363

wants to merge 1 commit into from

Conversation

mhkabir
Copy link
Member

@mhkabir mhkabir commented Jun 6, 2017

This adds graph-based "smart" RTL capabilities from @samuelsadok :

Adds Smart Return To Home capability by recording the flight path in a memory optimimized format. This means the UAV can return to home by using only known-good flight paths.

The flight graph is stored as a series of delta elements at 1m resolution and a list of nodes. Both lists share the same buffer. Each delta element takes up 2 bytes or sometimes 6 bytes if the delta is large. The path can consist of multiple disconnected segments, in which case the gaps are stored as delta elements with a jump-bit set.

Once in a while or when required the graph is consolidated, which means:

  • Points that lie roughly in a line are replaced by a single line
  • Points that lie close to previously recorded lines are pruned
  • For lines that pass close to each other a node element is created

Furthermore:

  • The graph is recorded at a higher precision closer to home
  • If the graph becomes full, the overall precision is reduced and the whole graph is re-consolidated
  • If the graph becomes full once more, all data is removed except for the shortest path home at that moment. One of these actions is repeated at each subsequent fill-up.

Path finding information is generated/refreshed on demand and stored in the nodes. During return-to-home, the best direction to home is continuously evaluated by using the information stored in the nodes.

The graph recording and path finding is implemented in navigator/tracker.cpp.
The graph based return-to-home is implemented in navigator/smart_rtl.cpp. by Samuel Sadok

@mhkabir mhkabir changed the title Smart RTL from @samuelsadok [WIP] Smart RTL from @samuelsadok Jun 6, 2017
@mhkabir
Copy link
Member Author

mhkabir commented Jun 7, 2017

OK, I quickly tested in SITL. Works nicely, but needs a load of polishing.

I'll also port this over to use local coordinates instead of global coordinates, which is the direction PX4 is generally heading.

@samuelsadok
Copy link

Cool thanks for taking over!

Here's the accompanying document: https://drive.google.com/open?id=0Bzbo-c8nJd81cmxTaE1YT1hpUWs

Yeah I didn't find out how to set setpoints using local coordinates. The graph's native format is local coordinates, so all conversions are just a simple wrapper function that can be removed. If the local frame moves (if that's even possible), there are several absolute coordinates that need to be shifted.

@dagar dagar self-assigned this Aug 30, 2017
@dagar dagar self-requested a review August 30, 2017 20:05
@dagar
Copy link
Member

dagar commented Aug 30, 2017

TODO:

  • check nuttx code size and memory overhead, figure out if we can fit it into px4fmu-v2
  • high level UX vs RTL vs SmartRTL, I still think we need both to be accessible
  • flight testing

@dagar
Copy link
Member

dagar commented Aug 30, 2017

thesis-release.pdf

@dagar
Copy link
Member

dagar commented Aug 30, 2017

Reviewing some details from your thesis, I think this could be acceptable if we break it off to run consolidation/rewrite in the low priority work queue rather than the main navigator thread.

image

@samuelsadok
Copy link

Yes that makes sense, however in this case synchronisation considerations are necessary.

Adding points while the consolidation is running should be possible with minor changes. Currently the consolidation function assumes the global graph_next_write index remains constant. So it needs to be changed to keep a local copy and in the end shift the new points so there's no gap in the graph buffer.

Doing a rewrite while recording this rather difficult but it's probably acceptable to just drop new positions while a rewrite is in progress.

@sanderux
Copy link
Member

sanderux commented Oct 3, 2017

Can we augment this with a last moment possible FW decend to transition altitude for VTOL?
The FW could be at very high altitude when RTL kicks in and might not have enough energy to land in MC mode at that altitude.

Assuming we will be on the path we know is safe we could descend as FW to the RTL altitude, and do this at the last moment possible (so FW descend rate over current altitude - RTL altitude = distance from home to start descending)

@dagar dagar mentioned this pull request Oct 12, 2017
@dagar dagar added this to the Release v1.8.0 milestone Dec 13, 2017
@dagar dagar force-pushed the pr-smart-rtl branch 2 times, most recently from 7f32b3d to 9cf7af6 Compare February 2, 2018 06:25
@TSC21 TSC21 mentioned this pull request Feb 21, 2018
@dagar dagar removed this from the Release v1.8.0 milestone May 4, 2018
@dagar dagar added this to the Release v1.10.0 milestone Feb 6, 2019
@PX4 PX4 deleted a comment from stale bot Feb 6, 2019
@PX4 PX4 deleted a comment from stale bot Jul 15, 2019
@stale stale bot removed the Admin: Wont fix label Jul 15, 2019
@Pedro-Roque
Copy link
Member

@mhkabir should this still be open?

@stale stale bot removed the stale label May 3, 2020
@Pedro-Roque
Copy link
Member

@dagar @julianoes Is this still ongoing or can I close it?

@mhkabir mhkabir closed this May 8, 2020
@dagar
Copy link
Member

dagar commented May 8, 2020

@dagar @julianoes Is this still ongoing or can I close it?

Definitely not ongoing, but it would be wonderful if someone would like to take another pass at getting it in.

@LorenzMeier LorenzMeier reopened this May 8, 2020
@LorenzMeier
Copy link
Member

Not going to give up on this.

@Pedro-Roque
Copy link
Member

Alright I can take a pass on it after I'm done with debugging CI

@Pedro-Roque Pedro-Roque self-assigned this May 8, 2020
@dagar dagar modified the milestones: Release v1.10.0, Release v1.12.0 May 8, 2020
@stale stale bot added the stale label Aug 8, 2020
…a memory optimimized format. This means the UAV can return to home by using only known-good flight paths.

The flight graph is stored as a series of delta elements at 1m resolution and a list of nodes. Both lists share the same buffer. Each delta element takes up 2 bytes or sometimes 6 bytes if the delta is large. The path can consist of multiple disconnected segments, in which case the gaps are stored as delta elements with a jump-bit set.

Once in a while or when required the graph is consolidated, which means:
 - Points that lie roughly in a line are replaced by a single line
 - Points that lie close to previously recorded lines are pruned
 - For lines that pass close to each other a node element is created

Furthermore:
 - The graph is recorded at a higher precision closer to home
 - If the graph becomes full, the overall precision is reduced and the whole graph is re-consolidated
 - If the graph becomes full once more, all data is removed except for the shortest path home at that moment. One of these actions is repeated at each subsequent fill-up.

Path finding information is generated/refreshed on demand and stored in the nodes. During return-to-home, the best direction to home is continuously evaluated by using the information stored in the nodes.

The graph recording and path finding is implemented in navigator/tracker.cpp.
The graph based return-to-home is implemented in navigator/smart_rtl.cpp.
@stale stale bot removed the stale label Oct 4, 2020
@PX4 PX4 deleted a comment from stale bot Oct 4, 2020
@PX4 PX4 deleted a comment from stale bot Oct 4, 2020
@dagar dagar marked this pull request as draft October 4, 2020 16:19
@junwoo091400
Copy link
Contributor

Super interesting! @mhkabir are you interested in resurrecting this PR? Maybe we could discuss in today's PX4 Dev call?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants