Update runtime
This commit is contained in:
parent
a822ea5184
commit
ad5eb5bbb3
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,4 +21,5 @@ map*.png
|
|||||||
build
|
build
|
||||||
# Generated label images
|
# Generated label images
|
||||||
labels
|
labels
|
||||||
temp
|
temp
|
||||||
|
pick_count.txt
|
@ -6,7 +6,7 @@ core:
|
|||||||
loopspeed: 60 # fps
|
loopspeed: 60 # fps
|
||||||
|
|
||||||
mqtt:
|
mqtt:
|
||||||
enabled: False
|
enabled: True
|
||||||
server: 172.31.108.4
|
server: 172.31.108.4
|
||||||
|
|
||||||
arm:
|
arm:
|
||||||
|
226
run.py
226
run.py
@ -661,6 +661,7 @@ def mainloop_server(pool, manager):
|
|||||||
global mainloop_get
|
global mainloop_get
|
||||||
global cable_list_state
|
global cable_list_state
|
||||||
global scan_value
|
global scan_value
|
||||||
|
global sensors
|
||||||
global oldmode
|
global oldmode
|
||||||
global arm_updates
|
global arm_updates
|
||||||
global animation_wait
|
global animation_wait
|
||||||
@ -675,6 +676,7 @@ def mainloop_server(pool, manager):
|
|||||||
global arm_distance_old
|
global arm_distance_old
|
||||||
global arm_distance_total
|
global arm_distance_total
|
||||||
global placed
|
global placed
|
||||||
|
global spot
|
||||||
|
|
||||||
if mode != oldmode:
|
if mode != oldmode:
|
||||||
print(" ***** Running mode:", mode, "***** ")
|
print(" ***** Running mode:", mode, "***** ")
|
||||||
@ -924,81 +926,7 @@ def mainloop_server(pool, manager):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if mode == "Idle":
|
|
||||||
# do nothing
|
|
||||||
if arm_ready is False:
|
|
||||||
pass
|
|
||||||
|
|
||||||
else:
|
|
||||||
global mainloop_get
|
|
||||||
|
|
||||||
|
|
||||||
if not mainloop_get.empty():
|
|
||||||
global sensors
|
|
||||||
action, get_cable = mainloop_get.get()
|
|
||||||
if action == "show":
|
|
||||||
animation_wait = False
|
|
||||||
ring_animation = get_cable
|
|
||||||
start_animation = True
|
|
||||||
led_set_mode = "Show"
|
|
||||||
fprint("Showing cable at position " + str(get_cable))
|
|
||||||
elif action == "shutdown":
|
|
||||||
fprint("SHUTTING DOWN!!")
|
|
||||||
pool.apply_async(ur5_control.move_to_packup, (arm,), callback=arm_start_callback, error_callback=handle_error)
|
|
||||||
sleep(30)
|
|
||||||
killme.set(1)
|
|
||||||
elif action == "returnCheck":
|
|
||||||
print("Checking sensors..")
|
|
||||||
if real:
|
|
||||||
newtube = get_full_spot(sensors)
|
|
||||||
else:
|
|
||||||
newtube = -1
|
|
||||||
if newtube >= 0:
|
|
||||||
# need to return a cable
|
|
||||||
mainloop_get.put(("return", newtube))
|
|
||||||
mainloop_get.put(("returnCheck", 0))
|
|
||||||
else:
|
|
||||||
fprint("Movement requested. Keep clear of the machine!")
|
|
||||||
|
|
||||||
placed = 0
|
|
||||||
arm_distance_total = 0
|
|
||||||
#mqtt_send("{\"value\": " + str(time.time() * 1000) + " }", "cycle_start")
|
|
||||||
cycle_start_time = int(time.time() * 1000)
|
|
||||||
increment_counter()
|
|
||||||
mqtt_send("{\"value\": " + str(1) + " }", "pick_count_total")
|
|
||||||
if get_cable > -1:
|
|
||||||
|
|
||||||
global spot
|
|
||||||
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:
|
|
||||||
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"
|
|
||||||
else:
|
|
||||||
# LED idle anim
|
|
||||||
pass
|
|
||||||
|
|
||||||
if mode == "Pickup":
|
if mode == "Pickup":
|
||||||
# complete
|
# complete
|
||||||
@ -1063,42 +991,52 @@ def mainloop_server(pool, manager):
|
|||||||
pool.apply_async(camera.read_qr, (10,), callback=camera_start_callback, error_callback=handle_error)
|
pool.apply_async(camera.read_qr, (10,), callback=camera_start_callback, error_callback=handle_error)
|
||||||
|
|
||||||
elif scan_value.upper().find("BLDN.APP/") > -1:
|
elif scan_value.upper().find("BLDN.APP/") > -1:
|
||||||
scan_value = scan_value[scan_value.upper().find("BLDN.APP/")+9:]
|
scan_value = scan_value[scan_value.upper().find("BLDN.APP/")+9:].strip("\r\n\t ")
|
||||||
|
|
||||||
fprint("Got cable: " + str(scan_value))
|
|
||||||
if scan_value[0:2] == "BL" or scan_value[0:2] == "AW":
|
if scan_value[0:2] == "BL" or scan_value[0:2] == "AW":
|
||||||
scan_value = scan_value[2:]
|
scan_value = scan_value[2:]
|
||||||
print(cable_list)
|
#print(cable_list)
|
||||||
print(scan_value)
|
fprint("Got cable: " + repr(scan_value))
|
||||||
|
|
||||||
for idx in range(len(cable_list)):
|
for idx in range(len(cable_list)):
|
||||||
cable = cable_list[idx]
|
cable = cable_list[idx]
|
||||||
if cable == scan_value and cable_list_state[idx] == False:
|
|
||||||
cable_list_state[idx] = True # mark cable as returned
|
if cable is not False and cable.find(scan_value) == 0 and len(scan_value) == len(cable):
|
||||||
arm_ready = False
|
if cable_list_state[idx] == False:
|
||||||
if real:
|
cable_list_state[idx] = True # mark cable as returned
|
||||||
animation_wait = True
|
arm_ready = False
|
||||||
ring_animation = idx
|
if real:
|
||||||
led_set_mode = "GrabC"
|
animation_wait = True
|
||||||
start_animation = True
|
ring_animation = idx
|
||||||
pool.apply_async(ur5_control.camera_to_holder, (arm, arm_updates, idx), callback=arm_start_callback, error_callback=handle_error)
|
led_set_mode = "GrabC"
|
||||||
|
start_animation = True
|
||||||
|
fprint("Returning to spot " + str(idx))
|
||||||
|
pool.apply_async(ur5_control.camera_to_holder, (arm, arm_updates, idx), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
arm_ready = True
|
||||||
|
mode = "Return"
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
arm_ready = True
|
print(cable_list)
|
||||||
mode = "Return"
|
print("Length:", len(cable_list))
|
||||||
break
|
for idx in range(len(cable_list)-1,-1,-1):
|
||||||
elif cable == scan_value and cable_list_state[idx] == True:
|
cable = cable_list[idx]
|
||||||
fprint("WARNING: Holder still marked as occupied!")
|
if cable is False:
|
||||||
arm_ready = False
|
if real:
|
||||||
if real:
|
animation_wait = True
|
||||||
animation_wait = True
|
ring_animation = idx
|
||||||
ring_animation = idx
|
led_set_mode = "GrabC"
|
||||||
led_set_mode = "GrabC"
|
start_animation = True
|
||||||
start_animation = True
|
cable_list_state[idx] = True
|
||||||
pool.apply_async(ur5_control.camera_to_holder, (arm, arm_updates, idx), callback=arm_start_callback, error_callback=handle_error)
|
fprint("Returning to unused spot " + str(idx))
|
||||||
else:
|
pool.apply_async(ur5_control.camera_to_holder, (arm, arm_updates, idx), callback=arm_start_callback, error_callback=handle_error)
|
||||||
arm_ready = True
|
else:
|
||||||
mode = "Return"
|
arm_ready = True
|
||||||
break
|
|
||||||
|
|
||||||
if mode == "Scan":
|
if mode == "Scan":
|
||||||
|
fprint("Unable to match cable.")
|
||||||
mode = "Idle"
|
mode = "Idle"
|
||||||
else: # camera not ready
|
else: # camera not ready
|
||||||
timecount += 1
|
timecount += 1
|
||||||
@ -1121,6 +1059,85 @@ def mainloop_server(pool, manager):
|
|||||||
# led animation
|
# led animation
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if mode == "IdleWait":
|
||||||
|
if arm_ready is True:
|
||||||
|
mode = "Idle"
|
||||||
|
|
||||||
|
if mode == "Idle":
|
||||||
|
# do nothing
|
||||||
|
if arm_ready is False:
|
||||||
|
mode = "IdleWait"
|
||||||
|
|
||||||
|
else:
|
||||||
|
global mainloop_get
|
||||||
|
|
||||||
|
|
||||||
|
if not mainloop_get.empty():
|
||||||
|
|
||||||
|
action, get_cable = mainloop_get.get()
|
||||||
|
if action == "show":
|
||||||
|
animation_wait = False
|
||||||
|
ring_animation = get_cable
|
||||||
|
start_animation = True
|
||||||
|
led_set_mode = "Show"
|
||||||
|
fprint("Showing cable at position " + str(get_cable))
|
||||||
|
elif action == "shutdown":
|
||||||
|
fprint("SHUTTING DOWN!!")
|
||||||
|
pool.apply_async(ur5_control.move_to_packup, (arm,), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
sleep(30)
|
||||||
|
killme.set(1)
|
||||||
|
elif action == "returnCheck":
|
||||||
|
print("Checking sensors..")
|
||||||
|
if real:
|
||||||
|
newtube = get_full_spot(sensors)
|
||||||
|
else:
|
||||||
|
newtube = -1
|
||||||
|
if newtube is not False and newtube >= 0:
|
||||||
|
# need to return a cable
|
||||||
|
mainloop_get.put(("return", newtube))
|
||||||
|
mainloop_get.put(("returnCheck", 0))
|
||||||
|
else:
|
||||||
|
fprint("Movement requested. Keep clear of the machine!")
|
||||||
|
|
||||||
|
placed = 0
|
||||||
|
arm_distance_total = 0
|
||||||
|
#mqtt_send("{\"value\": " + str(time.time() * 1000) + " }", "cycle_start")
|
||||||
|
cycle_start_time = int(time.time() * 1000)
|
||||||
|
increment_counter()
|
||||||
|
mqtt_send("{\"value\": " + str(1) + " }", "pick_count_total")
|
||||||
|
if get_cable > -1:
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
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"
|
||||||
|
else:
|
||||||
|
# LED idle anim
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def ping(host):
|
def ping(host):
|
||||||
@ -1162,6 +1179,7 @@ def setup_client(pool):
|
|||||||
sleep(0.25)
|
sleep(0.25)
|
||||||
|
|
||||||
fprint("VM online.")
|
fprint("VM online.")
|
||||||
|
sleep(2)
|
||||||
# Windows client setup
|
# Windows client setup
|
||||||
fprint("Running full jukebox control system...")
|
fprint("Running full jukebox control system...")
|
||||||
jb = subprocess.Popen("ssh root@192.168.1.25 -t -- /root/jukebox-software/run.sh".split(' '), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True, encoding='utf-8')
|
jb = subprocess.Popen("ssh root@192.168.1.25 -t -- /root/jukebox-software/run.sh".split(' '), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True, encoding='utf-8')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user