Intelligent vehicle embedded code automatic generation method and device

By using a pre-trained neural network conversion model in intelligent vehicles, the initial code is converted into intermediate-layer code and compiled into C language code according to the platform type, the problem of low code generation efficiency in intelligent vehicle complex systems is solved, and the more Optimized and easy-to-maintain embedded code.

CN119127202APending Publication Date: 2024-12-13BEIJING HANGSHENG NEW ENERGY TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411052088.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The existing automatic code generation method is inefficient in code generation and bloated when dealing with complex intelligent vehicle systems, making it difficult to meet the application needs of intelligent vehicles.

Method used

By obtaining the initial code, input it into the pre-trained conversion model, outputting the intermediate layer code, and compiling it according to the different platform types of the vehicle control system, generating the C language code that the platform can execute. This transformation model is obtained by training preset neural networks through known sample sets, including the Modelica language library and the C language library in standard formats. The neural network is used for feature extraction and encoding processing to ensure the efficient and accurate code.

Benefits of technology

It realizes the more accurate and efficient description of the structure and behavior of complex systems, thereby generating more optimized and easier to maintain code, meeting the needs of intelligent vehicle complex systems for automatic code generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127202A_ABST
    Figure CN119127202A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent vehicle embedded code automatic generation method and device. The method comprises the steps that an initial code used for describing an intelligent vehicle control system is acquired; inputting the initial code into a pre-trained conversion model, and outputting to obtain an intermediate layer code; wherein the conversion model is obtained by training a preset neural network through a known sample set, the known sample set comprises a Modelica language library and a C language library in a standard format, and the known sample set is obtained by analyzing a Modelica meta-model and a C language meta-model through a preset data analysis model; and compiling the middle layer code to obtain an embedded code used for executing a control system function. According to the scheme, the codes required by the vehicle-mounted embedded system can be quickly and efficiently generated, and the software development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for automatically generating embedded code for an intelligent vehicle. Background Art

[0002] With the rapid development of intelligent vehicles, the requirements for vehicle electronic technology are constantly increasing, and the demand for vehicle control codes in automotive electronic control software is showing an exponential growth trend. Traditional manual code writing is prone to unstable quality, affecting the robustness and maintainability of the software. Therefore, automatic code generation technology came into being.

[0003] In the related art, the existing automatic code generation method is difficult to meet the application requirements of smart vehicles when processing the complex systems of smart vehicles due to its low code generation efficiency and bloated code.

[0004] Based on this, there is an urgent need for a method and device for automatically generating embedded code for intelligent vehicles to solve the above technical problems. Summary of the invention

[0005] The embodiments of the present invention provide a method and device for automatically generating embedded code for an intelligent vehicle, which can automatically generate code that meets the needs of a complex system of an intelligent vehicle.

[0006] In a first aspect, an embodiment of the present invention provides a method for automatically generating embedded code for an intelligent vehicle, comprising:

[0007] Obtaining initial code for describing an intelligent vehicle control system;

[0008] The initial code is input into a pre-trained conversion model, and the intermediate layer code is output; wherein the conversion model is obtained by training a preset neural network with a known sample set, the known sample set includes a Modelica language library and a C language library in a standard format, and the known sample set is obtained by respectively parsing the Modelica metamodel and the C language metamodel with a preset data parsing model;

[0009] The intermediate layer code is compiled to obtain an embedded code for executing the control system function.

[0010] In a second aspect, an embodiment of the present invention further provides a device for automatically generating embedded code for an intelligent vehicle, comprising:

[0011] An acquisition module, used for acquiring an initial code for describing an intelligent vehicle control system;

[0012] A conversion module, used for inputting the initial code into a pre-trained conversion model, and outputting an intermediate layer code; wherein the conversion model is obtained by training a preset neural network with a known sample set, the known sample set includes a Modelica language library and a C language library in a standard format, and the known sample set is obtained by respectively parsing the Modelica metamodel and the C language metamodel with a preset data parsing model;

[0013] The compiling module is used to compile the intermediate layer code to obtain the embedded code for executing the control system function.

[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in any embodiment of this specification is implemented.

[0015] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method described in any embodiment of this specification.

[0016] The embodiment of the present invention provides a method and device for automatically generating embedded code for intelligent vehicles. First, a compiled initial model is obtained, the initial model is input into a pre-trained conversion model, and the intermediate layer code is output. Finally, according to different platform types of vehicle control systems, the intermediate layer code is compiled into C language code that can be executed by the platform. The above method can achieve a more accurate and efficient description of the structure and behavior of complex systems, thereby generating more optimized and easier to maintain codes, meeting the needs of complex systems of intelligent vehicles for automatic code generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 It is a flow chart of a method for automatically generating embedded code for a smart vehicle provided by an embodiment of the present invention;

[0019] Figure 2 is a hardware architecture diagram of an electronic device provided by an embodiment of the present invention;

[0020] Figure 3It is a structural diagram of an automatic generation device for embedded code of a smart vehicle provided by an embodiment of the present invention;

[0021] Figure 4 It is a schematic diagram of the conversion model structure provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0023] Please refer to Figure 1 , an embodiment of the present invention provides a method for automatically generating embedded code for an intelligent vehicle, the method comprising:

[0024] Step 100, obtaining an initial code for describing an intelligent vehicle control system;

[0025] Step 102, input the initial code into a pre-trained conversion model, and output the intermediate layer code;

[0026] Step 104: compile the intermediate layer code to obtain an embedded code for executing the control system function.

[0027] In the embodiment of the present invention, the compiled initial model is first obtained, the initial model is input into the pre-trained conversion model, and the intermediate layer code is outputted, and finally the intermediate layer code is compiled into C language code that can be executed by the platform according to the different platform types of the vehicle control system. The above method can achieve a more accurate and efficient description of the structure and behavior of the complex system, thereby generating more optimized and easier to maintain code, meeting the needs of the complex system of intelligent vehicles for automatic code generation.

[0028] Described below Figure 1 How the various steps are performed.

[0029] First, for step 100, an initial code for describing an intelligent vehicle control system is obtained.

[0030] Modelica is a programming language with a powerful ability to describe complex systems. It can effectively handle complex systems and generate efficient and easy-to-maintain code, thereby improving the efficiency of code generation. At the same time, Modelica also allows the definition of custom component models, and modules that support the AUTOSAR standard can be added to improve the reusability and portability of the software, meet the needs of different hardware platforms, and thus enhance adaptability. Therefore, applying this language to complex in-vehicle embedded systems can meet the urgent needs of modern intelligent connected vehicles for high-performance and high-reliability software.

[0031] In the embodiment of the present invention, when developing the vehicle-mounted embedded system software, relevant technical personnel will use a graphical method based on the Modelica language platform to complete the control strategy and function design. Each designed graphical module has a corresponding Modelica model, which is then parsed using a preset data parsing model, thereby obtaining the initial code for describing the intelligent vehicle control system.

[0032] Then, for step 102, the initial code is input into a pre-trained conversion model, and the intermediate layer code is output.

[0033] Since the embedded code executed by the vehicle's control system is in C language format, it is necessary to convert the Modelica language code used by developers to design software into executable C language code.

[0034] The embodiment of the present invention uses a pre-trained conversion model to convert Modelica language code into C language code. The conversion model is obtained by training a preset neural network with a known sample set. The known sample set includes a Modelica language library and a C language library in a standard format. The known sample set is obtained by respectively parsing the Modelica metamodel and the C language metamodel with a preset data parsing model.

[0035] In the embodiment of the present invention, the training process of the model includes the following steps: performing feature extraction processing on the Modelica language library to obtain feature information of the Modelica language; based on the feature information after optimization processing, processing to obtain a first code sequence with position information; performing conversion processing on the C language structure library to obtain a C code sequence with position information; and processing the first code sequence and the C code sequence based on a preset neural network to obtain the conversion model. The feature information includes vocabulary information and structure information.

[0036] Specifically, the training process of the conversion model includes two stages, namely the data processing stage and the model training stage. In the data processing stage, it is first necessary to extract feature information from the standard format Modelica language library, including two main features: vocabulary information and structural information; vocabulary information, namely code tags, is obtained by parsing the Modelica code into plain text format and then extracting tags from the plain text code; structural information, namely the abstract syntax tree (AST), is generated by parsing and extracting the structural information of the code. Then, the extracted code tags and AST are optimized to facilitate subsequent model training.

[0037] Furthermore, in the model training stage, the optimized feature information is first processed to obtain a first code sequence with position information. The processing process includes converting the feature information and the code with position information to obtain an embedded vector; and performing convolution processing on the embedded vector to obtain a first code sequence with position information.

[0038] Specifically, in order to process and reduce the length of input features to increase the training speed, this embodiment uses a convolutional neural network (CNN) layer to process feature information. The neural network includes residual connections, batch normalization, and full connections. Figure 4 As shown in the figure, the code with code tags and the code with position information are transformed to obtain an embedding vector, which is input into CNN for encoding using a multi-head attention mechanism. The code tags and AST are set as the source sequence and target sequence of the multi-head attention to complete the corresponding encoding process, so as to understand the correlation within the Modelica code tags. Finally, the code tag sequence with position information and the abstract syntax tree sequence are obtained in turn.

[0039] Furthermore, after completing the processing of the Modelica language, it is also necessary to process the C language library in the standard format to obtain a C code sequence with position information, and then use a neural network to process the first code sequence and the C code sequence to obtain a conversion model.

[0040] In an embodiment of the present invention, the processing includes: performing a first decoding process on a code tag sequence and obtaining a first decoding result; wherein the source sequence of the first decoding process is a C code sequence, and the target sequence is a code tag sequence; performing a second decoding process on an abstract syntax tree sequence to obtain a second decoding result; wherein the source sequence of the second decoding process is a C code sequence, and the target sequence is an abstract syntax tree sequence; using a convolutional neural network to normalize the first decoding result and the second decoding result to obtain a selection probability of the C code corresponding to each position of the Modelica code; and screening the selection probability to obtain a conversion model in which the C code at each position has the highest selection probability.

[0041] Specifically, the C code sequence is used as the source sequence and target sequence of the masked multi-head attention to learn the relationship between Modlica code and C code. After that, two multi-head attentions are implemented to decode the code information and AST information. One uses the C code sequence as the source sequence and the code sequence as the target sequence. The other uses the C code sequence as the source sequence and the AST sequence as the target sequence. Finally, the probability of each C code is output through the Softmax layer.

[0042] Furthermore, the output is processed by the Softmax layer for probability distribution, and the words or code snippets with the highest probability are selected as the conversion rules of the conversion model, thereby ensuring the coherence and accuracy of the generated code. Through this mechanism, the conversion model can simultaneously learn and integrate the lexical information and structural information of the program, thereby achieving efficient and accurate automatic code generation from Modelica language to C language.

[0043] After obtaining the trained conversion model through the above process, the acquired initial code can be converted and input into the conversion model to output the corresponding C language intermediate layer code. Since the formats of executable C language codes of different system platforms of smart vehicles are different, these intermediate layer codes need to be further compiled to obtain executable embedded code.

[0044] It is worth noting that after obtaining the conversion model, a complete conversion architecture can be constructed with the model as the core, including a conversion unit based on the conversion model, a model data parsing unit, and a configuration unit. The model data parsing unit is used to interpret the model data, including various meta-models, which can also be considered as a kind of auxiliary tool. The configuration unit is used to configure the auxiliary tools used in the code generation process, including meta-models used in the conversion, code optimization, template editing extensions, and template processing engines. For example, in the process of realizing code conversion generation using the conversion model, pre-configured auxiliary tools, such as code optimizers, will also be called to improve the fluency of the generated intermediate layer code.

[0045] With respect to step 104, the intermediate layer code is compiled to obtain an embedded code for executing the control system function.

[0046] In an embodiment of the present invention, the compilation process includes obtaining an embedded code metamodel for executing control system functions; parsing the embedded code metamodel to obtain a standard format of the embedded code; and compiling the intermediate layer code to obtain an embedded code that conforms to the standard format.

[0047] The above compilation process allows developers to define custom component models and integrate modules that support the AUTOSAR standard, thereby improving the reusability and portability of the software. This capability makes it easier for developers to follow industry standards and quickly develop high-quality software that meets standard requirements.

[0048] like Figure 2 , Figure 3 As shown, the embodiment of the present invention provides a device for automatically generating embedded code for intelligent vehicles. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. From the hardware level, Figure 2 As shown in FIG. 1 , a hardware architecture diagram of an electronic device in which an automatic generation device for embedded code of an intelligent vehicle provided by an embodiment of the present invention is located is shown in FIG. Figure 2 In addition to the processor, memory, network interface, and non-volatile memory shown, the electronic device in the embodiment may also include other hardware, such as a forwarding chip responsible for processing messages, etc. Taking software implementation as an example, Figure 3 As shown, as a device in a logical sense, the CPU of the electronic device in which it is located reads the corresponding computer program in the non-volatile memory into the memory and runs it. This embodiment provides an automatic generation device for embedded code of intelligent vehicles, including:

[0049] An acquisition module 200 is used to acquire an initial code for describing an intelligent vehicle control system;

[0050] The conversion module 202 is used to input the initial code into a pre-trained conversion model and output the intermediate layer code; wherein the conversion model is obtained by training a preset neural network with a known sample set, the known sample set includes a Modelica language library and a C language library in a standard format, and the known sample set is obtained by respectively parsing the Modelica metamodel and the C language metamodel with a preset data parsing model;

[0051] The compiling module 204 is used to compile the intermediate layer code to obtain an embedded code for executing the control system function.

[0052] In the embodiment of the present invention, the conversion model is specifically obtained by training in the following manner: performing feature extraction processing on the Modelica language library to obtain feature information of the Modelica language; based on the feature information after optimization processing, processing to obtain a first code sequence with position information; performing conversion processing on the C language library to obtain a C code sequence with position information; processing the first code sequence and the C code sequence based on a preset neural network to obtain a conversion model.

[0053] In the embodiment of the present invention, the feature information includes vocabulary information and structure information.

[0054] In an embodiment of the present invention, based on the optimized feature information, a first code sequence with position information is processed, including: converting the feature information and the code with position information to obtain an embedded vector; and convolving the embedded vector to obtain the first code sequence with position information.

[0055] In the embodiment of the present invention, the first code sequence includes a code tag sequence and an abstract syntax tree sequence. The code tag sequence is obtained by encoding vocabulary information, and the abstract syntax tree sequence is obtained by encoding structure information.

[0056] In an embodiment of the present invention, a first code sequence and a C code sequence are processed based on a preset neural network to obtain a conversion model, including: performing a first decoding process on a code tag sequence and a first decoding result; wherein the source sequence of the first decoding process is a C code sequence, and the target sequence is a code tag sequence; performing a second decoding process on an abstract syntax tree sequence to obtain a second decoding result; wherein the source sequence of the second decoding process is a C code sequence, and the target sequence is an abstract syntax tree sequence; using a convolutional neural network to normalize the first decoding result and the second decoding result to obtain a selection probability of the C code corresponding to each position of the Modelica code; and screening the selection probability to obtain a conversion model in which the C code at each position has the highest selection probability.

[0057] In an embodiment of the present invention, when the compilation module 204 compiles the intermediate layer code to obtain the embedded code for executing the control system function, it is specifically used to perform the following operations: obtain the embedded code metamodel for executing the control system function; perform data parsing on the embedded code metamodel to obtain the standard format of the embedded code; compile the intermediate layer code to obtain the embedded code that conforms to the standard format.

[0058] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on an automatic generation device for an embedded code of an intelligent vehicle. In other embodiments of the present invention, an automatic generation device for an embedded code of an intelligent vehicle may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0059] The information interaction, execution process and other contents between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For the specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.

[0060] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, a method for automatically generating embedded code for an intelligent vehicle in any embodiment of the present invention is implemented.

[0061] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes a method for automatically generating embedded code for an intelligent vehicle in any embodiment of the present invention.

[0062] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.

[0063] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0064] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0065] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0066] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0067] It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical factors in the process, method, article or device including the elements.

[0068] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.

[0069] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for automatically generating embedded code for intelligent vehicles, It is characterized in that include: Obtaining initial code for describing an intelligent vehicle control system; The initial code is input into a pre-trained conversion model, and the intermediate layer code is output; wherein the conversion model is obtained by training a preset neural network with a known sample set, the known sample set includes a Modelica language library and a C language library in a standard format, and the known sample set is obtained by respectively parsing the Modelica metamodel and the C language metamodel with a preset data parsing model; The intermediate layer code is compiled to obtain an embedded code for executing the control system function.

2. The method according to claim 1, It is characterized in that The conversion model is specifically trained in the following way: Performing feature extraction processing on the Modelica language library to obtain feature information of the Modelica language; Based on the optimized feature information, a first code sequence with position information is obtained; Converting the C language library to obtain a C code sequence with position information; The first code sequence and the C code sequence are processed based on a preset neural network to obtain the conversion model.

3. The method according to claim 2, It is characterized in that The feature information includes vocabulary information and structure information.

4. The method according to claim 2, It is characterized in that The step of obtaining a first code sequence with position information based on the optimized feature information includes: Transforming the feature information and the code with position information to obtain an embedding vector; The embedding vector is subjected to convolution processing to obtain the first code sequence with position information.

5. The method according to claim 3, It is characterized in that The first code sequence includes a code tag sequence and an abstract syntax tree sequence. The code tag sequence is obtained by encoding the vocabulary information, and the abstract syntax tree sequence is obtained by encoding the structure information.

6. The method according to claim 5, It is characterized in that The first code sequence and the C code sequence are processed based on a preset neural network to obtain the conversion model, including: Performing a first decoding process on the code mark sequence and to obtain a first decoding result; wherein the source sequence of the first decoding process is the C code sequence, and the target sequence is the code mark sequence; Performing a second decoding process on the abstract syntax tree sequence to obtain a second decoding result; wherein the source sequence of the second decoding process is the C code sequence, and the target sequence is the abstract syntax tree sequence; Normalizing the first decoding result and the second decoding result by using a convolutional neural network to obtain a selection probability of the C code corresponding to each position of the Modelica code; The selection probabilities are screened to obtain a conversion model in which the C code at each position has the highest selection probability.

7. The method according to claim 1, It is characterized in that The compiling of the intermediate layer code to obtain an embedded code for executing the control system function includes: obtaining an embedded code metamodel for performing control system functions; Performing data parsing on the embedded code metamodel to obtain a standard format of the embedded code; The intermediate layer code is compiled to obtain an embedded code that complies with the standard format.

8. An automatic generation device for embedded code of intelligent vehicles, It is characterized in that include: An acquisition module, used for acquiring an initial code for describing an intelligent vehicle control system; A conversion module, used for inputting the initial code into a pre-trained conversion model, and outputting an intermediate layer code; wherein the conversion model is obtained by training a preset neural network with a known sample set, the known sample set includes a Modelica language library and a C language library in a standard format, and the known sample set is obtained by respectively parsing the Modelica metamodel and the C language metamodel with a preset data parsing model; The compiling module is used to compile the intermediate layer code to obtain the embedded code for executing the control system function.

9. An electronic device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, It is characterized in that A computer program is stored thereon, and when the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Modelica proxy model generation method, device and medium

    CN119808611A