Robot control program debugging method and device based on RAPID language formal semantics
By reconstructing the syntax of the RAPID language and designing formal semantics RAPID-FS, combined with the debugging method of the K framework, the problem of time-consuming and labor-consuming debugging of existing robot control program is solved, and convenient and efficient program debugging and security analysis are achieved.
Patent Information
- Application Number
- CN202211034504.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2042-08-26
AI Technical Summary
The existing robot control program debugging methods require the establishment of workstations and the addition of variables to be observed one by one, which consumes a lot of time and labor costs and lacks convenient and intuitive debugging methods.
By reconstructing the syntax of the RAPID language, defining the running configuration format, designing formal semantic RAPID-FS, and using the K framework for debugging, it realizes fast and intuitive debugging of robot control programs.
It reduces labor and time costs, provides a more convenient program debugging method, can intuitively observe the intermediate state of the robot, and improves the accuracy and safety analysis efficiency of the program.
Smart Images

Figure CN115357504B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a robot control program debugging method and device based on RAPID language formal semantics. Background Art
[0002] Robots are programmable automated mechanical devices that are widely used in (intelligent) manufacturing. With the widespread use of robots, safety accidents caused by their misoperation occur from time to time. In recent years, accidents have occurred in production line robots in many parts of the world, causing casualties and property losses. These incidents show that once an abnormality occurs in the robots located at the production site, it will pose a direct threat to human life and surrounding equipment, and have an impact on the production process. Therefore, it is necessary to ensure that their control software runs safely and correctly. Robots can be programmed in two ways, online or offline. Online programming is achieved through the "show and teach" method, while offline programming requires the help of proprietary languages. Robot programming languages contain a series of instructions to control the robot, which can move the robot, manipulate the end effector and communicate with the robot user. Therefore, it is very important to ensure that the robot's control program can be executed correctly and exhibits the expected behavior when executed.
[0003] In order to ensure the correctness and safety of the robot, before the robot control program is actually used in production, the developer needs to debug the control program to find out whether there are functional defects or safety risks. At present, the debugging methods of robot control programs are all based on the simulation development environment of the robot, which has the following defects: before debugging the control program, it is necessary to establish a workstation according to the robot model, tools, operation objects and other information, and add the variables to be observed one by one in the variable monitoring window. This process will consume a lot of time and manpower costs. Therefore, it is necessary to provide robot control program developers with a more convenient program debugging method that can intuitively view the results. Summary of the invention
[0004] The purpose of the present invention is to provide a robot control program debugging method and device based on RAPID language formal semantics in view of the deficiencies of the prior art.
[0005] The objective of the present invention is achieved through the following technical solutions:
[0006] According to a first aspect of the present specification, there is provided a robot control program debugging method based on the formal semantics of the RAPID language, the method comprising the following steps:
[0007] (1) Reconstructing the grammar: The grammar format in the official documentation of the RAPID language, the extended Backus-Naur form, is reconstructed into the traditional Backus-Naur form that complies with the provisions of the K framework;
[0008] (2) Define the run configuration format: Based on the characteristics of the RAPID language and the program status to be observed during debugging, define the run configuration format. The run configuration is used to save the intermediate status of the program during runtime.
[0009] (3) Design formal semantics: Based on the syntax and runtime configuration parameters of the RAPID language, the K framework is used to define the RAPID language formal semantics RAPID-FS. RAPID-FS covers the features of the RAPID language, including module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction.
[0010] (4) Debugging the program: Based on RAPID-FS, the robot control program is debugged using the K framework. During the debugging process, the correctness and security of the program are analyzed by observing the intermediate states of the program stored in the running configuration.
[0011] Furthermore, the RAPID language formal semantics is an executable operational semantics, and the robot control program specifically refers to a control program written in the RAPID language.
[0012] Furthermore, the syntax of the RAPID language described in step (1) is defined in a programming language definition framework, namely, the K framework, and the form of the syntax follows the traditional Backus-Naur form.
[0013] Furthermore, the syntax of the RAPID language described in step (1) is used to parse data types, array declarations, variable declarations, constant declarations, scopes, basic statements, routine declarations and calls, module declarations, and robot operation instructions in the program.
[0014] Furthermore, the running configuration described in step (2) is defined based on the K framework and is represented by a nested configuration unit, and the intermediate state of the program running is stored in the configuration unit.
[0015] Furthermore, the operation configuration described in step (2) includes 6 main units, namely a program configuration unit, an environment configuration unit, a property configuration unit, a storage configuration unit, a control configuration unit and a robot state configuration unit; the program configuration unit records the program fragment to be executed; the environment configuration unit records the environment variables during the program running process; the property configuration unit records the properties of each object in the program; the control configuration unit maintains the program stack, function return type, current call parameter information, and current running module information; the storage configuration unit is used to store the values of variables or functions in the program; and the robot state configuration unit records the position, input and output, and user interaction information of the robot during operation.
[0016] Furthermore, the RAPID language formal semantics RAPID-FS described in step (3) is obtained by rewriting the meaning of each statement in the robot control program into formal semantic rules based on rewriting logic and using the K framework.
[0017] Furthermore, the RAPID language formal semantics RAPID-FS described in step (3) covers the features of module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction in the RAPID language, including data types, array declaration, variable declaration, constant declaration, scope, basic statements, routine declaration and call, module declaration, and robot operation instructions, where:
[0018] Data types, including atomic type, composite type, and equivalent type;
[0019] Array declaration, declaration for one-dimensional array;
[0020] Variable declaration, including declaration of common variables and permanent variables;
[0021] Scope, including global scope and local scope;
[0022] Basic statements, including assignment statements, function return statements, routine exit statements, conditional statements, loop statements, loop termination statements, test statements, and labels;
[0023] Routine declaration and call, including declaration and call of custom routines with and without return values, and declaration of system predefined routines with and without return values;
[0024] Robot operation instructions, including robot movement instructions, input and output instructions, and user interaction instructions.
[0025] Furthermore, step (4) uses the K framework to compile RAPID-FS, and then enables the debugger through the K framework to debug the robot control program, thereby analyzing the correctness and security of the program.
[0026] According to a second aspect of the present specification, there is provided a robot control program debugging device based on RAPID language formal semantics, the device comprising the following modules:
[0027] Grammar reconstruction module: reconstructs the grammar format in the official document of RAPID language, the extended Backus Naur form, into the traditional Backus Naur form that complies with the provisions of the K framework;
[0028] Run configuration format definition module: Based on the characteristics of the RAPID language and the program status to be observed during debugging, the run configuration format is defined. The run configuration is used to save the intermediate status of the program during runtime.
[0029] Formal semantics design module: Based on the syntax and runtime configuration parameters of RAPID language, the K framework is used to define the RAPID language formal semantics RAPID-FS. RAPID-FS covers the features of module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction in RAPID language.
[0030] Program debugging module: Based on RAPID-FS, the robot control program is debugged using the K framework. During the debugging process, the correctness and security of the program are analyzed by observing the intermediate states of the program stored in the running configuration.
[0031] The beneficial effect of the present invention is that the robot control program debugging method and device based on the RAPID language formal semantics proposed by the present invention enables developers to avoid using the traditional debugging method based on the simulation environment, thereby avoiding the necessary steps of establishing a workstation and adding variables in the monitoring window, and at the same time, the intermediate state of the robot operation can be observed intuitively. The present invention achieves a better program debugging effect while reducing manpower and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a flow chart of a debugging method provided by an exemplary embodiment of the present invention.
[0033] Figure 2 It is a schematic diagram of a running configuration format provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0035] As attached Figure 1 As shown, a robot control program debugging method based on RAPID language formal semantics provided by an embodiment of the present invention comprises the following steps:
[0036] 1. Refactoring the grammar: Refactor the grammar format in the official documentation of the RAPID language, the extended Backus Nar form, to express it as the traditional Backus Nar form that complies with the K framework. This reconstruction process covers the following features of the RAPID language:
[0037] (1) Identifier: An identifier is a symbol used to identify an entity, and is used to name variables, constants, routines, statement blocks, etc.
[0038] (2) Data types. Data types are divided into three categories: atomic data, record data, and alias data. Atomic data can only be composed of basic elements such as numbers and characters, and the data cannot be further decomposed. Composite data is composed of multiple data, and the data used for compounding can be either basic data or other composite data. Alias data is actually equivalent to defining an alias for a certain data type.
[0039] (3) Data definition. There are two types of data scope: global data and local data. Global data is program data that can be used by all tasks, all modules and programs. It is the system default setting and does not require special declaration. Local data can only be used by this module and its affiliated programs and needs to be declared with the "LOCAL" keyword. Data can be declared as constants CONST, permanent data PERS, and variables VAR.
[0040] (4) Expression. An expression is an arithmetic, logical operation, or comparison expression used to calculate the value or logical state of program data. Operands in an expression need to be connected using operators, and different operations have regulations and requirements for the types of operands. Simple arithmetic and comparison operations can use basic operators, while complex operations need to be implemented using function commands.
[0041] (5) Assignment statement. An assignment statement is used to replace the current value of a variable, permanent data, or parameter with the value defined by an expression. The assignment target and the expression must have the same type.
[0042] (6) Return and exit statements. The return statement is used to terminate the execution of a routine and specify a return value. The exit statement is used to stop the execution of the entire program, including "EXIT", "Break", "Stop", and "ExitCycle".
[0043] (7) Conditional statements. Conditional statements include IF statements and TEST statements.
[0044] (8) Loop statements. Loop statements include FOR statements and WHILE statements.
[0045] (9) Labels. Labels are "no-operation" statements used to define named program locations.
[0046] (10) Routine call. Routines in RAPID language are divided into two types: Function and Procedure. The main difference between the two is that Function has a type and a return value, while Procedure does not. RAPID-FS supports both required and optional parameters of routines. Required parameters are parameters that must be passed in with actual parameters when calling a routine; while optional parameters can be used or not when calling, that is, passing in actual parameters or not. Parameter access modes are quite diverse. Access modes are used to specify the setting and conversion methods of parameter values. RAPID-FS supports access modes such as INOUT, VAR / INOUT VAR, PERS / INOUT PERS, and switch. The beginning of the routine internal statement is the definition of data. The definition method is similar to module data, but routine internal data does not support permanent data PERS, and cannot be declared with the LOCAL keyword. In addition, routine internal data can only be used within the routine. There are also some built-in routines provided by some companies in RAPID language, mainly including some basic statements, operation instructions and functions, movement instructions and functions, IO instructions and functions, and human-computer interaction instructions.
[0047] (11) Statements. Statements are divided into assignment statements, return statements, exit statements, conditional statements, loop statements, labels, statement blocks, routine call statements, etc.
[0048] (12) Routine definition. Routine definitions within a module are divided into instruction definitions and function definitions. They can be declared as module instructions or module functions using the LOCAL keyword.
[0049] (13) Module definition. RAPID language adopts modular programming. A task may contain multiple program modules and system modules. Depending on the module function and access rights, different module attributes can be assigned to the module, including "SYSMODULE", "NOVIEW", "NOSTEPIN", "VIEWONLY", and "READONLY".
[0050] 2. Define the run configuration format: Define the run configuration format based on the characteristics of the RAPID language and the program status to be observed during debugging. The run configuration is used to save the intermediate status of the program when it is running. The multi-layer nested structure diagram of the run configuration is shown in the attached figure. Figure 2 As shown. The operation configuration includes 6 main units, namely program configuration unit, environment configuration unit, attribute configuration unit, storage configuration unit, control configuration unit and robot state configuration unit. The format of each operation configuration unit is described as follows:
[0051] (1) Program configuration unit: The value of each unit is initialized in the configuration and its type is specified. A dot followed by any type represents the empty set of that type. For example, ".List" is an empty list. Unit T is the top-level unit that contains all units.
[0052] In cell "k", a source program named "Pgm" is stored for execution. If the program stored in cell "k" terminates in a normal manner, the contents of the cell will become a dot, indicating that the cell is empty and no more programs can be executed.
[0053] (2) Environment configuration unit: During the running of RAPID program, it is necessary to save the runtime environment variables of the program, that is, the location of variables, constants, functions and other objects in memory, involving four units: "env", "genv", "tenv" and "lenv". The unit "env" records the local environment variables during the running of the program, "genv" records the global environment variables during the running of the program, "tenv" records the backup of local environment variables, and "lenv" records the environment variables inside the loop statement. The storage form of "env", "genv", "tenv" and "lenv" is a list composed of the mapping of variables to their locations, and the initial value is an empty mapping ".Map".
[0054] (3) Attribute configuration unit: The unit "attribute" records the attributes of each object when the program is running, including type, value, module, and whether it can be modified. The unit "type" is used to save the type, and the storage form is the definition of position to type, and the initial value is an empty mapping. Since the module to which variables and functions belong has an impact on their scope, the unit "module" is used to record the module to which the object belongs. The "module" contains two units "mname" and "local", which respectively indicate the module name and whether the object can only be used within this module. The unit "mutable" records whether the value of the data can be modified. For example, the value of the constant CONST type cannot be modified, but the variable VAR and permanent data PERS can be modified.
[0055] (4) Storage configuration unit: The unit "store" is the "memory" when the program is running, storing the values of objects such as variables, constants, and routines. The initial value is an empty mapping. "nextloc" saves the index value of the next memory unit in the memory. The initial value is 0. As the stored content increases, the index value gradually increases.
[0056] (5) Control configuration unit: Some units are used to save intermediate states. The unit "curmodu" records the name of the module to which the statement currently executed by the program belongs. Since the entry point of the program is in the main module, the initial value is "mainmodu", which means "main module". The unit "bfexe" records whether it is currently in the program parsing stage or has entered the execution stage. The default value is "true", which means "true". The fstack unit is a list that records the state of the stack during the routine call process. "returntype" is used to record the return value type of the function. "present" is used to record the optional parameters used when calling the upper layer routine.
[0057] (6) Robot status configuration unit: Since the RAPID language covers functions such as robot movement and IO, it is necessary to design units to record related states. Here, five units are involved: "tcp-pos", "tool", "aliasio", "in" and "out". The "tcp-pos" unit is used to represent the position information of the robot tool center point (TCP point), and the storage type is pos type. "Tool" records the tool data currently used by the robot, and the storage type is tooldata. In order to increase the versatility of the program, the I / O signals used in the RAPID program can be freely named. When the program is used for a specific robot, the connection between the program I / O and the actual configuration I / O of the system can be established through the I / O connection definition instruction, and the unit "aliasio" is used to record this connection relationship. The communication between the robot controller and the teach pendant is the most commonly used communication operation of the RAPID program. The controller can output information to the teach pendant screen through instructions. Here, the "out" unit is used to simulate the teach pendant screen output and display information; the user can also input information from the teach pendant to the robot, and the "in" unit is used to simulate the teach pendant screen input.
[0058] 3. Design formal semantics: Based on the syntax and runtime configuration parameters of the RAPID language, the K framework is used to define the formal semantics of the RAPID language, RAPID-FS. RAPID-FS covers the features of the RAPID language, such as module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction, including data types, array declarations, variable declarations, constant declarations, scopes, basic statements, routine declarations and calls, module declarations, and robot operation instructions.
[0059] In order to facilitate the design of formal semantics, some data types and data structures are defined. They are used to write formal semantic rules and are different from the original data types and data structures of the RAPID language. Among them, Int represents an integer and Id represents an identifier. Value can be an integer (Int), a floating-point number (Float), a string (String), a Boolean type (Bool), etc. Type represents the data type in RAPID, such as num, pos, opcalc, etc. Expression represents an expression. Pos consists of three integers or floating-point numbers and represents the pos type in RAPID. Similarly, Tool represents tooldata. ModDataDeclarations and RoutDataDeclaraions are lists of variable or constant declarations. RoutDeclarations is a list of routine declarations. RoutBody represents the body of the routine. Paras and Args are the formal parameter sequence and the actual parameter sequence, respectively. Statements represents the statement sequence in RAPID.
[0060] The following uses the assignment statement in the RAPID language as an example to demonstrate the design of formal semantics, which involves two semantic rules, namely RULE Assignment and Write.
[0061] (1)RULE Assignment:
[0062]
[0063] RULE Assignment describes the formal semantic rules of assignment statements in the RAPID language, such as assigning a new value to a variable of type num. In the run configuration unit k, the function #pcsStatement is used to process an assignment statement X:Id:=E:Expression, where X is a variable name and E is an expression. The function is rewritten as a #write function, and its corresponding semantic rules are introduced in RULE Write. In the run configuration unit env, the variable name X is used to find the corresponding index L. In the run configuration unit type, the index L is used to find its corresponding variable type T, and T is finally used as the parameter of the #write function. In addition, since the assigned variable needs to have the property of being modifiable, it is necessary to check whether it has the attribute true in the unit mutable.
[0064] (2)RULE Write:
[0065]
[0066] RULE Write specifies the semantic rules of the #write function. In the running configuration unit k, the three parameters of the #write function are extracted: index L, value V and type T, and then the #write function is rewritten to "." (representing no operation). In the running configuration unit store, the original value V' of the variable is found using index L and rewritten to value V, thus completing an assignment operation. It is worth noting that RULE Write needs to meet a condition to be executed, that is, the type of V must be consistent with T.
[0067] 4. Debug the program: Based on RAPID-FS, use the K framework to debug the robot control program. During the debugging process, the correctness and security of the program are analyzed by observing the intermediate states of the program stored in the running configuration.
[0068] For example, we debug the following program:
[0069]
[0070] Assuming the program file name is example.rapid, the debugging command will be krun example.rapid --debugger. It allows developers to set breakpoints at semantic rules, execute the program from one breakpoint to the next, and output the current state. After the first run of the 6th line of code, part of the intermediate state of the debugged program is shown below. This intermediate state is related to variable a. It can be seen that variable a is a global variable of type num, and its value can be changed. At this time, the value of a is 1.
[0071]
[0072] The above embodiments are used to illustrate the present invention rather than to limit the present invention. Any modification and change made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A robot control program debugging method based on RAPID language formal semantics, It is characterized in that include: (1) Reconstructing the grammar: The grammar format in the official documentation of the RAPID language, the extended Backus-Naur form, is reconstructed into the traditional Backus-Naur form that complies with the provisions of the K framework; (2) Define the run configuration format: Based on the characteristics of the RAPID language and the program status to be observed during debugging, define the run configuration format. The run configuration is used to save the intermediate status of the program during runtime. (3) Design formal semantics: Based on the syntax and runtime configuration parameters of the RAPID language, the K framework is used to define the RAPID language formal semantics RAPID-FS. RAPID-FS covers the features of the RAPID language, including module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction. (4) Debugging program: Based on RAPID-FS, use the K framework to debug the robot control program; During the debugging process, the correctness and security of the program are analyzed by observing the intermediate states of the program stored in the running configuration.
2. A robot control program debugging method based on RAPID language formal semantics according to claim 1, It is characterized in that The syntax of the RAPID language described in step (1) is defined in a programming language definition framework, namely, the K framework, and the form of the syntax follows the traditional Backus-Naur form.
3. A robot control program debugging method based on RAPID language formal semantics according to claim 1, It is characterized in that The running configuration described in step (2) is defined based on the K framework and is represented by a nested configuration unit. The intermediate state of the program running is stored in the configuration unit.
4. A robot control program debugging method based on RAPID language formal semantics according to claim 1, It is characterized in that The operation configuration described in step (2) includes 6 main units, namely, a program configuration unit, an environment configuration unit, an attribute configuration unit, a storage configuration unit, a control configuration unit and a robot state configuration unit; the program configuration unit records the program fragment to be executed; the environment configuration unit records the environment variables during the program running process; the attribute configuration unit records the attributes of each object in the program; the control configuration unit maintains the program stack, function return type, current call parameter information, and current running module information; the storage configuration unit is used to store the values of variables or functions in the program; The robot state configuration unit records the position, input and output, and user interaction information of the robot during operation.
5. A robot control program debugging method based on RAPID language formal semantics according to claim 1, It is characterized in that The RAPID language formal semantics RAPID-FS described in step (3) is obtained by rewriting the meaning of each statement in the robot control program into formal semantic rules based on rewriting logic and using the K framework.
6. A robot control program debugging method based on RAPID language formal semantics according to claim 1, It is characterized in that The RAPID language formal semantics RAPID-FS described in step (3) covers the features of module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction in the RAPID language, including data types, array declaration, variable declaration, constant declaration, scope, basic statements, routine declaration and call, module declaration, and robot operation instructions, among which: Data types, including atomic type, composite type, and equivalent type; Array declaration, declaration for one-dimensional array; Variable declaration, including declaration of common variables and permanent variables; Scope, including global scope and local scope; Basic statements, including assignment statements, function return statements, routine exit statements, conditional statements, loop statements, loop termination statements, test statements, and labels; Routine declaration and call, including declaration and call of custom routines with and without return values, and declaration of system predefined routines with and without return values; Robot operation instructions, including robot movement instructions, input and output instructions, and user interaction instructions.
7. A robot control program debugging method based on RAPID language formal semantics according to claim 1, It is characterized in that Step (4) uses the K framework to compile RAPID-FS, and then enables the debugger through the K framework to debug the robot control program, thereby analyzing the correctness and security of the program.
8. A robot control program debugging device based on RAPID language formal semantics, It is characterized in that include: Grammar reconstruction module: reconstructs the grammar format in the official document of RAPID language, the extended Backus Naur form, into the traditional Backus Naur form that complies with the provisions of the K framework; Run configuration format definition module: Based on the characteristics of the RAPID language and the program status to be observed during debugging, the run configuration format is defined. The run configuration is used to save the intermediate status of the program during runtime. Formal semantics design module: Based on the syntax and runtime configuration parameters of RAPID language, the K framework is used to define the RAPID language formal semantics RAPID-FS. RAPID-FS covers the features of module definition, variable declaration and assignment, routine definition and call, robot movement, input and output, and user interaction in RAPID language. Program debugging module: Based on RAPID-FS, use K framework to debug robot control program; During the debugging process, the correctness and security of the program are analyzed by observing the intermediate states of the program stored in the running configuration.
Citation Information
Patent Citations
Method for carrying out process monitoring on reconfigurable FPGA software
CN113392025A
Reconstruction method and system for storage module in digital integrated circuit design
CN114461272A