Welcome to JetCobot repository
8. Apriltag stacking
apriltag stacking
1. apriltag stacking instructions
The path for saving the file of the 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 to reduce repeated calibration actions.
2. Important code explanation
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 gripping position of the building block, it is necessary to increase the deviation parameter 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 you need 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 type,def 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 stacking area. If the coordinate of the placement position is inaccurate, you can modify this coordinate value appropriately.
x# stackingdef goStackingNum1Pose(self):coords = [140, -160, 110, -180, -2, -43]self.go_coords(coords, 3)def goStackingNum2Pose(self):coords = [145, -160, 145, -180, -2, -43]self.go_coords(coords, 3)def goStackingNum3Pose(self):coords = [145, -160, 175, -180, -2, -43]self.go_coords(coords, 3)def goStackingNum4Pose(self):coords = [145, -160, 205, -180, -2, -43]self.go_coords(coords, 3)
3. Start the program
Start the program
Open the jupyterlab webpage and find the corresponding .ipynb program file.
Then click Run All Commands.

4. Experimental operation and effect
After the program is running, the jupyterlab webpage will display the control, the camera screen on the left, and the functions of the related buttons on the right.

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 overlap the displayed blue line with the black line of the recognition area.

Click [calibration_ok] to calibrate OK, and the camera screen will switch to the recognition area.

Place multiple building blocks with the label code facing up in the recognition area.

Then click [target_detection] to start identifying the label code.

Then click the [grap stacking] button to start stacking. The system will identify the ID number of the label code and grab the building blocks to the stacking area according to the label number and stack them.
If you need to exit the program, please click the [Exit] button.