Python Script to Control movements of cobot

The below code works perfectly without any problem. The problem I find is the movement is not smooth. If I remove the time between commands the robot does not moves. The python code does not behaves like the pendant. Is there a way not to use the timer in between commands, and movements are smooth.

import socket
import time
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_socket.connect((“10.232.49.5”, 30002))
tcp_command = ‘set_digital_out(2, True)\n’
tcp_socket.send(str.encode(tcp_command))
time.sleep(3)

#global Waypoint_1_q = [-0.07097226778139287, -2.0622245273985804, 2.2466591040240687, -1.7546187839903773, -1.562280003224508, -0.05255490938295537]

start_point = “movel([-0.07097226778139287, -2.0622245273985804, 2.2466591040240687, -1.7546187839903773, -1.562280003224508, -0.05255490938295537], a=1.2, v=0.1)\n”
tcp_socket.send(str.encode(start_point))
time.sleep(3)

approach = “movel([0.04418822377920151, -1.6160809002318324, 2.214836899434225, -2.1689473591246546, -1.5629714171039026, 0.06623820215463638], a=1.2, v=0.1)\n”
tcp_socket.send(str.encode(approach))
time.sleep(3)

Waypoint_2 = “movel([0.02882671356201172, -1.4694293302348633, 2.212179485951559, -2.312949319879049, -1.5635736624347132, 0.05195114389061928], a=1.2, v=0.05)\n”
tcp_socket.send(str.encode(Waypoint_2))
time.sleep(3)

tcp_command = ‘set_digital_out(2, False)\n’
tcp_socket.send(str.encode(tcp_command))

tcp_socket.close()

i would recommend against sending encoded commands like that as RTDE control and receive interface handles such for you and you dont need random sleeps as such

Check out my UR Robot Controller on GitHub.

It contains a function called run_program to send bulk lines of code in interpreter mode, so movements calculated in python can be run smoothly on UR. I takes the commands not encoded as list and send them.

This controller use all open ports of the Robot as RTDE, Control, Dashboard, Interpreter to grant best performance of all functions of the robot.

Hi,
What you describe is not a good way to control our robots remotely. Once upon a time it was the method to use but it has problems and the better approach is to use RTDE natively OR, some 3rd party SDK that does this for you OR, interpreter mode as someone else has advised.

The best place to start understanding what the options are is here :
Developer Network
And, more specifically this article :
Five ways to program a cobot
And, on the subject of 3rd party client libraries :
Client libraries for external monitoring and control

And finally, this article talks about all the various native interfaces and provides some examples :
Remote operation of robots
(see RemoteOperationGuideV1.1.pdf - read this thoroughly)