Enhancement for terrain following with a rangefinder

Dear all,

Nowadays, I have been working on terrain following. First of all, thank you guys for the amazing improvement in the terrain following!

I would like to request an enhancement for the terrain following with a rangefinder.
The current version of Copter keeps increasing its altitude when its altitude is higher than the rangefinder’s maximum distance.
As far as I know, that’s why there is WPNAV_RFND_USE parameter.

However, is there any way to automatically switch the rangefinder and terrain data?
For example, when the Copter’s altitude is less than RNGFND1_MAX_CM, it leverages the altitude from the rangefinder. If the altitude is higher than RNGFND1_MAX_CM, the Copter uses the altitude from the terrain data.

Hi @Benjamin,

This is already on the issues list here. It’s not trivial though because the two altitudes measure different things. The terrain database will report the ground level while a range finder reports the distance to the tallest object on the ground level. An extreme example is if you tried to fly through a city. The terrain database would say that the altitude (of the ground) is very even while a rangefinder would report jumps of many 10s of meters.

There have been some suggestions made about recording offsets and then perhaps bleeding off those offsets over time but it’s not really easy to blend the two sources.