Based on contributions by How-to, salvacmp.
Doosan robots can read results from a Cognex vision system directly over a TCP socket, without any extra hardware — the robot connects to the camera’s native command interface, logs in, triggers a capture, and reads back the values from a cell in the camera’s job.
What you need
- A Doosan robot
- A Cognex camera, configured with a job that writes results to a table cell
- The camera set to Online Mode (triggering only works in this mode)
- The Doosan and the Cognex camera on the same IP subnet
Steps
1. Configure the connection parameters
port = 10000
ip = "192.168.137.10"
Set
ipto your camera’s actual IP address, and make sure the Doosan controller is on the same subnet.
2. Open a TCP connection to the camera
socket = client_socket_open(ip, port)
3. Log in
After connecting, the camera sends a welcome message and then asks for a username and password:
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "admin\r\n".encode()) # username + carriage return, newline
### asked for a password ###
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "\r\n".encode()) # empty password + carriage return, newline
A successful login returns a logged-in message:
receive = client_socket_read(socket, -1, -1)[1].decode()
4. Trigger the camera
This only works if the camera is in Online Mode.
client_socket_write(socket, "SE8\r\n".encode())
wait(3)
triggerstatus = client_socket_read(socket, -1, -1)[1].decode()[:-2]
if triggerstatus != "1":
tp_log("Trigger failed: " + str(triggerstatus))
return 0
5. Read a cell value
Cell names follow the pattern GVxyyy: x is the column letter, yyy is the row number. For example GVC019 reads cell C19.
cel_data = "GVC019"
client_socket_write(socket, (cel_data + "\r\n").encode())
getvaluestatus, rec, _empty = str(client_socket_read(socket, -1, -1)[1].decode()).split("\r\n")
if getvaluestatus == "1":
rec = str(rec).split(",")
else:
tp_log("GetValue failed: " + str(getvaluestatus))
6. Close the connection
client_socket_close(socket)
Full code
Combining the steps above into one reusable function:
def get_data_from_cognex(cel_data):
### configuration, adjust as needed ###
port = 10000
ip = "192.168.137.10"
### connect to the camera ###
socket = client_socket_open(ip, port)
### camera sends a welcome message and asks for username and password ###
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "admin\r\n".encode()) # username + carriage return, newline
### asked for a password ###
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "\r\n".encode()) # empty password + carriage return, newline
### logged-in message ###
receive = client_socket_read(socket, -1, -1)[1].decode()
### trigger the camera, only works in Online Mode ###
client_socket_write(socket, "SE8\r\n".encode())
wait(3)
triggerstatus = client_socket_read(socket, -1, -1)[1].decode()[:-2]
if triggerstatus != "1":
tp_log("Trigger failed: " + str(triggerstatus))
return 0
wait(1) # extra safety margin, can likely be removed
client_socket_write(socket, (cel_data + "\r\n").encode())
getvaluestatus, rec, _empty = str(client_socket_read(socket, -1, -1)[1].decode()).split("\r\n")
if getvaluestatus == "1":
rec = str(rec).split(",")
else:
tp_log("GetValue failed: " + str(getvaluestatus))
client_socket_close(socket)
return rec
| Input | Type | Description |
|---|---|---|
| cel_data | string | The GVxyyy get-value command. x is the column letter, yyy is the row number of the cell to read — e.g. GVC013 reads cell C13. |
This returns a list of the comma-separated values in that cell. It’s commonly used to get an object’s X/Y position, rotation, and an ID number from the camera in one call. An empty result (['']) means the camera found no valid detection.
7. Use the result, and handle no-detection
X_Y_R = get_data_from_cognex('GVC019')
if X_Y_R == ['']:
tp_popup('No mold detected, please place mold in the detectable square', pm_type=DR_PM_MESSAGE, button_type=1)
return 0
pos_x = float(X_Y_R[0])
pos_y = float(X_Y_R[1])
pos_r = float(X_Y_R[2])
mold_number = int(X_Y_R[3])
See How to show pop-up messages on the Doosan teach pendant with tp_popup for more on tp_popup().
Troubleshooting
- No response after connecting: confirm the robot and camera are on the same IP subnet, and that
ip/portmatch the camera’s actual settings. - Trigger fails: the camera must be in Online Mode — it won’t respond to the
SE8trigger command otherwise. GetValue failed: check that the job on the camera actually writes a value to the cell you’re reading, and that the cell reference (e.g.GVC019) is correct.
Related
Rewritten and consolidated (Sept 2026) from the original student how-to’s: Connect a Cognex camera to a Doosan robot, How to Connect a Cognex camera to a Doosan robot.