Discussion

Left ArrowBack to discussions page
danield271danield271 Posts: 11 Apprentice
Hi, 
I'm trying to receive 4 different parameters from a cognex camera. using the The UR10e cobot. This one should receive four double value of X,Y,R,P(X and Y means the pixel coordinate value of target object from camera, and R means the rotation degree of target object, and P means the match percent of target object). I'm using the code provided by UR (https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/vision-system-with-the-robot-15576/) but this doesn't work. I'm able to open the socket but I'm not  4 logical values (see attached photo).
Thanks for your help.  

Comments

  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    Which Cognex camera are you using?  Not all of the cameras have a socket server on them, you need a camera with a socket server. Also, I do not see any attached photos. 
  • danield271danield271 Posts: 11 Apprentice
    Thanks Matthew. The model number of my camera is 8402. I attach some photos. I tested the communication between camera-computer and robot-computer as you can see in the photos. 
  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    edited September 20
    What is on the communication tab on Cognex Easy-builder?

    also how is your data string that is returned structured on the camera?
  • danield271danield271 Posts: 11 Apprentice
    I'm attaching a screenshot of the communication tab on Cognex-Easy-builder. On the other hand, I'm sending 4 different floating ppoint values from the camera (x,y,angle and score, Screenshot attached), I also tried sending these values as string values but the result was the same.  
  • danield271danield271 Posts: 11 Apprentice
    edited September 20
    I just realized that during the first seconds I can receive data but then my variable (var 1) is empty (screenshots attached). This is my program: 

     Program
       Init Variables
       BeforeStart
         conn≔ False 
         Loop conn≟ False 
           conn≔socket_open("10.10.10.10",3000,"socket0")
           Wait: 0.02
       Robot Program
         socket_send_byte(15,"socket0")
         socket_send_byte(10,"socket0")
         var_1≔socket_read_string("socket0")
         var_2≔socket_read_ascii_float(4,"socket0")
         Wait: 0.2

  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    Couple of questions.  Are you sending byte 15 and byte 10 as the trigger for the camera?  I believe there has to be brackets in the leading and trailing text fields on the format string as you are trying to send in a list of values but I could be wrong, its been a while since I last set up a Cognex using easy builder and I can't get my system to let me open a file without the camera plugged in which is at the customer site.

    Also, have you looked at just using the URCap that Cognex has?  Assuming that you are using the camera for pick and place and not some other task.  It allows you to calibrate the camera to the robot and then use robot guidance with the cap to communicate.  You can find information on the cap at https://www.cognex.com/programs/urcap-solution
  • danield271danield271 Posts: 11 Apprentice
    I'm sending 15 and 10 just as carriage return and newline commands. On the other hand, I already tested the cognex URcap tool and it worked well but it's limited just to one guidance and I need to identify two different elements (screws and nuts). 
  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    Ah, so if you aren’t triggering the camera each time you want to read the server quits sending out responses after a certain time out period. UR by default gives the server 2 seconds to send a packet after which it times out and returns an empty string. How is the camera being triggered?
  • danield271danield271 Posts: 11 Apprentice
    I'm triggering the camera manually clicking on the trigger button on In-sight several times. If I use the commands provided by UR in order to get a snapshot (sending the string r and the byte 13), my variable (var1) keeps the same behaviour (I see some data for the first seconds and then it becomes empty).  This is the program modified: 

     Program
       Init Variables
       BeforeStart
         conn≔ False 
         Loop conn≟ False 
           conn≔socket_open("10.10.10.10",3000,"socket0")
           Wait: 0.02
       Robot Program
         socket_send_byte(15,"socket0")
         socket_send_byte(10,"socket0")
         socket_send_string("r","socket0")
         socket_send_byte(13,"socket0")
         var_1≔socket_read_string("socket0")
         Wait: 0.2


    Any idea about the real commands I have to send to the in-sight in order to get a snapshot? 
  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    Let me see if I can find it, we usually just run in continuous snapshot mode. You could try that just to see if that starts sending data reliably. 
  • danield271danield271 Posts: 11 Apprentice
    HI Matthew, I just tested it using the continuous snapshot mode and the problem is the same, after 3 seconds the variable is completely empty.
  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    That is very strange behavior, if I get some spare time today I will try to test a spare camera that we have lying around here.
  • danield271danield271 Posts: 11 Apprentice
    I'm now receiving the data constantly in my variable after running my job in continuous mode. The only way to extract the coordinates from the camera was using the command "socket_read_string("sockect0") instead of "socket_read_ascii_float(4,"socket0")".  Now, I have two problems: 1) I need to transform this string variable into a integer vector. 2) Once I have X, Y and the angle given by the camera, how can I transform this camera goal position into a robot goal position.
  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    Have you tried putting the [ and ] brackets before and after the string you are compiling on the robot?  
  • danield271danield271 Posts: 11 Apprentice
    I just tried but it didn't work. 
  • GiannakakisGiannakakis Posts: 2 Recruit
    Hello to all.  I think the most important is the settings on camera too.

  • GiannakakisGiannakakis Posts: 2 Recruit
    On the settings of The camera leave the Server Host Name  blank . Then the Camera run as server .

  • danield271danield271 Posts: 11 Apprentice
    Thank you so much for your comments, the problem was related to the login of the camera. UR must send"admin" as the username and ""(void) as the password. These 2 messages need to be followed by a line feed and carriage return (13 and 10).
  • matthewd92matthewd92 Posts: 964Founding Pro, Tactile Sensor Beta Testers Handy
    @danield271 thanks for the update!
Sign In or Register to comment.
Left ArrowBack to discussions page