diydrones/ardupilot — pull request #492 by mavbot (2013-08-13 14:54:34+00:00)
Title: RTL Always Climb

Not really "always climb", but with a few exceptions will cause a climb of RTL_ALT cm whenever RTL is entered. This is great for FPV over trees or terrain, where if you lose video or RC signal, the best way to get it back is a quick climb; whereas going straight home may cause a crash into whatever obstacle blocked the signal in the first place. Before the only solution was to set RTL_ALT higher than all possible obstacles, but in the mountains obstacles can be hundreds of meters high, and it can be annoying for a simple RTL intended just to get your craft back home to detour to hundreds of meters if not necessary.

Exceptions to the "always climb" rule:

* If a max alt fence is enabled, it will not climb higher than to RTL_ALT_MARGIN (500 cm) below the fence.

* If RTL_ALT is set to zero, it will RTL at current altitude

* If you are in a valley (below launch altitude) it will RTL at RTL_ALT

* If you are in a valley, or near the ground, even if RTL_ALT is set to zero, it will still RTL at RTL_ALT_MARGIN (500 cm) above home (so it's not scraping the ground by the time it arrives home).