SintefManufacturing / python-urx

Python library to control a robot from 'Universal Robots' http://www.universal-robots.com/
GNU Lesser General Public License v3.0
526 stars 275 forks source link

How to get continuous tcp_pose? #59

Open EdXian opened 5 years ago

EdXian commented 5 years ago

Hi all, The following is my test code

import urx
import logging

if __name__ == "__main__":
    logging.basicConfig(level=logging.WARN)

    rob = urx.Robot("192.168.50.50")
    #rob = urx.Robot("localhost")

while True:
    try:
       pose = rob.get_pose()
       print(pose)
       print("============================")            
    finally:
        rob.close()

image

I found that the pose is fixed all time eventhough I changed the position of the tcp. How do I get the realtime position data of the tcp? thanks!!

ALharchi commented 5 years ago

I think because you close the connection every iteration. How about this?

import time
while True:
    try:
        pose = rob.get_pose()
        print(pose)
        print("============================")   
        time.sleep(0.05)
rob.close()