A robot control method and system based on large language model

Through the dual large language model evaluation mechanism and control verification module, the ambiguity, computational overhead and security issues of large language models in robot control are solved, and the high adaptability and security of the robot control system in complex environments are achieved.

CN119871428BActive Publication Date: 2025-09-16HUBEI QILING ROBOT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510205492.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-24
Publication Date
2025-09-16
Estimated Expiration
2045-02-24

AI Technical Summary

Technical Problem

In the existing technology, large language models have problems in robot control, such as ambiguity and fuzziness of natural language instructions, high computational overhead, and insufficient security and reliability, which may cause the generated control instructions to be incorrect or cause the robot movement to lose control.

Method used

A dual large language model (Claude 3.5SONNET and GPT-4O) evaluation mechanism is used, combined with security prompts and control verification modules to generate and optimize control code. The lower-level motion module is constructed through reinforcement learning to ensure the security and accuracy of the generated code.

Benefits of technology

It achieves high adaptability and security of robot control systems in complex environments, reduces the computational overhead and real-time requirements of large language models, and improves the quality and security of generated code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119871428B_ABST
    Figure CN119871428B_ABST
Patent Text Reader

Abstract

The present invention provides a robot control method and system based on a large language model. This system employs a dual large language model evaluation mechanism. The large language model of the code generation and modification module uses Claude 3.5sonnet to generate control code, which is then evaluated and optimized using OpenAI's GPT-4O evaluation model. This reduces the risk of difficulty identifying problems during evaluation due to the homogeneity of the same module, thereby improving the quality, safety, and security of the generated code. In addition to the dual large language model evaluation mechanism, the system incorporates safety prompts into the prompts of the generated model and provides generation template examples. This restricts operation within a specific framework, reduces the likelihood of errors, and further ensures the standardization and security of the generated code. Furthermore, a control verification module constructs a simple simulation environment after the control code is generated, enabling early screening of the generated code for syntax errors and logical vulnerabilities, further reducing potential safety hazards.
Need to check novelty before this filing date? Find Prior Art

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 robotic control, traditional approaches use dynamic modeling to construct low-level motion control modules. However, these methods struggle to obtain accurate dynamic models, making them less than ideal for controlling complex nonlinear systems. In recent years, reinforcement learning, with its ability to handle high-dimensional, continuous, and nonlinear state and action spaces, has become a powerful technique for constructing low-level motion control modules. Traditional approaches for constructing high-level controllers to manage and schedule low-level motion control modules include state machines that describe robot behavior through a series of states and transition rules between them, task trees that organize tasks in a tree-like structure, planning-based high-level controllers that generate task sequences by solving target states and constraints using algorithms such as A*, and fuzzy controllers that map tasks to low-level modules using fuzzy rules. These approaches often require extensive manual rule design, resulting in a high workload for developing complex tasks and a lack of adaptability to single tasks. Large language models (such as OpenAI's GPT series) offer new possibilities for robotic control and motion planning, thanks to their superior 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 unattainable 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 for completing corresponding tasks. However, this type of algorithm can only enable 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 the large language model that cause code errors.

[0003] Currently, there are the following challenges in controlling robot motion using large language models: natural language instructions are ambiguous and fuzzy, 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 present invention provides the following technical solutions:

[0006] An embodiment of the present invention provides a robot control method based on a large language model, comprising the following steps:

[0007] In step 1, the user conveys the task requirements in natural language. The code generation and modification module combines the requirements with prompt word 1 and passes it to Claude 3.5sonnet through the API to obtain an initial response.

[0008] Step 2: The code is then passed to the code evaluation and optimization module, which mixes the input and prompt word 2 and passes it to gpt-4o to obtain an evaluation of the current solution and modification suggestions;

[0009] Step 3: The code is then sent back to the code generation and modification module, where 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 execution, the error is sent back to the code generation and modification module, where Claude 3.5 sonnet corrects it 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 results will be displayed in a visual form for the user to select whether they are 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 phase, when the user inputs a requirement in natural language form, it is mixed with the preset prompt word 1 and passed to the model through the API. After receiving the response, the module uses the regular expression python(.*?) to extract the Python code in the response; in the modification phase, the module sends the optimization suggestions obtained by the evaluation module back to the generation model and extracts the Python code using 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 robot motion, prompt word 1 contains a description of a key method gpt_50hz_step and a method definition gpt_50hz_step of the RobotControl class, 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), which 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 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.

[0012] In a preferred embodiment of the present invention, 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 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 commands; consider smooth movement to prevent the robot from overturning. At the same time, a smooth movement 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 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 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.

[0014] In a preferred embodiment of the present invention, the code evaluation and optimization module in step 2 uses a large language model called 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.

[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, scope and logical correctness; suggestions for safety and algorithm improvement: providing feasible ideas for improving speed planning or protection mechanisms to avoid giving the robot excessive 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 commands are 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 update is 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 a position trajectory diagram during the simulation. If the program reports an error during operation, the error message is recorded and sent back to the code generation and modification module to require the large language model to repair the error. Repeat this process until the program runs normally. At this time, if human verification is selected, the user can decide whether to adopt this solution based on the visualized simulation process. If it passes, the control code is 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 for training 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, 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, which 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 uses a large language model to generate corresponding code to construct a control class based on the requirements in the form of natural language input by a user, and can modify the generated code according to optimization suggestions; the code evaluation and optimization module uses a second large language model to evaluate the generated code and make 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 their 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.

[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. The invention 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 has 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, so that the robot control has 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; in the application stage, the large language model only generates control code according to 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 prompt words of the generated model and generation template examples are provided, it can limit its operation 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 security 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 following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 portion 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 of a large language model in 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 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 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 the trajectory diagram of Experiment 1 provided in the embodiment of this application.

[0039] Figure 8 This is the trajectory diagram of Experiment 2 provided in the embodiment of this application.

[0040] Figure 9 This is the trajectory diagram of Experiment 3 provided in the embodiment of this application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this 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] In step 1, the user conveys the task requirements in natural language. The code generation and modification module combines the requirements with prompt word 1 and passes it to Claude 3.5sonnet through the API to obtain an initial response.

[0044] Step 2: The code is then passed to the code evaluation and optimization module, which mixes the input and prompt word 2 and passes it to gpt-4o to obtain an evaluation of the current solution and modification suggestions;

[0045] Step 3: The code is then sent back to the code generation and modification module, where 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 execution, the error is sent back to the code generation and modification module, where Claude 3.5 sonnet corrects it 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 results will be displayed in a visual form for the user to select whether they are 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. During the generation phase, when users input natural language requirements, they are mixed with the preset prompt word 1 and passed to the model through the API. After receiving the response, the module uses the regular expression python(.*?) to extract the Python code in the response. During the modification phase, the module sends the optimization suggestions obtained by the evaluation module back to the generation model and extracts the Python code using 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 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 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 robot motion control: Linear velocity lin_vel_I is in world coordinates, a floating-point number or vector type. Description: Represents the robot's linear velocity in the world coordinate system, typically containing components in the x and y directions. Angular velocity ang_vel_I is in world coordinates, a floating-point number type. Description: Represents the robot's angular velocity in the world coordinate system, typically referring to the rotational speed around the z-axis. Position pos_IB is in world coordinates, a NumPy array vector type. Description: Represents the robot's current position in the world coordinate system, typically containing x, y, and z coordinates. Quaternion q_IB is in scalar-first format, an array or object quaternion type. Description: Represents the robot's orientation in the world coordinate system, represented by a quaternion in scalar-first format. Linear velocity lin_vel_b is in body coordinates, a floating-point number or vector type. Description: Represents the robot's linear velocity in the body coordinate system, typically containing components in the front-back x direction and left-right y direction. The angular velocity ang_vel_b is a floating-point value in the body coordinate system. It represents the robot's angular velocity in the body coordinate system, typically referring to its rotational speed around the -z axis. The current time now_time is a floating-point value. It represents the current time value, starting at 0 and incrementing. It is used for time step tracking and control.

[0049] The key method, gpt_50hz_step, is responsible for generating appropriate velocity commands to control the robot's motion based on the current robot state and time. Specifically, it includes the following: Input processing: Receives and interprets linear velocity, angular velocity, position, and posture information from the world and body coordinate systems; uses the current time, now_time, to manage the time step and adjust the control logic. Velocity command generation: Based on the input parameters, it calculates the velocity command appropriate for the next time step; and generates a 3D NumPy array containing the x-axis velocity command, the y-axis velocity command, and the yaw angular velocity command about the z-axis. Unit and range control: All velocity commands are expressed in SI units to ensure consistency and standardization. Velocity command values ​​are limited to the range of -2 to 2 to prevent excessively large or small control commands from affecting robot stability. Coordinate system conversion: Ensures that the generated velocity commands are in the body coordinate system, not the world coordinate system, to meet the requirements of the lower-level control module. Control command transmission: Passes the generated velocity commands to the lower-level neural network controller to perform specific motion control. Corrective Action: Because the lower-level controller cannot accurately track velocity commands, this method must implement appropriate corrections based on observed feedback to improve control accuracy and responsiveness. This method returns a 3D NumPy array containing the following: the x-axis velocity command (unit: m / s), the y-axis velocity command (unit: m / s), and the yaw rate command (unit: rad / s). Range Limitation: All command values ​​must be between -2 and 2 to ensure they are within the controllable range.

[0050] The control flow of step 1 is as follows: method call, in the outer 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 controller's tracking, 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 section aims to guide the robot control system to fully consider the robot's performance limitations when performing specific tasks, ensuring safe and effective operations. Tip 1 includes the following: Avoid setting speed commands to the maximum value to prevent tracking difficulties and excessive wear or damage to mechanical components caused by excessive speeds, thereby extending the robot's service life; be wary of very small speed commands and limit the robot's lower speed limit to prevent sending too small commands that may cause the robot to become immobile; consider smooth motion to prevent the robot from tipping over. Smooth motion trajectories help maintain the robot's stability, ensuring reliable execution even in complex or dynamic environments and avoiding potential safety hazards to the surrounding environment and personnel due to unstable robot motion; prioritize safety and make safety the primary consideration in all control commands and operational decisions.

[0052] like Figure 4 As shown, the main goal of standardizing the output quality of large language models is to generate complete Python class code that meets specific requirements, while ensuring the correct structure and dependencies. Tip 1 also includes the following: Limiting Code Scope: Explicitly stating that external call code need not be written, focusing on the internal implementation of the class; Ensuring Dependency Completeness: Instructing the import of all necessary packages to ensure the functional integrity and operability of the class; Guiding the Development Process: Encouraging step-by-step thinking and selecting the best solution to ensure code quality and efficiency; Final Delivery: Requires the provision of final code results, ensuring that the output code meets all specified requirements and standards.

[0053] See also Figure 5 ,The example of prompt word 1 is provided in the example of tracking a heart ,trajectory to further standardize the quality of the generation of ,large language models.

[0054] The code evaluation and optimization module in step 2 uses the large language model GPT-4O. It mixes the generation results of the code generation and modification module with the preset prompt word 2 and passes it 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 passed by the code generation and modification module, it passes the 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 size, 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 a position trajectory diagram during the simulation. If the program reports an error during operation, the error message is recorded and sent back to the code generation and modification module to require the large language model to repair the error. Repeat this process until the program runs normally. At this time, if human verification is selected, the user can decide whether to adopt this solution based on the visualized simulation process. If it passes, the control code is 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 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 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 the 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, which 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 uses a large language model to generate corresponding code to construct a control class based on the requirements in the form of natural language input by a user, and can modify the generated code according to optimization suggestions; the code evaluation and optimization module uses a second large language model to evaluate the generated code and make 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 their 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.

[0066] The experiment was conducted on the Isaac Sim simulation platform using Boston Dynamics' spot quadruped robot.

[0067] Experiment 1: Heart-shaped trajectory tracking. The task prompt is "Let the robot walk a heart-shaped trajectory of 7 meters in length". The generation phase consumes 2164 tokens and takes 13 seconds. The number of code abnormal regenerations in the verification phase is 0. The trajectory diagram is shown in Figure 7 .

[0068] Experiment 2: Three-leaf rose trajectory tracking. The task prompt is "Let the robot follow a three-leaf rose trajectory of 7 meters in length." The generation phase consumes 2180 tokens and takes 13 seconds. The verification phase has 0 code regeneration exceptions. The trajectory diagram is shown in the figure. Figure 8 .

[0069] Experiment 3: Star-shaped trajectory tracking. Enter the task prompt "Let the robot walk out a star-shaped trajectory of 5m in size". The generation phase consumes 2176 tokens and takes 13 seconds. The number of code abnormal regenerations in the verification phase is 0. The trajectory diagram is shown in Figure 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] An embodiment of the present invention provides a computer-readable storage medium storing a computer program, characterized in that when the computer program is executed on a processor, the processor executes a robot control method based on a large language model as described in the above-mentioned embodiment. If implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the process of the method in the above-mentioned embodiment by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when executed by the processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal, and software distribution medium.

[0072] In summary, although the present invention has been disclosed above with reference to 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: In step 1, the user conveys the task requirements in natural language. The code generation and modification module combines the requirements with prompt word 1 and passes it to Claude 3.5sonnet through the API to obtain an initial response. Step 2: The code is then passed to the code evaluation and optimization module, which passes the input mixed with prompt word 2 to gpt-4o to obtain an evaluation of the current solution and modification suggestions; Step 3: The code is then sent back to the code generation and modification module, where Claude3.5 sonnet generates an optimized version based on the suggestions. The control code is extracted from the optimized version and then verified by the control verification module. If a code error occurs during execution, it will be transmitted back to the code generation and modification module, where Claude 3.5sonnet will correct it based on the error information until the control verification module runs the code without error. At this point, if human verification is selected, the running results will be displayed in a visual form for the user to select whether it passes. If it passes, the control code will be integrated with the policy network pre-built by reinforcement learning to form a motion control module, which will then be activated to control the robot's movement. The code generation and modification module in step 1 uses the Claude 3.5sonnet large language model. During the generation phase, when a user enters a requirement in natural language, it is mixed with the preset prompt word 1 and passed to the Claude 3.5sonnet large language model via the API. After receiving a response, the Claude 3.5sonnet large language model uses the regular expression python(.*?) to extract the Python code in the response. During the modification phase, the Claude 3.5sonnet large language model sends the optimization suggestions obtained by the evaluation module back to the generation model and extracts the Python code using the above regular expression. Hint 1 is intended to guide the generation of a Python class RobotControl for controlling robot motion. Hint 1 contains a key method gpt_50hz_step and a description of the method definition gpt_50hz_step of the RobotControl class. 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 an appropriate speed command based on the current robot state and time to control the robot's motion. The code evaluation and optimization module in step 2 uses the large language model GPT-4O. It mixes the generation results of the code generation and modification module with the preset prompt word 2 and passes it to GPT-4O through the API. After receiving the response, GPT-4O sends the obtained optimization suggestions back to the code generation and modification module.

2. A robot control method based on a large language model according to claim 1, characterized in that: Tip 1 includes the following: Avoid setting the speed command to the maximum value to prevent tracking difficulties and excessive wear or damage to mechanical components caused by excessive speed, thereby extending the service life of the robot; be wary of very small speed commands and limit the lower limit of the robot's speed command to 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 robot's stability, ensuring that tasks can be performed reliably in complex or dynamic environments, and avoiding potential safety hazards to the surrounding environment and personnel due to unstable robot motion; safety is the primary consideration in all control instructions and operational decisions; Tip 1 also includes the following: Limit the scope of the code: clearly state 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.

3. The robot control method based on a large language model according to claim 2, characterized in that: 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, scope, and logical correctness; suggestions for safety and algorithm improvement: providing feasible ideas for improving speed planning or protection mechanisms to avoid giving the robot excessive 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 revising the LLM later.

4. The robot control method based on a large language model according to claim 3, 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 passed by the code generation and modification module, it passes the 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 size, 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 a position trajectory diagram during the simulation. If the program reports an error during operation, the error message is recorded and sent back to the code generation and modification module to require the large language model to repair the error. Repeat this process until the program runs normally. At this time, if human verification is selected, the user can decide whether to adopt this solution based on the visualized simulation process. If it passes, the control code is passed to the motion control module.

5. The robot control method based on a large language model according to claim 4, characterized in that: The 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, and calls this class to generate the expected speed command at this time as one of the inputs of the strategy in the motion control module; the 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 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 the PD controller and transmitted to each motor.

6. The robot control method based on a large language model according to claim 5, characterized in that: The parameters are linear velocity, angular velocity, position, and time.

7. A robot control system based on a large language model, used to implement the robot control method based on a large language model as claimed in claim 6, 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 code based on the user's natural language input requirements 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 uses a second large language model to evaluate the generated code and provide optimization suggestions. The control verification module executes the generated control code in a simplified virtual environment to verify its safety and effectiveness; the motion control module calls the control code generated by the code generation and modification module, the code evaluation and optimization module, and the control 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 motion control module constructed by reinforcement learning for motion control.

8. 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 the robot control method based on a large language model as described in any one of claims 1-6.

9. 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 the robot control method based on a large language model as described in any one of claims 1 to 6.

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