An IROS-based service tool and its usage method

The srv_generate tool generates custom service classes and dynamic libraries based on IROSSrvBaseClass, which solves the problem that users in IROS need to manually write code to use custom service data types, and realizes the function of service requests and queries without manual code, reducing the time cost of developers and testers.

CN115469942BActive Publication Date: 2025-06-03SHANDONG NEW GENERATION INFORMATION IND TECH RES INST CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211125770.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-16
Publication Date
2025-06-03
Estimated Expiration
2042-09-16

AI Technical Summary

Technical Problem

In IROS, users need to manually write code to use custom service data types, resulting in increased workload for developers and testers, and different services need to write different programs, which is time-consuming and complex.

Method used

The srv_generate tool generates a custom service class based on IROSSrvBaseClass, implements the serialization, deserialization and type query interfaces of requests and responses, and generates a dynamic library containing specific service objects, so that IROSService can dynamically load and call specific service objects.

Benefits of technology

It enables convenient service requests and queries for specified service types without manually writing test code, effectively reducing the time cost of IROS developers and testers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115469942B_ABST
    Figure CN115469942B_ABST
Patent Text Reader

Abstract

The present invention provides a service - type tool based on IROS and a usage method. The service - type tool IROSService based on IROS is based on the service base class of IROS. By using rospack to load the dynamic library of specific service sub - classes, and finally through the way of calling virtual function interfaces by the base - class pointer, it realizes the dynamic serialization and deserialization of IROS services, and realizes practical functions such as IROS service requests, type queries, name queries, request - type queries, etc. This application can conveniently perform service requests and service queries of specified service types through this tool, without manually writing test code, which will effectively reduce the time cost of IROS developers and testers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a service - type tool based on IROS and a usage method, belonging to the technical field of IROS services. Background Art

[0002] In IROS, the service data types customized by users are defined in a text file with the suffix ".srv", which includes service names, request and response types, and note information, etc. For C++ users, it is necessary to convert this data file into a directly - usable data structure, such as classes, structures, etc. In IROS, a service conversion class tool "srv_generate" is provided, which can conveniently generate C++ - type header files.

[0003] However, when users want to use such header files for service requests and queries, they need to manually write relevant code, including including the header files of relevant classes, which is relatively time - consuming. In addition, different programs need to be written for different services, which increases the workload of IROS developers and testers to varying degrees. Summary of the Invention

[0004] The purpose of the present invention is to provide a service - type tool based on IROS and a usage method, which is not only firmly structured and not easily separated, but also convenient for construction.

[0005] To achieve the above - mentioned purpose, the present invention is realized through the following technical solutions:

[0006] A service - type tool based on IROS, characterized in that the service - type tool of IROS is a user - defined service class generated by srv_generate in IROS. Based on the service base class IROSSrvBaseClass, it implements the serialization interfaces of requests and services, deserialization, and type - query interfaces according to its own data structure. Srv_generate also generates a dynamic library containing this user - defined service class, enabling IROSService to load a specific service object into memory. IROSService queries the corresponding dynamic library through rospack according to the service name specified by the user, points to the specific service object through the IROSSrvBaseClass pointer, and uses the polymorphism of C++ to call virtual function interfaces through the base - class pointer to implement the functions of the specific service class;

[0007] Preferably, the IROSSrvBaseClass includes request serialization, request deserialization, response serialization, response deserialization, and type - query interfaces.

[0008] Preferably, the service processing tool srv_generate of IROS generates a C++ header file that can be called by IROS according to the service file customized by the user. This header file contains the class implementation with the service file name as the class name, inherits from IROSSrvBaseClass, and implements each interface according to its own structure. At the same time, srv_generate also generates a dynamic library containing specific service objects for dynamic loading by IROSService.

[0009] Preferably, the IROSService provides IROS service queries, including all service list queries, querying service types by service name, and reverse querying service names by service type, and can directly request functions with specified parameters to a specified service. This tool uses the rospack tool to find the specified dynamic library by service name and load it into memory, and uses an IROSSrvBaseClass pointer to point to a specific service class object to implement serialization and deserialization of requests and responses, and finally realizes functions such as service requests and queries.

[0010] A method for using a service class tool based on IROS includes the following steps:

[0011] Step 1: IROSService first checks whether the input parameters conform to the specification. If they do not conform to the input specification, it will output the usage instructions to the user and directly exit after specifying the message name;

[0012] Step 2: If the specification is met, IROSService uses rospack to find service files under all packages and checks whether there is a corresponding dynamic library. If the corresponding dynamic library cannot be found, it will directly give a prompt message and return; if the corresponding dynamic library is found, it will continue to load the dynamic library;

[0013] Step 3: After correctly loading the dynamic library, IROSService loads the specific service object entity into memory from the dynamic library and creates an interface class pointer IROSSrvBaseClass* to point to this object to complete the loading of the user-defined service object;

[0014] Step 4: Call the corresponding interfaces to implement their functions. Specifically, when calling the list function, IROSService directly queries the current valid message types through rospack; when calling the type function, after loading the service object, IROSService calls the servicetype interface to display the service type; when calling the call function, IROSService creates a client object for the specified service, serializes the incoming request data part, and requests the corresponding service; when calling the info function, IROSService determines according to the specified service name, the type of the service, and the address of the service publisher.

[0015] The advantages of the present invention are as follows: With this tool, the present application can conveniently perform service requests, service queries, etc. for specified service types without manually writing test codes, which will effectively reduce the time costs of IROS developers and testers. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention but do not constitute a limitation to the present invention.

[0017] Figure 1 It is a schematic diagram of the process structure of the present invention.

[0018] Figure 2 It is a schematic diagram of the structure of the interface class IROSSrvBaseClass of the present invention.

[0019] Figure 3 It is a schematic diagram of the service definition of SetBool.srv of the present invention.

[0020] Figure 4 It is a schematic diagram of the structure of the SetBool class of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0022] To achieve the above object, first, the service interface class IROSSrvBaseClass is defined, and its class diagram and the virtual function interfaces it contains are as shown in the following figures:

[0023] The interface class IROSSrvBaseClass provides five virtual function interfaces, including request serialization (reqserialize), request deserialization (reqdeserialize), response serialization (resserialize), response deserialization (resdeserialize) and type query (servicetype).

[0024] Take the custom SetBool.srv service as an example, its specific definition is as follows Figure 3 As shown:

[0025] The sample service class SetBool generated by srv_generate implements these three interfaces. The request serialization interface serializes the request data data into the pointer message of type char* in the form of a string, and specifies the length messagelen after serialization; the request deserialization interface deserializes message into the data of SetBool; the response serialization and deserialization interfaces are similar, completing the serialization and deserialization operations of the two member variables success and message of SetBool; the type query interface returns the type of the service in the form of a string. In addition, srv_generate will also generate a dynamic library containing the SetBool object. After IROSService loads the dynamic library, it can load the object into memory.

[0026] IROSService provides the following four functions, each of which requires different parameter types, as shown in Table 1:

[0027] Table 1: IROSService supported functions and parameter list

[0028] Function type Parameter list None type [service name] call [service name] [request data] info [service name]

[0029] After specifying the message name, IROSService will use rospack to search for service files in all packages and check whether there is a corresponding dynamic library. If it cannot be found, it will directly give a prompt message and return;

[0030] After correctly loading the dynamic library, IROSService will load the specific service object entity from the dynamic library into the memory and create an interface class pointer IROSSrvBaseClass* to point to the object. At this point, the loading of the user-defined service object is completed.

[0031] For the list function of the IROSService, the IROSService can directly query the current valid message types through rospack; for the type function, after loading the service object, the IROSService calls the servicetype interface to display the service type; for the call function, the IROSService will create a client object for the specified service, serialize the incoming request data part, and request the corresponding service; for the info function, the IROSService is based on the specified service name, the type of the service, and the address of the service publisher.

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

Claims

1. An IROS-based service tool, characterized in that, the user-defined service class generated by the IROS-based service tool through srv_generate in IROS is based on the service base class IROSSrvBaseClass and implements the serialization interface, deserialization, and type query interface of requests and services according to its own data structure. Srv_generate also generates a dynamic library containing this custom service class, enabling IROSService to load specific service objects into memory. IROSService queries the corresponding dynamic library through rospack according to the service name specified by the user, points to the specific service object through the IROSSrvBaseClass pointer, and uses the polymorphism of C++ to call the virtual function interface through the base class pointer to implement the functions of the specific service class.

2. The IROS-based service tool according to claim 1, characterized in that, the IROSSrvBaseClass includes request serialization, request deserialization, response serialization, response deserialization, and type query interfaces.

3. The IROS-based service tool according to claim 1, characterized in that, the service processing tool srv_generate of IROS generates a C++ header file that can be called by IROS according to the user-defined service file. This header file contains the class implementation with the service file name as the class name, inherits from IROSSrvBaseClass, and implements each interface according to its own structure; at the same time, srv_generate also generates a dynamic library containing specific service objects for dynamic loading by IROSService.

4. The IROS-based service tool according to claim 1, characterized in that, the IROSService provides IROS service queries, including all service list queries, querying service types by service name, and reverse querying service names by service type, and can directly send requests with specified parameters to the specified service; this tool uses rospack to find the specified dynamic library by service name and load it into memory, and uses the IROSSrvBaseClass pointer to point to the specific service class object to implement the serialization and deserialization of requests and responses, and finally implement functions such as service requests and queries.

5. A method for using the IROS-based service tool according to any one of claims 1-4, characterized in that, it includes the following steps: Step 1; IROSService first checks whether the input parameters conform to the specification. If they do not conform to the input specification, it will output the usage instructions to the user and directly exit after specifying the message name; Step 2: If the specification is met, IROSService uses rospack to find the service files under all packages and checks whether there is a corresponding dynamic library. If the corresponding dynamic library cannot be found, it will directly give a prompt message and return; if the corresponding dynamic library is found, it will continue to load the dynamic library; Step 3: After correctly loading the dynamic library, IROSService loads the specific service object entity from the dynamic library into memory and creates an interface class pointer IROSSrvBaseClass* to point to this object, completing the loading of the user-defined service object; Step 4: Call the corresponding interfaces to implement their functions. Specifically, when calling the list function, IROSService directly queries the current valid message types through rospack; when calling the type function, after loading the service object, IROSService calls the servicetype interface to display the service type; when calling the call function, IROSService creates a client object for the specified service, serializes the incoming request data part, and requests the corresponding service; when calling the info function, IROSService is based on the specified service name, the type of the service, and the address of the service publisher.

Citation Information

Patent Citations

  • Method for calling IROS service based on plug-in framework

    CN115562678A