Help on lua scripting for wall following drone

Hi everyone,

i am currently doing some research and development works for my university and i am looking into making a drone which can maintain its distance from a surface ( wall ) which distance information will be given by a forward mounted range finder. the flow will be as follows:

  1. pilot fly in loiter ( indoor with optical flow)
  2. pilot approach the surface, flies x distance from surface
  3. via some toggle switch enable surface lock ( so all pitch will not register while drone is maintaining the “x” distance from the surface)

with this in mind, where could be a good direction in which i can try to develop the lua script? additionally where/what resources i can use to know what commands are available in lua scripting?
any idea on how such function (wall following) could be implemented?

any help will be very much appreciated.

thanks in advance.

Zeke

there are a lot of examples here

This is my lua script for horizontal optical flow for wall in loiter mode

w2.lua (2.3 KB)

thank you very much, i will surely try it

can you give me a rundown on how the script works? thank you very much!