The present disclosure relates to the field of vehicle software development technologies, and in particular to a vehicle model simulation performance optimization method and system.
In the scenarios with high requirements for real-timeness, such as real-time control, real-time simulation, hardware-in-loop simulation, and co-simulation, program performances are of great importance. At present, most of the similar softwares achieve performance improvement by software optimization, for example, the program performance is optimized by replacing single thread with multiple threads, by exchanging space for time by using lookup table, or by avoiding iterative computation by using cache or the like. But, it is still difficult to optimize program performance to a higher performance level because the program performance, in much time, cannot be further optimized due to design framework and language limitation. In this case, many softwares cannot reach a higher performance level even though optimized.
The present disclosure relates to a vehicle model simulation performance optimization method, which includes:
The summary of the present disclosure aims to provide brief descriptions for the subjects of the specification. Thus, it should be understood that the above features are only illustrative and shall not be interpreted as narrowing the scope or essence of the subject of the specification in any way.
Other features, aspects and advantages of the subjects of the present disclosure will become apparent by way of the specific embodiments, drawings and claims.
In order to more clearly describe the technical solutions in the specific embodiments of the present disclosure or in the prior arts, the drawings required for descriptions of the specific embodiments or the prior arts will be briefly introduced below. Apparently, the drawings hereunder are some embodiments of the present disclosure, and other drawings may be obtained by those skilled in the arts based on these drawings without making creative work.
In order to make the objects, the technical solutions and the advantages of the embodiments of the present disclosure clearer, the technical solutions of the present disclosure will be clearly and fully described below in combination with drawings. Apparently, the embodiments described herein are some embodiments of the present disclosure rather than all embodiments. All other embodiments obtained by those skilled in the arts based on these embodiments of the present disclosure without making creative work shall fall within the scope of protection of the present disclosure.
When a vehicle part is to be functionally tested, it is firstly required to enable this part to run normally. Therefore, a vehicle on which the part can run normally should be prepared to provide a complete electric environment, a network communication environment and a vehicle running state feedback and the like. Meanwhile, it is required to perform real-time control on the part to trigger it to generate a corresponding function during the running process of the vehicle and the part. In this process, the behavior of the part depends on the feedback information of the vehicle itself and the feedback information of other relevant parts.
It is extremely unrealistic to prepare one vehicle for each part, with all other relevant parts as environment. Further, in a special working condition, for example, in an emergency braking condition and a vehicle stability test process, the test method itself may bring vehicle damages and casualties. Therefore, under normal circumstances, it is required to employ a virtual method for a functional test of a part, namely, replace a true vehicle, sensors and other parts etc. with a vehicle model software to perform simulation so as to reduce costs, increase verification efficiency and guarantee personal safety. But, the real-timeness of the simulation leads to higher requirements for the simulation performance of the system programs.
In view of the above, at least one embodiment provides a vehicle model simulation performance optimization method, which includes: creating a real-time kernel program for executing a vehicle model real-time simulation task; enabling the real-time kernel program to perform inter-process communication with a host software through memory sharing to read and write a vehicle simulation signal through the host software, automatically control the real-time kernel program to execute a simulation command through a code program, and record simulation data fed back by the real-time kernel program.
In the vehicle model simulation performance optimization method provided by some embodiments, an independently-running real-time kernel program is introduced as a daemon process of the host software to transfer all performance-related operations on the host software to the real-time kernel program, so as to reduce the optimization overhead of the host software and achieve the purpose of simulation performance optimization.
Various non-limiting implementations of the embodiments of the present disclosure will be detailed below in combination with drawings.
As shown in
In some embodiments, the real-time kernel program refers to an internal core program specially designed to execute a real-time simulation task. The creation method includes but not limited to development by a development environment, for example, Visual Studio. The host software refers to a program which uses a real-time kernel program to directly serve the simulation and test requirements of a user. The code program refers to a user script program running in the host software, which can access the resources of the host software and run by relying on the host software itself. The host software can record simulation data in the present computer for data replay and analysis, and the simulation data recorded is used to evaluate a simulation result and facilitate searching for problems in a simulation process.
In some embodiments, the real-time kernel program is configured as a daemon process of the host software.
The daemon process can control its own process priority and simulation thread priority so as to optimize the simulation performance without being affected by the host software program and affecting the host software program. Furthermore, the daemon process may also interface with the host software program of any architecture, for example, support a 32-bit host software program and a 64-bit host software program.
As a preferred implementation of some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of automatically controlling the real-time kernel program to execute the simulation command through the code program includes:
For example, a host software designed to run on a Windows platform calls a vehicle dynamics simulation engine CarSim to achieve the simulation of the vehicle model.
In the method of some embodiments, a real-time kernel program CSController is designed as a daemon process of the host software, and the real-time kernel program calls the API function “SetPriorityClass” of Windows upon startup to improve the priority of the daemon process. Meanwhile, the real-time kernel program calls the API function “SetThreadPriority” of Windows upon startup of a simulation thread (in this case, the simulation thread refers to a thread calling CarSim) to increase the priority of the thread. Therefore, it can be known that the daemon process can optimize its daemon process performance and simulation thread performance separately without being affected by the host software and affecting the host software, thereby reducing the optimization overhead of the host software and achieving the purpose of the simulation performance optimization.
The daemon process CSController is started to enable a shared memory for executing a simulation command and monitor an event name CmdTx, and the host software, during simulation startup, attempts to open the shared memory and will stop simulation and report an error if failing to do so.
After the host software successfully opens the shared memory, the simulation stage is started. The simulation command includes multiple types of operations. With a simulation startup command as an example, the data of the simulationstartup command is set to 0x01, and the host software sets the first byte data of the shared memory to 0x01 and then sets the event CmdTx to send the simulation startup command to the daemon process. Next, the host software monitors the event name CmdRx to wait for completion of the command execution by the daemon process.
After obtaining the event name CmdTx, the daemon process reads the first byte data of the shared memory to determine what type of simulation command it is. When the daemon process reads the first byte data as 0x01, the daemon process starts simulation, where the simulation start may be successful or unsuccessful. It is supposed that the return value for success is 0 and the return value for failure is 1. The daemon process writes the return value for simulation start into the first byte of the shared memory and sets the event CmdRx to feed an execution result of the simulation command back to the host software. Next, the daemon process continues monitoring the event name CmdTx to wait for a next command from the host software.
After obtaining the event name CmdRx, the host software reads the first byte of the shared memory to determine an execution result of a previous command. When the byte data read is 0, it indicates the simulation start is successful, and when the byte data read is 1, it indicates that the simulation start is unsuccessful. The host software, based on contents to be executed next, sets the event name CmdTx again to control the daemon process to continue executing the simulation command.
In some embodiments, the daemon process may interface with the host software program of any architecture and can support both the 32-bit host software program and the 64-bit host software program. With the 32-bit host software program as an example, descriptions are made on a method of reading and writing the vehicle simulation signal after the real-time kernel program is configured as the daemon process of the host software.
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of reading the vehicle simulation signal includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 32-bit shaped gear signal Gear is read to the 32-bit shaped variable “v”, the codes for calling the InterlockedIncrement function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of reading the vehicle simulation signal includes:
A method of converting the function return value into the 32-bit floating-point value includes: taking 4 bytes back from a first address of the function return value as the 32-bit floating-point value.
Detailed descriptions are made below in combination with examples.
For example, when the value of the 32-bit floating-point signal Vx is read to the 32-bit floating-point variable “v”, the codes for calling the InterlockedIncrement function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of reading the vehicle simulation signal includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 64-bit shaped time signal TimeUs is read to the 64-bit shaped variable “v”, the codes for calling the InterlockedIncrement64 function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of reading the vehicle simulation signal includes:
A method of converting the function return value into the 64-bit floating-point value includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 64-bit floating-point signal EngForce is read to the 64-bit floating-point variable “v”, the codes for calling the InterlockedIncrement64 function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of writing the vehicle simulation signal includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 32-bit shaped signal x is written into the 32-bit shaped gear signal Gear, the codes for calling the InterlockedExchange function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of writing the vehicle simulation signal includes:
A method of converting the to-be-written floating-point value into the shaping value desired by the function parameter includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 32-bit floating-point signal x is written into the 32-bit floating-point signal Vx, the codes for calling the InterlockedExchange function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of writing the vehicle simulation signal includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 64-bit shaped signal x is written into the 64-bit shaped signal TimeUs, the codes for calling the InterlockedExchange64 function are as follows:
In some embodiments, after the real-time kernel program is configured as the daemon process of the host software, a method of writing the vehicle simulation signal includes:
A method of converting the to-be-written floating-point value into the shaping value desired by the function parameter includes:
Detailed descriptions are made below in combination with examples.
For example, when the value of the 64-bit floating-point signal x is written into the 64-bit floating-point signal EngForce, the codes for calling the InterlockedExchange64 are as follows:
As shown in
Specifically, the specific working method of the real-time kernel program and the host software can be referred to the above descriptions of the vehicle model simulation performance optimization method and will not be repeated herein.
In some embodiments, an electronic device includes a processor, a readable storage medium, a communication bus and a communication interface, wherein the processor, the readable storage medium and the communication interface communicate with each other via the communication bus;
An electronic device in some embodiments will be described below from the angle of hardware processing.
In some embodiments, the specific implementation of the electronic device is not limited.
As shown in
In other embodiments, a computer device, and an industrial personal computer may be one of the electronic devices.
The structure shown in
In some embodiments, the communication interface may be RS232, RS485, USB interface or TYPE interface or the like, which may be connected with an external bus adapter. The communication interface may also include wired or wireless network interface. The network interface may optionally include wired interface and/or wireless interface (such as WI-FI interface, Bluetooth interface and the like), which is usually used to establish communication connection between the server and other computer devices.
The readable storage medium or the computer readable storage medium includes at least one type of memories. The memory includes flash memory, harddisk drive, multimedia card, card type memory (e.g. SD or DX memory or the like), magnetic memory, magnetic disk or compact disk or the like. In some embodiments, the memory may be an internal storage unit in the computer device, for example, a harddisk drive of the computer device. In some other embodiments, the memory may also be an external storage device of the computer device, for example, a plug type hard disk drive, a smart media card (SMC), a secure digital (SD) card, a flash card or the like on the computer device. Furthermore, the memory may include both the internal storage unit in the computer device and the external storage device. The memory may be used to not only store an application software installed on the computer device and various types of data, for example, the codes of the computer programs and the like but also temporarily store data already output or to be output.
In some embodiments, the processor may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or another data processing chip, which is used to run the program codes in the memory or process the data, for example, execute the computer programs or the like.
In some embodiments, the communication bus may also be an input/output bus, which may be a Peripheral Component Interconnect (PCI) bus, or an Enhanced Industry Standard Architecture (EISA) bus or the like. The bus may include an address bus, a data bus and a control bus and the like.
Optionally, the computer device may also include a user interface, which may include a display, and an input unit, for example, a keyboard. Optionally, the user interface may also include a standard wired interface and wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch liquid crystal display and an Organic Light-Emitting Diode (OLED) touch display and the like. The display may also be appropriately referred to as display screen or display unit for displaying information processed in the computer device as well as a visual user interface.
The processor executes the programs to perform the steps of the embodiments of the vehicle model simulation performance optimization method shown in
In some embodiments, the processor is specifically configured to perform the steps of:
Optionally, as one possible implementation, the processor is further configured to perform the steps of:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
Optionally, as one possible implementation, the processor is further configured to perform the following steps:
One or more embodiments further provide a computer readable storage medium storing programs of performing the above vehicle model simulation performance optimization method, where the programs are executed by a processor to perform the steps of the above vehicle model simulation performance optimization method, where the steps are indicated in the specific descriptions of the vehicle model simulation performance optimization method in some embodiments and will not be repeated herein.
One or more embodiments further provide a computer program product, including a computer program or instruction, where the computer program or instruction is executed on a computer to cause the computer to perform any one of the vehicle model simulation performance optimization methods.
In some embodiments, a computer readable storage medium, storing computer readable instructions, wherein the computer readable instructions are executed by at least one processor to perform the method:
In some embodiments, a computer program product, including a computer readable storage medium on which computer readable program codes are stored, wherein the computer readable program codes include instructions, which cause at least one processor (one or more computer devices) to perform the following operations:
In the several embodiments provided by the present disclosure, it should be understood that the disclosed device and method can be implemented another way. The above device embodiments are merely illustrative, for example, the flowcharts or block diagrams in the drawings show possible system architectures, functions and operations of the device, method, and computer program product in the several embodiments provided by the present disclosure. Thus, each block in the flowcharts or block diagrams may represent one module, one program fragment or one part of codes. The module, the program fragment or the part of codes includes one or more executable instructions for implementing the specified logic functions. It should be noted that in some alternative embodiments, the functions indicated in the blocks may also be performed in a sequence different from that indicated in the drawings. For example, two continuous blocks can be actually performed basically in parallel, and sometimes may be performed in a reverse sequence, which is dependent on the functions involved. It is further noted that each block in the block diagrams and/or flowcharts and the combinations of the blocks in the block diagrams and/or flowcharts may be implemented by a dedicated hardware-based system for executing specified functions or actions, or by combination of dedicated hardware and computer instructions.
Furthermore, the functional modules in the embodiments of the present disclosure can be integrated into one independent part, or exist as separate modules or two or more of the modules are integrated into one independent part.
The functions, when implemented by software function modules and sold or used as independent products, can be stored in one computer readable storage medium. Based on such understanding, the essence of technical solutions of the present disclosure, or a part contributing to the prior arts or a part of the technical solutions can be embodied in the form of software product. The computer software product is stored in one storage medium which includes several instructions to enable one computer device (for example, a personal computer, a server, or a network device or the like) to perform all or part of the steps of the method of each of the embodiments of the present disclosure.
Enlightened by the ideal embodiments of the present disclosure, relevant workers can, based on the contents of the specification, make various changes and modifications within the scope of protection of the technical idea of the present disclosure. The technical scope of the present disclosure is not limited to the contents of the specification but to the technical scope claimed by the claims.