Recover from a stop
A stop cuts the arm's motor power wherever it is. The arm loses its home position and moves again only after it recovers. The plate may be in the gripper, at the source, or at the destination.
This script stops a move on purpose, then recovers the way you would after a real stop. You need the SDK installed and the PF400 connector running.
import asyncio
from unitelabs.sdk import AsyncApiClient
ARM = "Brooks PreciseFlex 400" # the connector's name in GroundControl
SLOW = 0 # built-in motion profile, 10% of rated speed
async def wait_for_state(arm, homed=None):
"""The arm's next state, or the next one where Homed equals `homed`."""
states = await arm.information_provider.subscribe_state()
async with states:
async for state in states: # the first event carries no state
if "Homed" in state and (homed is None or state["Homed"] is homed):
return state
raise RuntimeError("The state stream closed without a state")
async def main():
client = AsyncApiClient()
arm = await client.get_service_by_name(name=ARM)
if not (await wait_for_state(arm))["Homed"]:
await arm.movement_controller.home()
# A 100 mm lift. Every axis needs an offset, including the rail on a rail arm
lift = dict(column=100.0, shoulder=0.0, elbow=0.0, wrist=0.0)
suffix = ""
if await arm.information_provider.get_rail_installed():
lift["rail"], suffix = 0.0, "_with_rail"
# Load the action first, so the task below starts the move right away
move_by = await getattr(arm.joint_movement_controller, "move_by" + suffix)
# Start the lift slowly, then stop it partway
move = asyncio.create_task(move_by(**lift, profile=SLOW))
await asyncio.sleep(0.5)
await arm.safety_controller.stop() # halts the arm and cuts motor power
try:
await move
except Exception as error:
print("Move interrupted:", error)
print("After stop:", await wait_for_state(arm, homed=False))
# Recovery re-homes the arm, and the gripper opens and closes again
input("Take out any plate in the gripper, clear the arm's path, then press Enter")
await arm.safety_controller.recover() # clears the fault and re-homes
print("After recover:", await wait_for_state(arm, homed=True))
asyncio.run(main())
Run it with uv run recover_from_a_stop.py. It prints the error from the interrupted move, the
state after the stop with Homed false, and the state after recovery with Homed true.
Stop or cancel
Use stop in an emergency, like an imminent collision or a person in the arm's reach.
To call off a move you no longer want, use cancel_motion. The arm slows to a halt with power on
and the gripper still holding, so there's nothing to recover. It can come to rest near a point on
its path instead of on it, so read its position before the next move.
After a stop in a workflow
Don't retry a transfer automatically after a stop. The workflow can't tell whether the plate is at the source, in the gripper, or at the destination, and repeating the pick-up could drive the gripper into a plate that's already there.
Pause the workflow instead, and let an operator check the arm and put the plate where it belongs. Then recover and continue. Basic Human-in-the-Loop shows how to pause for an operator.
Last updated