Commit 6a43a113 authored by Emil Madsen's avatar Emil Madsen
Browse files

Implemented functions "load_program(name)", "play_program", and "stop_program".

parent 8cf999b5
......@@ -13,6 +13,14 @@ class RobotLiveTests(unittest.TestCase):
ur5e.start_recording(filename=f'randomMotion.csv')
ur5e.stop_recording()
def test_program_load_start_stop(self):
ur5e = RobotConnection("192.168.56.101") # VirtualBox
print(f"load succeeded? {ur5e.load_program('Simple_Motion.urp')}")
time.sleep(1.0)
print(f"play succeeded? {ur5e.play_program()}")
time.sleep(5.0)
print(f"stop succeeded? {ur5e.stop_program()}")
def test_movej(self):
# ur5e = RobotConnection("192.168.56.101") # VirtualBox
ur5e = RobotConnection("192.168.12.245") # Robot @ DeepTech
......
......@@ -90,9 +90,20 @@ class RobotConnection:
self._send_ascii_bytes(program, self.controller_socket)
self._ensure_ready()
def stop_motion(self):
def load_program(self, program_name):
self._send_ascii_bytes(f"load {program_name}\n", self.dashboard_socket)
return self.dashboard_socket.recv(1024).decode().startswith("Loading program: ")
def play_program(self):
self._send_ascii_bytes("play\n", self.dashboard_socket)
msg = self.dashboard_socket.recv(1024).decode()
if not msg.startswith("Starting program"):
print(f"{msg}Make sure that the robot is positioned in the starting position of the program or auto-initialize as described in: https://www.zacobria.com/universal-robots-knowledge-base-tech-support-forum-hints-tips/knowledge-base/auto-load-program/")
return msg.startswith("Starting program")
def stop_program(self):
self._send_ascii_bytes("stop\n", self.dashboard_socket)
return self.dashboard_socket.recv(1024).decode() == "Stopped"
return self.dashboard_socket.recv(1024).decode().startswith("Stopped")
def record_samples(self, config_file='resources/record_configuration.xml', filename='robotdata.csv', overwrite=False,
frequency=500, samples=10, rtde_port=30004, RtdeConstructor=rtde.RTDE):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment