How to connect to a Doosan robot via TCP connection

1. Requirements

You’ll need these parts to connect to a Doosan robot:

  • Ethernet cable
  • Windows Computer with ethernet port
  • Python interpreter (I’ve used python version 3.13.2, but should work with supported python version)
  • At least one from the following to write code on the Doosan itself:
    • DART Studio (Recommended)
    • Doosan Robot Teach Pendant

Software versions:

The Doosan runs on DRL (Doosan Robot Language) but works largely like Python version 3.2 and could use most of its libraries.

2. Setup

Now that we’ve got all the parts, we are going to make sure that both your computer and the Doosan are ready to pair. Connect the Doosan to your computer with the ethernet cable.

IP Addresses:

First, make sure the robot is on the same IP address as your computer. To check the IP of your computer, open a terminal and execute:

ipconfig

In the list that follows, find the IPv4 address under “Ethernet adapter Ethernet” and mark it down.

Now open the Network settings on the Doosan Robot (e.g., via the Teach Pendant) and change its IP address to one in the same network as your computer.

For example, if your computer has IP address 192.168.0.1, change the Doosan IP to 192.168.0.X, making sure X is a unique number in your network. Set the subnet mask to 255.255.255.0.

Connection:

The Doosan is now on the same network as your computer, so now we must open a server on the robot for your computer to connect to. For this step, DART Studio is recommended, as programming on the teach pendant is hell.

For the Doosan:

from DCRF import *
# Socket port
PORT = 56666
# Open socket connection
tp_log("Waiting for Connection!")
sock = server_socket_open(PORT)
tp_log("Connected!")

For your computer:

import socket

host = “192.168.0.100” # Example IP for the Doosan
port = 56666 # Same port as the Doosan
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print(“Trying to connect”)
sock.connect((host, port))
print(“Connected!”)

Make sure to run the Doosan program before running the computer script, because otherwise the computer has nothing to connect to.

Communication:

The connection is now made, so we are ready to send commands back and forth.

For the Doosan:

# Read a command from the computer
res, data = server_socket_read(sock)
data = data.decode()
tp_log(data)

# Send a command back
server_socket_write(sock, “Received!”.encode())

For your computer:

# Send a command to the Doosan
sock.sendall(“Sending command”.encode(‘utf-8’))

# Receive a command back
data = sock.recv(1024).decode().strip() # strip not necessary but gets rid of accidental whitespace
print(data)

3. Examples:

A few examples to get you started :blush:

1. sendMoveCommand (computer)

# This function sends the given command (like coordinates 
# that the Doosan should move to), and waits until the robot sends the command “MOVE DONE” back, indicating that a new command is ready to be sent.
def sendMoveCommand(command:str):
    try:
        sock.sendall(command.encode('utf-8'))

        status = ""
        while status != "MOVE DONE":
            status = sock.recv(1024).decode().strip()
    except Exception as e:
        print(f"sendMoveCommand Error: {e}")

2. moveRobot (Doosan)

# This function receives a command (like a string of coordinates “x, y, z, rx, ry, rz”) 
# from the computer, processes the string and moves the robot to those coordinates. 
# Make sure to safely send the coordinates and do not move the robot while others are near it.

def moveRobot():
	data = None
	res, data = server_socket_read(sock)
	data = data.decode()
	tp_log(“Coordinates: “ + data)

	# Creates a list of coordinates from a string of coordinates
	data = data.split(“,”).strip() 
	# Convert the list of coordinate strings to usable numbers
	x = float(data[0])
	y = float(data[1])
	z = float(data[2])
	rx = float(data[3])
	ry = float(data[4])
	rz = float(data[5])

	# Move the robot
	tp_log("TrapEye coordinates: " + ", ".join([str(x), str(y), str(z), str(rx), str(ry), str(rz)]))
	movel(posx(x, y, z, rx, ry, rz), 100, 100)
	
	# Send the “MOVE DONE” command
	server_socket_write(sock, “MOVE DONE”.encode())	
    movel(posx(x, y, z, rx, ry, rz), 100, 100)
	
	# Send the “MOVE DONE” command
	server_socket_write(sock, “MOVE DONE”.encode())
2 Likes