Skip to content

on_motion_complete

Runs in the client Sends nothing to the robot

Set a function to call when a queued command of this client finishes. The function receives the command's id, the value the queued call returned, each time a command this client queued finishes: a move, a delay, or a gripper command once the jaws have settled. Other clients' commands do not call it, nor do failed ones: see on_motion_error().

It runs on the callback thread, so wait_motion_complete() and wait_idle() can return before it has run. A client has one such function: a new call replaces it, and None removes it.

Syntax

robot.on_motion_complete(fn)

Arguments

Name Type Default Description
fn Callable[[str], None] required The function, called with the command id. None removes it.

Returns

Nothing.

Examples

done = []
robot.on_motion_complete(done.append)
robot.move_joints(90, -105, 165, 0, -30, 180)
robot.wait_motion_complete()

Further details

Note

The function runs on the client's callback thread, one call at a time, in the order the events arrived, so a command or a wait called from it works. Keep it short: the next events wait for it. If the function raises, the client prints the exception and goes on.

See also