Based on contributions by 19080425, RolandW, sarahstam, ViktorWenemoser1, How-to.
A TCP socket lets a DRL program running on the Doosan controller exchange messages with a Python program running on a PC — for example to receive coordinates from a vision system, or to trigger a move from an external program. This article sets up the basic connection; once it works, see How to send data in a custom format between Python and DRL Studio for sending real data over it.
The Doosan controller runs a very old Python (around version 3.2, from ~2011) inside DRL Studio. Only core standard-library modules work there — no
pip install, no third-party packages (nonumpy,requests, etc.). Keep any code that runs on the robot limited to plain built-ins (socketfunctions provided byDRCF, string methods, basic math). Your PC-side Python has no such restriction and can use any modern Python 3 version and any package.
What you need
- A Doosan collaborative robot and control box, connected to a PC with an Ethernet cable.
- DRL Studio installed on the PC — Doosan’s offline programming tool. Depending on your reseller this may be branded DART Studio.
Check with your supplier which download link is current for your robot; two links have shown up in different how-tos: dormac-cobots.nl and homberger-robotica.com. - Python 3 installed on the PC (any recent version).
- Both devices reachable on the same subnet.
Steps
1. Put the robot and PC on the same network
- On the PC, open a terminal and run
ipconfig(Windows) to find your Ethernet adapter’s IPv4 address. - On the Doosan Teach Pendant (or in DRL Studio’s connection settings), open the network settings and set the robot’s IP address to the same subnet as the PC, with a unique host part.
For example, if the PC is192.168.0.1, set the robot to192.168.0.X(X unique on your network), subnet mask255.255.255.0.
2. Pick a port
A port is a number between 0 and 65535 that identifies the connection on top of the IP address:
- 0–1023 are reserved for standard services (HTTP, HTTPS, FTP, SSH) — don’t use these.
- 1024–49151 are registered with IANA for specific applications.
- 49152–65535 are free for private/dynamic use — pick a number in this range for your own socket connection (the examples below use
56666).
3. Choose which side is the server
A socket connection always has one server (opens a port and waits) and one client (connects to that port). Either the PC or the robot can be the server; both work. Most examples in these how-tos make the PC the server and the robot the client, so that’s the recommended default below. Whichever side is the server must be started first — the client has nothing to connect to otherwise.
4. Recommended setup: PC as server, robot as client
Python (PC) — server:
import socket
HOST = '192.168.0.1' # the PC's own IP address
PORT = 56666
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
print(f"Server is running on {HOST}:{PORT}")
conn, address = s.accept()
print(f"Connection from {address} established!")
# Send a value to the robot
conn.sendall(str(72).encode())
# Receive data from the robot until it stops sending
while True:
data = conn.recv(1024)
if not data:
break
print(f"Received: {data.decode()}")
conn.close()
DRL (robot) — client:
from DRCF import *
IP = "192.168.0.1" # the PC's IP address
PORT = 56666
sock = client_socket_open(IP, PORT)
# Read a value the PC sent
resp, data = client_socket_read(sock, length=4, timeout=60)
received_number = int.from_bytes(data, 'big')
tp_log(str(received_number))
# Send a value back to the PC
client_socket_write(sock, "Received!".encode())
client_socket_read blocks for up to timeout seconds waiting for length bytes; if nothing arrives in that time it raises a timeout. client_socket_write sends bytes back to the server.
5. Alternative setup: robot as server, PC as client
If you’d rather have the robot wait and the PC connect to it, swap the roles:
DRL (robot) — server:
from DRCF import *
PORT = 56666
tp_log("Waiting for connection...")
sock = server_socket_open(PORT)
tp_log("Connected!")
# Read a command from the PC
res, data = server_socket_read(sock)
tp_log(data.decode())
# Send a reply back
server_socket_write(sock, "Received!".encode())
Python (PC) — client:
import socket
HOST = "192.168.0.100" # the Doosan's IP address
PORT = 56666
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Trying to connect...")
sock.connect((HOST, PORT))
print("Connected!")
# Send a command to the robot
sock.sendall("Sending command".encode('utf-8'))
# Receive the reply
data = sock.recv(1024).decode().strip()
print(data)
Run the DRL program on the robot first so its server is listening before the PC script tries to connect.
6. Example: sending a move command and waiting for it to finish
A common pattern is to send coordinates from the PC and have the robot confirm when the move is complete, so the PC knows when it’s safe to send the next command.
Python (PC):
def send_move_command(sock, command: str):
"""Send a command string and block until the robot confirms the move is done."""
try:
sock.sendall(command.encode('utf-8'))
status = ""
while status != "MOVE DONE":
status = sock.recv(1024).decode().strip()
except Exception as e:
print(f"send_move_command error: {e}")
DRL (robot):
def move_robot(sock):
"""Receive 'x,y,z,rx,ry,rz' from the PC and move the robot there.
Make sure nobody is near the robot before sending coordinates."""
res, data = server_socket_read(sock)
data = data.decode()
tp_log("Coordinates: " + data)
values = data.split(",")
x = float(values[0])
y = float(values[1])
z = float(values[2])
rx = float(values[3])
ry = float(values[4])
rz = float(values[5])
movel(posx(x, y, z, rx, ry, rz), 100, 100)
server_socket_write(sock, "MOVE DONE".encode())
Troubleshooting
ModuleNotFoundError: No module named 'DRCF' in DRL Studio. This usually means DRL Studio picked up a broken or conflicting Python installation. Fix:
- Uninstall DRL Studio.
- Uninstall all Python installations on the PC.
- Reboot.
- Reinstall DRL Studio.
If DRL Studio still doesn’t offer the DRCF import when creating a new project, create the project without selecting a Python interpreter — several students found this avoided the problem entirely.
Nothing happens / connection refused. Check that:
- The server side (whichever one you chose) was started before the client side.
- Both devices are on the same subnet and the IP/port in the code match the robot’s and PC’s actual addresses.
- You’re not accidentally using a reserved port (see step 2).
SyntaxError on a line that looks fine. If you copy code from a forum post or a word processor, quotation marks can turn into curly “smart quotes” (“ ”) instead of straight ones ("). DRL’s Python doesn’t accept curly quotes — retype them as straight quotes.
Related
- How to send data in a custom format between Python and DRL Studio — sending real data (numbers, lists) over this connection in a custom format.
- How to control a Doosan robot from Python using the API-DRFL wrapper — an alternative, socket-free way to control a Doosan from Python using a compiled API wrapper.
- How to use force control on a Doosan robot from DRL — using force control once you can move the robot from Python.
- How to save freedrive coordinates as variables on a Doosan robot — saving freedrive coordinates as variables.
Rewritten and consolidated (Sept 2026) from the original student how-to’s: How to establish a socket connection to a doosan robot & a laptop, How to connect to a Doosan robot via TCP connection, How to connect DRL studio and python via sockets, How to Control a Doosan Robot from a PC Server, Connect a Doosan robot to a Python program on a computer.