Collaborative robot command processing method and apparatus, computer device, and storage medium
Patent Information
- Application Number
- CN202510165082.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2026-08-21
AI Technical Summary
然而,这种方式主要适用于状态数量、命令数量不多(比如数十条)的情况,对于具有多种状态及命令的协作机器人系统,上述方式的软件复杂度会急剧增加,可扩展性也会急剧降低,后期维护会变得非常艰难
Smart Images

Figure CN122606557A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of robot control, and in particular to a collaborative robot command processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] With the continuous advancement of technology, the application of automation technology has become a reality. Robotics plays a significant role in the industrial sector, helping to improve the accuracy and safety of industrial operations in factories, greatly reducing human error, and increasing work efficiency.
[0003] Collaborative robots undergo various state changes during operation. Typically, developers implement these state transitions by designing numerous switch / case statements in the program. However, this approach is primarily suitable for situations with a limited number of states and commands (e.g., a few dozen). For collaborative robot systems with multiple states and commands, the software complexity increases dramatically, scalability decreases drastically, and maintenance becomes extremely difficult.
[0004] Therefore, it is necessary to design an efficient method to handle these state transitions, command execution, and output. Summary of the Invention
[0005] Therefore, it is necessary to provide a collaborative robot command processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the efficiency of state machine state transitions of collaborative robots, in order to address the above-mentioned technical problems.
[0006] Firstly, this application provides a collaborative robot command processing method, including:
[0007] Receive control commands;
[0008] In response to control commands, the system searches for a command execution function that matches the current state of the collaborative robot and the control command in the pre-built mapping table of the collaborative robot system state machine.
[0009] Execute the command execution function and obtain the return value of the command execution function;
[0010] Based on the return value of the command execution function, determine whether the state of the collaborative robot system's state machine needs to change.
[0011] In one embodiment, in response to a control command, a command execution function matching the current state of the collaborative robot and the control command is looked up from a pre-built mapping table of the collaborative robot system state machine, including:
[0012] Identify the command type and command content of control commands;
[0013] Obtain the current state of the collaborative robot system's state machine;
[0014] Based on the command type, command content, and the current state of the collaborative robot system state machine, the command execution function that matches the control command is found from the mapping table of the collaborative robot system state machine.
[0015] In one embodiment, determining whether the state of the collaborative robot system's state machine needs to change based on the return value of the command execution function includes:
[0016] If the return value of the command execution function represents a state transition, then the collaborative robot system state machine will be transitioned from the current state to the next target state.
[0017] If the return value of the command execution function indicates that the state does not need to change, then the collaborative robot system state machine will be maintained in the current state.
[0018] In one embodiment, before updating the current state of the collaborative robot system state machine, the method further includes:
[0019] Call the exit state function associated with the current state to release the resources allocated in the current state and stop the tasks associated with the current state;
[0020] After updating the current state of the collaborative robot system state machine, the method also includes:
[0021] When the collaborative robot system state machine transitions to the next target state, the state entry function associated with the target state is called to initialize the state machine parameters and start the task associated with the target state.
[0022] In one embodiment, the method further includes:
[0023] If the received command includes both external commands and internal timer commands, then the external commands and internal timer commands are added to the command queue, triggering the synchronization lock mechanism to control access to the command queue and the collaborative robot system state machine.
[0024] Secondly, this application also provides a collaborative robot command processing device, comprising:
[0025] The command receiving module is used to receive control commands;
[0026] The command execution function matching module is used to find the command execution function that matches the current state of the collaborative robot and the control command in response to the control command from the mapping table in the pre-built collaborative robot system state machine;
[0027] The command execution module is used to execute command execution functions and obtain the return value of the command execution functions;
[0028] The state transition judgment module is used to determine whether the state of the collaborative robot system's state machine needs to change based on the return value of the command execution function.
[0029] In one embodiment, the apparatus further includes a command synchronization module, which, if the received command includes an external command and an internal timer command, adds the external command and the internal timer command to the command queue, triggers a synchronization lock mechanism, and controls access to the command queue and the collaborative robot system state machine.
[0030] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above-described embodiments of the collaborative robot command processing method.
[0031] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in any of the above embodiments of the collaborative robot command processing method.
[0032] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in any of the above-described embodiments of the collaborative robot command processing method.
[0033] Compared to existing methods that design collaborative robot instruction processing mechanisms using branching statements, the aforementioned collaborative robot command processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product cleverly map the collaborative robot's states and corresponding command execution functions using a pre-built mapping table of the collaborative robot system's state machine model. The return value of the command execution function serves as the basis for determining whether to perform a state transition. Executing commands initiates state transitions. This simplifies the collaborative robot system's command processing logic and reduces design complexity. Furthermore, executing control commands through the mapping table improves command processing efficiency and enhances the ease of managing state transitions. When state transition rules change, updating the mapping table adapts to the changes without modifying a large amount of scattered code logic, improving system maintainability and scalability. Finally, separating command execution logic from state transitions facilitates functional expansion based on business needs, improving system flexibility and scalability, while also enhancing system maintainability. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0035] Figure 1 A flowchart illustrating a collaborative robot command processing method in one embodiment;
[0036] Figure 2 This is a flowchart illustrating the collaborative robot command processing method in another embodiment;
[0037] Figure 3 This is a flowchart illustrating the collaborative robot command processing method in yet another embodiment;
[0038] Figure 4 This is a flowchart illustrating a collaborative robot command processing method in a detailed embodiment;
[0039] Figure 5 This is a structural block diagram of a collaborative robot command processing device in one embodiment;
[0040] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0042] In one exemplary embodiment, such as Figure 1 As shown, a collaborative robot command processing method is provided. Taking the application of this method to a collaborative robot as an example, the method includes the following steps S100 to S400. Wherein:
[0043] S100 receives control commands.
[0044] Among them, control commands are used to control the state of the collaborative robot system.
[0045] In practical applications, collaborative robot systems can receive control commands from multiple sources during normal operation. Specifically, these control commands can include external commands and internal timer commands. External commands can be control commands input by the operator through a teach pendant, control commands sent from a remote computer or other device via a TCP / IP network connection, I / O signals through physical interfaces (such as buttons or sensors), and commands obtained through communication with a PLC or other industrial equipment via the Modbus protocol. Internal timer commands can be commands generated periodically at high frequency by a timer, used to check the system's operating environment.
[0046] S200, in response to control commands, looks up the command execution function that matches the current state of the collaborative robot and the control command from the mapping table of the pre-built collaborative robot system state machine.
[0047] In this embodiment, the collaborative robot system state machine is constructed based on a Moore-type finite state machine and is used for state transitions.
[0048] In practical applications, a state machine mapping table for the collaborative robot system can be pre-built. This table stores the possible state transition rules of the collaborative robot. Specifically, it defines the actions to be taken when a specific control command is received in the current state and the target state to be transitioned to. Each entry in the mapping table contains the current state, the control command, the command execution function, and the target state. For example, the mapping table includes AddTran(currentState, cmd, cmdFun, newState), where the current state currentState and the target state newState represent the mode or specific conditions of the collaborative robot system, such as initialization, power-on, establishing connection with the robot body, de-enabled, enabled, and movement states; the control command cmd is used to trigger the state transition; and the command execution function cmdFun contains the actual business processing logic corresponding to the control command, such as moving the robotic arm or reading sensor data. After receiving a control command, the command execution function that matches the current state and control command is searched from the pre-built state machine mapping table.
[0049] S300 executes the command execution function and obtains the return value of the command execution function.
[0050] In practical applications, the command execution function is executed, and the return value of the command execution function is obtained. The return value can include true or false.
[0051] S400 determines whether the state of the collaborative robot system's state machine needs to change based on the return value of the command execution function.
[0052] In practical applications, the state transition of the collaborative robot system's state machine is determined based on the specific return value. For example, if the return value is true, a state transition is required; if the return value is false, no state transition is performed.
[0053] In the aforementioned collaborative robot command processing method, compared to the existing method of designing the collaborative robot's instruction processing mechanism through branch statements, this application cleverly maps the collaborative robot's state and its corresponding command execution function to each other using a pre-built mapping table of the collaborative robot system's state machine model. The return value of the command execution function serves as the basis for whether to perform a state transition. Executing the command initiates the state transition. On one hand, this simplifies the collaborative robot system's command processing logic and reduces design complexity. On the other hand, executing control commands through the mapping table improves command processing efficiency and enhances the ease of managing state transitions. When state transition rules change, updating the mapping table adapts to the changes without modifying a large amount of scattered code logic, improving the system's maintainability and scalability. Furthermore, separating the command execution logic from state transitions facilitates functional expansion based on business needs, improving the system's flexibility and scalability, while also enhancing its maintainability.
[0054] To improve command processing efficiency, in one exemplary embodiment, such as Figure 2 As shown, S200 includes S220 to S260. Wherein:
[0055] S220 identifies the command type and command content of control commands.
[0056] The command type of the control command can include external commands and internal timer commands (i.e., timer commands). The command content can include the identifier or name of the control command, used to uniquely represent a specific operation or request.
[0057] In practical applications, the command type of a control command can be identified by its fields, and the command content can be identified by parsing the control command, so as to find the corresponding command execution function.
[0058] S240, obtain the current state of the collaborative robot system state machine.
[0059] In practical applications, the current state can be obtained by accessing state properties, querying the current state through predefined methods, or obtaining the current state through a state listener.
[0060] S260: Based on the command type, command content, and the current state of the collaborative robot system state machine, find the command execution function that matches the control command from the mapping table of the collaborative robot system state machine.
[0061] In practical applications, a mapping table is used to find the command execution function corresponding to the command type, content, and current state. For example, the mapping table includes `AddTran(currentState, cmdType, cmd, cmdFun, newState)`, where the current state is the running state `currentState`, the received command type `cmdType` is an external command, the command content `cmd` indicates stopping the running task, and the corresponding command execution function `cmdFun` is matched from the mapping table as `handle_stop_task()`, which is used to stop the current task.
[0062] In this embodiment, the command processing method of the command execution function that matches the current state, the command type and the command content of the control command are found through the mapping table of the collaborative robot system state machine, thereby improving the command processing efficiency.
[0063] In one exemplary embodiment, such as Figure 3 As shown, S400 includes S420 to S440. Wherein:
[0064] S420, if the return value of the command execution function represents a state transition, then the collaborative robot system state machine will be transitioned from the current state to the next target state.
[0065] In practical applications, the corresponding command execution function is matched through the mapping table. The matching items also include the target state corresponding to the control command. The command execution function is executed. If the return value of the command execution function represents the state transition (such as the return value being true), the collaborative robot system state machine is transitioned from the current state to the target state.
[0066] S440, if the return value of the command execution function indicates that the state does not need to change, then the collaborative robot system state machine will be maintained in the current state.
[0067] In practical applications, when executing a command execution function, if the return value of the command execution function indicates that no state transition is required (such as a return value of false), the collaborative robot system state machine is maintained in the current state.
[0068] In this embodiment, by cleverly mapping the state of the collaborative robot to the corresponding command execution function, and using the return value of the command execution function as the basis for whether to perform a state transition, the command is executed to perform the state transition, which simplifies the command processing logic of the collaborative robot system, reduces the design complexity, and improves the command processing efficiency.
[0069] In one exemplary embodiment, before updating the current state of the collaborative robot system state machine, the method further includes:
[0070] Call the exit state function associated with the current state to release the resources allocated in the current state and stop the tasks associated with the current state.
[0071] The exit state function is used to exit the current state.
[0072] In practical applications, corresponding exit state functions can be defined for each state of the collaborative robot system's state machine. These functions can be defined using `AddExitState(currentState, fun)`. Exit state functions can include releasing resources, stopping the task, and saving data. For example, a control command indicates stopping execution, the current state is running, the return value of the command execution function indicates the need for a state transition, and the exit state function associated with the current state is called to close open files, network connections, or hardware interfaces, terminate the currently running task, and clean up related threads or processes.
[0073] After updating the current state of the collaborative robot system state machine, the method also includes:
[0074] When the collaborative robot system state machine transitions to the next target state, the state entry function associated with the target state is called to initialize the state machine parameters and start the task associated with the target state.
[0075] The state entry function is used to enter the target state.
[0076] In practical applications, corresponding entry state functions can be defined for each state of the collaborative robot system's state machine. These functions can be defined using `AddEntryState(newState, fun)`. Entry state functions can include initializing state machine parameters and starting tasks. For example, a control command represents execution, the current state is idle, the return value of the command execution function indicates the required state transition, the target state is running, the entry state function associated with the running state is called, state machine parameters (such as task ID) are initialized, and the transport task or other related tasks are started.
[0077] In this embodiment, by calling the exit state function associated with the current state, the collaborative robot can ensure that all resources are correctly released and tasks are safely stopped when the state changes. By calling the enter state function associated with the target state, the collaborative robot can ensure that the state machine parameters are correctly initialized when the state changes, and that any necessary tasks or services can be started in a timely manner, thereby improving the reliability and stability of the system and helping to maintain the healthy operation of the system.
[0078] To ensure the correctness of control command processing in a complex multi-threaded environment, in an exemplary embodiment, the method further includes: if the received command includes an external command and an internal timer command, then adding the external command and the internal timer command to the command queue, triggering a synchronization lock mechanism, and controlling access to the command queue and the collaborative robot system state machine.
[0079] In practical applications, considering that multiple threads from multiple channels can simultaneously send control commands to external commands, and internal timers may also send internal timer commands simultaneously, a synchronization lock is introduced to ensure the orderly and safe processing of control commands and avoid data inconsistency caused by concurrent access. This ensures thread synchronization during command execution in the collaborative robot system's state machine. Specifically, received external commands and internal timer commands are added to the command queue, triggering the synchronization lock mechanism. The synchronization lock is acquired to retrieve the control command from the command queue. The collaborative robot system's state machine is accessed based on the control command to determine if a state transition is needed. Referring to the steps in the above embodiment, responding to the control command, a command execution function matching the current state and control command is found in the pre-built mapping table of the collaborative robot system's state machine. The command execution function is executed, and its return value is obtained. Based on the return value, the steps in the embodiment determining whether a state transition is needed for the collaborative robot system's state machine are performed are not repeated here. After the control command is processed, the lock is released.
[0080] In this embodiment, a command queue and synchronization lock mechanism are used to manage the control commands received by the collaborative robot system from multiple channels, ensuring that these control commands can be processed safely and correctly. This prevents data inconsistency issues caused by concurrent access, improves the reliability and stability of the system, and ensures consistency and correctness in complex multi-threaded environments.
[0081] To provide a clearer explanation of the collaborative robot command processing method provided in this application, a specific embodiment and accompanying drawings are described below. Figure 4 The specific embodiment includes the following steps:
[0082] S1 receives control commands.
[0083] S2 identifies the command type and content of the control command and obtains the current state of the collaborative robot system state machine.
[0084] S3. If the received command includes both external command and internal timer command, then add the external command and internal timer command to the command queue, trigger the synchronization lock mechanism, and control access to the command queue and the collaborative robot system state machine.
[0085] S4. Based on the command type, command content, and the current state of the collaborative robot system state machine, find the command execution function that matches the control command from the mapping table of the collaborative robot system state machine.
[0086] S5. If the return value of the command execution function indicates that the state does not need to change, then the collaborative robot system state machine will be maintained in the current state.
[0087] S6. If the return value of the command execution function represents a state transition, before updating the current state of the collaborative robot system state machine, call the exit state function associated with the current state to release the resources allocated in the current state and stop the tasks associated with the current state. If the collaborative robot system state machine transitions to the next target state, call the enter state function associated with the target state to initialize the state machine parameters and start the tasks associated with the target state to transition the collaborative robot system state machine from the current state to the next target state.
[0088] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0089] In one exemplary embodiment, such as Figure 5 As shown, a collaborative robot command processing device 600 is provided, including: a command receiving module 610, a command execution function matching module 620, a command execution module 630, and a state transition judgment module 640, wherein:
[0090] Command receiving module 610 is used to receive control commands;
[0091] Command execution function matching module 620 is used to look up a command execution function that matches the current state of the collaborative robot and the control command in a mapping table in a pre-built collaborative robot system state machine in response to a control command.
[0092] Command execution module 630 is used to execute command execution functions and obtain the return value of command execution functions;
[0093] The state transition judgment module 640 is used to determine whether the state of the collaborative robot system state machine needs to change based on the return value of the command execution function.
[0094] In an exemplary embodiment, the command execution function matching module 620 is further configured to identify the command type and command content of the control command; obtain the current state of the collaborative robot system state machine; and, based on the command type, command content, and the current state of the collaborative robot system state machine, find the command execution function that matches the control command from the mapping table of the collaborative robot system state machine.
[0095] In an exemplary embodiment, the state transition judgment module 640 is further configured to, if the return value of the command execution function represents a state transition, transition the collaborative robot system state machine from the current state to the next target state; if the return value of the command execution function represents a state transition that does not require a transition, maintain the collaborative robot system state machine in the current state.
[0096] In an exemplary embodiment, the collaborative robot command processing device 600 further includes a state accompaniment function execution module 650, which is used to call an exit state function associated with the current state before updating the current state of the collaborative robot system state machine, so as to release the resources allocated in the current state and stop the tasks associated with the current state; and to call an entry state function associated with the target state when the collaborative robot system state machine transitions to the next target state, so as to initialize the state machine parameters and start the tasks associated with the target state.
[0097] In one exemplary embodiment, the collaborative robot command processing device 600 further includes a command synchronization module 660, which, if the received command includes an external command and an internal timer command, adds the external command and the internal timer command to the command queue, triggers a synchronization lock mechanism, and controls access to the command queue and the collaborative robot system state machine.
[0098] Each module in the aforementioned collaborative robot command processing device 600 can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0099] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a collaborative robot command processing method.
[0100] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0101] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above embodiments of the collaborative robot command processing method.
[0102] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in any of the above embodiments of the collaborative robot command processing method.
[0103] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in any of the above embodiments of the collaborative robot command processing method.
[0104] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0105] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0106] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0107] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for processing commands for a collaborative robot, characterized in that, The method includes: Receive control commands; In response to the control command, a command execution function matching the current state of the collaborative robot and the control command is found from the mapping table of the pre-built collaborative robot system state machine; Execute the command execution function and obtain the return value of the command execution function; Based on the return value of the command execution function, determine whether the state of the collaborative robot system state machine needs to change.
2. The method according to claim 1, characterized in that, In response to the control command, the process of searching a pre-built mapping table of the collaborative robot system state machine for a command execution function that matches the current state of the collaborative robot and the control command includes: Identify the command type and command content of the control command; Obtain the current state of the collaborative robot system state machine; Based on the command type, the command content, and the current state of the collaborative robot system state machine, a command execution function matching the control command is found from the mapping table of the collaborative robot system state machine.
3. The method according to claim 2, characterized in that, The step of determining whether the state of the collaborative robot system state machine needs to change based on the return value of the command execution function includes: If the return value of the command execution function represents a state transition, then the collaborative robot system state machine will be transitioned from the current state to the next target state. If the return value of the command execution function indicates that the state does not need to change, then the collaborative robot system state machine will be maintained in the current state.
4. The method according to claim 3, characterized in that, Before updating the current state of the collaborative robot system state machine, the method further includes: Invoke the exit state function associated with the current state to release the resources allocated in the current state and stop the tasks associated with the current state; After updating the current state of the collaborative robot system state machine, the method further includes: When the collaborative robot system state machine transitions to the next target state, the entry state function associated with the target state is called to initialize the state machine parameters and start the task associated with the target state.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: If the received command includes both external commands and internal timer commands, then the external commands and internal timer commands are added to the command queue, triggering a synchronization lock mechanism to control access to the command queue and the collaborative robot system state machine.
6. A command processing device for a collaborative robot, characterized in that, The device includes: The command receiving module is used to receive control commands; The command execution function matching module is used to, in response to the control command, search for a command execution function that matches the current state of the collaborative robot and the control command from a mapping table in a pre-built collaborative robot system state machine. The command execution module is used to execute the command execution function and obtain the return value of the command execution function; The state transition judgment module is used to determine whether the state of the collaborative robot system state machine needs to change based on the return value of the command execution function.
7. The apparatus according to claim 6, characterized in that, The device also includes a command synchronization module, which, if the received command includes an external command and an internal timer command, adds the external command and the internal timer command to the command queue, triggers a synchronization lock mechanism, and controls access to the command queue and the collaborative robot system state machine.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.