Welcome to DOFBOT Pro repository
3. Text Large Model + robotic arm control
Text Large Model + Robotic Arm Control(Text Version)
Before running the function, you need to close the App and large programs. For the closing method, refer to [4. Preparation] - [1. Manage APP control services].
1. Function Description
After the program runs, you can input a series of action commands through the terminal. The large model will plan the corresponding action functions for these commands and execute all instructions sequentially.
2. Startup
Users with Jetson-Nano board version need to enter the docker container and input the following command. Orin board users can directly open the terminal and input the following command:
xxxxxxxxxxros2 launch largemodel largemodel_control.launch.py text_chat_mode:=True
Then open a second terminal and input the following command:
xxxxxxxxxxros2 run text_chat text_chat
Then input the commands you want to control the robotic arm in the text_chat terminal. Currently, the following 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.
You can freely combine robotic arm control commands, and the large model will plan the corresponding action groups for each command. You can refer to the following content and input 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.

3. Core Code Analysis
Mainly look at the servo angle setting adjust_joint function. Other functions were analyzed in the source code analysis of the first lesson [AI Model - Text Version\1. Semantic Understand Instruction Following] and will not be repeated here.
The adjust_joint function source code path is: LargeModel_ws/src/largemodel/largemodel/action_service.py
#Pass two parameters, joint_id is the servo number, ranging from 1-6, angle is the angle value, ranging from 0-180def adjust_joint(self,joint_id,angle): #Directly communicate with the top-level driver board, send 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")