Low-level commands¶
Send protocol commands that have no dedicated method. Command IDs and parameter layouts are listed in the Command ID table.
| Member | Description |
|---|---|
Magician.send_command |
Send a command and return the response. |
Magician.write_command |
Send an immediate set command. |
Magician.queue_command |
Queue a set command. |
Magician.execute_command |
Queue a set command and wait until it executes. |
Magician.read_command |
Send a get command. |
Frame |
Decoded protocol frame. |
CommandID |
Protocol command IDs. |
| Parameter packing | Encode and decode parameter bytes. |
Magician.send_command¶
Send a command and return the response.
Queued commands sent with this method are not tracked by wait_idle. Use queue_command instead.
Parameters
| Name | Type | Description |
|---|---|---|
command_id |
CommandID or int |
Command ID. |
params |
bytes, default b"" |
Parameter bytes. |
write |
bool |
True for a set command, False for a get command. |
queued |
bool, default False |
Add the command to the firmware queue. |
Returns Frame: the response.
Raises
DobotConnectionError: the instance is not connected.
Magician.write_command¶
Send a set command that executes immediately.
Returns Frame: the response.
Magician.queue_command¶
Add a set command to the firmware queue.
The index is tracked by wait_idle.
Returns int: queue index of the command.
Magician.execute_command¶
Queue a set command and wait until the arm has executed it, as the DobotLab functions do.
Inside batch, the command is only queued.
Returns bool: True.
Raises DobotAlarmError subclass: the arm reported an alarm.
Magician.read_command¶
Send a get command.
Returns Frame: the response.
Example
Frame¶
Decoded protocol frame. Immutable.
| Attribute | Type | Description |
|---|---|---|
cmd_id |
int |
Command ID. |
ctrl |
int |
Control byte. |
params |
bytes |
Parameter bytes. |
rw |
bool |
True for a set command. |
is_queued |
bool |
True if the queued bit is set. |
The frame layout is described in Frame format.
CommandID¶
Protocol command IDs, for example CommandID.GET_POSE (10). The full list is in the Command ID table.
Parameter packing¶
Functions in pydobotlab.protocol. All use little-endian byte order.
| Function | Description |
|---|---|
pack_u8(*values) |
Pack unsigned 8-bit integers. |
pack_u16(*values) |
Pack unsigned 16-bit integers. |
pack_u32(*values) |
Pack unsigned 32-bit integers. |
pack_u64(value) |
Pack one unsigned 64-bit integer. |
pack_floats(*values) |
Pack 32-bit floats. |
unpack_floats(data) |
Unpack 32-bit floats into a tuple. |
unpack_u64(data) |
Unpack one unsigned 64-bit integer. |
Example