Home Programming


Left ArrowBack to discussions page
drpzdrpz Posts: 5 Apprentice
edited June 2021 in Programming

I'm using Cam Locate to find an object, and would like to write the XYZ coordinates of the object to Modbus, but I'm a little unsure of the syntax. It looks like the XYZ position is stored in Fx, Fy and Fz variables, and I also see Copilot functions like "get_sensor_fx()". I have tried: Set MODBUS_3=Fx or Set MODBUS_3=get_sensor_fx(), but that isn't working. Anyone know how to do this?

I'm also curious to know if someone can explain what these coordinates are offset from, and how to find that?

Thank you!


  • bcastetsbcastets Vacuum Beta tester Posts: 674 Expert
    Fx, Fy and Fz are not coordinates. This is the force apply on each axis.

    You can get the position of the object detected via the variable : object_location
    object_location is a UR waypoint like: P[x,y,z,rx,ry,rz]
    Knowing that you can get the x,y,z position.
    • x=object_location[0]
    • y=object_location[1]
    • z=object_location[2]
  • drpzdrpz Posts: 5 Apprentice
    Thank you for the help and quick reply. 

    This makes sense, but it isn't working. On testing I get an error: "Compile error: name 'object_location' is not defined.

    Any ideas on what I might be doing wrong?
  • bcastetsbcastets Vacuum Beta tester Posts: 674 Expert
    It should be fine.
    Make sure that you call this variable after a camlocate and not before.
    Could you please share your program ?
  • drpzdrpz Posts: 5 Apprentice
    edited June 2021
    Okay, got it. Had to convert the object location to an integer, so I muliplied by 1000 and used the floor function, and in two cases (for y and z) multiplied by -1 to ensure it was positive.

    Thank you!!

         Gripper Reset and Activate
           Gripper Move50% (1)
           Set MODBUS_6=0
       Robot Program
         Set DO[0]=On
         Cam Locate
           For object(s) found
             Set MODBUS_3=var_1
             Set MODBUS_4=var_2
             Set MODBUS_5=var_3
               'Insert pick action here'
               Gripper Move70% (1)
               Set MODBUS_6=1
               Wait: 0.25
           If no object found

  • bcastetsbcastets Vacuum Beta tester Posts: 674 Expert
    It is supposed to work.

    You can eventually define the variable at the beginning of the program.


    For your information, here below is an extract of the camera manual about the object_location variable.

  • drpzdrpz Posts: 5 Apprentice
    It worked great. Thank you for your help!
Sign In or Register to comment.
Left ArrowBack to discussions page