DobotTCP Library
DobotTCP is a Python library to control the Dobot robot range via its TCP interface. The library provides functions for managing motion, I/O, and configuration of the Dobot robot. It was specially developed with the Dobot Magician E6 in mind.
Installation
Install the library via pip:
pip install DobotTCP
Ensure Python 3.10+ is installed. Install dependencies if not automatically installed:
pip install multipledispatch
Import the library in your project:
from DobotTCP import Dobot
Basic Usage
Example
from DobotTCP import Dobot
# Connect the robot
robot = Dobot(ip="192.168.5.1", port=29999)
robot.Connect()
# Enable robot and parse response
(err, rsp, cmd) = robot.EnableRobot()
print(f" Error code: {err}")
print(f" Response: {rsp}")
print(f" Command: {cmd}")
# Move robot with joint motion to pose (returns once the motion is finished)
robot.MovJ("pose={0,0,0,0,0,0}")
# Home robot
robot.Home()
robot.Disconnect()
Numeric arguments can be given as int or float, e.g. robot.RelMovLTool(10, 0, 0, 0, 0, 0).
Error handling and motion waiting
By default every command that the robot answers with an error raises a DobotError (with code, message and command attributes), and every queued motion command only returns once the robot has finished the motion. With debugLevel > 0 the returned value or error of each command is printed.
from DobotTCP import Dobot, DobotError
robot = Dobot()
robot.Connect()
try:
robot.MoveJJ(0, 0, 0, 0, 0, 0) # Waits until the move is done
except DobotError as e:
print(e.code, e.message)
robot.SetRaiseOnError(False) # Only print errors and return the response tuple
robot.SetWaitForMotion(False) # Return immediately after sending motion commands
robot.WaitForMotion() # Wait manually for the last motion
robot.SetWaitForMotion(True, timeout=60)
A motion counts as finished when the robot is enabled and idle and the current command ID has reached the ID returned by the motion command. Waiting raises a TimeoutError after the timeout (default 30 s) and a RuntimeError if the robot goes into alarm, collision, disabled or power-off status.
Additional move functions
Besides the commands of the TCP protocol, some shortcut functions are included:
robot.MoveJJ(0, 0, -90, 0, 90, 0) # Joint motion to joint angles
robot.MoveJP(300, 0, 200, 180, 0, 0) # Joint motion to pose
robot.MoveLJ(0, 0, -90, 0, 90, 0) # Linear motion to joint angles
robot.MoveLP(300, 0, 200, 180, 0, 0) # Linear motion to pose
robot.MoveOffsetZ(-20) # Linear move 20 mm along tool -Z
robot.MoveOffsetX(15, frame="user") # Linear move 15 mm along user X
MoveOffsetX/Y/Z calculate the target from the current pose with RelPointTool or RelPointUser (default frame: tool) and move there linearly.
Included Classes
Additional classes for robot accessories have been added.
Flexible Gripper
Basic controls for a flexible gripper
from DobotTCP import Dobot, FlexGripper
robot = Dobot()
gripper = FlexGripper(robot)
gripper.Open()
gripper.Close()
Servo Gripper
Basic controls for a servo gripper (IO mode)
from DobotTCP import Dobot, ServoGripper
robot = Dobot()
servo_gripper = ServoGripper(robot)
servo_gripper.SetState(1) # Open
servo_gripper.SetState(2) # Close
print(servo_gripper.GetState())
Sucker
Suction cup on a tool DO with an "adsorbed" signal on a tool DI. ApproachAndAdsorb jogs along tool Z until an object is adsorbed and stops after a safety distance if nothing is picked up.
from DobotTCP import Dobot, Sucker
robot = Dobot()
sucker = Sucker(robot) # Tool DO 1 for suction, tool DI 1 for adsorbed signal
if sucker.ApproachAndAdsorb(speed=3, retract_dist=10, max_dist=50):
# ... move to the place position ...
sucker.Release()
Feedback
This class was implemented to receive feedback from the robot via TCP. Incomplete or misaligned packets are discarded and fetched again automatically.
from DobotTCP import Dobot, Feedback
robot = Dobot()
feedback = Feedback(robot)
feedback.Connect()
feedback.Get() # Optional: Get(retries=5, timeout=1.0)
print(feedback.data.get("RobotType"))
Notes
-
This class was written with the intention to stay as close to the syntax formatting of the original Dobot TCP protocol v4.6.0. (Note, as per 19.11.2026, this PDF is not findable on the Dobot Webpage. The latest version there is still v4.5.2) Therefore, not all python style guides are followed. For example function names start with a capital letter.
-
Since method overloading is not trivial in python, some functions had to be changed in order to make them work in python. This is especially the case for the tray functions.
-
The drag sensitivity command is sent as
DragSensivity, which is the spelling used in the Dobot protocol. The Python method is still calledDragSensitivity.
Version Changelog
- v1.0.0 (17.01.2025): Initial release based on TCP protocol v4.5.0
- v1.1.0 (20.01.2025):
- Update library based on new TCP protocol v4.6.0. Some new commands may require the robot controller version to be updated to V4.6.0.
- Add module docstring and parsing functions
- v1.1.1 (27.01.2025): Various bug fixes
- v1.1.2 (31.01.2025): Fixes bugs when parsing robot responses
- v1.1.3 (16.06.2025): Fixes bug with incorrect init file
- v1.1.4 (27.06.2025): Fixes bugs with Flexgripper class
- v1.1.5 (15.01.2026): Fixes typos in relative motion commands
- v1.1.6 (15.01.2026): Fixes naming mismatch
- v1.2.0 (19.11.2026): Major update. Contains breaking changes, see below.
- New features:
- Motion commands wait until the robot has finished the motion (
SetWaitForMotion,WaitForMotion) - Robot errors raise a
DobotError(SetRaiseOnError). Returned values and errors are printed withdebugLevel > 0 - New
Suckerclass withApproachAndAdsorb(incl. safety distance) andRelease - New offset moves
MoveOffsetX,MoveOffsetY,MoveOffsetZ - New command
FCSetStiffness - Overloaded functions accept
intandfloatarguments
- Motion commands wait until the robot has finished the motion (
- Fixes (checked against TCP protocol v4.6.0):
MovLIOandMovJIOsentMovL/MovJinstead ofMovLIO/MovJIO- Overloads of
EnableRobot(4 and 5 parameters),MovJIOandRelJointMovJcould not be called - Motion commands with
speed/rsent bothvandspeedand bothcpandr. Nowspeedandrare only sent if > 0 SetCoilsdid not send thecountparameterDragSensitivitynow sendsDragSensivity, the command name used in the protocolStartPath,RunTo,ServoJandServoPnow send optional parameters askey=value,ForceDriveModesendsuseras plain value- String parameters of
RunScript,SetPayload,ModbusCreate,ModbusRTUCreateandSetTool485are quoted InverseKinonly sendsuseJointNear/jointNearwhen usedForceDriveSppedrenamed toForceDriveSpeedandRelMovLUsersent a malformedvparameter- Feedback parser was shifted by 2 bytes from
BrakeStatusonwards. AddedHandTypeandSafeState Feedback.Getfailed on incomplete packets. It now reads complete packets, validates them and retries, with timeout- Responses from the robot are read completely (previously a single
recvcould return a partial response) ServoGripper.GetStatenever matched a state
- Other changes:
- Corrected docstrings (ranges, units, defaults, examples) and spelling throughout
FCSetMassandFCSetDampingrotational defaults corrected to 20 and 50setHoldRegsrenamed toSetHoldRegs(old name still works)- Removed duplicate
StopDrag
- Breaking changes:
- Errors now raise a
DobotErrorby default. UseSetRaiseOnError(False)for the previous behaviour - Motion commands now block until the motion is finished. Use
SetWaitForMotion(False)for the previous behaviour Dobot.SetSuckerwas removed. UseSucker(robot).On()/Off()- In the full motion overloads,
speed=0/r=0now means "usev" / "usecp" - Requires Python 3.10+
- Errors now raise a
- New features:
Contributing
Feel free to contribute to the project by submitting issues or pull requests.
License
This project is licensed under the MIT License.
Metadata
Release files for DobotTCP 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dobottcp-1.2.0.tar.gz | 31.0 kB | Without provenance | Details for dobottcp-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dobottcp-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for dobottcp-1.2.0-py3-none-any.whl |
Total release size: 62.6 kB
Release files / dobottcp-1.2.0.tar.gz
| Download URL | dobottcp-1.2.0.tar.gz |
|---|---|
| Size | 31.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b244cde439baf8b80d1f027324eb9d14a859cdc68b1c0a0caf07293ffc294cbf
|
|
BLAKE2b-256 checksum How to use checksums |
c121f670163a21327eb035a3a8de47a0585cd1cd20d6f033b5d3aaec7e7ee6c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.5
|
Release files / dobottcp-1.2.0-py3-none-any.whl
| Download URL | dobottcp-1.2.0-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47b574ba46e7c3c768d509746aa3418a3e18828e5af4e49f08c3762966d1f920
|
|
BLAKE2b-256 checksum How to use checksums |
1eabe685bb6be218003a020366ee863c746e16e3d3e9dfc31b1c55f0c828a92b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.5
|
Security for DobotTCP 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.