A method for invoking IROS services based on a plug-in framework

Through the plug-in framework, the srv file is parsed and the MD5 encryption algorithm is used to solve the problem of unknown parameter types and names in IROS service communication, and efficient collaboration and robust calls for intelligent robot development are realized.

CN115562678BActive Publication Date: 2025-07-04SHANDONG NEW GENERATION INFORMATION IND TECH RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211413824.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-11
Publication Date
2025-07-04
Estimated Expiration
2042-11-11

AI Technical Summary

Technical Problem

In IROS service communication, it is difficult for developers to determine the parameter type and name, resulting in node call errors or abnormal exits, and the progress of multiple teams is inconsistent when developing in collaboration with each other is not consistent.

Method used

Use the plug-in framework to define interface information, parse the srv file to obtain parameters, use the MD5 encryption algorithm to ensure parameter consistency, and generate interface functions for parameter checksum processing.

Benefits of technology

Automatically complete parameters, improve development efficiency, enhance service call robustness, and save development time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115562678B_ABST
    Figure CN115562678B_ABST
Patent Text Reader

Abstract

A method for invoking IROS services based on a plugin framework, based on the service functions of IROS and robot development components, can automatically complete parameters, facilitate developers to view the types, names, and return values of service parameters, facilitate developers to write corresponding interfaces, and improve the collaborative development efficiency of intelligent robots. At the same time, this solution can also be used as a service testing tool to test whether the service functions are normal, saving development time and improving development efficiency. In addition, this framework also proposes to encrypt the parameters and types of srv files using MD5 as the basis for invoking services, enhancing the robustness of service invocation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of intelligent robot development, and particularly relates to a method for calling IROS services based on a plug-in framework. Background Art

[0002] IROS (Intelligent Robot Operating System, hereinafter referred to as "IROS") has functions similar to ROS, replaces the kernel of open-source ROS, provides an interface compatible with ROS, solves problems related to the reliability, performance, security, etc. of ROS, and adds new functions, supports cloud-based robot development, supports cloud-edge communication, supports multi-robot collaboration, etc.

[0003] Service communication is also an extremely common communication mode in ROS. Service communication is based on a request-response mode and is a kind of response mechanism. In service communication, data is divided into two parts, requests and responses, and requests and responses are separated by --- in the srv file. During the development and debugging stage, the caller of the node service often does not know exactly which parameters need to be passed in and the types of the parameters. Especially when the parameters change, or other programs provide the same service, the calling program of the node is sometimes correct and sometimes incorrect, or exits abnormally. In addition, in multi-person team collaborative development, the development progress of the program service provider and the caller is inconsistent, which means that joint debugging cannot be carried out. Summary of the Invention

[0004] In order to overcome the above-mentioned deficiencies in technology, the present invention provides a method for calling IROS services based on a plug-in framework, which makes the development process more efficient and convenient.

[0005] The technical solution adopted by the present invention to overcome its technical problems is as follows:

[0006] A method for calling IROS services based on a plug-in framework includes the following steps:

[0007] a) Define the interface information of the plug-in;

[0008] b) Define the plug-in interface class;

[0009] c) Define the plug-in management framework;

[0010] d) Obtain the default parameters;

[0011] e) Calculate the MD5 value;

[0012] f) Generate the initialization interface function, which is empty by default;

[0013] g) Generate the send message interface function;

[0014] h) Generate a plug-in request handling function. The request handling function verifies whether the parameter types and names match and whether any parameters are missing. If the parameter name or type is incorrect, an exception is thrown and the program execution is terminated. If a parameter is missing, the default value is used for processing;

[0015] i) Generate a receive message interface function to parse and return the result;

[0016] j) Generate a plug-in response handling function to print out the return result.

[0017] The interface information of the plug-in defined in step a) is as follows:

[0018] a-1) Initialize the interface;

[0019] a-2) Registration interface of the plug-in;

[0020] a-3) Uninstallation interface of the plug-in;

[0021] a-4) Interface to obtain default parameters;

[0022] a-5) Obtain the MD5 value of the plug-in;

[0023] a-6) Define the message sending interface between plug-ins;

[0024] a-7) Define the message receiving interface between plug-ins;

[0025] a-8) Define the plug-in function execution interface.

[0026] The interface class of the plug-in in step b) defines that all the interfaces in step a) are pure virtual functions and are inherited and implemented by subclasses.

[0027] Step c) includes the following steps:

[0028] c-1) Parse the parameters to obtain the srv file used by the service;

[0029] c-2) Determine whether the plug-in of the srv file has been registered. If it has been registered, execute step c-6). If not, obtain the location of the package where the srv file is located and find the corresponding srv file and library;

[0030] c-3) Use the dlopen() function to load the library corresponding to the srv file;

[0031] c-4) Use the dlsym() function to parse the interfaces of the library and create a plug-in class corresponding to the srv file;

[0032] c-5) Register the service using the plug-in class;

[0033] c-6) Obtain the default parameters of the plug-in class for parameter comparison;

[0034] c-7) If the parameters are incompatible after comparison, an exception is thrown and all open dynamic libraries are closed. If the parameters are compatible after comparison, the missing parameters are filled with default values;

[0035] c-8) Obtain the MD5 code of the srv file used by the service provider;

[0036] c-9) Compare whether the MD5 codes are the same. If they are not the same, an error is prompted and the execution is terminated. If they are the same, step c-10) is executed;

[0037] c-10) Call the service interface of the plugin and send the request parameters to the service provider;

[0038] c-11) Wait for the return result of the service, parse and print the result.

[0039] Step d) includes the following steps:

[0040] d-1) Read the content of the srv file;

[0041] d-2) Create a JSON object root;

[0042] d-3) Determine whether the srv file has been completely read. If so, execute step d-15). If not, execute step d-4);

[0043] d-4) Obtain a line of data;

[0044] d-5) Determine whether the obtained data is a comment. If so, return and execute step d-4). If not, execute step d-6);

[0045] d-6) Obtain the parameter name and type name;

[0046] d-7) Determine whether the type name is a basic type. If so, execute step d-8). If not, execute step d-9);

[0047] d-8) Insert the parameter name and basic type into the JSON object and then return to execute step d-4);

[0048] d-9) Determine whether the type name is a msg type. If so, execute step d-10). If not, exit;

[0049] d-10) Obtain the path where the msg file is located and open it. After opening, execute step d-11);

[0050] d-11) Create a JSON object msg;

[0051] d-12) Determine whether the msg file has been completely read. If so, execute step d-13); otherwise, return to execute step d-4).

[0052] d-13) Insert the parameter name and the JSON object msg into the JSON object, and return to execute step d-4).

[0053] d-14) Set default values according to the type of the JSON object value.

[0054] d-15) Write the default values into the interface for obtaining default values.

[0055] Step e) includes the following steps:

[0056] e-1) Sort according to the parameter names of the keys in the JSON object.

[0057] e-2) Serialize the JSON object into a string.

[0058] e-3) Encrypt the serialized string using the MD5 decryption algorithm.

[0059] e-4) Write the MD5 corresponding to the srv file parameters into the interface function.

[0060] The beneficial effects of the present invention are as follows: Based on the service functions of IROS and robot development components, it can automatically complete parameters, facilitating developers to view the types, names, and return values of service parameters, facilitating developers to write corresponding interfaces, and improving the collaborative development efficiency of intelligent robots. At the same time, this solution can also be used as a service testing tool to test whether the service functions are normal, saving development time and improving development efficiency. In addition, this framework also proposes to encrypt the parameters and types of the srv file using MD5 as the basis for calling the service, enhancing the robustness of calling the service. Description of the Drawings

[0061] Figure 1 It is a flowchart of the method for obtaining default parameters of the present invention. Detailed Embodiments

[0062] The present invention will be further described below.

[0063] The method of the present invention is as follows: First, by parsing the srv file, corresponding request parameter classes and response parameter classes are generated according to the protocol; Secondly, the names and types of srv parameters are recursively obtained and then encrypted using the MD5 encryption algorithm. Thirdly, the type of the service is obtained by calling the system interface, and then the path of the srv file is found through the package management tool to determine the location of the so. Fourthly, the so file corresponding to the service is loaded by dlopen, the interface information of the dynamic library is obtained using dlsym, and request parameter objects and response parameter objects are created; Fifthly, the default parameter list of the request parameters is obtained through the bash completion function and printed out; Sixth: The service is called through the system interface, specifying the parameters and waiting for the response. Finally, the corresponding result is printed out.

[0064] Specifically, in an embodiment of the present invention, the specific method is as follows:

[0065] a) Define the interface information of the plugin.

[0066] b) Define the plugin interface class (virtual base class).

[0067] c) Define the plugin management framework.

[0068] d) Obtain the default parameters.

[0069] e) Calculate the MD5 value.

[0070] f) Generate the initialization interface function, which is empty by default, and the provider of the library defines by itself what initializations need to be done when using the library.

[0071] g) Generate the send message interface function. The default message sending function is to call the relevant interfaces of IROS and pass in the parameters of the program. (Of course, the user can modify it).

[0072] h) Generate the plugin request processing function. The request processing function verifies whether the parameter types and names match and whether any parameters are missing. If the parameter name or type is incorrect, an exception is thrown and the program execution is terminated. If a parameter is missing, the default value is used for processing.

[0073] i) Generate the receive message interface function, parse and return the result.

[0074] j) Generate the plugin response processing function and print out the returned result.

[0075] Based on the service functions of IROS and robot development components, it can automatically complete parameters, facilitating developers to view the types, names, and return values of service parameters, making it convenient for developers to write corresponding interfaces and improving the collaborative development efficiency of intelligent robots. At the same time, this solution can also be used as a service testing tool to test whether the service functions properly, saving development time and enhancing development efficiency. In addition, this framework also proposes to perform MD5 encryption on the parameters and types of srv files as the basis for calling services, enhancing the robustness of service calls.

[0076] Embodiment 1:

[0077] The interface information of the plugin defined in step a) is as follows:

[0078] a-1) Initialize the interface.

[0079] a-2) Registration interface of the plugin.

[0080] a-3) Uninstallation interface of the plugin.

[0081] a-4) Interface for obtaining default parameters.

[0082] a-5) Obtain the MD5 value of the plugin.

[0083] a-6) Define the message sending interface between plugins.

[0084] a-7) Define the message receiving interface between plugins.

[0085] a-8) Define the plugin function execution interface.

[0086] Embodiment 2:

[0087] The interface class of the plugin in step b) defines that all the interfaces in step a) are pure virtual functions and are inherited (i.e., plugin class inheritance) and implemented by subclasses.

[0088] Embodiment 3:

[0089] Step c) includes the following steps:

[0090] c-1) Parse the parameters to obtain the srv file used by the service.

[0091] c-2) Determine whether the plugin of the srv file has been registered. If it has been registered, execute step c-6). If not, obtain the location of the package where the srv file is located and find the corresponding srv file and library.

[0092] c-3) Use the dlopen() function to load the library corresponding to the srv file.

[0093] c-4) Use the dlsym() function to parse the interface of the library and create a plugin class corresponding to the srv file.

[0094] c-5) Register the service using the plugin class.

[0095] c-6) Obtain the default parameters of the plugin class and perform parameter comparison.

[0096] c-7) If the parameters are incompatible after comparison (the parameter names are different or the types are different), an exception is thrown and all opened dynamic libraries are closed. If the parameters are compatible after comparison, the missing parameters are filled with default values.

[0097] c-8) Obtain the MD5 code of the srv file used by the service provider.

[0098] c-9) Compare whether the MD5 codes are the same. If they are different, an error is prompted and the execution is terminated. If they are the same, step c-10) is executed;

[0099] c-10) Call the service interface of the plugin and send the request parameters to the service provider.

[0100] c-11) Wait for the return result of the service, parse and print the result.

[0101] Example 4:

[0102] As shown in the appendix Figure 1 Step d) includes the following steps:

[0103] d-1) Read the content of the srv file;

[0104] d-2) Create a JSON object root;

[0105] d-3) Determine whether the srv file has been completely read. If so, execute step d-15). If not, execute step d-4) (pass in the JSON object root);

[0106] d-4) Obtain a line of data;

[0107] d-5) Determine whether the obtained data is a comment. If so, return to execute step d-4). If not, execute step d-6);

[0108] d-6) Obtain the parameter name and type name;

[0109] d-7) Determine whether the type name is a basic type. If so, execute step d-8). If not, execute step d-9);

[0110] d-8) After inserting the parameter name and the basic type into the JSON object (which may be the root or msg), return to execute step d-4);

[0111] d-9) Determine whether the type name is of the msg type. If so, execute step d-10); if not, exit.

[0112] d-10) Obtain the path where the msg file is located and open it. After opening, execute step d-11);

[0113] d-11) Create a JSON object msg;

[0114] d-12) Determine whether the msg file has been completely read (passing in the JSON object msg). If so, execute step d-13); if not, return to execute step d-4);

[0115] d-13) Insert the parameter name and the JSON object msg into the JSON object (which may be the root or msg), and return to execute step d-4);

[0116] d-14) Set the default value according to the type of the JSON object value;

[0117] d-15) Write the default value into the interface for obtaining the default value.

[0118] Example 5:

[0119] Step e) includes the following steps:

[0120] e-1) Sort according to the parameter name of the key of the JSON object.

[0121] e-2) Serialize the JSON object into a string. In an embodiment of the present invention, the specific string type can be: the key is in the front, the basic type is replaced with the corresponding number, an asterisk is added in front of the object type, a # sign is added at the end, and a [ is added in front of the array type and a ] is added at the end.

[0122] e-3) Encrypt the serialized string using the MD5 decryption algorithm.

[0123] e-4) Write the MD5 corresponding to the srv file parameter into the interface function.

[0124] Finally, it should be noted that the above are only preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for invoking IROS services based on a plug-in framework, characterized in that It includes the following steps: a) Define the interface information of the plugin; b) Define the plugin interface class; c) Define the plugin management framework; d) Obtain the default parameters; e) Calculate the MD5 value; f) Generate the initialization interface function, which is empty by default; g) Generate the message sending interface function; h) Generate the plugin request processing function. The request processing function verifies whether the parameter type and name match and whether any parameters are missing. If the parameter name or type is incorrect, an exception is thrown and the program execution is terminated. If a parameter is missing, the default value is used for processing; i) Generate the message receiving interface function, parse and return the result; j) Generate the plugin response processing function, and print out the returned result.

2. The method for invoking the IROS service based on the plug-in framework according to claim 1, wherein The interface information of the plugin defined in step a) is as follows: a-1) Initialization interface; a-2) Plugin registration interface; a-3) Plugin uninstallation interface; a-4) Default parameter acquisition interface; a-5) Obtain the MD5 value of the plugin; a-6) Define the message sending interface between plugins; a-7) Define the message receiving interface between plugins; a-8) Define the plugin function execution interface.

3. The method for invoking IROS services based on a plug-in framework according to claim 1, characterized in that: The interface class of the plugin in step b) defines that all the interfaces in step a) are pure virtual functions and are inherited and implemented by subclasses.

4. The method for invoking IROS services based on a plug-in framework according to claim 1, characterized in that Step c) includes the following steps: c-1) Parse the parameters and obtain the srv file used by the service; c-2) Determine whether the plugin of the srv file has been registered. If it has been registered, execute step c-6). If not, obtain the location of the package where the srv file is located and find the corresponding srv file and library; c-3) Use the dlopen() function to load the library corresponding to the srv file; c-4) Use the dlsym() function to parse the interface of the library and create the plugin class corresponding to the srv file; c-5) Register the service using the plugin class; c-6) Obtain the default parameters of the plugin class and perform parameter comparison; c-7) If the parameters are incompatible after comparison, an exception is thrown and all open dynamic libraries are closed. If the parameters are compatible after comparison, the missing parameters are filled with default values; c-8) Obtain the MD5 code of the srv file used by the service provider; c-9) Compare whether the MD5 codes are the same. If they are not the same, an error is prompted and the execution is exited. If they are the same, execute step c-10); c-10) Call the service interface of the plugin and send the request parameters to the service provider; c-11) Wait for the return result of the service, parse and print the result.

5. The method for invoking IROS services based on a plug-in framework according to claim 1, characterized in that, Step d) includes the following steps: d-1) Read the content of the srv file; d-2) Create a JSON object root; d-3) Determine whether the srv file has been completely read. If so, execute step d-15). If not, execute step d-4); d-4) Obtain a line of data; d-5) Determine whether the obtained data is a comment. If so, return and execute step d-4). If not, execute step d-6); d-6) Obtain the parameter name and type name; d-7) Determine whether the type name is a basic type. If so, execute step d-8). If not, execute step d-9); d-8) After inserting the parameter name and the basic type into the JSON object, return to execute step d-4); d-9) Determine whether the type name is of the msg type. If so, execute step d-10). If not, exit; d-10) Obtain and open the path where the msg file is located. After opening, execute step d-11); d-11) Create a JSON object msg; d-12) Determine whether the msg file has been completely read. If so, execute step d-13). If not, return to execute step d-4); d-13) Insert the parameter name and the JSON object msg into the JSON object, and return to execute step d-4); d-14) Set the default value according to the type of the JSON object value; d-15) Write the default value into the interface for obtaining the default value.

6. The method for invoking the IROS service based on the plug-in framework according to claim 1, characterized in that Step e) includes the following steps: e-1) Sort according to the parameter name of the key of the JSON object; e-2) Serialize the JSON object into a string; e-3) Encrypt the serialized string using the MD5 decryption algorithm; e-4) Write the MD5 corresponding to the srv file parameter into the interface function.

Citation Information

Patent Citations

  • A method of invoking Web Service services across platforms

    CN109086148A

  • Method and device for monitoring internal running state of program based on IROS

    CN114443428A