Modify copter-wall-climber.lua

Hi all,
I’am planning to modify copter-wall-climber.lua here
So my objective is to add another Lidar up to my drone to check the distance during climbing phase. So for example I’d like to modify the script to stop my drone at 1 meter of the wall and 1 meters of the ceiling.

I’ve already read the script and I understand what happend inside. So I have many lines thaht I should remove (all the part for climbing by lane etc) but my question is how to calculate the climbing rate with my Lidar distance ?
Should I do the same thing as

 -- convert rangefinder distance to pitch speed
    if rangefinder:has_data_orient(0) then
      local distance_m = rangefinder:distance_cm_orient(0) * 0.01
      wall_pitch_speed = (distance_m - wall_dist_target) * wall_dist_to_speed_P
      wall_pitch_speed = math.min(wall_pitch_speed, wall_pitch_speed_max)
      wall_pitch_speed = math.max(wall_pitch_speed, -wall_pitch_speed_max)

And the final objective is to do thaht without guided mode, just check input from pilot and adjust value from Lidar


Hello, simon you have already been able to use this script.
How does that work is that good? Do you have it on px4 or on a cube?