So im using a python library for using a lidar-sensor
Im trying to get it somehow to start the initialisation of the lib-stuff at the beginning and than at an fixed intervall read the values from and start again.
I dont fully understand how this run command works, manual says, its used to run a whole text dat, but i saw also running a string as a first argument.
my Code gives me an “name ‘initSensor’ is not defined” exception.
its a bit strange, i think it works 1-2 times, to run that function from itself and after that it throws that error…
What am i doing wrong? or some general tipps how to approach this?
import PyLidar3 import time import threading def initSensor(): port = "COM7" Obj = PyLidar3.YdLidarX4(port) isConnected = Obj.Connect() if(isConnected): gen = Obj.StartScanning() return gen else: print("connection failed, try to reconnect Sensor") #start_time = threading.Timer(1, initSensor()) #start_time.start() init_print = "initSensor()" run(init_print,delayFrames=60) #return null def getData(gen): if op("scanningSwitch")["chan1"] == 1: print("getting data") data = next(gen) for key in data: op("data")[int(key),0]=data[key] run("getData(gen)", delayFrames=60) #else: #return gen = initSensor() getData(gen)