Command queue¶
Commands that change the arm state are appended to the firmware command queue and run in order. The DobotLab functions, such as ptp, wait for their own command. These members wait on, pause, and clear the queue.
| Member | Description |
|---|---|
Magician.wait_for |
Block until a queued command has executed. |
Magician.wait_idle |
Block until every command queued by this instance has executed. |
Magician.wait |
Pause the arm. |
Magician.batch |
Queue commands and run them when the block exits. |
Magician.start_queue |
Start executing queued commands. |
Magician.stop_queue |
Pause execution of queued commands. |
Magician.force_stop_queue |
Stop execution immediately. |
Magician.clear_queue |
Remove all queued commands. |
Magician.queued_cmd_current_index |
Read the index of the last executed command. |
Magician.queued_cmd_left_space |
Read the free space in the queue. |
Magician.wait_for¶
Block until the queue has executed the command at index.
Parameters
| Name | Type | Description |
|---|---|---|
index |
int |
Queue index returned by a queued command. |
timeout |
float or None, default None |
Maximum wait, seconds. None waits indefinitely. |
poll |
float, default 0.02 |
Polling interval, seconds. |
raise_on_alarm |
bool, default True |
Raise as soon as any alarm is active. Commands still queued are then discarded. |
Raises
DobotAlarmErrorsubclass: an alarm is active while waiting.DobotTimeoutError:timeoutelapsed.
Example
Magician.wait_idle¶
Block until the queue has executed every command queued by this instance.
Returns immediately if nothing has been queued since connecting or since the last clear_queue.
Parameters
| Name | Type | Description |
|---|---|---|
timeout |
float or None, default None |
Maximum wait, seconds. None waits indefinitely. |
poll |
float, default 0.02 |
Polling interval, seconds. |
raise_on_alarm |
bool, default True |
Raise as soon as any alarm is active. Commands still queued are then discarded. |
Raises
DobotAlarmErrorsubclass: an alarm is active while waiting.DobotTimeoutError:timeoutelapsed.
Magician.wait¶
Pause the arm for second seconds and wait until the pause ends.
Inside batch, the pause is queued and the method returns at once.
Parameters
| Name | Type | Description |
|---|---|---|
second |
float |
Pause duration, seconds. Rounded to milliseconds. |
Returns bool: True.
Magician.batch¶
Context manager that queues commands and runs them when the block exits.
On entry, stops and clears the queue. Inside the block, the DobotLab functions only queue their command. On exit, starts the queue and waits until every command has executed. If the block raises, the queued commands are discarded. Nested blocks take effect only at the outermost level. move_to with wait=True, wait_for, and wait_idle do not return inside the block.
Returns A context manager that yields the Magician instance.
Raises DobotAlarmError subclass: the arm reported an alarm while running the commands.
Example
Magician.start_queue¶
Start executing queued commands.
connect calls this method when auto_start_queue=True.
Magician.stop_queue¶
Pause execution of queued commands.
Queued commands are kept, and new commands can still be queued.
Magician.force_stop_queue¶
Stop execution of queued commands immediately, including the command in progress.
Magician.clear_queue¶
Remove all queued commands.
Magician.queued_cmd_current_index¶
Read the index of the last executed queued command.
Magician.queued_cmd_left_space¶
Read the number of free slots in the firmware queue.