Discussion

Left ArrowBack to discussions page
VT_340VT_340 Posts: 23 Apprentice
Hi!

I would like to know how to get data (e.g a X/Y Variable position from a sensor outside the robot) via TCP into the robotic program?

In general this is described here:

http://www.zacobria.com/universal-robots-zacobria-forum-hints-tips-how-to/script-tcp-socket-test/

But I don't feel like to remake this huge program within the PolyScope GUI. Lets say for testing I just want to send a variable from my computer (e.g via Python) to the robot that I can check their value within the "Variables" tab. In a second step I want to make the robot move to positions given by the variables.

I was succsellful in sending complete move commands to the robot via Python but I want to use the advantage of the GUI which means easy programming but insert changes from the computer.

Thanks,


Hans

Best Answer

Comments

  • matthewd92matthewd92 Posts: 813Founding Pro, Tactile Sensor Beta Testers Handy
    edited April 2017
    There are two ways to do it, set up a socket server or xmlrpc server on your computer. Then within URScript you would request a value and then assign the return to a variable. XMLrpc is definitely more performant than socket commands. Also it's only one command to ask and receive a value. With a socket server you'd have to request the value you want then listen for the return with a separate command. 

    If you need more specifics on how to implement let me know and I can setup a simple demo when I'm home tomorrow. 
  • matthewd92matthewd92 Posts: 813Founding Pro, Tactile Sensor Beta Testers Handy
    @louis_bergeron that's something I'll have to remember!  Thanks for the example
  • VT_340VT_340 Posts: 23 Apprentice
    Hi!
    Thanks Louis for your example script.
    So far I just sent the move command via TCP on Port 30002 and this works like charm. As I am not into Modbus I would rather use ordinary TCP socket. Another thing is: How can I get the code into Polyscope? I just can open .urp data.

    Thanks,

    Hans
  • matthewd92matthewd92 Posts: 813Founding Pro, Tactile Sensor Beta Testers Handy
    @VT_340 if you are running a polyscope program and then send a move command to that port your main program should stop running. You can only send secondary programs that do not control motion while a primary program is running.  You should test just making a simple polyscope program, start it and then send the move command, pretty certain it will stop as the server always processes the last program sent to the server. Same as if you sent a move and before that was done sent a different move. It would stop executing the first to execute the second prior to completing the first program. 
  • mariem_werfelli22mariem_werfelli22 Posts: 13 Apprentice
    edited April 4
    Hi!
    how to receive data from a server to the client ? i know the comand "socket_read_ascii_float(4)" i got as a received data(receiveFromServe:=[6.0,0.0,0.0,0.0,0.0] then after less than a second it's change to [0.0,NAN,NAN,NAN,NAN] i don't undesrtand what is the problem i need help 

  • matthewd92matthewd92 Posts: 813Founding Pro, Tactile Sensor Beta Testers Handy
    Are you doing that in a loop or thread by any chance?
  • mariem_werfelli22mariem_werfelli22 Posts: 13 Apprentice
    Hi Matthew!
    yes it's a loop the new error noww is "getInverse: the function did not find a solution" maybe 
    I need a loop that allows me to continue the initial loop even if there is an error
  • matthewd92matthewd92 Posts: 813Founding Pro, Tactile Sensor Beta Testers Handy
    Just validate the data you received, the first position in the list returned tells you how many responses there were, if its 0, you know you have bad data ask for it again.

    Are you sending the distances back in mm or m?  The robot needs meters and radians to work, that gets me sometimes.
  • mariem_werfelli22mariem_werfelli22 Posts: 13 Apprentice
    edited April 5

    so what should I do the problem appeared when I changed the values ​​I sent from 0 to 30 or any other number here is what i'm talking about 



                          
  • matthewd92matthewd92 Posts: 813Founding Pro, Tactile Sensor Beta Testers Handy
    You could either send 0.03 instead of 30 (either enter it that way or between the input and the send convert it), or you will need to divide each array element by 1000 before using them.
  • mariem_werfelli22mariem_werfelli22 Posts: 13 Apprentice
    Hi Mathew !
     it works, 
    my new problem is that I want that when I change the values ​​of x and y and R the robot moves according to these coordinates i don't know it's not how to do that
Sign In or Register to comment.
Left ArrowBack to discussions page