I have an improvement idea/recommendation to enhance the useability of the geofencing function.
The user should be able to choose in which altitude frame (eg. relative, absolute, terrain) the geofencing function is considered. This could easily be set by the user with an additional FENCE_ parameter.
Airspace altitude limitations are either given in absolute (MSL), or terrain (AGL) frames. This feature would be very useful to limit drones to a specific uncontrolled (F or G) airspace, that is usually up to a cerain altitude above ground. In flat areas this is not much of a concern, but very much so in mountanious terrain.
Furthermore the new EU regulations 2019/947 and 2019/945 consider such a feature as a risk mightigation measure, which could potentally ease the certification process through assigning a lower air risk class to the UAV.
It is possible with the terrain based geofencing, that the fence would breach in a position, where the normal RTL feature would crash the aircraft into terrain. However the conditions, that would trigger such an event is rather unlikely, because a very specific terrain/settings combination are needed and the aircraft would probably experience a link loss before breaching the fence in such a case. Furthermore using the smartRTL feature or terrain following while normal RTL eliminates this problem alltogether.