wait¶
Runs in the client Sends nothing to the robot
Wait until the robot's status meets a condition of your own. predicate receives the latest status the robot sent: the dict latest_status() returns, with keys such as mode, state, homed, err, errors, exec_paused and control_holder. The call returns once predicate returns a true value. It checks it at once, then each time a new status arrives: the robot sends its status when it changes, checking 50 times a second. It sends no command. wait_mode(), wait_enabled(), wait_homed() and wait_error_reset() are built on it.
Syntax¶
Arguments¶
| Name | Type | Default | Description |
|---|---|---|---|
predicate |
Callable[[dict], bool] |
required | A function that takes the status dict and returns a true value when the wait is over. Read it with s.get(...): before the first status arrives the dict is empty. |
timeout |
float | None |
10.0 |
Seconds to wait at most. None waits as long as it takes. |
what |
str |
'wait' |
A name for the wait in the RobotTimeout message, which reads " |
Returns¶
Nothing.
Examples¶
robot.wait(lambda s: s.get("state") == "ENABLED" and s.get("homed"))
robot.wait(lambda s: not s.get("exec_paused"), timeout=30,
what="wait_resumed")
Further details¶
Note
predicate gets a copy of the status, and the client takes in no new
status until it returns: keep it short, and do not send commands from
it. An exception it raises ends the wait and reaches the caller.
Exceptions¶
RobotTimeout:predicatewas not true withintimeout.RobotConnectionError: The client is not connected, or lost its connection while waiting.