Welcome to JetCobot repository
7.apriltag sorting
apriltag sorting
1. apriltag sorting instructions
The file path for robot arm position calibration is ~/jetcobot_ws/src/jetcobot_color_identify/scripts/XYT_config.txt.
After calibration, restart the program and click the calibration mode to automatically read the file information, reducing repeated calibration actions.
2. About code
Code path:~/jetcobot_ws/src/jetcobot_apriltag/scripts/apriltag_sorting_stacking.ipynb
~/jetcobot_ws/src/jetcobot_utils/src/jetcobot_utils/grasp_controller.py
Since the camera may have deviations in the position of the building block, it is necessary to add deviation parameters to adjust the deviation value of the robot arm to the recognition area.
The type corresponding to apriltag sorting and apriltag stacking is "apriltag", so it is necessary to change the offset parameter under type == "apriltag".
The X offset controls the front and back offset, and the Y offset controls the left and right offset.
x# Get the XY offset according to the task typedef grasp_get_offset_xy(self, task, type):offset_x = -0.012offset_y = 0.0005if type == "garbage":offset_x = -0.012offset_y = 0.002elif type == "apriltag":offset_x = -0.012offset_y = 0.0005elif type == "color":offset_x = -0.012offset_y = 0.0005return offset_x, offset_y
The coordinate value of the color area to be placed.
If the coordinate of the placement position is inaccurate, you can modify this coordinate value appropriately.
x# Apriltag label locationdef goApriltag1fixedPose(self, layer=1):coords = [-60, 170, 105+50*(layer-1), -175, 0, -45]self.go_coords(coords, 2)def goApriltag2fixedPose(self, layer=1):coords = [10, 170, 105+50*(layer-1), -175, 0, -45]self.go_coords(coords, 2)def goApriltag3fixedPose(self, layer=1):coords = [75, 170, 105+50*(layer-1), -175, 0, -45]self.go_coords(coords, 2)def goApriltag4fixedPose(self, layer=1):coords = [140, 170, 110+50*(layer-1), -175, 0, -45]self.go_coords(coords, 2)
3. Run program
Start roscore
Open the system terminal and enter the following command. If roscore is already started, you do not need to start it again.
xxxxxxxxxxroscore
Start the program
Open the jupyterlab webpage and find the corresponding .ipynb program file.
Click the Run button to run the entire code.

4. Experimental operation and results
After the program runs, the Jupyterlab webpage will display the control button.
Camera image on the left side, related buttons on the right side.

Click the 【position_model】button, drag the joint angle above, update the position of the robot arm, and make the recognition area in the middle of the entire image.
Then, click 【calibration_model】 to enter the calibration mode, and adjust the robot arm joint slider and threshold slider above to make the displayed blue line overlap with the black line of the recognition area.

Click 【calibration_ok】 to calibrate OK.
The camera screen will switch to the recognition area perspective.

Place the blocks into the recognition area and select the color order on the right.

Click 【target_detection】to start label code recognition.

Then click the 【grap sorting】 button to start sorting.
The system will recognize the ID number of the label code and grab the building blocks to the area with the corresponding number according to the label number.


If you need to exit the program, please click the 【Exit】 button.