Scanning a roof using a distance sensor

Hello,

I am trying to do the following: I want to take photos of a roof using an autonomous mission. Since the photos need to be made really close to the roof I would like to use a lidar sensor to make sure the drone is for example 2 meters away from the roof all the time. As the GPS accuracy is not that good I have the problem that the drone can sometimes get besides the roof. If that happens I do not want the lidar sensor to be used anymore since the drone would fly to a distance of 2 meters from the ground and would crash into the wall when turning around.
My easiest idea was to set the maximum distance of the distance sensor to something like 5 meters so the drone uses the barometer measurement instead of the distance sensor and I set another altitude for the barometer that is roughly calculated. The problem is that I cannot set a different altitude for distance sensor / barometer and since the drone starts on the ground it would also climb down to a distance of 2 meters away from the ground.
Another option would be to write the whole mission to a companion computer to actively adjust the height dependent on a threshold. Unfortunately I cannot find an option to only control the altitude by the companion computer so I would have to convert my whole mission into code and I would have no visualisation of the mission, which I do not like.
The last option I see would be to modify the px4 firmware, but this seems to be rather complicated for this case. I have looked into it, but as I am a beginner I think this option is not feasible.
Is there another option to realise this in a better way that I did not notice?