Halcon Vision : Adding your own program¶
1. Halcon driver structure¶
The Halcon drag&bot driver is based on the TCP client(Halcon)/server(drag&bot) communication, where the drag&bot will send the program triggering commands to Halcon and wait for its response.
The flowcharts below show how detect object/tex and get images are working:
1.1 Halcon Global variables¶
The drag&bot Halcon driver is using the global variables to communicate the detection results between the main procedure (communication loop) and the detection programs/procedures. Your program should save its detection data in one of these variables in order to send it to drag&bot
Variable | Type | Description | Structure |
---|---|---|---|
list_2d | global tuple | list to save the detection result in the 2D space | [ Object-1 Type (Int32), Object-1 x-coordinate (float32), Object-1 y-coordinate(float32), Object-1 RZ rotation(float32), Object-2 Type (Int32), Object-2 x-coordinate (float32), Object-2 y-coordinate(float32), Object-2 RZ rotation(float32), ... Object-N Type (Int32), Object-N x-coordinate (float32), Object-N y-coordinate(float32), Object-N RZ rotation(float32) ] |
list_3d | global tuple | list to save the detection result in the 3D space | [ Object-1 Type (Int32), Object-1 x-coordinate (float32), Object-1 y-coordinate(float32), Object-1 z-coordinate(float32), Object-1 RX rotation(float32), Object-1 RY rotation(float32), Object-1 RZ rotation(float32), Object-2 Type (Int32), Object-2 x-coordinate (float32), Object-2 y-coordinate(float32), Object-2 z-coordinate(float32), Object-2 RX rotation(float32), Object-2 RY rotation(float32), Object-2 RZ rotation(float32), ... Object-N Type (Int32), Object-N x-coordinate (float32), Object-N y-coordinate(float32), Object-N z-coordinate(float32), Object-N RX rotation(float32), Object-N RY rotation(float32), Object-N RZ rotation(float32) ] |
list_string | global tuple | list to save the detected string | [detect string] |
global_image | global object | Save your program image in this variable for publishing | - |
2. Adding your Halcon program¶
In order to add your Halcon program into the drag&bot Halcon driver you need to follow below steps.
Step 1: Create your procedure¶
-
From the Procedure menu select Create new procedure
-
Enter your Procedure name.
-
Open your newly created Procedure and copy your program inside it.
-
Declare the global Halcon variables. E.gel. if your procedure is for detecting 2D positions then you need the list_2d and global_image.
-
Just before the return() at the end of your procedure insert the detected data into the global variables. Please take care of the global variable structures and the data sequence inside it when you fill it. Refer to here
Step 2: Add your procedure to the Main loop commands switch¶
- Open the Main Procedure. Add your procedure call inside the required program ID number, for example inside the id condition named as Case of get 2 dimensions objects results.
- Save and run the drag&bot Halcon program.
Note
- For 3D detection program look for Case of get 3 dimensions objects results.
- For Text detection program look for Case of get string result.