Add show mode

This commit is contained in:
2024-07-29 13:38:14 -05:00
parent 1ac8712e0f
commit 4591dc6900
4 changed files with 65 additions and 32 deletions

61
run.py
View File

@@ -335,7 +335,9 @@ def check_server():
mainloop_get.put(("return", data["tray"]))
else:
fprint("Invalid data.")
elif call == 'request':
if "position" in data:
mainloop_get.put(("show", data["position"]))
case _:
fprint("Unknown/unimplemented data type: " + decoded["type"])
except Exception as e:
@@ -782,36 +784,43 @@ def mainloop_server(pool, manager):
mainloop_get.put(("return", newtube))
if not mainloop_get.empty():
fprint("Movement requested. Keep clear of the machine!")
action, get_cable = mainloop_get.get()
if get_cable > -1:
global sensors
if action == "pickup":
spot = get_open_spot(sensors)
if spot is not False:
if action == "show":
animation_wait = False
ring_animation = get_cable
start_animation = True
led_set_mode = "Show"
else:
fprint("Movement requested. Keep clear of the machine!")
if get_cable > -1:
global sensors
if action == "pickup":
spot = get_open_spot(sensors)
if spot is not False:
arm_ready = False
if real:
animation_wait = False
ring_animation = get_cable
start_animation = True
led_set_mode = "GrabAA"
pool.apply_async(ur5_control.holder_to_tray, (arm, arm_updates, get_cable, spot), callback=arm_start_callback, error_callback=handle_error)
else:
arm_ready = True
fprint("Getting cable at position " + str(get_cable))
mode = "Pickup"
cable_list_state[get_cable] = False # mark as removed
if action == "return":
arm_ready = False
fprint("Returning cable from tray position " + str(get_cable))
if real:
animation_wait = False
ring_animation = get_cable
start_animation = True
led_set_mode = "GrabAA"
pool.apply_async(ur5_control.holder_to_tray, (arm, arm_updates, get_cable, spot), callback=arm_start_callback, error_callback=handle_error)
failcount = 0
pool.apply_async(ur5_control.tray_to_camera, (arm, arm_updates, get_cable), callback=arm_start_callback, error_callback=handle_error)
else:
arm_ready = True
fprint("Getting cable at position " + str(get_cable))
mode = "Pickup"
cable_list_state[get_cable] = False # mark as removed
if action == "return":
arm_ready = False
fprint("Returning cable from tray position " + str(get_cable))
if real:
failcount = 0
pool.apply_async(ur5_control.tray_to_camera, (arm, arm_updates, get_cable), callback=arm_start_callback, error_callback=handle_error)
else:
arm_ready = True
mode = "ReturnC"
mode = "ReturnC"
else:
# LED idle anim
pass