Hi,
I’m in my first project with UR and I did stuck with scripts.
I’m measuring a parallel gripper clearence between fingers with analog laser sensor and what im trying to do is, when i set and close the gripper i will measure the distance for every 0,1sec and if its stable for example 5 times with 10mm accuracy will go on the program.
Gripper_Analog = (1000 * get_analog_in(0) * 19.266) + 79.68
thats the function that converts analog signal to mm.
any suggestions?
What i did so far
def Gripper_Olcum():
parca_genislik=268
stable_count = 0 # İstikrarlı sayacı başlangıç değeri
measurement_interval = 0.5 # Ölçüm aralığı, 0.1 saniye
while stable_count<=5:
Gripper_Analog = (1000 * get_analog_in(0) * 19.266) + 79.68
textmsg("Olcum ", Gripper_Analog)
if -10 < (parca_genislik - Gripper_Analog) and (parca_genislik - Gripper_Analog) < 10:
stable_count = +1 # Fark 10 birimi geçtiğinde sayacı artır
textmsg("Stable ", stable_count)
else:
stable_count = 0 # Fark 10 birimden azsa sayacı sıfırla
sleep(measurement_interval) # 0.5 saniye bekle
end
end
stable_count=0
end