This is related to another article written by rdawg which can be found here: Enhancing Terrain Capabilities in Plane
Idea for hybridization,
Dynamically change reference offset value based on rangefinder value
The reference offset is used by ardupilot to offset the entire terrain dataset based on the planes relation to the ground. Essentially when the craft is on the ground we know that it’s on the ground but the terrain might be off and would say that the craft is not on the ground. So to rectify this ardupilot will automatically offset the entire dataset by that difference. But this is only done once; as the plane is flying there are still inaccuracies in the terrain data set that can throw off terrain following, one proposal is to update the offset periodically using a rangefinder to mitigate error.
After a discussion with the devs I think the best way to do this would be to write a lua script to set the desired offset periodically
Safety Precaustions
One thing to note is that we will need to be very particular with how we set the offset value, we want to make the offset relative to the ground ideally so we’d need some way to filter out tree canopy and other undesirables.
We also need to figure out the rate at which we want to perform these updates.