Discussion

Left ArrowBack to discussions page
PrasannaPrasanna Posts: 53 Apprentice
Dear @matthewd92,

using the socket, I continuously send and receive the commands from gripper (schunk-wsg model).

Error is (Hope) UR (3e series) buffering the messages.
Example,
socket_send(a)------------> from UR
wait(0.2)
socket_receive(a ack)<----------to UR
socket_send(b)
wait(0.2)
socket_receive(b ack)
socket_send(c)
wait(0.2)
socket_receive(c ack)

but Instead sometimes
socket_send(a)------------> from UR
wait(0.2)
socket_receive(a ack)<----------to UR
socket_send(b)
wait(0.2)
socket_receive()   "Receive Nothing"
socket_send(c)
wait(0.2)
socket_receive(b ack)

1. is there any way to wait for receive command. 
2. is there any way to check receive command
3. is there any way to clear the buffer and receive the current one.

Also am receiving
"a=4"
i need to compare this integer value.......please let me know how to do it

Comments

  • matthewd92matthewd92 Posts: 948Founding Pro, Tactile Sensor Beta Testers Handy
    First off I would remove the waits between the send and receive, that way the server can send it immediately back and I’m ready to receive.  Also, if you look in the script manual you will see that all of the read methods for a socket have an optional timeout parameter, per the docs if you set the timeout to 0 it will not return until a value is received which means the code will sit there until the read happens. You could also set the timeout to some number of seconds and then use the first item returned in the read value is the number of elements returned, if it’s 0 then you know a read did not occur, or an empty string if you are reading a string. 

    The default for the timeout is 2 seconds as well.  

    As as far as comparison in URScript you would use the == operator 

    local a = socket_read_binary_integer(2,”socket_name”, timeout=5)

    # I requested two integers so by saying 3 I know I received 2 integers plus the length of the return value, so below if the first element is equal to 3 then process the data. 

    if a[0] == 3: 
      local width=a[1]
      local force=a[2]
    else:
      local width=0
      local force=0
    end
     
Sign In or Register to comment.
Left ArrowBack to discussions page