Robot control method and system based on large language model
Through the dual language model evaluation mechanism and reinforcement learning, the lower-level motion module is constructed, and the fuzziness, high computing overhead and safety of the robot motion controlled by the large language model is solved, and efficient, safe and adaptable robot control is achieved.
Patent Information
- Application Number
- CN202510205492.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-02-24
AI Technical Summary
The existing large language model controls robot motion with problems such as ambiguity and ambiguity in natural language instructions, high computational overhead of large language models, limited real-time performance, and lack of security and credibility guarantee mechanisms.
The dual language model evaluation mechanism is adopted, the initial control code is generated through Claude 3.5sonnet, and the code evaluation and optimization is used using gpt-4o. The lower-level motion module is constructed in combination with reinforcement learning to ensure the safety and reliability of the generated control instructions.
It reduces the computing overhead and real-time requirements of large language models, improves the security and credibility of generated code, and enhances the adaptability and stability of robot control.
Smart Images

Figure CN119871428A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent control technology, and in particular relates to a robot control method and system based on a large language model. Background Art
[0002] In robot control, traditional methods use dynamic modeling to construct the underlying motion control module, but this type of method is difficult to obtain an accurate dynamic model, so it is not satisfactory in complex nonlinear system control tasks. In recent years, reinforcement learning has become a powerful technology for constructing lower-level motion modules by virtue of its ability to handle high-dimensional, continuous, and nonlinear state spaces and action spaces. When constructing upper-level controllers to manage and schedule the underlying motion control modules, traditional methods include state machines that describe robot behavior through a series of states and transition rules between states, task trees that organize tasks in a tree structure, upper-level controllers based on planning that generate task sequences by solving target states and constraints using algorithms such as A*, and fuzzy controllers that map tasks to underlying modules through fuzzy rules. Most of these methods have the disadvantages of requiring a large number of manually designed rules, a large workload when developing complex tasks, and a lack of adaptability for single tasks. Large language models (such as OpenAI's GPT series) provide new possibilities for robot control and motion planning with their excellent performance in natural language understanding and generation. One method is to directly replace the policy network in previous reinforcement learning with a large language model, so that it can output joint positions based on natural language and observations. However, this method requires GPT4 to respond at a high frequency of 10 Hz, which is impossible to achieve in reality, and consumes a lot of money to call the large language model. In addition, a small change in the prompt word can greatly affect the gait, which is not feasible in reality. Algorithms such as Eureka and DrEureka only use large language models in the reinforcement learning stage to provide robot motion control with reward functions, domain randomization parameters and other components to complete corresponding tasks. However, this type of algorithm can only allow the robot to complete a specific task in a single training. NARRATE uses a large language model to convert natural language into mathematical formulas as objective functions and constraints, and inputs them into model predictive control to enable it to complete multiple tasks. However, experiments show that this method may have problems such as collisions, planning errors, and incorrect formulas generated by large language models that cause code errors.
[0003] At present, there are the following challenges in controlling robot motion with large language models: natural language instructions are ambiguous and confusing, and the control instructions generated by large language models may be incorrect; large language models have high computational overhead and may be limited in real-time robot motion; large language models themselves lack security and credibility assurance mechanisms, and the generated instructions may cause the robot motion to lose control, etc. Summary of the invention
[0004] The present invention provides a robot control method and system based on a large language model, which can solve the problems existing in the prior art.
[0005] To solve the above problems, the technical solution provided by the present invention is as follows:
[0006] An embodiment of the present invention provides a robot control method based on a large language model, comprising the following steps:
[0007] Step 1: The user transmits the task requirements in natural language. The code generation and modification module mixes the requirements with prompt word 1 and passes it to Claude 3.5sonnet through the API to obtain an initial response.
[0008] Step 2, then pass it to the code evaluation and optimization module, which passes the input mixed with prompt word 2 to gpt-4o to get the evaluation and modification suggestions of the current solution;
[0009] Step 3, then the code generation and modification module is returned, and Claude3.5 sonnet generates an optimized version based on the suggestions. The control code is extracted from the optimized version and submitted to the control verification module for verification. If a code error occurs during the execution process, the error will be returned to the code generation and modification module, and Claude 3.5sonnet will correct it according to the error information until the control verification module runs the code without error. At this time, if human verification is selected, the running result will be visualized for the user to choose whether it is qualified. If qualified, the control code will be integrated with the policy network pre-built by reinforcement learning into a motion control module, and then the motion control module will be started to control the robot movement.
[0010] In a preferred embodiment of the present invention, the code generation and modification module in step 1 adopts the Claude 3.5sonnet large language model; in the generation stage, when the user inputs the requirements in natural language form, it will be mixed with the preset prompt word 1 and passed to the model through the API. After receiving the response, the module will use the regular expression python(.*?) to extract the Python code in the response; in the modification stage, the module sends the optimization suggestions obtained by the evaluation module back to the generation model, and extracts the Python code through the above regular expression.
[0011] In a preferred embodiment of the present invention, prompt word 1 is intended to guide the generation of a Python class RobotControl for controlling the motion of a robot, prompt word 1 includes a description of a key method gpt_50hz_step and a method definition gpt_50hz_step of the class RobotControl, wherein the method definition signature is def gpt_50hz_step(self,lin_vel_I,ang_vel_I,pos_IB,q_IB,lin_vel_b,ang_vel_b,now_time), and the method will be called at a frequency of 50Hz in an external loop, that is, 50 times per second; the method receives the following input parameters, each of which plays a specific role in the robot motion control; the main responsibility of the key method gpt_50hz_step is to generate an appropriate speed command according to the current robot state and time to control the robot's motion.
[0012] In a preferred embodiment of the present invention, prompt word 1 includes the following content: avoid setting the speed command to the maximum value to prevent tracking difficulties and excessive wear or damage of mechanical parts caused by excessively high speed, thereby extending the service life of the robot; be wary of very small speed commands, limit the lower limit of the robot speed command, and prevent the robot from being unable to move due to sending too small instructions; consider smooth movement to prevent the robot from overturning, and at the same time, a smooth movement trajectory helps maintain the stability of the robot, ensuring that tasks can be reliably performed in complex or dynamic environments, and avoiding potential safety hazards to the surrounding environment and personnel caused by unstable movement of the robot; safety is given priority, and safety is considered as the primary factor in all control instructions and operation decisions;
[0013] Tip 1 also includes the following: Limit the scope of the code: clearly state that there is no need to write external calling code, and focus on the internal implementation of the class; Ensure dependency completeness: instruct to import all necessary packages to ensure the functional integrity and operability of the class; Guide the development process: encourage step-by-step thinking, choose the best solution, and ensure the quality and efficiency of the code; Final delivery: require the provision of the final code results to ensure that the output code meets all specified requirements and standards.
[0014] In a preferred embodiment of the present invention, the large language model used by the code evaluation and optimization module in step 2 is GPT-4O, the generation result of the code generation and modification module is mixed with the preset prompt word 2, and is passed to the model through the API. After receiving the response, the module sends the obtained optimization suggestions back to the code generation and modification module;
[0015] Hint 2 includes the following aspects of code rationality analysis: evaluation of whether the generated classes or functions meet the robot control requirements, including input / output, units, range and logical correctness; suggestions for safety and algorithm improvement: providing feasible ideas for improving speed planning or protection mechanisms to avoid giving the robot too many instructions; suggestions for structure and maintainability: extracting common logic functions and code comments; providing feasible ideas or examples: so that there is a specific direction to follow when modifying the LLM later.
[0016] In a preferred embodiment of the present invention, the control verification module in step 3 sets a two-dimensional particle with an initial position at (0, 0), a yaw angle of 0, and an initial velocity of 0, and runs at a simulation frequency of 50 Hz. When receiving the control code transmitted by the code generation and modification module, the above required parameters are transmitted to gpt_50hz_step at each time step, and the expected velocity command is obtained as the actual machine system x-direction velocity vx, y-direction velocity vy, and yaw angular velocity w, and the current position (px, py) and angle theta are updated to the next moment position (px_new, py_new) and angle theta_new using the following formula: Let t be the simulation step length, and the angle is updated to theta_new=theta+w*t;
[0017] If the yaw angular velocity w is not 0:
[0018] px_new=px+(vx / w)*(sin(theta+w*t)-sin(theta))+(vy / w)*(cos(theta+w*t)-cos(theta));
[0019] py_new=py+(vx / w)*(-cos(theta+w*t)+cos(theta))+(vy / w)*(sin(theta+w*t)-sin(theta));
[0020] If the yaw angular velocity w is 0:
[0021] px_new=px+(vx*cos(theta)-vy*sin(theta))*t;
[0022] py_new=py+(vx*sin(theta)+vy*cos(theta))*t;
[0023] Run a simulation step in the above manner and draw the position trajectory diagram during simulation; if the program reports an error during operation, record the error information at this time, send it back to the code generation and modification module to require the large language model to repair the error, and repeat this process until the program runs normally. At this time, if you choose to add human verification, the user can decide whether to adopt this solution based on the visualized simulation process. If it passes, the control code will be passed to the motion control module.
[0024] In a preferred embodiment of the present invention, the lower-level motion control module in step 3 receives the generated control class code and instantiates it by dynamically loading the code at runtime, collects the parameters required by the gpt_50hz_step method of this class, such as linear velocity, angular velocity, position, and time, at a frequency of 50hz, and calls this class to generate the expected speed command at this time as one of the inputs of the strategy in the lower-level motion control module; the lower-level motion control module establishes a complex terrain in the Isaac simulation environment for the robot to be controlled, and uses the usual reinforcement learning PPO algorithm to train to obtain a strategy network constructed by a neural network to map the expected speed command with information such as joint position and joint angle to the expected position of each joint, and the expected position is then converted into a motor torque command through a PD controller and transmitted to each motor.
[0025] An embodiment of the present invention provides a robot control system based on a large language model, the robot control system comprising a code generation and modification module, a code evaluation and optimization module, a control class verification module and a motion control module; the code generation and modification module generates corresponding codes based on the natural language form of user input using a large language model to construct a control class, and can modify the generated code according to optimization suggestions; the code evaluation and optimization module evaluates the generated code using a second large language model and makes optimization suggestions; the control class verification module executes the generated control class code in a simplified virtual environment to verify its safety and effect; the motion control module calls the control class code generated by the code generation and modification module, the code evaluation and optimization module and the control class verification module, and calls its related methods at a specific frequency to generate an expected speed command for each time step, which is passed to a lower-level motion control module constructed by reinforcement learning for motion control.
[0026] An embodiment of the present invention provides an electronic device, comprising: at least one memory for storing computer programs; and at least one processor for executing the programs stored in the memory. When the program stored in the memory is executed, the processor is used to execute a robot control method based on a large language model as described in the above embodiment.
[0027] An embodiment of the present invention provides a computer-readable storage medium, which stores a computer program, and is characterized in that when the computer program runs on a processor, the processor executes a robot control method based on a large language model as described in the above embodiment.
[0028] Compared with the prior art, the embodiments of the present invention provide a robot control method and system based on a large language model, which have at least the following beneficial effects:
[0029] (1) The lower-level motion module is constructed by reinforcement learning, and the upper-level controller is constructed by the large language model. This enables the robot control to have both the ability of reinforcement learning to cope with complex environments and the natural language understanding ability of the large language model, and has strong adaptability. During the application stage, the large language model only generates control code based on user needs at the beginning, and the motion process is controlled by the generated code. Therefore, the large language model is called less frequently, and the computational overhead and real-time requirements are low.
[0030] (2) A dual large language model evaluation mechanism is adopted. The large language model for code generation uses Anthropic's Claude 3.5sonnet, which has advantages over other large language models in code generation. It generates control code, and then uses OpenAI's gpt-4o evaluation model to make evaluation and optimization suggestions. Because the two large language models belong to different institutions, different network structures, and different training data, the risk of difficulty in finding problems due to the homogeneity of the same model can be reduced, and its generation quality, security and assurance can be improved. In addition to the dual large language model evaluation mechanism, since security prompts are added to the prompts of the generated model and generation template examples are provided, it can be restricted to operate within a specific framework, reduce the possibility of errors, and further provide standardization and security of the generation effect. In addition, the control verification module will build a simple simulation environment after the control code is generated to screen the syntax errors and logical loopholes of the generated code in advance, further reducing safety risks. Therefore, under the above multiple mechanisms, the security and generation quality of the large language model are guaranteed to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 A flowchart of a robot control method based on a large language model provided in an embodiment of the present application.
[0033] Figure 2 A schematic diagram of the basic task description part of prompt word 1 of a robot control method based on a large language model provided in an embodiment of the present application.
[0034] Figure 3 A schematic diagram of the safety restriction requirement part of prompt word 1 of a robot control method based on a large language model provided in an embodiment of the present application.
[0035] Figure 4 A schematic diagram of a prompt word 1 for regulating the output quality portion of a large language model of a robot control method based on a large language model provided in an embodiment of the present application.
[0036] Figure 5 A schematic diagram of an example portion of a prompt word 1 of a robot control method based on a large language model provided in an embodiment of the present application.
[0037] Figure 6 A schematic diagram of a prompt word 2 of a robot control method based on a large language model provided in an embodiment of the present application.
[0038] Figure 7 This is a trajectory diagram of Experiment 1 provided in an embodiment of the present application.
[0039] Figure 8 This is the trajectory diagram of Experiment 2 provided in the embodiment of the present application.
[0040] Fig. 9 This is the trajectory diagram of Experiment 3 provided in the embodiment of the present application. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0042] like Figure 1 As shown, an embodiment of the present invention provides a robot control method based on a large language model, comprising the following steps:
[0043] Step 1: The user transmits the task requirements in natural language. The code generation and modification module mixes the requirements with prompt word 1 and passes it to Claude 3.5sonnet through the API to obtain an initial response.
[0044] Step 2, then pass it to the code evaluation and optimization module, which passes the input mixed with prompt word 2 to gpt-4o to get the evaluation and modification suggestions of the current solution;
[0045] Step 3, then the code generation and modification module is returned, and Claude3.5 sonnet generates an optimized version based on the suggestions. The control code is extracted from the optimized version and submitted to the control verification module for verification. If a code error occurs during the execution process, the error will be returned to the code generation and modification module, and Claude 3.5sonnet will correct it according to the error information until the control verification module runs the code without error. At this time, if human verification is selected, the running result will be visualized for the user to choose whether it is qualified. If qualified, the control code will be integrated with the policy network pre-built by reinforcement learning into a motion control module, and then the motion control module will be started to control the robot movement.
[0046] The code generation and modification module in step 1 uses the Claude 3.5sonnet large language model; in the generation phase, when the user inputs the requirements in natural language form, it will be mixed with the preset prompt word 1 and passed to the model through the API. After receiving the response, the module will use the regular expression python(.*?) to extract the Python code in the response; in the modification phase, the module will send the optimization suggestions obtained by the evaluation module back to the generation model and extract the Python code through the above regular expression.
[0047] like Figure 2 As shown in the figure, in the basic task description part, prompt word 1 is intended to guide the generation of a Python class RobotControl for controlling the robot motion. Prompt word 1 contains a description of a key method gpt_50hz_step and the method definition gpt_50hz_step of the RobotControl class, where the method definition signature is def gpt_50hz_step(self,lin_vel_I,ang_vel_I,pos_IB,q_IB,lin_vel_b,ang_vel_b,now_time). This method will be called at a frequency of 50Hz in the external loop, that is, 50 times per second; this method receives the following input parameters, each of which plays a specific role in the robot motion control; the main responsibility of the key method gpt_50hz_step is to generate appropriate speed commands according to the current robot state and time to control the robot's motion.
[0048] This method accepts the following input parameters, each of which plays a specific role in the robot's motion control: Linear velocity lin_vel_I uses the world coordinate system, floating point or vector numerical type, description: represents the robot's linear velocity in the world coordinate system, usually including components in the x and y directions. Angular velocity ang_vel_I uses the world coordinate system, floating point numerical type, description: represents the robot's angular velocity in the world coordinate system, usually refers to the rotation speed around the z axis. Position pos_IB uses the world coordinate system, NumPy array vector type, description: represents the current position of the robot in the world coordinate system, usually including x, y and z coordinates. Quaternion q_IB uses the scalar-first format, array or object quaternion type, description: represents the robot's attitude direction in the world coordinate system, using a quaternion in scalar-first format. Linear velocity lin_vel_b uses the body coordinate system, floating point or vector numerical type, description: represents the robot's linear velocity in the body coordinate system, usually including components in the front and back x and left and right y directions. Angular velocity ang_vel_b uses the body coordinate system, floating point value type, description: represents the angular velocity of the robot in the body coordinate system, usually refers to the rotation speed around its vertical axis - z axis. Current time now_time uses floating point value type, description: represents the current time value, starting from 0 and increasing, used for time step tracking and control.
[0049] The main responsibility of the key method gpt_50hz_step is to generate appropriate speed commands to control the movement of the robot according to the current robot state and time, including: Input processing: Receive and parse the linear velocity, angular velocity, position and posture information from the world coordinate system and the body coordinate system; Use the current time now_time to manage the time step and adjust the control logic. Speed command generation: Based on the input parameters, calculate the speed command suitable for the next time step; Generate a 3D NumPy array, including: the x-direction speed command of the body coordinate system, the y-direction speed command of the body coordinate system, and the yaw angular velocity command of the rotation speed around the z-axis. Unit and range control: All speed commands are expressed in the International System of Units SI to ensure consistency and standardization; The value of the speed command is limited to the range of -2 to 2 to prevent too large or too small control commands from affecting the stability of the robot. Coordinate system conversion: Ensure that the generated speed command is in the body coordinate system, not the world coordinate system, to meet the needs of the lower-level control module. Control command transmission: Pass the generated speed command to the lower-level neural network controller to perform specific motion control. Corrective measures: Since the lower-level controller cannot accurately track the speed command, the method needs to implement appropriate corrections based on the observed feedback to improve control accuracy and responsiveness. The return value of this method is a 3D NumPy array containing the following: x-direction speed command of the body coordinate system (unit: m / s), y-direction speed command of the body coordinate system (unit: m / s), and yaw angular velocity command (unit: rad / s). Range limitation: All command values are between -2 and 2 to ensure that the command is within the controllable range.
[0050] The control flow of step 1 is: method call, in the external loop, the gpt_50hz_step method is called 50 times per second to ensure real-time control and response; execution of speed command: the speed command generated by the method is passed to the lower-level neural network controller, which is responsible for converting these commands into actual motion execution; feedback and correction, due to errors in the tracking of the controller, the method needs to be corrected based on real-time observation data (such as actual speed, position deviation, etc.) to adjust the control instructions for the next time step and improve the accuracy and stability of the overall control.
[0051] like Figure 3As shown in the figure, the safety limitation requirements are intended to guide the robot control system to fully consider the performance limitations of the robot when performing specific tasks, ensuring the safety and effectiveness of the operation. Prompt word 1 includes the following: avoid setting the speed command to the maximum value to prevent tracking difficulties and avoid excessive wear or damage to mechanical parts caused by excessive speed, thereby extending the service life of the robot; be wary of very small speed commands, limit the lower limit of the robot speed command, and prevent the robot from being unable to move due to sending too small commands; consider smooth motion to prevent the robot from overturning. At the same time, a smooth motion trajectory helps maintain the stability of the robot, ensuring that tasks can be performed reliably in complex or dynamic environments, and avoiding potential safety hazards to the surrounding environment and personnel caused by unstable motion of the robot; safety is the primary consideration in all control instructions and operation decisions.
[0052] like Figure 4 As shown in the figure, the main goal of the large language model output quality part is to generate a complete Python class code that meets specific requirements, while ensuring that the structure and dependencies of the code are correct. Prompt word 1 also includes the following: Limit the scope of the code: clearly point out that there is no need to write external call code, and focus on the internal implementation of the class; Ensure dependency completeness: instruct to import all necessary packages to ensure the functional integrity and operability of the class; Guide the development process: encourage step-by-step thinking, choose the best solution, and ensure the quality and efficiency of the code; Final delivery: require the provision of the final code results to ensure that the output code meets all specified requirements and standards.
[0053] See also Figure 5 ,The Tip Word 1 Example section provides an example of tracking a heart-shaped trajectory to further normalize the quality of the generation of a large language model.
[0054] The large language model used by the code evaluation and optimization module in step 2 is GPT-4O. The generation result of the code generation and modification module is mixed with the preset prompt word 2 and passed to the model through the API. After receiving the response, the module sends the obtained optimization suggestions back to the code generation and modification module.
[0055] like Figure 6 As shown, prompt word 2 includes the following aspects of code rationality analysis: evaluation of whether the generated class or function meets the robot control requirements, including input / output, unit, range and logical correctness; suggestions for safety and algorithm improvement: providing feasible ideas for improving speed planning or protection mechanism to avoid giving the robot too many instructions; suggestions for structure and maintainability: extracting common logic functions and code comments; providing feasible ideas or examples: so that there is a specific direction to follow when modifying the LLM later.
[0056] The control verification module in step 3 sets a two-dimensional particle with an initial position at (0,0), a yaw angle of 0, and an initial velocity of 0, and runs at a simulation frequency of 50 Hz. When receiving the control code transmitted by the code generation and modification module, it transmits the above required parameters to gpt_50hz_step at each time step, and obtains the expected velocity command as the actual machine system's x-direction velocity vx, y-direction velocity vy, and yaw angular velocity w, and uses the following formula to update the current position (px, py) and angle theta to the next moment position (px_new, py_new) and angle theta_new: Let t be the simulation step length, and the angle update is theta_new = theta + w*t;
[0057] If the yaw angular velocity w is not 0:
[0058] px_new=px+(vx / w)*(sin(theta+w*t)-sin(theta))+(vy / w)*(cos(theta+w*t)-cos(theta));
[0059] py_new=py+(vx / w)*(-cos(theta+w*t)+cos(theta))+(vy / w)*(sin(theta+w*t)-sin(theta));
[0060] If the yaw angular velocity w is 0:
[0061] px_new=px+(vx*cos(theta)-vy*sin(theta))*t;
[0062] py_new=py+(vx*sin(theta)+vy*cos(theta))*t;
[0063] Run a simulation step in the above manner and draw the position trajectory diagram during simulation; if the program reports an error during operation, record the error information at this time, send it back to the code generation and modification module to require the large language model to repair the error, and repeat this process until the program runs normally. At this time, if you choose to add human verification, the user can decide whether to adopt this solution based on the visualized simulation process. If it passes, the control code will be passed to the motion control module.
[0064] The lower-level motion control module in step 3 receives the generated control class code and instantiates it by dynamically loading the code at runtime, collects the parameters required by the gpt_50hz_step method of this class, such as linear velocity, angular velocity, position, and time, at a frequency of 50hz, and calls this class to generate the expected speed command at this time as one of the inputs of the strategy in the lower-level motion control module; the lower-level motion control module establishes complex terrain in the Isaac simulation environment for the robot to be controlled, and uses the usual reinforcement learning PPO algorithm to train to obtain a strategy network constructed by a neural network that maps the expected speed command with information such as joint position and joint angle to the expected position of each joint. The expected position is then converted into a motor torque command through a PD controller and transmitted to each motor.
[0065] An embodiment of the present invention provides a robot control system based on a large language model, the robot control system comprising a code generation and modification module, a code evaluation and optimization module, a control class verification module and a motion control module; the code generation and modification module generates corresponding codes based on the natural language form of user input using a large language model to construct a control class, and can modify the generated code according to optimization suggestions; the code evaluation and optimization module evaluates the generated code using a second large language model and makes optimization suggestions; the control class verification module executes the generated control class code in a simplified virtual environment to verify its safety and effect; the motion control module calls the control class code generated by the code generation and modification module, the code evaluation and optimization module and the control class verification module, and calls its related methods at a specific frequency to generate an expected speed command for each time step, which is passed to a lower-level motion control module constructed by reinforcement learning for motion control.
[0066] The experiment was conducted on the Isaac Sim simulation platform using Boston Dynamics' spot quadruped robot.
[0067] Experiment 1: Heart-shaped trajectory tracking. Enter the task prompt "Let the robot walk out a heart-shaped trajectory of 7 meters in size". The generation phase consumes 2164 tokens and takes 13 seconds to generate. The number of abnormal code regenerations in the verification phase is 0. The trajectory diagram is shown in Figure 7 .
[0068] Experiment 2: Three-leaf rose trajectory tracking. Enter the task prompt "Let the robot walk out of the three-leaf rose line trajectory of 7m in size". The generation phase consumes 2180 tokens and takes 13 seconds to generate. The number of abnormal code regenerations in the verification phase is 0. The trajectory diagram is shown in Figure 8 .
[0069] Experiment 3: Star-shaped trajectory tracking. Enter the task prompt "Let the robot walk out of a star-shaped trajectory of 5m in size". The generation phase consumes 2176 tokens and takes 13 seconds. The number of abnormal code regenerations in the verification phase is 0. The trajectory diagram is shown in Fig. 9 .
[0070] An embodiment of the present invention provides an electronic device, comprising: at least one memory for storing computer programs; and at least one processor for executing the programs stored in the memory. When the program stored in the memory is executed, the processor is used to execute a robot control method based on a large language model as described in the above embodiment.
[0071] The embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, characterized in that when the computer program is run on a processor, the processor executes a robot control method based on a large language model as in the above embodiment. If it is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium, etc.
[0072] In summary, although the present invention has been disclosed as above in terms of preferred embodiments, the above preferred embodiments are not intended to limit the present invention. A person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be based on the scope defined in the claims.
Claims
1. A robot control method based on a large language model, characterized in that: The following steps are involved: Step 1: The user transmits the task requirements in natural language. The code generation and modification module mixes the requirements with prompt word 1 and passes it to Claude 3.5sonnet through the API to obtain an initial response. Step 2, then pass it to the code evaluation and optimization module, which passes the input mixed with prompt word 2 to gpt-4o to get the evaluation and modification suggestions of the current solution; Step 3, then the code generation and modification module is returned, and Claude3.5 sonnet generates an optimized version based on the suggestions, and the control class code is extracted from the optimized version and submitted to the control class verification module for verification; If a code error occurs during the execution process, the error will be transmitted back to the code generation and modification module, and Claude 3.5sonnet will make corrections based on the error information until the control verification module runs the code without error. At this time, if human verification is selected, the running result will be displayed in a visual form for the user to choose whether it is qualified. If qualified, the control code will be integrated with the policy network pre-built by reinforcement learning into a motion control module, and then the motion control module will be started to control the robot movement.
2. A robot control method based on a large language model according to claim 1, characterized in that: The code generation and modification module in step 1 uses the Claude 3.5sonnet large language model; in the generation phase, when the user inputs the requirements in natural language form, it will be mixed with the preset prompt word 1 and passed to the model through the API. After receiving the response, the module will use the regular expression python(.*?) to extract the Python code in the response; in the modification phase, the module will send the optimization suggestions obtained by the evaluation module back to the generation model and extract the Python code through the above regular expression.
3. A robot control method based on a large language model according to claim 2, characterized in that: Prompt word 1 is intended to guide the generation of a Python class RobotControl for controlling robot motion. Prompt word 1 contains a description of a key method gpt_50hz_step and the method definition gpt_50hz_step of the RobotControl class, where the method definition signature is defgpt_50hz_step(self,lin_vel_I,ang_vel_I,pos_IB,q_IB,lin_vel_b,ang_vel_b,now_time). This method will be called at a frequency of 50Hz in an external loop, that is, 50 times per second; this method receives the following input parameters, each of which plays a specific role in robot motion control; the main responsibility of the key method gpt_50hz_step is to generate appropriate speed commands based on the current robot state and time to control the robot's motion.
4. A robot control method based on a large language model according to claim 3, characterized in that: Prompt word 1 includes the following: avoid setting the speed command to the maximum value to prevent tracking difficulties and excessive wear or damage of mechanical parts caused by excessive speed, and extend the service life of the robot; be wary of very small speed commands, limit the lower limit of the robot speed command, and prevent the robot from being unable to move due to sending too small commands; consider smooth movement to prevent the robot from overturning. At the same time, smooth movement trajectories help maintain the stability of the robot, ensure that tasks can be performed reliably in complex or dynamic environments, and avoid potential safety hazards to the surrounding environment and personnel caused by unstable movement of the robot; safety is the first priority, and safety is the primary consideration in all control instructions and operation decisions; Tip 1 also includes the following: Limit the scope of the code: clearly state that there is no need to write external calling code, and focus on the internal implementation of the class; Ensure dependency completeness: instruct to import all necessary packages to ensure the functional integrity and operability of the class; Guide the development process: encourage step-by-step thinking, choose the best solution, and ensure the quality and efficiency of the code; Final delivery: require the provision of the final code results to ensure that the output code meets all specified requirements and standards.
5. A robot control method based on a large language model according to claim 4, characterized in that: The large language model used by the code evaluation and optimization module in step 2 is GPT-4O. The generated results of the code generation and modification module are mixed with the preset prompt word 2 and passed to the model through the API. After receiving the response, the module sends the obtained optimization suggestions back to the code generation and modification module. Hint 2 includes the following aspects of code rationality analysis: evaluation of whether the generated classes or functions meet the robot control requirements, including input / output, units, range and logical correctness; suggestions for safety and algorithm improvement: providing feasible ideas for improving speed planning or protection mechanisms to avoid giving the robot too many instructions; suggestions for structure and maintainability: extracting common logic functions and code comments; Provide feasible ideas or examples so that there is a specific direction to follow when modifying the LLM later.
6. A robot control method based on a large language model according to claim 5, characterized in that: The control verification module in step 3 sets a two-dimensional particle with an initial position at (0,0), a yaw angle of 0, and an initial velocity of 0, and runs at a simulation frequency of 50 Hz. When receiving the control code transmitted by the code generation and modification module, it transmits the above required parameters to gpt_50hz_step at each time step, and obtains the expected velocity command as the actual machine system's x-direction velocity vx, y-direction velocity vy, and yaw angular velocity w, and uses the following formula to update the current position (px, py) and angle theta to the next moment position (px_new, py_new) and angle theta_new: Let t be the simulation step length, and the angle update is theta_new = theta + w*t; If the yaw angular velocity w is not 0: px_new=px+(vx / w)*(sin(theta+w*t)-sin(theta))+(vy / w)*(cos(theta+w*t)-cos(theta)); py_new=py+(vx / w)*(-cos(theta+w*t)+cos(theta))+(vy / w)*(sin(theta+w*t)-sin(theta)); If the yaw angular velocity w is 0: px_new=px+(vx*cos(theta)-vy*sin(theta))*t; py_new=py+(vx*sin(theta)+vy*cos(theta))*t; Run a simulation step in the above manner and draw the position trajectory diagram during simulation; if the program reports an error during operation, record the error information at this time, send it back to the code generation and modification module to require the large language model to repair the error, and repeat this process until the program runs normally. At this time, if you choose to add human verification, the user can decide whether to adopt this solution based on the visualized simulation process. If it passes, the control code will be passed to the motion control module.
7. A robot control method based on a large language model according to claim 6, characterized in that: The lower-level motion control module in step 3 receives the generated control class code and instantiates it by dynamically loading the code at runtime, collects the parameters required by the gpt_50hz_step method of this class at a frequency of 50hz, such as linear velocity, angular velocity, position, and time, and calls this class to generate the expected speed command at this time as one of the inputs of the strategy in the lower-level motion control module; the lower-level motion control module establishes complex terrain in the Isaac simulation environment for the robot to be controlled, and uses the usual reinforcement learning PPO algorithm to train to obtain a strategy network constructed by a neural network that maps the expected speed command with the information of joint position and joint angle into the expected position of each joint. The expected position is then converted into a motor torque command through a PD controller and transmitted to each motor.
8. A robot control system based on a large language model, characterized in that: The robot control system includes a code generation and modification module, a code evaluation and optimization module, a control class verification module and a motion control module; the code generation and modification module generates corresponding codes based on the natural language form of user input using a large language model to construct a control class, and can modify the generated code according to the optimization suggestions; the code evaluation and optimization module evaluates the generated code using a second large language model and makes optimization suggestions; The control class verification module executes the generated control class code in a simplified virtual environment to verify its safety and effectiveness; the motion control module calls the control class code generated by the code generation and modification module, the code evaluation and optimization module, and the control class verification module, and calls its related methods at a specific frequency to generate the expected speed command for each time step, which is passed to the lower-level motion control module constructed by reinforcement learning for motion control.
9. An electronic device, characterized in that: include: at least one memory for storing a computer program; At least one processor is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute a robot control method based on a large language model as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program runs on a processor, the processor is enabled to execute a robot control method based on a large language model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Building assembly robot closed-loop control method based on large-scale language model
CN118024237A
Code generation method and system based on large language model
CN118210489A
Large language model evaluation method and device, equipment, medium and program product
CN118445576A
Visual intelligent programming method based on large language model
CN119045806A
Enzyme activity parameter extraction method and system based on large language model
CN119443093A
Cited By
Control method and device of multi-mode intelligent manipulator
CN120347781A
Heating ventilation and air conditioning system control code automatic modification method based on large language model
CN121233090A
Intelligent instruction execution method, system and equipment and medium
CN121742820A
A somatically intelligent instruction execution method, system, device, and medium
CN121742820B
Robot skill primitive library automatic generation method and system based on large language model
CN122311404A