Add shutdown routine

This commit is contained in:
Cole Deck 2024-07-29 13:50:58 -05:00
parent 4591dc6900
commit 0ad656728d
2 changed files with 12 additions and 2 deletions

13
run.py
View File

@ -338,6 +338,9 @@ def check_server():
elif call == 'request': elif call == 'request':
if "position" in data: if "position" in data:
mainloop_get.put(("show", data["position"])) mainloop_get.put(("show", data["position"]))
case "shutdown":
mainloop_get.put(("shutdown", 0))
case _: case _:
fprint("Unknown/unimplemented data type: " + decoded["type"]) fprint("Unknown/unimplemented data type: " + decoded["type"])
except Exception as e: except Exception as e:
@ -571,7 +574,7 @@ def mainloop_server(pool, manager):
print(ring_animation, animation_wait, ledsys.mode, arm_position) print(ring_animation, animation_wait, ledsys.mode, arm_position)
if start_animation: if start_animation and real:
# animation start requested # animation start requested
# may not be immediate # may not be immediate
if ring_animation is not None: if ring_animation is not None:
@ -601,7 +604,7 @@ def mainloop_server(pool, manager):
else: else:
# no new animation # no new animation
if ring_animation is not None: if ring_animation is not None and real:
ledsys.mainloop(None, ring_animation, arm_position=arm_position) ledsys.mainloop(None, ring_animation, arm_position=arm_position)
else: else:
@ -790,6 +793,12 @@ def mainloop_server(pool, manager):
ring_animation = get_cable ring_animation = get_cable
start_animation = True start_animation = True
led_set_mode = "Show" 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)
else: else:
fprint("Movement requested. Keep clear of the machine!") fprint("Movement requested. Keep clear of the machine!")

View File

@ -266,6 +266,7 @@ def move_to_home(robot, keep_flip=False, speed=2):
return True return True
def move_to_packup(robot, speed=0.25): def move_to_packup(robot, speed=0.25):
robot = connect(robot)
rob = robot.robot rob = robot.robot
# known good starting point to reach store position # known good starting point to reach store position