Welcome to DOFBOT SE repository
9.Multimodal Large Model+Color Blocks Back In Place
Multimodal Large Model+Color Blocks Back In Place
Function Description
After the program runs, after waking up the voice module, input the command to remember the current positions of the color blocks by voice. After the program finishes recording, shuffle the positions of the color blocks. Then wake up the voice module again and input by voice to end the current recording task. Then wake up the voice module again and input the color blocks return-to-place command by voice. After the large model thinks it through, it will plan an action list, and the program will control the robotic arm to complete the color blocks return-to-place task based on the action functions in the action list.
Startup
Open the terminal and enter the following command:
ros2 launch largemodel largemodel_control.launch.py
After waking up the voice module, input by voice:
xxxxxxxxxxRemember the current positions of the color blocks
After recording the color block positions, after waking up the voice module, input by voice:
xxxxxxxxxxEnd the current recording task
Then you can shuffle the positions of the color blocks. After shuffling, after waking up the voice module, input by voice:
xxxxxxxxxxReturn the blocks on the desktop to their original positions
After the buzzer beeps once, it starts gripping the color blocks according to the order in which the color block positions were recorded in the program and placing them back to their original positions. If there are other color blocks on top of the color block that needs to be returned to its original position, it will first remove the color blocks on top, then grip and place back to the original position.
Task Planning
Record Current Positions of Color Blocks
Call
seewhat()to observe the environment;Call
seewhat()again to observe the environment, then determine which color block is the top block;If there are two or more piles of color blocks in the environment, select and execute the following content based on whether a color block is a single one. Calculate for each pile of color blocks. Only one action function can be output at a time here:
(1) If it is a single color block, pass the outer frame coordinates of the color block into the functioncompute_pose(x1, y1, x2, y2, 'name'), wherenamerepresents the color of the color block, and its value can bered,blue,green, oryellow;
(2) If it is not a single color block, pass the outer frame coordinates of the top color block into the functioncompute_pose_order(x1, y1, x2, y2, 'name', 'order'), wherenamerepresents the color of the color block (with valuesred,blue,green, oryellow), andorderrepresents the top-to-bottom arrangement order of the color blocks. Its value is a string composed of the initial letters of the colors of each layer of color blocks from top to bottom. For example, if the top-to-bottom arrangement order of the color blocks is red, blue, green, yellow, then the value oforderisrbgy, and so on.If there is only one pile of color blocks, pass the outer frame coordinates of the top color block into the function
compute_pose_order(x1, y1, x2, y2, 'name', 'order'), wherenamerepresents the color of the color block (with valuesred,blue,green, oryellow), andorderrepresents the top-to-bottom arrangement order of the color blocks. Its value is a string composed of the initial letters of the colors of each layer of color blocks from top to bottom. For example, if the top-to-bottom arrangement order of the color blocks is red, blue, green, yellow, then the value oforderisrbgy, and so on.
Color Blocks Back In Place
First, call the
color_back_to_orin()function to control the color blocks to return to their original positions.Call the
check_remove(color)function to check whether the target color block exists in the removal list (wherecoloris the color of the target color block, and its value range isred,blue,green, oryellow).If the target color block exists in the removal list, perform the following operations:
(1) Call thegrasp_from_rm_list(color)function to grasp the target color block from the removal list (the meaning of thecolorparameter is the same as above);
(2) Pass the color of the target color block as a parameter into thereturn_to_orin(color)function. For example, when the target color block is red, callreturn_to_orin(red)(the value range of thecolorparameter is the same as above).If the target color block does not exist in the removal list, follow the steps below to put the color block back to its original position (only one action function can be output at a time):
(1) Call theseewhat()function to observe the environment;
(2) Determine whether there are other color blocks on top of the target color block that needs to be returned to its original position;
(3) If there are no other color blocks on top of the target color block that needs to be returned to its original position, perform the following steps: ①Call thegrasp_obj(x1, y1, x2, y2)function to grasp the target color block that needs to be returned to its original position (where(x1, y1, x2, y2)are the border coordinates of the top surface of the target color block that needs to be returned to its original position);
②Pass the color of the target color block as a parameter into thereturn_to_orin(color)function (the value range of thecolorparameter is the same as above).
(4) If there are other color blocks on top of the target color block that needs to be returned to its original position, perform the following steps:
①Call theremove_obj(x1, y1, x2, y2, color)function to remove the color block (where(x1, y1, x2, y2)are the border coordinates of the top surface of this color block, andcoloris the color of this color block, with a value range ofred,blue,green, oryellow);
②Call theseewhat()function to observe the environment;
③If there are no other color blocks above the target color block that needs to be returned to its original position, call thegrasp_obj(x1, y1, x2, y2)function to grasp the target color block (where(x1, y1, x2, y2)are the border coordinates of the top surface of the target color block); ④Pass the color of the target color block as a parameter into thereturn_to_orin(color)function (the value range of thecolorparameter is the same as above).
Core Code Analysis
Please refer to the Core Code Analysis content in the tutorial 【AI Model-Text Version】-【Multimodal Large Model + Color Blocks Back In Place】. The voice version and text version have the same action functions; only the input method for task commands is different.