on_motion_error¶
Runs in the client Sends nothing to the robot
Set a function to call when a queued command of this client fails. The function is called as soon as a command this client queued fails after the robot accepted it, STOPPED and ABORTED included. It receives a dict with id (the value the queued call returned), code and message, and the error catalog's number, title and fix when the robot sent them. The next wait_idle() reports the same failure as MotionFailed, unless this client's stop() discards it first or a call already raised it; this function lets a program react at once.
A command the robot refused when it was sent raises in its own call instead. The failures a lost connection causes reach it too, with the code CONNECTION_LOST, or DISCONNECTED after disconnect(). A client has one such function: a new call replaces it, and None removes it.
Syntax¶
Arguments¶
| Name | Type | Default | Description |
|---|---|---|---|
fn |
Callable[[dict], None] |
required | The function, called with the failure dict. None removes it. |
Returns¶
Nothing.
Examples¶
failures = []
robot.on_motion_error(failures.append)
robot.move_joints(90, -105, 165, 0, -30, 180)
robot.wait_idle(raise_on_error=False)
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.