Welcome to DOFBOT SE repository
3.Text Large Model + robotic arm control
Text Large Model + Robotic Arm Control
Function Description
After the program runs, input a sequence of action commands through the terminal. The large model will plan the action functions corresponding to the action commands and execute all commands in sequence.
Startup
Open the terminal and enter the following command:
xxxxxxxxxxros2 launch largemodel largemodel_control.launch.py text_chat_mode:=True
Then open a second terminal and enter the following command:
xxxxxxxxxxros2 run text_chat text_chat
Then input the commands to control the robotic arm in the text_chat terminal. Currently, the following types of robotic arm control commands are available:
Individual servo control: Set servo x to y degrees, where x ranges from 1-6 and y ranges from 0-180, for example, set servo 1 to 120 degrees.
Individual robotic arm action control: Robotic arm up/down/left/right, gripping posture, tracking posture, for example, set the robotic arm to gripping posture, robotic arm extend upward;
Control robotic arm motion action groups: Robotic arm dance/clap/nod/shake head, for example, please nod your head;
Change robotic arm end position: Robotic arm adjust up/down/left/right/forward/backward by x centimeters, for example, adjust the robotic arm upward by 3 centimeters.
Freely combine robotic arm control commands. The large model will plan the corresponding action groups for each command. You can refer to the following content and enter it in the text_chat terminal:
xxxxxxxxxxFirst, adjust the robotic arm upward by 3 centimeters, wait 3 seconds, then extend the robotic arm downward, stay for 3 seconds, then have the robotic arm shake its head, pause for 3 seconds, and finally set servo 1 to 150 degrees.

Core Code Analysis
Let's mainly look at the adjust_joint function for setting servo angles. Other functions have been analyzed in the source code analysis of the first lesson [AI Model - Text Version\1. Semantic Understand Instruction Following]. They will not be repeated here.
The adjust_joint function source code path is: LargeModel_ws/src/largemodel/largemodel/action_service.py
#Two parameters are passed in: joint_id is the servo number, with values ranging from 1-6, and angle is the angle value, with values ranging from 0-180def adjust_joint(self,joint_id,angle): #Directly communicate with the top-level driver board, sending the servo value and angle value to be set Arm.Arm_serial_servo_write(int(joint_id), int(angle), 1000) time.sleep(1.0) if not self.combination_mode and not self.interrupt_flag: self.action_status_pub("adjust_joint_done")