fixed i/o lock on global variable
This commit is contained in:
parent
7694f1a968
commit
662fc1956f
|
@ -67,7 +67,7 @@ class URModbusServer:
|
||||||
|
|
||||||
if (packet is None) or (packet_signs is None):
|
if (packet is None) or (packet_signs is None):
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
print(f"[Angles] Modbus Error: retrying")
|
print(f"[Angles] Modbus Error #{tries}: retrying")
|
||||||
return self.get_joint_angles(tries+1)
|
return self.get_joint_angles(tries+1)
|
||||||
else:
|
else:
|
||||||
base = self._format_sign(packet[9:11], packet_signs[9:11])
|
base = self._format_sign(packet[9:11], packet_signs[9:11])
|
||||||
|
@ -96,7 +96,7 @@ class URModbusServer:
|
||||||
|
|
||||||
if (packet is None):
|
if (packet is None):
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
print(f"[Speeds] Modbus Error: retrying")
|
print(f"[Speeds] Modbus Error#{tries}: retrying")
|
||||||
return self.get_joint_speeds(tries+1)
|
return self.get_joint_speeds(tries+1)
|
||||||
else:
|
else:
|
||||||
base = self._format(packet[9:11]) / 1000
|
base = self._format(packet[9:11]) / 1000
|
||||||
|
|
|
@ -200,7 +200,7 @@ class URSentry:
|
||||||
|
|
||||||
# Deadzones where we still consider the target in the middle, to avoid jittering
|
# Deadzones where we still consider the target in the middle, to avoid jittering
|
||||||
horizontal_dead_zone_radius = 0.1
|
horizontal_dead_zone_radius = 0.1
|
||||||
vertical_dead_zone_radius = 10.08
|
vertical_dead_zone_radius = 0.08
|
||||||
|
|
||||||
# Speeds for the base and neck joints
|
# Speeds for the base and neck joints
|
||||||
base_max_speed = 1.5
|
base_max_speed = 1.5
|
||||||
|
|
12
main.py
12
main.py
|
@ -24,15 +24,17 @@ class CameraJoystick(threading.Thread):
|
||||||
self.keep_running = True
|
self.keep_running = True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
global current_joystick
|
||||||
while self.keep_running:
|
while self.keep_running:
|
||||||
|
time.sleep(0.0001)
|
||||||
q_val = []
|
q_val = []
|
||||||
try:
|
try:
|
||||||
q_val = q.get_nowait()
|
q_val = q.get_nowait()
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
#print(bb)
|
#print(bb)
|
||||||
bb = b.get_joystick_position_from_new_set_of_bboxes(q_val)
|
current_joystick = b.get_joystick_position_from_new_set_of_bboxes(q_val)
|
||||||
self.joystick_queue.put(bb)
|
#self.joystick_queue.put(bb)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.keep_running = False
|
self.keep_running = False
|
||||||
|
@ -58,8 +60,8 @@ class JoystickScheduler(threading.Thread):
|
||||||
|
|
||||||
camera_joystick = CameraJoystick(joystick_queue)
|
camera_joystick = CameraJoystick(joystick_queue)
|
||||||
camera_joystick.start()
|
camera_joystick.start()
|
||||||
joystick_scheduler = JoystickScheduler(joystick_queue)
|
# joystick_scheduler = JoystickScheduler(joystick_queue)
|
||||||
joystick_scheduler.start()
|
# joystick_scheduler.start()
|
||||||
|
|
||||||
ur.initialize_pose()
|
ur.initialize_pose()
|
||||||
|
|
||||||
|
@ -70,5 +72,5 @@ while True:
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
camera_joystick.stop()
|
camera_joystick.stop()
|
||||||
joystick_scheduler.stop()
|
# joystick_scheduler.stop()
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue