Home Programming

Discussion

Left ArrowBack to discussions page
drpzdrpz Posts: 5 Apprentice
edited June 7 in Programming
Hi,

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!

Comments

  • bcastetsbcastets Vacuum Beta tester Posts: 432 Handy
    @drpz
    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: 432 Handy
    @drpz
    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 8
    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!!

    Program:
     Program
       BeforeStart
         Gripper Reset and Activate
         MoveJ
           Waypoint_1
           Gripper Move50% (1)
           Set MODBUS_6=0
       Robot Program
         Set DO[0]=On
         Cam Locate
           For object(s) found
             var_1≔floor(object_location[0]*1000)
             Set MODBUS_3=var_1
             var_2≔floor(-object_location[1]*1000)
             Set MODBUS_4=var_2
             var_3≔floor(-object_location[2]*1000)
             Set MODBUS_5=var_3
             MoveL
               Approach_Point
               Pick_Point
               'Insert pick action here'
               at_pick
               Gripper Move70% (1)
               Set MODBUS_6=1
               Wait: 0.25
               Retract_Point
           If no object found
             'Optional'<br>

  • bcastetsbcastets Vacuum Beta tester Posts: 432 Handy
    It is supposed to work.

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

    object_location=p[0,0,0,0,0,0]

    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