Color sorting

1. Color recognition instructions

Use the HSV color recognition function. The path to save the HSV color calibration file is ~/jetcobot_ws/src/jetcobot_color_identify/scripts/HSV_config.txt. If the color recognition is not accurate enough, please recalibrate the HSV value of the block color according to the 【2.Block color calibration】 course.

After the calibration operation is completed, it will be automatically saved to the HSV_config file. Rerun the program without additional code modification.

The path to save the file for the robot 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. About code

Code path:~/jetcobot_ws/src/jetcobot_color_identify/scripts/color_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 robotic arm to the recognition area.

The type corresponding to color sorting and color stacking is "color", so it is necessary to change the offset parameter under type == "color". The X offset controls the front and back offset, and the Y offset controls the left and right offset.

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.

 

3. Start program

Start roscore

Start the program

Open the jupyterlab webpage and find the corresponding .ipynb program file.

Click the Run button to run the entire code.

202309010001

 

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.

image-20240704171744350

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.

image-20240704173349649

Click 【calibration_ok】 to calibrate OK.

The camera screen will switch to the recognition area perspective.

image-20240704173735754

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

image-20240704174839987

Click 【target_detection】to start color recognition.

If the color recognition is inaccurate, please calibrate the color and then run the program again.

image-20240704180114682

Click the 【grap sorting】 button to start sorting.

The system will sort the recognized colors into the color area in order.

image-20240704180616115

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