Skip to content

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

Magician.send_command(command_id, params=b"", *, write, queued=False) -> Frame

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


Magician.write_command

Magician.write_command(command_id, params=b"") -> Frame

Send a set command that executes immediately.

Returns Frame: the response.


Magician.queue_command

Magician.queue_command(command_id, params=b"") -> int

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

Magician.execute_command(command_id, params=b"") -> bool

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

Magician.read_command(command_id, params=b"") -> Frame

Send a get command.

Returns Frame: the response.

Example

frame = bot.read_command(CommandID.GET_DEVICE_VERSION)
major, minor, revision = frame.params[:3]

Frame

class pydobotlab.protocol.Frame(cmd_id, ctrl, params)

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

class pydobotlab.CommandID(IntEnum)

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

from pydobotlab.protocol import pack_floats

bot.execute_command(CommandID.GET_SET_PTP_COMMON_PARAMS, pack_floats(50.0, 50.0))