Tried the following but keep getting “UnboundLocalError: local variable ‘p’ referenced before assignment”
however, I thought I assigned p early on. When I ask it to print p, it will give me a valid integer. Then when i try to utilize p in a subsequent function, i get an error
from robot_control_class import RobotControl
import time
robotcontrol = RobotControl()
import math
dis = robotcontrol.get_laser_full()
ang = range(0,719,1)
dictionary = dict(zip(dis, ang))
p = int(max(dis))
print (p)
def goahead():
robotcontrol.move_straight()
while p < 99999999999999999999:
robotcontrol.rotate(int(dictionary[int(p)]) -360)
dis = robotcontrol.getlaserfull()
p = int(max(dis))
else:
robotcontrol.stop_robot()
print ("done")
goahead()