Home› Programming
Discussion
Back to discussions page
jensss
Posts: 23 Apprentice
control simulation with python |
264 views
|
Answered | |
/ Most recent by jelms
in Programming
|
10 comments |

in Programming
dear
I would like to control my UR5 with a python program. At the moment I'm trying it out with the ursim. This is part of my bachelor's thesis. And since I can't do an internship right now, I want to realize this through the simulation. On pc 1 I make the program and send it to pc 2.
I can connect to the simulation through a socket connection. When I forward my python program, I don't get any error on my python program. I do get feedback. But the robot on my simulation does not move.
Do you know how this happened? Do I need to program something on my cobot to listen to my pc 1?
Attached you find my program and the feedback I get.
Thank you in advance for your time & answer.
yours sincerely
https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/overview-of-client-interfaces/
Controlling UR via client interface is frequently used,
UR also have a ROS package to control the robot. That may be interesting for you.
http://wiki.ros.org/action/show/universal_robots?action=show&redirect=universal_robot
Also when you get to sending programs textmsg is useful in debugging. With the simulator you can also open a terminal and look at ~/ursim-current/URControl.log and ~/ursim-current/log_history.txt (the log_history.txt contains the messages from the log tab although messaged aren't always flushed to log_history, you can force it by using the clear button on the log tab).
I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.
With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).
I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.
With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).
# Echo-clientprogramma
import socket
import time
host = "192.168.56.104" # De externe host
port = 30002 # Dezelfde poort als gebruikt door de server
print ('Startprogramma')
tel = 0
data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')
while (tel < 1):
s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)
s.connect((host, port))
time.sleep(0.5)
s.send(data)
time.sleep(5)
tel = tel+1
time.sleep(1)
data = s.recv(1024)
s.close()
print ("Received", repr(data))
print ("Status data received from robot")
I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.
With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).
# Echo-clientprogramma
import socket
import time
host = "192.168.56.104" # De externe host
port = 30002 # Dezelfde poort als gebruikt door de server
print ('Startprogramma')
tel = 0
data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')
while (tel < 1):
s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)
s.connect((host, port))
time.sleep(0.5)
s.send(data)
time.sleep(5)
tel = tel+1
time.sleep(1)
data = s.recv(1024)
s.close()
print ("Received", repr(data))
print ("Status data received from robot")
I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.
With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).
# Echo-clientprogramma
import socket
import time
host = "192.168.56.104" # De externe host
port = 30002 # Dezelfde poort als gebruikt door de server
print ('Startprogramma')
tel = 0
data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')
while (tel < 1):
s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)
s.connect((host, port))
time.sleep(0.5)
s.send(data)
time.sleep(5)
tel = tel+1
time.sleep(1)
data = s.recv(1024)
s.close()
print ("Received", repr(data))
print ("Status data received from robot")