Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
It should be further noted that, for the convenience of description, only some but not all of the relevant aspects of the present invention are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example one
Fig. 1 is a flowchart of a component loading method according to an embodiment of the present invention, where this embodiment is applicable to a case of dynamically loading a component, and the method may be executed by a component loading apparatus in an embodiment of the present invention, where the apparatus may be implemented in a software and/or hardware manner, and may be generally integrated in a device with certain computing capability, for example, a terminal or a server. Typically, it may be integrated in a device that installs an integrated system (e.g., an autopilot system) configured with a plurality of relatively independent components. As shown in fig. 1, the method specifically includes the following operations:
s110, when a starting instruction of the system is detected, reading a pre-configured configuration file, wherein the configuration file comprises information of components to be loaded, and each component corresponds to one algorithm module in the system.
The information that the configuration file storage system needs to configure the program or each component in the system when starting is the set of the environment and the files needed by the system, the configuration file is configured in advance, and the content in the configuration file can be read after the system is started.
Optionally, the configuration file may be: a local profile, a roaming profile, a mandatory profile, and a temporary profile. The local configuration file is a configuration file stored on the hardware equipment where the system is located, and any change made to the local configuration file only acts on the changed hardware equipment; roaming configuration file, which is the copy of local configuration file is duplicated and stored in the server on the network, the file will be downloaded each time the system is started, any change to roaming configuration file will be synchronous with the copy of the server; a mandatory configuration file which can be modified only by an administrator of the system; the temporary configuration file is used when the local configuration file cannot be loaded due to misoperation, the temporary configuration file allows a user using the system to modify any configuration which may cause loading failure of the local configuration file, and the temporary configuration file is deleted after each calling is finished.
Optionally, the information of the component includes: full path information for the component, context information for the component, and component execution processes for the component. The full path information of the component contains the path information for calling the component, and comprises the following steps: absolute path and relative path, the full path information of the component is used for indicating the storage address of the component; the context information includes: input channel index information for specifying the component data read channel and output channel index information for specifying the component data write channel, that is: the input channel index information is used for indicating where the data required to be processed by the component is obtained, and the output channel index information is used for indicating where the data obtained after the processing by the component is output. The running process of the component reflects the running state of the component, namely a running activity of a program with certain independent functions about a certain data set and a basic unit for resource allocation and scheduling running of a system, a plurality of running processes exist in one system at the same time, the running processes occupy a CPU and various resources in turn, when the system calls a component, the running process corresponding to the component is created, and the component is based on that after the running process is completed, the system repeals the running process, reclaims the occupied resources, and the process from creation to cancellation is a complete process.
The configuration file contains the information of the components to be loaded and the corresponding components, each component corresponds to one algorithm module in the system, and the corresponding algorithm module can be called according to the information of the loaded components.
An algorithm is a finite sequence of instructions describing a problem to be solved, with each instruction representing one or more operations. The algorithm is written into the algorithm module through the programming language, so that the algorithm has reusability and better transportability, meanwhile, the algorithm module also reduces the difficulty of the algorithm, and the application field of the algorithm is widened to a great extent. After the system is started, reading a pre-configured configuration file, and calling a corresponding algorithm module according to the information of the components contained in the configuration file so as to realize different functions.
In this embodiment, before the system is started each time, the information of the components in the configuration file may be dynamically updated according to the algorithm module that needs to be used when the system runs each time, so as to achieve the purpose of dynamically loading the components.
S120, determining the component to be loaded and the information of the component according to the read configuration file.
S130, loading the component according to the information of the component, and operating the component after the loading is finished. Optionally, the component is called according to the full path information in the information of the component, the component is loaded, and after the loading is completed, a component running process of the component is established; after the component running process of the component is established, the class in the component may be registered through the component running process, and in this embodiment, the class in the component may be registered using the macro defined in the component; then creating a class object of the class registered in the component; then, running a process through the component of the component, and initializing the created class object by combining the context information of the component so as to declare the input channel index information and the output channel index information corresponding to the class object; and finally, calling a processing function of the class object defined in the component through a component running process of the component, processing the data from the data reading channel, and providing a data processing result to the data writing channel, thereby completing component running.
Wherein, each time a new class is added to the component, the new class needs to be registered in the factory class before being used. The prior art can add these registered codes to the application code in such a way that the coupling is strengthened, and each manual addition of the registered code increases the workload of the application layer. In this embodiment, a macro pre-defined in the component is used to automate the registration of classes. This avoids modifying the code at the application level, making the code easy to maintain.
According to the technical scheme of the embodiment of the invention, the components to be loaded and the information of the components are determined according to the read configuration files by reading the pre-configured configuration files; the module is loaded according to the module information, the module is operated after the loading is finished, and the module is dynamically determined to be loaded according to the preset configuration file, so that whether the algorithm participates in the whole system can be flexibly determined during the operation on the basis of ensuring the independence of each algorithm, and the algorithm debugging, development and maintenance are facilitated.
Example two
Fig. 2 is a flowchart of a component loading method in a second embodiment of the present invention, which is embodied based on the above embodiments, in this embodiment, information of a component further includes a priority of a component running process of the component, and different operations are executed according to different priorities when the component running process is finished according to different priorities. Correspondingly, the method of the embodiment specifically includes the following operations:
s210, when a starting instruction of the system is detected, reading a pre-configured configuration file, wherein the configuration file comprises information of components to be loaded, and each component corresponds to one algorithm module in the system.
The information of the component includes: full path information of the component, context information of the component, component running processes of the component, and priorities of the component running processes of the component.
S220, determining the component to be loaded and the information of the component according to the read configuration file;
and S230, loading the component according to the information of the component, and operating the component after the loading is finished.
Optionally, the component is called according to the full path information in the information of the component, the component is loaded, and after the loading is completed, a component running process of the component is established.
S240, if the fact that the component running process of the target component is finished is detected, executing a finishing processing strategy matched with the target component according to the priority of the component running process of the target component.
Each running process has a corresponding priority, the priority determines the time when the component runs and occupies the CPU, and in the same scheduling period, the process with the high priority occupies a long time, while the process with the low priority occupies a short time.
S250, if the priority of the component running process of the target component meets a first priority condition, ending the system running process of the system; and restarting the component running process of the target component if the priority of the component running process of the target component meets a second priority condition.
Alternatively, the priority may be divided into values from 0 to 31, with a priority of 0-15 being defined as a first priority and a priority of 16-31 being defined as a second priority, the lower the priority value, the higher the priority. If the fact that the component running process of the target component is finished is detected, and the priority of the component running process of the target component meets a first priority condition, finishing the system running process of the system; and restarting the component running process of the target component if the component running process of the target component is detected to be finished and the priority of the component running process of the target component meets a second priority condition.
The method has the advantage that the safety and the reliability of the whole system are ensured on the basis of considering the independent and dynamic loading of each component. For example, in an automatic driving system, a component for performing environmental sensing (hereinafter, simply referred to as a first component) is a very important component, and if the first component malfunctions, the automatic driving system cannot safely and effectively control the vehicle. Thus, a very high priority may be set for the first component and the autopilot system may be turned off immediately after the component running process of the first component is unexpectedly ended (e.g., by kill) to bring the vehicle to a standstill on the roadway as quickly as possible to ensure the safety of other vehicles in the roadway; similarly, the component for acquiring the vehicle state (hereinafter referred to as the second component) in the automatic driving system has a lower effect on the safety of the entire automatic driving system than the first component, so that a relatively low priority may be set for the second component, and the component running process may be restarted when the component running process of the second component is unexpectedly ended.
According to the technical scheme of the embodiment of the invention, the running process priority of the component is set in the configuration file, when the running process of the component is finished after the configuration file is read and the component is loaded, whether the system running process is finished or the component running process of the component is restarted can be judged according to the priority of the component running process of the component, and the function of the component in the whole system is considered, and the safety and the reliability of the whole system are ensured while an exception recovery mechanism is introduced to the component to the greatest extent by establishing the corresponding relation between the component importance and the component priority and executing different processing operations according to different priorities.
EXAMPLE III
Fig. 3 is a flowchart of a component loading method in a third embodiment of the present invention, which is embodied based on the above embodiment, and in this embodiment, a driving system of a drone device is taken as an example.
Unmanned equipment realizes unmanned operation through the intelligent control system that equipment carried, and common unmanned equipment includes: unmanned automobiles, unmanned aerial vehicles, and the like; taking an unmanned system of an unmanned automobile as an example, the unmanned automobile is an intelligent automobile which senses road environment through a vehicle-mounted sensing system, automatically plans a driving route and controls the automobile to reach a preset target. The vehicle-mounted sensor is used for sensing the surrounding environment of the vehicle, and controlling the steering and the speed of the vehicle according to the road, the vehicle position and the obstacle information obtained by sensing, so that the vehicle can safely and reliably run on the road.
A number of algorithms are included in these modules of the unmanned system. These algorithms are characterized by: 1) algorithm processing itself is independent 2) algorithm has definite input and output, and needs to exchange data with upstream and downstream. Adding an algorithm and modifying the code can affect unnecessary compiling of other modules; in order to write and debug an algorithm, it is necessary to learn the code of other modules that are not related to the current algorithm module. A plurality of modules are completely coupled together, so that the maintainability of codes is reduced, the expansion of the modules is difficult, the learning cost is increased, and the overall efficiency is reduced.
The embodiment discloses a component loading method applicable to an unmanned system, which comprises the following steps:
s310, when a starting instruction of the unmanned system is detected, reading a pre-configured configuration file, wherein the configuration file comprises information of components to be loaded, and each component corresponds to one algorithm module in the system; the algorithm module comprises: the system comprises an environment perception module, a behavior decision module, a state acquisition module and a control module.
The environment perception module integrates research results of key technologies such as visual and auditory information cooperative computing and natural language understanding and is used for substituting human brain to perceive the environment; the behavior decision module integrates key technologies such as cognition based on driving behaviors and the like and is used for making a decision on the next action of the vehicle platform according to the sensed environmental information; the state acquisition module is used for collecting data acquired by each sensor on the self state of the vehicle; and the control module is used for controlling the vehicle to run under the non-autonomous control, so that the running safety of the vehicle is guaranteed. Each module includes a number of algorithms, such as: the environment perception module positions the vehicle based on a visual system, and obtains a disparity map for calculating depth information of each point through triangulation of a stereo image; then, by matching the significant features between the continuous stereo image frames, establishing correlation through the features between different frames, and estimating the motion condition between the two frames; finally, the current position of the vehicle is calculated by comparing the captured salient features with points on a known map.
S320, determining the component to be loaded and the information of the component according to the read configuration file;
optionally, the information of the component includes: full path information for the component, context information for the component, and component execution processes for the component.
S330, loading the assembly according to the information of the assembly, and operating the assembly after the loading is finished.
S340, if the fact that the component running process of the target component is finished is detected, executing a finishing processing strategy matched with the target component according to the priority of the component running process of the target component.
S350, if the priority of the component running process of the target component meets a first priority condition, ending the system running process of the system; and restarting the component running process of the target component if the priority of the component running process of the target component meets a second priority condition.
Alternatively, the priority may be divided into values from 0 to 31, with a priority of 0-15 being defined as a first priority and a priority of 16-31 being defined as a second priority, the lower the priority value, the higher the priority. If the fact that the component running process of the target component is finished is detected, and the priority of the component running process of the target component meets a first priority condition, finishing the system running process of the system; and restarting the component running process of the target component if the component running process of the target component is detected to be finished and the priority of the component running process of the target component meets a second priority condition.
According to the technical scheme of the embodiment of the invention, the priorities of different component running processes are set for different components, and the loaded components are dynamically determined according to the pre-configured configuration file, so that on the basis of ensuring the independence of each algorithm, whether the algorithm participates in the whole system or not can be flexibly determined during running, and the algorithm debugging, development and maintenance are facilitated. The problems that due to the fact that a plurality of modules are coupled together, maintainability of codes is reduced, module expansion is difficult and the like are solved, the learning cost is reduced, and meanwhile the overall efficiency is improved.
Example four
Fig. 4 is a schematic structural diagram of a component loading apparatus according to a fourth embodiment of the present invention. The present embodiment may be applicable to a case of dynamically loading a component, where the apparatus may be implemented in a software and/or hardware manner, and the apparatus may be integrated in any device that provides a component loading function, as shown in fig. 4, where the component loading apparatus specifically includes: the device comprises a configurationfile reading module 410, a to-be-loaded componentinformation determining module 420 and a component loading and runningmodule 430.
A configurationfile reading module 410, configured to read a pre-configured configuration file when a start instruction of a system is detected, where the configuration file includes information of components to be loaded, and each component corresponds to an algorithm module in the system;
a module for determining information of the component to be loaded 420, configured to determine the component to be loaded and information of the component according to the read configuration file;
and the component loading and runningmodule 430 is configured to load the component according to the information of the component, and run the component after the loading is completed.
According to the technical scheme of the embodiment of the invention, the components to be loaded and the information of the components are determined according to the read configuration files by reading the pre-configured configuration files; the method for loading the components according to the information of the components and operating the components after loading is finished dynamically determines which components are loaded according to the preset configuration file, so that whether the algorithms participate in the whole system can be flexibly determined during operation on the basis of ensuring the independence of each algorithm, and the algorithm debugging, development and maintenance are facilitated.
EXAMPLE five
On the basis of the foregoing embodiments, in the component loading apparatus shown in fig. 4, the information of the component included in the configuration file read by the configurationfile reading module 410 may include: the method comprises the steps of obtaining full path information of a component, context information of the component and a component running process of the component;
the context information may include: input channel index information for specifying the component data read channel and output channel index information for specifying the component data write channel.
The component loading and runningmodule 430 may be specifically configured to:
loading the component according to the full path information of the component, and establishing a component running process of the component after the loading is finished;
the method comprises the steps that a process is run through a component of the component, a class in the component is registered, and a class object of the class registered in the component is created;
initializing the created class object according to the context information of the component by the component running process of the component so as to declare the input channel index information and the output channel index information corresponding to the class object;
and calling a processing function of the class object defined in the component through a component running process of the component, processing the data from the data reading channel, and providing a data processing result to the data writing channel.
Optionally, the macro defined in the component may be used to register the class in the component.
Optionally, the information about the components included in the configuration file further includes: a component of the component runs a priority of a process.
The component loading and runningmodule 430 may further be configured to:
and if the component running process of the target component is detected to be ended, executing an ending processing strategy matched with the target component according to the priority of the component running process of the target component.
If the priority of the component running process of the target component meets a first priority condition, ending the system running process of the system;
and if the priority of the component running process of the target component meets a second priority condition, restarting the component running process of the target component.
The product can execute the method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example six
Fig. 5 is a schematic structural diagram of a computer device according to a sixth embodiment of the present invention. FIG. 5 illustrates a block diagram of anexemplary computer device 12 suitable for use in implementing embodiments of the present invention. Thecomputer device 12 shown in FIG. 5 is only an example and should not bring any limitations to the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 5,computer device 12 is in the form of a general purpose computing device. The components ofcomputer device 12 may include, but are not limited to: one or more processors orprocessing units 16, asystem memory 28, and abus 18 that couples various system components including thesystem memory 28 and theprocessing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible bycomputer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
Thesystem memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/orcache memory 32.Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only,storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected tobus 18 by one or more data media interfaces.Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) ofprogram modules 42 may be stored, for example, inmemory 28,such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment.Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device,display 24, etc.), with one or more devices that enable a user to interact withcomputer device 12, and/or with any devices (e.g., network card, modem, etc.) that enablecomputer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O)interface 22. Also,computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) vianetwork adapter 20. As shown, thenetwork adapter 20 communicates with the other modules of thecomputer device 12 over thebus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction withcomputer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Theprocessing unit 16 executes various functional applications and data processing by executing programs stored in thesystem memory 28, for example, implementing the component loading method provided by the embodiment of the present invention: when a starting instruction of a system is detected, reading a pre-configured configuration file, wherein the configuration file comprises information of components to be loaded, and each component corresponds to one algorithm module in the system; determining the component to be loaded and the information of the component according to the read configuration file; and loading the component according to the information of the component, and operating the component after the loading is finished.
Typically, the computer apparatus of embodiments of the present invention may be deployed on an unmanned vehicle.
EXAMPLE seven
A seventh embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the component loading method provided in all the embodiments of the present invention of the present application:
when a starting instruction of a system is detected, reading a pre-configured configuration file, wherein the configuration file comprises information of components to be loaded, and each component corresponds to one algorithm module in the system;
determining the component to be loaded and the information of the component according to the read configuration file;
and loading the component according to the information of the component, and operating the component after the loading is finished.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that the present invention is not limited to the particular embodiments described herein, and that various obvious changes, rearrangements and substitutions will now be apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.