How to use rangefinder to improve althold without surface tracking

Hi. I would like to know if it is possible to use a rangefinder to help improve altitude hold of a drone without it jumping up and down when it flies over an obstacle as it happens when we active surface tracking.

In other words, can the range finder behave like the vision system of dji where the drones fly at constant level even over obstacles?

Thanks in advance

You might try varying the RNGFND_FILT parameter.

The biggest issue here is that the flight controller doesn’t know what the terrain is doing. With default settings the terrain model has about 100m resolution. Imagine flying over a flat but sloped field, this can work reasonably well. Now there is a shed on your way, let’s say 3m high, lidar detects change in altitude. Flight controller doesn’t know if the change was caused by the drone being shifted or small terrain feature got in the way. If it was given ATL target it will assume its desired position is relative to the terrain and adjust accordingly.

If you want something like that you will need companion computer running either high resolution (probably 1m or better) DEM and RTK or terrain profile matching or full simultaneous localization and mapping stack. Either one is significantly harder and more expensive than lidar.

You could turn surfacetracking off using the RCx_OPTIONS but keep the rangefinder active.

That smooths the response of the lidar but does not change the fact that if the terrain elevation changes the drone will follow :frowning:

That is what I usually fly with but this way only the barometer controls altitude which is not precise enough, changing around 1m with wind and braking maneuvers

Thank you for your detailed answer. That is what I have been thinking about. Lidar alone can not detect if the drone is flying over an obstacle or if it was the altitude changing.

Do you think it is possible to implement a vision system pointing downwards like DJI? And would it help keeping altitude constant even over obstacles?

Constant in reference to what?
Mean or average distance to terrain? ToF with companion computer processing data.
Constant pressure? Tune baro compensation.
Geoid? Visual or other SLAM.

why dont you use a lua script to disable surface tracking when speed is above a set limit. that way its only going to care abound terrain when stationary to help with hovering, it wont try and terrain follow when moving.

or better yet, rather than disable surface tracking just reduce the the maximum range of the rangefinder by changing the rangefinder max parameter when its moving so it will only avoid terrain if it gets really close.

1 Like

That really seems a good idea. However, how can I know the drone speed in the situations when I don´t have gps signal? Instead, would it be a good idea to disable surface tracking when there is stick input and enable when sticks are inside the deadzone (for loiter mode)?

The part of reducing the maximum range of the rangefinder while its moving does not seem to be a good idea for my case because if the drone is moving in loiter mode without gps signal, only trusting in optical flow (which happens a lot in the placs I usually fly), the optical flow will lose the ability to send good velocity data because of the lack of rangefinder data, and so I will not be able to have good loiter performance while moving.

1 Like

I didn’t realise you were using optical flow. Disabling it with RC input sounds like a good idea, you could still re-enable it if it gets too close to the ground so it will still avoid the ground if you get too low.

You could not know because I was not clear about that … sorry :sweat_smile:

Yes I am thinking about doing that also! Thanks for your help!

If your using RC input and you have opentx the. You could enable and disable ground tracking with a logical switch, you wouldn’t need to do any code that way.

That is also a possibility but it is not my case. I have a simple dji fpv remote controller