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

Graph-based Return-To-Land #5829

Closed
wants to merge 2 commits into from
Closed

Conversation

samuelsadok
Copy link

#5745 rebased

@samuelsadok
Copy link
Author

Still out of flash, and quite significantly. It seems strange that the tracker would use that much flash. Maybe it has to some dependencies on complex functions from the stdlib that get linked into the binary. I might investigate if I have time, otherwise one could just disable the tracker for px4fmu-v2.

@dagar
Copy link
Member

dagar commented Jan 2, 2017

@samuelsadok Any thoughts on getting this small enough to fit in fmu-v2? Try moving your test date to ROMFS/px4fmu_test. If you can resolve the merge conflicts and get this small enough I'll add the test to SITL in the builds.

@samuelsadok
Copy link
Author

The target px4fmu-v2_default, which is the one that fails, does not include the navigator_tests module as can be seen here:
https://github.com/samuelsadok/Firmware/blob/smartrtl/cmake/configs/nuttx_px4fmu-v2_test.cmake
That target therefore does not contain the large test data. It is only included in px4fmu-v2_test, px4fmu-v4_default and posix_sitl_default.

I'm kind of busy right now, so I can't do an in-depth investigation on what causes the huge size. Are there many people still using fmu-v2? If not, we could just disable it (how is that done best?), so that at least other users get the feature.

@dagar
Copy link
Member

dagar commented Jan 4, 2017

Ah, sorry I missed the inclusion.
Yes there are many fmu-v2 users. The Pixhawk is by far the most common board.

@dagar
Copy link
Member

dagar commented Jan 28, 2017

@samuelsadok we now have space available on px4fmu-v2.

@samuelsadok
Copy link
Author

The problem is that with each rebase the quality decreases because there usually are conflicts/incompatibilities and I don't have the time to test/fix my stuff each time.

This time, it seems for instance that the navigator_tests (which I added in this PR) don't run anymore when I make tests. Maintainers, you can edit, so feel free to polish the PR.

@dagar
Copy link
Member

dagar commented Feb 2, 2017

Yes, sorry about that. I was hoping we could get it into a state to review and safely merge, but it's even less likely to be reviewed if the builds aren't passing.

For running tests under SITL the tests are now listed here https://github.com/PX4/Firmware/blob/master/src/firmware/posix/sitl_tests.cmake#L20, then ctest runs them individually to report overall pass/fail.

@samuelsadok
Copy link
Author

Ok I added the navigator_tests. Please note that they only test the logic of the Tracker object. Someone needs to make sure that the integration with the whole RTL works as expected in the real-world (I don't have hardware).

Do we have a script to automatically format the code?

@dagar
Copy link
Member

dagar commented Feb 7, 2017

We use astyle for formatting. The configuration is Tools/astylerc, but if you have the latest version installed (v2.06) you can just run make check_format locally.

@dagar
Copy link
Member

dagar commented Feb 7, 2017

This is really well done. I'm mainly wondering how we should fit it in with the current behavior. There are certain situations where this is better, but many where classic RTL (climb to safe altitude, straight line home) would still be preferred.

@LorenzMeier do you have any thoughts on how smart RTL fits into PX4, particularly from the user perspective and fail safes?

@LorenzMeier
Copy link
Member

@samuelsadok We are just stabilising master for the next stable release, but this is a super high priority for me to get in, so hang in there. I will do a test flight on this branch as soon as time permits.

@mhkabir
Copy link
Member

mhkabir commented May 25, 2017

With v1.6 almost out of the door, I would like to focus on getting this excellent piece of work in. @LorenzMeier @dagar @samuelsadok.

@samuelsadok
Copy link
Author

So what's blocking this? I can rebase again but I can't keep doing it forever. I guess the main point is someone actually needs to to flight test it, because I don't have the necessary hardware.

@mhkabir
Copy link
Member

mhkabir commented May 28, 2017

@samuelsadok It would be great if you could rebase it just once more, and then I'll take over. Let me know places where it could break, what needs testing, open concerns, etc.

Thanks a lot!

@samuelsadok
Copy link
Author

Ok sure that would be cool, I'll have a look and rebase some time this week

@mhkabir
Copy link
Member

mhkabir commented Jun 4, 2017

@samuelsadok Any luck?

@samuelsadok
Copy link
Author

I did a rebase locally today and tried to run the SITL but that broke something in the way I set setpoints. I didn't have the time though to track it down yet. The recorded graph data looks fine. I'll get to the bottom of it as soon as time permits.

…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.
@samuelsadok
Copy link
Author

Ok got it to work again. The issue was probably related to something that changed in the conversion from local to global coordinates. Now I pass the transformation-reference explicitly. That also made me aware that if this reference changes mid-flight this is unhandled.

I added an overview of the implementation in the commit message and to tracker.h. @mhkabir if you want a more in-depth insight I can upload the thesis that I wrote on this (upload where?). Also with DEBUG_TRACKER, you can see quite verbose information which also hints a lot about the inner workings.

As for testing/maintenance: The graph and pathfinding implementation itself is verified through unit tests, so I'm pretty confident in that. The more uncertain part for me is the integration, i.e. the logic in smart_rtl.cpp. The whole thing was thoroughly tested in SITL but never in real flight under real use conditions. So it just needs more of "enter RTL, exit RTL, fly a few meters, enter RTL again, make coffee, and then restart RTL again". One remaining glitch is the drone never actually proceeds to land, it just hovers at the home position, should be easy to fix though.

Let me know if you need more information or run across issues while testing. I'm just slightly constrained in time but I'll do my best to assist.

@mhkabir
Copy link
Member

mhkabir commented Jun 6, 2017

@samuelsadok Thanks a lot! I will start having a look now. Can you please upload your thesis to e.g Google Drive? Or you could email it to me at [email protected].

@mhkabir
Copy link
Member

mhkabir commented Jun 6, 2017

OK, I'm closing this in favour of #7363 . I moved the commits over to our repo so that I can work on it easily.
@samuelsadok Again, many thanks :)

@mhkabir mhkabir closed this Jun 6, 2017
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.

4 participants