Disable range finder above certain height

Hi all,

When flying with a downfacing range finder, I often don’t want use terrain following when flying above a certain altitude. For example: I don’t want the drone to have terrain following when flying 20 meter above trees, but I do like to have terrain following activated when landing. As far as I know, there is no parameter (or another way) to achieve this, so I would like to add this feature to the Ardupilot code.

I would like to add a parameter for each range finder that specifies the height at which the range finder turns off. As the height source I would like to use “Altitude Estimate” as shown below.

I obviously don’t want to make a mess of the range finder code that already exists, so I’m wondering if someone could quickly tell me where this feature could be best programmed.

I’m looking forward to your reply!

Best regards,
Max

Are you using Ardupilot or PX4 ?

In Ardupilot there is RNGFNDx_MAX_CM to set the upper limit, usually dictated by the rangefinders properties. And you can set an RC channel to enable or disable the rangefinder: RCx_OPTION,10

Thank you for your response @xfacta!

I’m using Ardupilot.
Setting RNGFNDx_MAX_CM doesn’t work very well (e.g. RNGFNDx_MAX_CM = 2000 and you are flying at 22 meters altitude. The drone will still climb in this case if you encounter a tree higher than 2 meters).
RCx_OPTION = 10 is a good solution, but in my opinion, it would be even handier if the drone takes care of this automatically.

I have also considerded to use a LUA script (this is possible too), but it might be better to implement this directly into the C++ firmware.