Integrated example - DR_VS_CUSTOM
Communication Protocol
The vision system must conform to the following protocol to ensure that vision commands run properly.
vs_request (cmd)
- Robot controller → Vision system
- "MEAS_START" +cmd[4byte]
- cmd refers to the number of detected objects: Conversion of the integer to 4 bytes. ex) cmd=1 → 00000001
- ex) In case of cmd= 1 : “MEAS_START"+00000001
- Acutal packet : 4D4541535F535441525400000001
- Vision system → Robot controller
- "MEAS_OK" is transmitted if the vision system is normal, and "MEAS_NG" is transmitted otherwise.
vs_result()
- Robot controller → Vision system
- “MEAS_REQUEST"
- Vision system → Robot controller
- “MEAS_INFO" +cnt[4byte] +[(x[4byte] + y[4byte] + t[4byte]) x cnt]
- cnt refers to the number of detected objects.
- The transmitted x (x coordinate), y (y coordinate), and t (rotation value) must be scaled up 100 times.
- ex) cnt = 1 , (x=1.1 , y=2.2, t=3.3)
- “MEAS_INFO"+1[4byte] +110[4byte] +220[4byte] +330[4byte]
- Actual packet: 4D4541535F494E464F000000010000006E000000DC0000014A
- ex) cnt = 2 , (x=1.1 , y=2.2, t=3.3) (x=1.1 , y=-2.2, t=-3.3)
- “MEAS_ INFO"+2[4byte] +110[4byte] +220[4byte] +330[4byte]+110[4byte] -220[4byte] -330[4byte]
- Actual packet: 4D4541535F494E464F000000020000006E000000DC0000014A0000006EFFFFFF24FFFFFEB6
- “MEAS_INFO" +cnt[4byte] +[(x[4byte] + y[4byte] + t[4byte]) x cnt]
Example
vs_set_info(DR_VS_CUSTOM)
res = vs_connect("192.168.137.200", 9999) #Vision and communication connection attempt
if res !=0: #Check the result of communication connection
tp_popup("connection fail",DR_PM_MESSAGE) #Upon connection failure, program termination
exit()
ret = vs_request(1) #Request of Vision Measurement Information for No. 1 Object
cnt, result = vs_result() #Get object measurement result information
for i in range(cnt):
x = result[i][0]
y = result[i][1]
t = result[i][2]
tp_popup("x={0},y={1}, t={2}".format(result[i][0], result[i][1], result[i][2]),DR_PM_MESSAGE)