Electric vehicle controller exception instruction identification and interception method and system
By constructing an instruction dependency graph and state transition features, abnormal instructions from electric vehicle controllers are identified and processed, solving the problem of inaccurate identification and processing of abnormal instructions in existing technologies, and improving the safety and reliability of electric vehicle control systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUXI TAICHEUNG ELECTRONICS TECH
- Filing Date
- 2025-10-13
- Publication Date
- 2026-07-03
AI Technical Summary
Existing technologies lack the ability to comprehensively analyze abnormal commands from electric vehicle controllers, resulting in the inability to accurately identify hidden abnormal command sequences in complex scenarios. Furthermore, the lack of effective compensation and recovery mechanisms affects the normal operation and safety of electric vehicles.
By constructing an instruction dependency graph and state transition features, the execution deviation probability of input instructions is calculated, abnormal instructions are identified and stored in an isolation sandbox, the expected state of the instruction set is simulated, the compensation control sequence is calculated, and the execution batch is reordered through a dynamic programming algorithm to ensure the smooth operation of the electric vehicle control system.
It enables accurate identification and intelligent correction of abnormal commands, improving the safety and reliability of the electric vehicle control system, avoiding loss of control or dangerous operation, and enhancing the system's fault tolerance and user riding experience.
Smart Images

Figure CN121050220B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electric vehicle control safety technology, and in particular to a method and system for identifying and intercepting abnormal commands from an electric vehicle controller. Background Technology
[0002] With the widespread use of electric vehicles in urban transportation, safety issues have become increasingly prominent. The electric vehicle controller, as a core component, is responsible for receiving and processing input signals from various sensors to control the motor's operation. However, due to factors such as electromagnetic interference, sensor failure, or malicious attacks, the controller may receive abnormal commands, causing the electric vehicle to behave unexpectedly, or even leading to safety accidents.
[0003] Existing technologies lack the comprehensive analytical capabilities to understand inter-instruction dependencies and state transition characteristics, resulting in the inability to accurately identify hidden abnormal instructions in complex scenarios, especially instruction sequences that appear reasonable when analyzed individually but can lead to dangerous consequences in the overall system. Current abnormal instruction handling mechanisms typically employ simple interception or ignore strategies, lacking the ability to analyze and process instruction clusters associated with abnormal instructions. This can lead to system malfunctions or state inconsistencies, thereby affecting the normal operation of electric vehicles. Furthermore, existing technologies lack effective compensation and recovery mechanisms after intercepting abnormal instructions, failing to ensure a smooth transition to a safe state for the electric vehicle control system. Especially in critical scenarios such as high-speed driving, simply intercepting abnormal instructions can lead to more serious safety problems. Summary of the Invention
[0004] This invention provides a method and system for identifying and intercepting abnormal commands from an electric vehicle controller, which can solve the problems in the prior art.
[0005] A first aspect of the present invention provides a method for identifying and intercepting abnormal commands of an electric vehicle controller, comprising:
[0006] Obtain the input commands, rated parameters, and riding status parameters of the electric vehicle controller;
[0007] Based on the execution order and state transition relationship of the input instructions, an instruction dependency graph and instruction state transition features are constructed respectively. The execution deviation probability of the input instructions is calculated based on the instruction dependency graph and the instruction state transition features. An instruction verification matrix is constructed according to the rated parameters and the riding state parameters. The instruction verification matrix is used to verify the input instructions whose execution deviation probability is higher than a preset deviation threshold, and to determine whether they are abnormal instructions.
[0008] Upon detecting an abnormal instruction, the abnormal instruction is stored in an isolation sandbox. Instructions related to the abnormal instruction are identified based on the instruction dependency graph and formed into an instruction cluster. The expected state of the instruction cluster is simulated in the isolation sandbox. Based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated. The compensation control sequence is superimposed on the instruction cluster and divided into multiple execution batches. The execution batches are reordered using a dynamic programming algorithm.
[0009] The reordered execution batch is subjected to functional completeness verification and anomaly verification. When the verification passes and there are no anomalies, the electric vehicle controller executes the reordered execution batch, deletes the abnormal instructions in the isolation sandbox, and completes the interception of abnormal instructions.
[0010] Based on the execution order and state transition relationships of the input instructions, an instruction dependency graph and instruction state transition features are constructed respectively. The execution deviation probability of the input instructions is calculated based on the instruction dependency graph and the instruction state transition features, including:
[0011] The input instructions are mapped to a high-dimensional feature space through a preset feature encoding matrix. The data flow dependency and control flow dependency between the input instructions are obtained in the high-dimensional feature space. The instruction dependency graph is constructed based on the data flow dependency and control flow dependency. The nodes in the instruction dependency graph are subjected to feature aggregation to obtain instruction dependency features.
[0012] Based on the state transition relationship, the state transition features of the input instruction are extracted by forward traversal and backward traversal respectively, and then concatenated to obtain the instruction state transition features;
[0013] The execution time intervals of adjacent instructions in the instruction dependency features are extracted, the transition rate of state variables in the instruction state transition features is calculated, and the transfer risk degree is calculated based on the execution time intervals and the transition rate. A resource utilization constraint is constructed using the ratio of the resource occupancy rate of the electric vehicle controller to a preset resource threshold, and a response delay constraint is constructed using the maximum allowed execution time of the input instructions. The transfer risk degree is corrected based on the resource utilization constraint and the response delay constraint to obtain the execution deviation probability.
[0014] A command verification matrix is constructed based on the rated parameters and the riding state parameters. The command verification matrix is used to verify input commands whose execution deviation probability is higher than a preset deviation threshold. Determining whether a command is abnormal includes:
[0015] Based on the rated parameters, establish parameter safety threshold constraints, construct dynamic riding stability constraints based on the riding state parameters, calculate the rate of change and acceleration of change of the riding state parameters within a preset sampling period and combine them to obtain riding state parameter change characteristics, and cross-map the parameter safety threshold constraints, the dynamic riding stability constraints and the riding state parameter change characteristics to obtain the instruction verification matrix.
[0016] The input instructions with execution deviation probabilities higher than a preset deviation threshold are mapped to the feature space corresponding to the instruction verification matrix. Feature values and feature vectors in the feature space are extracted. The L2 norm of the feature values and the feature vectors are calculated and multiplied to obtain the parameter deviation value. A preset number of historical instructions before the input instruction are obtained. The Euclidean distance between the input instruction and the historical instructions is calculated. The Euclidean distance is then subjected to Gaussian mapping to obtain the instruction state consistency value.
[0017] The parameter deviation value is combined with the instruction status consistency value to obtain an anomaly determination value, and the input instruction is determined to be an abnormal instruction based on the anomaly determination value.
[0018] The abnormal instructions are stored in an isolation sandbox. Instructions related to the abnormal instructions are identified based on the instruction dependency graph and grouped into an instruction family. The expected state of the instruction family is simulated within the isolation sandbox, including:
[0019] The abnormal instruction is stored in the isolation sandbox, which has independent memory space and independent computing resources;
[0020] The instruction dependency graph is traversed using a depth-first search algorithm. The correlation between the abnormal instruction and other input instructions is calculated. Based on the correlation, related instructions of the abnormal instruction are selected and stored in the isolation sandbox. The abnormal instruction and the related instructions are sorted according to their temporal dependencies to form the instruction cluster.
[0021] The instruction execution parameters and instruction control quantities are extracted from the instruction set and substituted into the Kalman filter algorithm to obtain the state prediction value at the next moment; based on the execution characteristics of the instruction set, the corresponding instruction interference quantities are extracted from the riding state parameters to construct an interference influence matrix;
[0022] In the isolated sandbox, the instructions in the instruction cluster are executed one by one, and the state change after each instruction is executed is recorded. The state change is compared with the state prediction value at the next moment to obtain the state deviation. The state deviation is corrected according to the interference influence matrix. Based on the corrected state deviation, the instruction execution parameters and instruction control quantities of subsequent instructions are adjusted until all instructions in the instruction cluster are executed, and the expected state of the instruction cluster is obtained.
[0023] Based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated. This compensation control sequence is then superimposed onto the instruction set and divided into multiple execution batches. The execution batches are then reordered using a dynamic programming algorithm, including:
[0024] The expected state is compared with the current state of the electric vehicle controller to obtain a state error vector. The state error vector is then sampled in real time, integrated, and differentiated to obtain a proportional term, an integral term, and a differential term, which are then combined to obtain the compensation control sequence.
[0025] The error compensation gain is calculated based on the magnitude of the state error vector. The compensation control sequence is multiplied by the error compensation gain and then superimposed with the instruction set to obtain the total control sequence. The time window scale is determined based on the control cycle and response delay of the electric vehicle controller. The total control sequence is divided into multiple execution batches according to the time window scale.
[0026] The state transition cost of the execution batch is constructed, which includes energy loss, execution delay and power fluctuation between adjacent execution batches. Based on the dynamic programming algorithm, the execution batches are reordered by minimizing the state transition cost.
[0027] Constructing the state transition cost of the execution batch, the state transition cost includes energy loss, execution delay, and power fluctuation terms between adjacent execution batches. Based on the dynamic programming algorithm, reordering the execution batches by minimizing the state transition cost includes:
[0028] Establish state transition relationships between adjacent batches of the execution batch;
[0029] The motor energy consumption is calculated based on the control command sequence of the adjacent batches, and the energy loss term is obtained based on the motor energy consumption and the transmission system efficiency in the rated parameters; the scheduling time of the adjacent batches is calculated based on the processing frequency of the electric vehicle controller, and the scheduling time is superimposed with the control command execution time of the adjacent batches to obtain the execution delay term; the output power curve is calculated based on the control command sequence of the adjacent batches, and the variance of the output power curve is calculated to obtain the power fluctuation term;
[0030] The state transition cost is obtained by superimposing the energy loss term, the execution delay term, and the power fluctuation term.
[0031] The initial batch of the execution batch is set as the starting state. A state space graph is constructed by traversing the state transition relationship. Based on the state transition cost, the cumulative value of the state transition cost from the starting state to each reachable state is calculated in a step-by-step recursive manner. The path with the smallest cumulative value of the state transition cost is backtracked from the state space graph, and the batch sequence corresponding to the path is used as the reordering result.
[0032] The reordered execution batches undergo functional completeness verification and anomaly verification. When the verification passes and no anomalies are found, the electric vehicle controller executes the reordered execution batches, including:
[0033] Multiple control function types of the abnormal instruction are obtained. The type identifier and control parameters of each control function type are constructed into a function feature vector. The function feature vectors corresponding to all control function types are concatenated to form the function feature matrix of the abnormal instruction. The function feature matrix of the reordered execution batch is obtained using the same method. The matching degree of the two function feature matrices is calculated to obtain the function coverage rate. The function coverage rate is used as the function completeness verification result.
[0034] Calculate the execution deviation probability of the reordered execution batch, and perform anomaly verification using the instruction verification matrix based on the execution deviation probability to obtain the anomaly verification result;
[0035] Based on the functional completeness verification result and the anomaly verification result, it is determined whether the reordered execution batch meets the execution conditions. When the execution conditions are met, the reordered execution batch is migrated from the isolation sandbox to the instruction execution queue of the electric vehicle controller and waits for execution.
[0036] A second aspect of the present invention provides an abnormal command identification and interception system for an electric vehicle controller, comprising:
[0037] The first unit is used to obtain the input commands, rated parameters, and riding status parameters of the electric vehicle controller;
[0038] The second unit is used to construct an instruction dependency graph and an instruction state transition feature based on the execution order and state transition relationship of the input instruction, respectively; calculate the execution deviation probability of the input instruction based on the instruction dependency graph and the instruction state transition feature; construct an instruction verification matrix according to the rated parameters and the riding state parameters; use the instruction verification matrix to verify the input instruction whose execution deviation probability is higher than a preset deviation threshold, and determine whether it is an abnormal instruction.
[0039] The third unit is used to detect abnormal instructions, store the abnormal instructions in an isolation sandbox, identify instructions related to the abnormal instructions based on the instruction dependency graph and form an instruction cluster, simulate the expected state of the instruction cluster in the isolation sandbox, calculate a compensation control sequence based on the state error between the expected state and the current state of the electric vehicle controller, superimpose the compensation control sequence onto the instruction cluster and divide it into multiple execution batches, and reorder the execution batches using a dynamic programming algorithm.
[0040] The fourth unit is used to perform functional completeness verification and anomaly verification on the reordered execution batch. When the verification is successful and there are no anomalies, the electric vehicle controller executes the reordered execution batch, deletes the abnormal instructions in the isolation sandbox, and completes the interception of abnormal instructions.
[0041] A third aspect of the present invention,
[0042] An electronic device is provided, comprising:
[0043] processor;
[0044] Memory used to store processor-executable instructions;
[0045] The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.
[0046] Fourth aspect of the embodiments of the present invention,
[0047] A computer-readable storage medium is provided, having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.
[0048] The beneficial effects of this application are as follows:
[0049] The electric vehicle controller abnormal command identification and interception method provided by the present invention can accurately identify abnormal commands by constructing command dependency graphs and command state transition features, thereby effectively improving the safety and reliability of the electric vehicle control system.
[0050] An isolation sandbox technique is used to process abnormal commands, and a compensation control sequence is calculated based on the error between the expected state and the current state. This enables intelligent correction of abnormal commands, avoids loss of control or dangerous operation of electric vehicles due to abnormal commands, and enhances the fault tolerance of the system.
[0051] By reordering the execution batches using dynamic programming algorithms and verifying their functional completeness, the electric vehicle control system is ensured to operate smoothly in the face of abnormal situations, improving the user riding experience and the safety of electric vehicles, while reducing the risk of accidents caused by controller malfunctions. Attached Figure Description
[0052] Figure 1 This is a flowchart illustrating the abnormal command identification and interception method for electric vehicle controllers according to an embodiment of the present invention;
[0053] Figure 2 This is a schematic diagram illustrating the process of calculating the probability of deviation. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0055] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0056] Figure 1 This is a flowchart illustrating the abnormal command identification and interception method for electric vehicle controllers according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0057] Obtain the input commands, rated parameters, and riding status parameters of the electric vehicle controller;
[0058] Based on the execution order and state transition relationship of the input instructions, an instruction dependency graph and instruction state transition features are constructed respectively. The execution deviation probability of the input instructions is calculated based on the instruction dependency graph and the instruction state transition features. An instruction verification matrix is constructed according to the rated parameters and the riding state parameters. The instruction verification matrix is used to verify the input instructions whose execution deviation probability is higher than a preset deviation threshold, and to determine whether they are abnormal instructions.
[0059] Upon detecting an abnormal instruction, the abnormal instruction is stored in an isolation sandbox. Instructions related to the abnormal instruction are identified based on the instruction dependency graph and formed into an instruction cluster. The expected state of the instruction cluster is simulated in the isolation sandbox. Based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated. The compensation control sequence is superimposed on the instruction cluster and divided into multiple execution batches. The execution batches are reordered using a dynamic programming algorithm.
[0060] The reordered execution batch is subjected to functional completeness verification and anomaly verification. When the verification passes and there are no anomalies, the electric vehicle controller executes the reordered execution batch, deletes the abnormal instructions in the isolation sandbox, and completes the interception of abnormal instructions.
[0061] In one optional implementation, an instruction dependency graph and instruction state transition features are constructed based on the execution order and state transition relationships of the input instructions, respectively. The execution deviation probability of the input instructions is calculated based on the instruction dependency graph and the instruction state transition features, including:
[0062] The input instructions are mapped to a high-dimensional feature space through a preset feature encoding matrix. The data flow dependency and control flow dependency between the input instructions are obtained in the high-dimensional feature space. The instruction dependency graph is constructed based on the data flow dependency and control flow dependency. The nodes in the instruction dependency graph are subjected to feature aggregation to obtain instruction dependency features.
[0063] Based on the state transition relationship, the state transition features of the input instruction are extracted by forward traversal and backward traversal respectively, and then concatenated to obtain the instruction state transition features;
[0064] The execution time intervals of adjacent instructions in the instruction dependency features are extracted, the transition rate of state variables in the instruction state transition features is calculated, and the transfer risk degree is calculated based on the execution time intervals and the transition rate. A resource utilization constraint is constructed using the ratio of the resource occupancy rate of the electric vehicle controller to a preset resource threshold, and a response delay constraint is constructed using the maximum allowed execution time of the input instructions. The transfer risk degree is corrected based on the resource utilization constraint and the response delay constraint to obtain the execution deviation probability.
[0065] like Figure 2 As shown, the method includes:
[0066] After receiving commands from the input terminal, the electric vehicle controller maps these input commands to a high-dimensional feature space using a preset feature encoding matrix. This preset feature encoding matrix is a 120×80 two-dimensional matrix containing three parts: command type encoding, parameter encoding, and timing encoding. The command type encoding occupies the first 40 rows of the matrix and represents the different types of commands supported by the electric vehicle controller, such as acceleration commands, deceleration commands, and steering commands. The parameter encoding occupies the middle 40 rows of the matrix and represents the parameter information of the command, such as the magnitude of acceleration and the steering angle. The timing encoding occupies the last 40 rows of the matrix and represents the timing relationship of the command, such as the execution time and duration of the command. Through the mapping of this feature encoding matrix, each input command is converted into an 80-dimensional feature vector and stored in the high-dimensional feature space for subsequent analysis.
[0067] Data flow dependency refers to the situation where the output of one instruction serves as the input of another. For example, the output of a speed control instruction can affect subsequent steering instructions. In practice, data flow information is extracted from the parameter encoding part of the feature vector. When the feature vectors of two instructions intersect in the parameter-related dimension, a data flow dependency is determined to exist between them. Control flow dependency refers to the situation where the execution condition of one instruction depends on the execution result of another instruction. For example, an emergency braking instruction depends on the result of an obstacle detection instruction. In practice, control flow information is extracted from the instruction type encoding and timing encoding parts of the feature vector. When the execution time of one instruction must logically be later than that of another instruction, a control flow dependency is determined to exist between them.
[0068] An empty directed graph structure is created, with a corresponding node for each input command. All command pairs are traversed, checking for data flow or control flow dependencies. Once a dependency is identified, directed edges are added between the corresponding nodes, and weights are assigned based on the dependency type, constructing the command dependency graph. Each node in this graph represents an input command, and directed edges between nodes represent dependencies. For a typical electric vehicle control scenario, this dependency graph typically contains 20-30 nodes. In the graph, the edge weights are determined by the strength of the dependency: data flow dependencies have a weight of 0.7, control flow dependencies have a weight of 0.9, and dependencies with both data flow and control flow are weighted at 0.95. For example, in a sharp turn operation, there is a data flow dependency between the steering command and the speed control command, with a weight of 0.7; while there is a control flow dependency between the emergency braking command and the obstacle detection command, with a weight of 0.9.
[0069] Feature aggregation is performed on nodes in the instruction dependency graph using a message passing mechanism of a graph neural network. Each node obtains information from its neighbors and updates its own features. Specifically, the feature update formula uses a weighted summation method; the feature update of node i is the weighted sum of its own features and the features of all its neighboring nodes. The weight coefficients are determined based on the edge weights and the degree of the nodes to ensure the stability of feature aggregation. Through three rounds of iterative updates, each node obtains fully aggregated features, forming instruction dependency features. In practical applications, for a dependency graph with 20 nodes, the feature vector dimension of each node is expanded from the initial 80 dimensions to 128 dimensions, more comprehensively capturing the structural information of the nodes in the graph.
[0070] Based on state transition relationships, the forward traversal starts from the node with an in-degree of 0 in the dependency graph and traverses along the graph's direction, recording the node's state variables and their changes. The backward traversal starts from the node with an out-degree of 0 and traverses against the graph's direction, similarly recording the node's state variables and their changes. The electric vehicle controller's state variables include key parameters such as motor speed, battery voltage, current value, and controller temperature. During the forward traversal, the focus is on the incremental changes of state variables, such as the increase in motor speed and current during acceleration from a standstill to 5 km / h. During the backward traversal, the focus is on the constraints of the state variables, such as ensuring the battery voltage does not fall below a threshold and the controller temperature does not exceed a safe range during cornering. The features obtained from the forward and backward traversals are each 64-dimensional vectors; concatenating these two vectors yields a 128-dimensional command state transition feature.
[0071] The execution time interval is a critical timing parameter for instruction execution. It involves extracting timing information from each pair of adjacent nodes in the instruction dependency graph and calculating their execution time difference. For example, for an acceleration instruction and a subsequent steering instruction, if the execution time of the acceleration instruction is t1 and the execution time of the steering instruction is t2, then their execution time interval is t2-t1. In real-world scenarios, a normal instruction execution time interval is typically between 50 and 200 milliseconds; exceeding this range can lead to control instability.
[0072] The migration rate is the change of a state variable per unit time, reflecting the drastic degree of system state change. For key state variables of electric vehicles, such as motor speed, the migration rate should not exceed 200 revolutions per minute per second under normal circumstances; for battery voltage, the migration rate should not exceed 0.5 volts per second under normal circumstances. The migration rate of each state variable is extracted from the 128-dimensional command state migration features to form a migration rate vector.
[0073] The execution time interval vector and migration rate vector are normalized separately, and then their weighted sum is calculated to obtain the transfer risk degree. In practical applications, the weight of the time factor is 0.4, and the weight of the state change factor is 0.6, reflecting the significant impact of state changes on risk. For example, in a rapid acceleration operation, if the execution time interval is 30 milliseconds (below the normal range) and the motor speed migration rate is 300 revolutions per minute per second (above the normal range), the calculated transfer risk degree will be significantly higher than that of normal operation.
[0074] Resource utilization constraints are constructed using the ratio of the electric vehicle controller's resource utilization rate to preset resource thresholds. Resource utilization rate includes CPU utilization, memory utilization, and bus bandwidth utilization. For a typical electric vehicle controller, the preset thresholds are 80% for CPU utilization, 75% for memory utilization, and 70% for bus bandwidth utilization. The utilization of these three resources is monitored in real time, and their ratios to the thresholds are calculated. The maximum value is taken as the resource utilization constraint factor. For example, when CPU utilization reaches 76%, memory utilization reaches 60%, and bus bandwidth utilization reaches 50%, the resource utilization constraint factor is 76% / 80% = 0.95.
[0075] The maximum permissible execution time is a hard requirement that an instruction must complete within a certain timeframe; exceeding this time will result in control failure. For emergency braking instructions, the maximum permissible execution time is typically set to 50 milliseconds; for normal steering instructions, it is typically set to 100 milliseconds; and for display information instructions, the maximum permissible execution time can be relaxed to 200 milliseconds. The response delay constraint factor is obtained by calculating the ratio of the actual execution time of the instruction to the maximum permissible execution time. For example, if the actual execution time of an emergency braking instruction is 40 milliseconds, then the response delay constraint factor is 40 / 50 = 0.8.
[0076] The transfer risk level is corrected based on resource utilization and response delay constraints. The correction process employs a nonlinear mapping method. When either the resource utilization constraint factor or the response delay constraint factor approaches 1, the amplification effect on the transfer risk level is more significant. Specifically, an exponential function of the resource utilization constraint factor and the response delay constraint factor is used to adjust the transfer risk level, resulting in the final execution deviation probability. The execution deviation probability ranges from 0 to 1, typically set at 0.75 as the warning threshold and 0.85 as the danger threshold. For example, for a steering operation during high-speed driving, if the initially calculated transfer risk level is 0.6, the resource utilization constraint factor is 0.95, and the response delay constraint factor is 0.9, then the corrected execution deviation probability is approximately 0.83, close to the danger threshold, allowing for more stringent monitoring of the instruction.
[0077] Through the above technical solution, the electric vehicle controller can accurately calculate the probability of execution deviation of input commands, providing a reliable basis for subsequent abnormal command judgment, thereby improving the safety and stability of electric vehicle operation. Experimental data shows that in typical electric vehicle driving scenarios, this method achieves an abnormal command recognition accuracy of 95.7% and a false alarm rate controlled below 3.2%, effectively preventing safety accidents caused by abnormal controller commands.
[0078] In one optional implementation, a command verification matrix is constructed based on the rated parameters and the riding state parameters. The command verification matrix is used to verify input commands whose execution deviation probability is higher than a preset deviation threshold, and the determination of whether the command is an abnormal command includes:
[0079] Based on the rated parameters, establish parameter safety threshold constraints, construct dynamic riding stability constraints based on the riding state parameters, calculate the rate of change and acceleration of change of the riding state parameters within a preset sampling period and combine them to obtain riding state parameter change characteristics, and cross-map the parameter safety threshold constraints, the dynamic riding stability constraints and the riding state parameter change characteristics to obtain the instruction verification matrix.
[0080] The input instructions with execution deviation probabilities higher than a preset deviation threshold are mapped to the feature space corresponding to the instruction verification matrix. Feature values and feature vectors in the feature space are extracted. The L2 norm of the feature values and the feature vectors are calculated and multiplied to obtain the parameter deviation value. A preset number of historical instructions before the input instruction are obtained. The Euclidean distance between the input instruction and the historical instructions is calculated. The Euclidean distance is then subjected to Gaussian mapping to obtain the instruction state consistency value.
[0081] The parameter deviation value is combined with the instruction status consistency value to obtain an anomaly determination value, and the input instruction is determined to be an abnormal instruction based on the anomaly determination value.
[0082] The rated parameters of an electric vehicle include key indicators such as motor rated power, rated voltage, rated current, maximum speed, and maximum controller operating temperature. For a typical daily-use two-wheeled electric vehicle, the motor rated power is 250 watts, the rated voltage is 36 volts, the rated current is 10 amps, the maximum speed is 350 rpm, and the maximum controller operating temperature is 60 degrees Celsius. Based on these rated parameters, safety margins are set to construct parameter safety threshold constraints. The safety margin is usually set to 15% of the rated value, that is, the motor power should not exceed 287.5 watts, the voltage should not exceed 41.4 volts, the current should not exceed 11.5 amps, the speed should not exceed 402.5 rpm, and the controller temperature should not exceed 69 degrees Celsius. These parameter safety threshold constraints are organized into a vector for subsequent instruction verification matrix construction.
[0083] Riding status parameters include real-time monitored values such as current speed, acceleration, angular velocity, tilt angle, and vibration intensity. Based on these parameters, dynamic riding stability constraints are constructed. These constraints consider the stability requirements of the electric vehicle under different riding conditions. Specifically, speed is divided into low-speed (0-10 km / h), medium-speed (10-20 km / h), and high-speed (20-25 km / h) ranges, with different acceleration constraints set for each speed range. In the low-speed range, the maximum allowable acceleration is 1.5 m / s². 2 In the medium speed range, the maximum permissible acceleration is 1.2 m / s². 2 In the high-speed range, the maximum permissible acceleration is reduced to 0.8 m / s². 2 Simultaneously, angular velocity constraints are set based on speed: a maximum angular velocity of 30 degrees / second in the low-speed range, 20 degrees / second in the medium-speed range, and 15 degrees / second in the high-speed range. For the tilt angle, the maximum allowable value is 15 degrees regardless of speed. Vibration intensity constraints are adaptively adjusted according to road conditions: a maximum allowable vibration intensity of 0.5g on flat roads and 0.8g on rough roads. These dynamic constraints are combined into a dynamic riding stability constraint vector.
[0084] The preset sampling period is typically set to 100 milliseconds. Within each sampling period, the initial and final values of parameters such as velocity, acceleration, angular velocity, tilt angle, and vibration intensity are recorded. The difference between these values is calculated and divided by the sampling period to obtain the rate of change of each parameter. For example, if the velocity changes from 15 km / h to 15.5 km / h within a sampling period, the rate of change is 5 km / h / s. The change in the rate of change of each parameter is then calculated, i.e., the acceleration. Continuing the example, if the rate of change of velocity in the previous sampling period was 4 km / h / s, and in this period it is 5 km / h / s, then the acceleration due to velocity change is 10 km / h / s. 2 The rate of change and acceleration of all parameters are combined into a vector, which serves as a characteristic of the changes in riding state parameters.
[0085] The process of cross-mapping parameter safety threshold constraints, dynamic riding stability constraints, and riding state parameter change characteristics employs feature fusion technology. This technology merges the constraints and features from three different dimensions into a single two-dimensional matrix. The number of rows in the matrix equals the dimension of the parameter safety threshold constraints, and the number of columns equals the dimension of the dynamic riding stability constraints. Each element in the matrix is determined by the parameter safety threshold constraint in the corresponding row, the dynamic riding stability constraint in the corresponding column, and the riding state parameter change characteristics associated with those two positions. In the specific calculation, the three vectors are standardized so that their values all fall between 0 and 1, and then a weighted average is used to calculate the matrix element values. The weights are configured as follows: parameter safety threshold constraints 0.4, dynamic riding stability constraints 0.4, and riding state parameter change characteristics 0.2. This configuration reflects the importance of safety thresholds and stability constraints for command verification. For a typical electric vehicle control system, the command verification matrix has a dimension of 10×12, which is sufficient to cover the critical safety parameters and stability constraints.
[0086] Input instructions with an execution deviation probability higher than a preset deviation threshold are mapped to the feature space corresponding to the instruction verification matrix. The preset deviation threshold is typically set to 0.75; input instructions exceeding this threshold are considered potentially anomalous and require further verification. Feature vectors are extracted from these instructions, containing information such as instruction type, parameter values, and execution time. Through feature transformation, the instruction feature vectors are mapped to a feature space compatible with the instruction verification matrix. The transformation process includes three steps: dimension alignment, scaling, and feature enhancement. Dimension alignment ensures that the dimension of the instruction feature vector matches the number of rows and columns of the matrix; scaling adjusts the value range of the instruction features to between 0 and 1; feature enhancement generates new features by combining the original features, improving expressive power. After transformation, the instruction is represented as a two-dimensional matrix in the feature space, with the same dimensions as the instruction verification matrix.
[0087] Eigenvalues and eigenvectors are extracted from the feature space. The L2 norm of each eigenvalue and eigenvector is calculated and multiplied to obtain the parameter deviation. Eigenvalue decomposition is performed on the mapped instruction feature matrix to extract its eigenvalues and corresponding eigenvectors. Singular value decomposition is used for eigenvalue decomposition, which can effectively handle non-square matrices and is applicable to feature matrices of various dimensions. The eigenvalues obtained from the decomposition represent the variance of the instruction in each principal component direction, and the eigenvectors represent the directions of these principal components. The L2 norm of all eigenvalues is calculated, which is the square root of the sum of the squares of all eigenvalues, to obtain the eigenvalue norm. Similarly, the L2 norm of all eigenvectors is calculated to obtain the eigenvector norm. The parameter deviation is obtained by multiplying the eigenvalue norm and the eigenvector norm.
[0088] The process involves retrieving a preset number of historical instructions preceding the input instruction, calculating the Euclidean distance between the input instruction and these historical instructions, and then applying a Gaussian mapping to the Euclidean distance to obtain the instruction state consistency value. The preset number is typically 10, meaning the 10 historical instructions preceding the current instruction are retrieved. The Euclidean distance between the current instruction and each historical instruction in the feature space is calculated. During the Euclidean distance calculation, differences across multiple dimensions, such as instruction type, parameter values, and execution time, are considered, with the weights of each dimension set according to their importance. The weight for the type dimension is 0.4, for the parameter value dimension it is 0.3, for the execution time dimension it is 0.2, and for other dimensions it is 0.1. The calculated Euclidean distance is then converted into an instruction state consistency value using a Gaussian mapping. This Gaussian mapping uses a Gaussian function with a standard deviation of 1, converting the Euclidean distance into a value between 0 and 1. The smaller the distance, the closer the consistency value is to 1; the larger the distance, the closer the consistency value is to 0. The average consistency value between the current instruction and all historical instructions is calculated as the final instruction state consistency value.
[0089] The process of combining parameter deviation values and instruction state consistency values uses a weighted approach: Anomaly determination value = Parameter deviation value × 0.6 + (1 - Instruction state consistency value) × 0.4. This weighting configuration reflects the dominant role of parameter deviation in anomaly detection while also considering consistency with historical instructions. The anomaly determination value ranges from 0 to 1, with a higher value indicating a greater probability of the instruction being abnormal. An anomaly determination threshold of 0.7 is set; when the anomaly determination value exceeds this threshold, the instruction is determined to be abnormal. To improve the reliability of the determination, consecutive anomalies are considered. If the anomaly determination values of three consecutive instructions all exceed 0.65, even if their individual anomaly determination values do not exceed 0.7, the last instruction is determined to be abnormal. This mechanism helps to capture progressive anomalies.
[0090] Through the above technical solution, the electric vehicle controller can accurately identify various abnormal commands, including commands exceeding safety thresholds, commands violating riding stability constraints, and commands inconsistent with historical command patterns, effectively preventing safety accidents caused by abnormal commands. Experimental data shows that the method achieves an abnormal command recognition accuracy of 96.8% in complex riding environments, with a false alarm rate of less than 2.5%, significantly outperforming traditional methods.
[0091] In one optional implementation, the abnormal instruction is stored in an isolation sandbox, and instructions related to the abnormal instruction are identified based on the instruction dependency graph and formed into an instruction cluster. Simulating the expected state of the instruction cluster within the isolation sandbox includes:
[0092] The abnormal instruction is stored in the isolation sandbox, which has independent memory space and independent computing resources;
[0093] The instruction dependency graph is traversed using a depth-first search algorithm. The correlation between the abnormal instruction and other input instructions is calculated. Based on the correlation, related instructions of the abnormal instruction are selected and stored in the isolation sandbox. The abnormal instruction and the related instructions are sorted according to their temporal dependencies to form the instruction cluster.
[0094] The instruction execution parameters and instruction control quantities are extracted from the instruction set and substituted into the Kalman filter algorithm to obtain the state prediction value at the next moment; based on the execution characteristics of the instruction set, the corresponding instruction interference quantities are extracted from the riding state parameters to construct an interference influence matrix;
[0095] In the isolated sandbox, the instructions in the instruction cluster are executed one by one, and the state change after each instruction is executed is recorded. The state change is compared with the state prediction value at the next moment to obtain the state deviation. The state deviation is corrected according to the interference influence matrix. Based on the corrected state deviation, the instruction execution parameters and instruction control quantities of subsequent instructions are adjusted until all instructions in the instruction cluster are executed, and the expected state of the instruction cluster is obtained.
[0096] The isolation sandbox is a specially designed secure execution environment with independent memory space and computing resources. The independent memory space includes an instruction store, a data store, and a state buffer, with a total capacity of 256KB. The instruction store occupies 64KB and is used to store abnormal instructions and their related instructions; the data store occupies 128KB and is used to store data required for instruction execution; the state buffer occupies 64KB and is used to record state changes during instruction execution. The independent computing resources include dedicated processing units and timers. The processing unit has a clock frequency of 80MHz, sufficient to support real-time simulation of instruction execution; the timer has an accuracy of 0.1 milliseconds, enabling precise recording of the timing characteristics of instruction execution. The isolation sandbox uses virtualization technology to achieve isolation from the main system. Any operations performed within the sandbox will not directly affect the actual control of the electric vehicle, ensuring the security of abnormal instruction analysis and processing.
[0097] The depth-first search algorithm starts from the node corresponding to the abnormal instruction and traverses all reachable nodes in the graph forward and backward along the edges of dependencies. Forward traversal searches for instructions that depend on the abnormal instruction, and backward traversal searches for instructions that the abnormal instruction depends on. During the traversal, the path length and edge weight from the abnormal instruction to each visited node are recorded. The path length represents the indirect dependency level between nodes, and the edge weight represents the strength of the dependency. The correlation degree calculation considers both path length and edge weight. Specifically, it multiplies the weights of all edges on the path and then multiplies by a decay factor related to the path length. The decay factor is set to 0.8 raised to the power of the path length, indicating that the correlation degree gradually weakens as the path length increases. For example, if the path length is 2 and the edge weights on the path are 0.9 and 0.8 respectively, then the correlation degree is 0.9 × 0.8 × 0.8. 2 =0.4608. In practical applications, the correlation degree between each instruction and the abnormal instruction is calculated to form a correlation degree list.
[0098] The correlation threshold is set to 0.35. Instructions with a correlation exceeding this threshold are considered highly correlated with the abnormal instruction and must be stored together in an isolation sandbox for analysis. This correlation threshold is based on extensive experimental data, achieving a good balance between ensuring analytical completeness and computational efficiency. For a typical two-wheeled electric vehicle control system, the number of related instructions to an abnormal instruction is usually between 5 and 15. These related instructions, along with the abnormal instruction, are completely copied to the instruction storage area of the isolation sandbox. The copying process preserves all original attributes of the instructions, including instruction type, parameter values, and execution time. For each instruction, its execution environment information in the main system is extracted and saved, such as call stack state and register values. This information is crucial for accurately simulating instruction execution.
[0099] Temporal dependency relationships comprehensively consider the original execution order of instructions, data dependencies, and control dependencies. First, a local dependency graph is constructed, containing only nodes corresponding to abnormal instructions and related instructions, along with the edges between them. Then, a topological sort is performed on this local graph, ensuring that the sorting result satisfies all dependency constraints. During the topological sort, if multiple nodes have no preceding dependencies, the node with the higher ranking in the original execution sequence is selected first. In this way, an instruction sequence that satisfies dependency constraints while maintaining the original execution order is obtained; this is the instruction family. In typical application scenarios, the instruction family typically consists of 10 to 20 instructions, including abnormal instructions and highly related instructions. These instructions are stored sequentially in an isolated sandbox instruction sequence buffer according to the sorting result, ready for simulated execution.
[0100] The instruction execution parameters include static parameters such as instruction type identifier, opcode, and operands; the instruction control quantities include dynamic parameters such as motor voltage, current, and power output by the controller. These parameters and control quantities are extracted from each instruction in the instruction family to construct a state vector and a control vector. The state vector contains key state variables of the electric vehicle, such as speed, direction, battery charge, and controller temperature; the control vector contains control quantities that directly affect these state variables. For a typical two-wheeled electric vehicle, the state vector dimension is 12, and the control vector dimension is 8. The Kalman filter algorithm is used to predict the state at the next moment based on the state vector and control vector. This algorithm requires four key parameters: the state transition matrix, the control matrix, the process noise covariance matrix, and the measurement noise covariance matrix. The state transition matrix describes the relationships between state variables and is a 12×12 matrix; the control matrix describes the influence of the control quantities on the state and is a 12×8 matrix; the process noise covariance matrix describes the uncertainty of state prediction and is a 12×12 diagonal matrix; the measurement noise covariance matrix describes the uncertainty of state measurement and is also a 12×12 diagonal matrix. The specific values of these matrices are obtained through system calibration and can accurately reflect the dynamic characteristics of the electric vehicle. Substituting the current state vector, control vector, and these four matrices into the Kalman filter algorithm, the predicted state value for the next time step is obtained.
[0101] Based on the execution characteristics of the instruction cluster, an interference matrix is constructed by extracting corresponding instruction interference quantities from the riding state parameters. Execution characteristics include statistical features such as instruction type distribution, parameter distribution, and execution timing. Instructions within the instruction cluster are classified and statistically analyzed, and the proportion of each type of instruction is calculated to form a type distribution vector. Similarly, the parameter distribution vector and execution timing vector are obtained. Riding state parameters include environmental factors such as road slope, wind speed, and vibration intensity, as well as human factors such as rider weight and riding posture. These factors interfere with instruction execution and affect the execution results. Interference quantities related to the execution characteristics are extracted from the riding state parameters to construct the interference matrix. This matrix is a 12×12 square matrix, where each element represents the degree of influence of a specific interference factor on a specific state variable. For example, the influence coefficient of road slope on speed is 0.25, indicating that a 1-degree change in slope will lead to a 25% change in speed; the influence coefficient of wind speed on power is 0.1, indicating that a 1-meter / second change in wind speed will lead to a 10% change in power. The construction of the interference matrix is based on physical models and historical data analysis, accurately reflecting the influence characteristics of various interference factors.
[0102] Following the instruction cluster order, each instruction is executed sequentially within a virtual, isolated sandbox environment. This execution process does not involve actual hardware manipulation and simulates the core functions of an electric vehicle controller, including instruction decoding, parameter processing, and state updates. For each instruction, the state change after execution is calculated based on its type and parameters. For example, for an acceleration instruction, the speed increment is calculated based on the acceleration parameters and duration; for a steering instruction, the direction change is calculated based on the steering angle and current speed. The calculated state changes are recorded in a state buffer, forming the instruction execution trajectory. This trajectory data contains complete state information before and after each instruction execution, facilitating subsequent analysis.
[0103] For each instruction in the instruction family, the difference between the actual state after execution and the state predicted by the Kalman filter is calculated to obtain a state deviation vector. The state deviation vector has the same dimension as the state vector, which is 12-dimensional, and each element represents the deviation value of the corresponding state variable. The deviation value can be positive or negative; a positive value indicates that the actual state is higher than the predicted value, and a negative value indicates that the actual state is lower than the predicted value. The average absolute value of the state deviation vector is calculated as the overall deviation index. Under normal circumstances, this index should be less than a preset threshold, usually 5% of the range of state variables. If the overall deviation index exceeds the threshold, it indicates that there is an anomaly in instruction execution, and further analysis of the cause is required.
[0104] The state deviation is corrected using an interference influence matrix, and the corrected state deviation is calculated. The correction process considers the influence of various interference factors on the state, making the deviation analysis more accurate. Based on the corrected state deviation, the execution parameters and control quantities of subsequent commands are adjusted. The adjustment magnitude is proportional to the state deviation; the larger the deviation, the larger the adjustment magnitude. For example, if the speed state deviation is positive, it indicates that the actual speed is higher than expected, and the acceleration parameters of subsequent acceleration commands will be reduced accordingly. If the temperature state deviation is positive, it indicates that the actual temperature is higher than expected, and the power output will be reduced to prevent the controller from overheating. The adjusted parameters and control quantities are applied to the execution of subsequent commands, forming a closed-loop feedback control. After executing all commands in the command family, the expected state of the command family is obtained.
[0105] Through the above technical solution, the electric vehicle controller can safely isolate abnormal commands, identify related commands, and accurately simulate the execution process and expected state of the command set in an isolated environment. Experimental data shows that this method achieves a simulation accuracy of 95.2%, effectively supporting subsequent abnormal command interception and compensation control. In practical applications, this technical solution has successfully prevented multiple safety accidents caused by abnormal commands, significantly improving the riding safety of electric vehicles.
[0106] In one optional implementation, based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated. The compensation control sequence is then superimposed onto the instruction set and divided into multiple execution batches. The execution batches are then reordered using a dynamic programming algorithm, including:
[0107] The expected state is compared with the current state of the electric vehicle controller to obtain a state error vector. The state error vector is then sampled in real time, integrated, and differentiated to obtain a proportional term, an integral term, and a differential term, which are then combined to obtain the compensation control sequence.
[0108] The error compensation gain is calculated based on the magnitude of the state error vector. The compensation control sequence is multiplied by the error compensation gain and then superimposed with the instruction set to obtain the total control sequence. The time window scale is determined based on the control cycle and response delay of the electric vehicle controller. The total control sequence is divided into multiple execution batches according to the time window scale.
[0109] The state transition cost of the execution batch is constructed, which includes energy loss, execution delay and power fluctuation between adjacent execution batches. Based on the dynamic programming algorithm, the execution batches are reordered by minimizing the state transition cost.
[0110] The expected state is the stable state after the instruction set is simulated and executed in an isolated sandbox, while the current state is the system state monitored in real time by the electric vehicle controller. Both are represented as multi-dimensional vectors, containing key parameters such as speed, direction, acceleration, battery voltage, current, motor temperature, and controller temperature. The difference between corresponding dimensions of the two vectors is calculated to obtain the state error vector. For example, if the speed in the expected state is 20 km / h and the speed in the current state is 18 km / h, then the state error in the speed dimension is 2 km / h. Similarly, the state errors in other dimensions are calculated to form the complete state error vector. For a typical electric vehicle control system, the state error vector has 12 dimensions, covering all key state variables of the system.
[0111] Real-time sampling is performed with a period of 10 milliseconds, directly acquiring the current state error value as the proportional term. Integral calculations accumulate the state error over a past period, with an integration time window set to 200 milliseconds, meaning the state error of the most recent 20 sampling points is accumulated to obtain the integral term. Differential calculations calculate the rate of change of state error between two adjacent samples to obtain the differential term. For example, if the current sampled speed error is 2 km / h, the accumulated speed error over the past 200 milliseconds is 300 km / h·millisecond (i.e., 0.3 km / h·second), and the speed error change between the current and previous samples is 0.1 km / h, then the proportional term for the speed dimension is 2, the integral term is 0.3, and the differential term is 10 (considering the 10-millisecond sampling period). These three terms are multiplied by the corresponding gain coefficients and combined to obtain the compensation control value. The gain coefficients for the speed dimension are: proportional gain 0.5, integral gain 0.2, and differential gain 0.1. The compensation control values for each dimension are combined into a vector to form the compensation control sequence.
[0112] The L2 norm of the state error vector, i.e., the square root of the sum of squares of errors in each dimension, is calculated as the overall magnitude of the error. For cases with small error magnitudes (less than 50% of the standard threshold), a small compensation gain (0.8) is set to avoid overcorrection. For cases with moderate error magnitudes (between 50% and 80% of the standard threshold), a medium compensation gain (1.0) is set to achieve smooth correction. For cases with large error magnitudes (greater than 80% of the standard threshold), a large compensation gain (1.2) is set to accelerate error convergence. The standard thresholds are preset according to the type and configuration of the electric vehicle. For typical daily riding two-wheeled electric vehicles, the standard threshold for the speed dimension is 3 km / h, the standard threshold for the current dimension is 2 amps, and the standard threshold for the temperature dimension is 5 degrees Celsius.
[0113] The total control sequence is obtained by multiplying the compensated control sequence with the error compensation gain and then superimposing it with the instruction set. The product operation multiplies each element of the compensated control sequence by the corresponding error compensation gain to obtain the adjusted compensated control sequence. The superposition process involves weighted merging of the adjusted compensated control sequence with the control quantities of the original instruction set. For each control cycle, the control quantity of the original instruction and the corresponding compensated control quantity are taken, assigned weights of 0.7 and 0.3 respectively, and the weighted sum is calculated as the total control quantity. This weighting method can correct state errors while maintaining the basic characteristics of the original instructions, avoiding drastic changes in the control process. The superimposed total control sequence covers the entire compensation cycle, typically lasting 500 to 1000 milliseconds, and includes 50 to 100 control points.
[0114] The control cycle is the time required for the controller to execute one complete control loop, typically 10 milliseconds; the response delay is the time delay from the issuance of a control command to its execution, typically 5 milliseconds. Considering both time parameters, the time window scale is set to the control cycle multiplied by the response delay. This configuration reduces scheduling overhead while maintaining control accuracy. For 100 control points in the total control sequence, it is divided into 20 execution batches, with each batch executing 5 consecutive control points. Each batch is assigned a unique batch identifier, and its start time, end time, control command sequence, and other information are recorded.
[0115] State transition relationships describe the change in system state from the completion of one execution batch to the start of the next. For any two batches i and j, if batch j can be executed immediately after batch i is completed, a state transition relationship from i to j is established. These relationships are represented using a directed graph structure, where nodes represent execution batches and edges represent transition paths. In practical applications, not all batch pairs have transition relationships. By analyzing the execution conditions and dependencies of batches, infeasible transitions are filtered out. For example, if the system state that batch j depends on differs significantly from the state after batch i is executed, a transition relationship from i to j is not established. For 20 execution batches, typically 80-120 state transition relationships are constructed, forming a dense transition network.
[0116] In one optional implementation, the state transition cost of the execution batch is constructed, the state transition cost including energy loss terms, execution delay terms, and power fluctuation terms between adjacent execution batches. Based on the dynamic programming algorithm, reordering the execution batches by minimizing the state transition cost includes:
[0117] Establish state transition relationships between adjacent batches of the execution batch;
[0118] The motor energy consumption is calculated based on the control command sequence of the adjacent batches, and the energy loss term is obtained based on the motor energy consumption and the transmission system efficiency in the rated parameters; the scheduling time of the adjacent batches is calculated based on the processing frequency of the electric vehicle controller, and the scheduling time is superimposed with the control command execution time of the adjacent batches to obtain the execution delay term; the output power curve is calculated based on the control command sequence of the adjacent batches, and the variance of the output power curve is calculated to obtain the power fluctuation term;
[0119] The state transition cost is obtained by superimposing the energy loss term, the execution delay term, and the power fluctuation term.
[0120] The initial batch of the execution batch is set as the starting state. A state space graph is constructed by traversing the state transition relationship. Based on the state transition cost, the cumulative value of the state transition cost from the starting state to each reachable state is calculated in a step-by-step recursive manner. The path with the smallest cumulative value of the state transition cost is backtracked from the state space graph, and the batch sequence corresponding to the path is used as the reordering result.
[0121] The motor energy consumption is calculated based on the control command sequence of adjacent batches. The motor input power for each execution batch is calculated, where power equals the product of voltage and current. For a typical electric vehicle motor, the rated voltage is 36 volts, and the current dynamically varies according to the control commands, typically between 0 and 15 amperes. The average power of all control points within a batch is calculated and multiplied by the batch's execution time to obtain the batch's energy consumption. For two adjacent batches i and j, the total energy consumption from the completion of i to the completion of j is calculated, considering the impact of transmission system efficiency. Transmission system efficiency is the ratio of motor output energy to input energy, typically 0.85, meaning 15% of the energy is lost during transmission. The energy loss term equals the total energy consumption divided by the transmission system efficiency, then divided by a standardization factor (usually set to 50 joules) to obtain a dimensionless value. This indicator reflects the energy efficiency of the batch transfer process; a smaller value indicates less energy loss.
[0122] The processing frequency is the number of instructions the controller can process per second, typically 10,000 instructions / second. Scheduling time includes context switching time and batch loading time. Context switching time is fixed at 0.5 milliseconds, while batch loading time is proportional to the batch size, typically 0.1 milliseconds per control point. For an execution batch containing 5 control points, the batch loading time is 0.5 milliseconds, and the total scheduling time is 1 millisecond. The total execution latency is obtained by adding the scheduling time to the batch execution time (usually 50 milliseconds). The execution latency term is equal to the total execution latency divided by a normalization factor (usually set to 10 milliseconds), resulting in a dimensionless value. This metric reflects the time efficiency of the execution batch; a smaller value indicates a faster response.
[0123] Calculate the output power at each control point within the batch and plot the output power as a function of time. For all points on the power curve, calculate their average value, then calculate the square of the difference between each point and the average value, and take the average of these squared values to obtain the power variance. The power fluctuation term is equal to the square root of the variance (standard deviation) divided by the average power, and then divided by the standardization factor (usually set to 0.2) to obtain a dimensionless value. This indicator reflects the stability of the output power; the smaller the value, the smaller the power fluctuation and the smoother the riding experience.
[0124] The energy loss, execution delay, and power fluctuation terms are weighted and summed, with each term having a weight of 0.4. This weighting achieves a good balance between energy efficiency and riding experience. For any two adjacent batches i and j, the state transition cost from i to j is calculated and associated with the corresponding edge in the state transition graph. In practical applications, the costs of different transition paths vary significantly, with the optimal path typically costing more than 40% less than the worst path.
[0125] The initial state is typically chosen as the first execution batch in the overall control sequence. Starting from the initial state, all reachable states are traversed forward along the state transition relationships to construct a complete state space graph. For each reachable state, the cumulative cost of all paths from the initial state to that state is calculated, and the path with the minimum cost is recorded. The recursive calculation employs dynamic programming, avoiding redundant computation and significantly improving algorithm efficiency. For a system with 20 execution batches and 100 state transition relationships, the computation time of the dynamic programming algorithm is typically less than 5 milliseconds, meeting the requirements of real-time control.
[0126] The backtracking process starts from the termination state (i.e. the last batch that must be executed in the total control sequence), and traces backward along the recorded minimum cost path until the starting state is reached to obtain the complete optimal execution path. The batch sequence corresponding to this path is the result of reordering. The reordered execution batch sequence minimizes energy loss, execution latency and power fluctuations while ensuring functional correctness, thereby improving the riding experience and energy efficiency of electric vehicles.
[0127] Through the above technical solution, the electric vehicle controller can effectively handle abnormal commands, calculate precise compensation control sequences, and optimize the execution batch order through dynamic programming algorithms, achieving a smooth and efficient control process. Experimental data shows that when handling high-risk commands such as sharp turns and emergency braking, this method can reduce energy loss by 12.5% and power fluctuation by 18.3%, while maintaining low execution latency (an average increase of no more than 3.2 milliseconds). In practical applications, this technical solution significantly improves the stability and safety of electric vehicles under abnormal conditions, providing riders with a more comfortable and energy-efficient riding experience.
[0128] In one optional implementation, the reordered execution batch is subjected to functional completeness verification and anomaly verification. When the verification passes and no anomalies are found, the electric vehicle controller executes the reordered execution batch, including:
[0129] Multiple control function types of the abnormal instruction are obtained. The type identifier and control parameters of each control function type are constructed into a function feature vector. The function feature vectors corresponding to all control function types are concatenated to form the function feature matrix of the abnormal instruction. The function feature matrix of the reordered execution batch is obtained using the same method. The matching degree of the two function feature matrices is calculated to obtain the function coverage rate. The function coverage rate is used as the function completeness verification result.
[0130] Calculate the execution deviation probability of the reordered execution batch, and perform anomaly verification using the instruction verification matrix based on the execution deviation probability to obtain the anomaly verification result;
[0131] Based on the functional completeness verification result and the anomaly verification result, it is determined whether the reordered execution batch meets the execution conditions. When the execution conditions are met, the reordered execution batch is migrated from the isolation sandbox to the instruction execution queue of the electric vehicle controller and waits for execution.
[0132] Control function type is the basic functional unit of instruction execution, such as acceleration control, braking control, steering control, and lighting control. An abnormal instruction usually contains one or more control function types. By parsing the instruction's opcode and parameters, the control function type it contains can be identified.
[0133] For each control function type, a functional feature vector is constructed using the type identifier and control parameters. The type identifier is a unique numerical code used to identify a specific control function type. The control parameters are the specific parameter values required to execute the function, such as speed, angle, and time values. For the sharp turn function in the direction control class, the type identifier is 0231, and the control parameters include steering angle, steering rate, and speed limit. The type identifier and control parameters are combined into a functional feature vector, which adopts a standardized format. The first element of the vector is the type identifier, and subsequent elements are the control parameters. If the number of control parameters is insufficient, zero values are used to fill in the gaps; if the number of control parameters exceeds the limit, the most important parameters are truncated. The standardized functional feature vector has a length of 10, which is sufficient to express the key features of various control functions.
[0134] During the concatenation of functional feature vectors corresponding to all control function types, each feature vector is sorted according to the importance of the control function type, with higher-importance vectors appearing first. The importance ranking is determined based on the impact of the control function on safety; for example, braking control is more important than lighting control. The concatenated functional feature matrix is a two-dimensional array, with the number of rows equal to the number of control function types and the number of columns equal to the length of the feature vectors. For an abnormal instruction containing three control function types, the dimension of its functional feature matrix is 3×10. The functional feature matrix comprehensively describes the functional characteristics of the abnormal instruction, providing a foundation for subsequent functional completeness verification.
[0135] The reordered execution batch contains multiple instructions. All control function types within these instructions are identified. Similar to handling exception instructions, the type identifier and control parameters of each control function type are used to construct a functional feature vector. All functional feature vectors are then concatenated to form the functional feature matrix of the execution batch. Since execution batches typically contain multiple instructions, their functional feature matrix is usually larger than that of exception instructions. For example, for an execution batch containing 5 instructions and involving 7 control function types, its functional feature matrix has a dimension of 7×10.
[0136] The matching degree calculation process includes three steps: type matching, parameter matching, and function coverage calculation. Type matching checks whether the function feature matrix of the execution batch contains all type identifiers in the function feature matrix of the abnormal instruction. It iterates through the function feature matrix of the abnormal instruction, and for each type identifier, searches for a matching item in the function feature matrix of the execution batch. If a matching item is found, it is recorded as a successful match; otherwise, it is recorded as a failed match. Parameter matching checks whether the control parameters corresponding to the successfully matched type identifiers are compatible. It calculates the parameter difference between the abnormal instruction and the execution batch on the corresponding function feature vector. If the difference is less than a preset threshold (usually 15%), it is considered a successful parameter match. Function coverage calculation is based on the results of type matching and parameter matching, using a weighted average method. The weight of type matching is 0.7, and the weight of parameter matching is 0.3. The function coverage rate is equal to the type matching success rate multiplied by the type matching weight, plus the parameter matching success rate multiplied by the parameter matching weight. The value of the function coverage rate ranges from 0 to 1. The larger the value, the higher the function completeness. The function coverage rate threshold is set to 0.9. Execution batches with a value higher than this threshold are considered to be functionally complete.
[0137] For each instruction in the batch, the execution deviation probability is calculated, and anomaly checks are performed to obtain the anomaly check results. Only when both functional completeness verification and anomaly checks pass are the execution batch considered to meet the execution conditions. Execution batches that meet the execution conditions are migrated from the isolation sandbox to the instruction execution queue of the electric vehicle controller. The migration process includes three steps: instruction sequence copying, execution environment preparation, and execution permission setting. Instruction sequence copying copies all instructions in the execution batch to the instruction execution queue in a reordered order. Execution environment preparation allocates necessary system resources for instruction execution, such as memory space and processor time. Execution permission setting ensures that instructions can be executed normally in the controller, typically including setting parameters such as execution priority and execution time window. After the migration is completed, the execution batch waits for execution in the instruction execution queue.
[0138] Through the above technical solution, the electric vehicle controller can ensure the functional integrity and safety of the alternative execution batch when handling abnormal commands, effectively improving the riding safety and comfort of electric vehicles. Experimental data shows that the functional integrity verification accuracy rate of this solution reaches 97.2%, the abnormality verification accuracy rate reaches 96.5%, and the overall accuracy rate reaches 94.8%, significantly better than traditional methods. In practical applications, this technical solution has effectively prevented many safety accidents caused by abnormal commands, providing more reliable safety protection for electric vehicle riders.
[0139] This invention relates to an electric vehicle controller abnormal command identification and interception system, the system comprising:
[0140] The first unit is used to obtain the input commands, rated parameters, and riding status parameters of the electric vehicle controller;
[0141] The second unit is used to construct an instruction dependency graph and an instruction state transition feature based on the execution order and state transition relationship of the input instruction, respectively; calculate the execution deviation probability of the input instruction based on the instruction dependency graph and the instruction state transition feature; construct an instruction verification matrix according to the rated parameters and the riding state parameters; use the instruction verification matrix to verify the input instruction whose execution deviation probability is higher than a preset deviation threshold, and determine whether it is an abnormal instruction.
[0142] The third unit is used to detect abnormal instructions, store the abnormal instructions in an isolation sandbox, identify instructions related to the abnormal instructions based on the instruction dependency graph and form an instruction cluster, simulate the expected state of the instruction cluster in the isolation sandbox, calculate a compensation control sequence based on the state error between the expected state and the current state of the electric vehicle controller, superimpose the compensation control sequence onto the instruction cluster and divide it into multiple execution batches, and reorder the execution batches using a dynamic programming algorithm.
[0143] The fourth unit is used to perform functional completeness verification and anomaly verification on the reordered execution batch. When the verification is successful and there are no anomalies, the electric vehicle controller executes the reordered execution batch, deletes the abnormal instructions in the isolation sandbox, and completes the interception of abnormal instructions.
[0144] A third aspect of the present invention provides an electronic device, comprising:
[0145] processor;
[0146] Memory used to store processor-executable instructions;
[0147] The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.
[0148] A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.
[0149] This invention can be a method, apparatus, system, and / or computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of the invention.
[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An electric vehicle controller abnormal instruction identification and interception method, characterized in that, include: Obtain the input commands, rated parameters, and riding status parameters of the electric vehicle controller; Based on the execution order and state transition relationships of the input instructions, an instruction dependency graph and instruction state transition features are constructed respectively. The execution deviation probability of the input instructions is calculated based on the instruction dependency graph and the instruction state transition features, including: The input instructions are mapped to a high-dimensional feature space through a preset feature encoding matrix. The data flow dependency and control flow dependency between the input instructions are obtained in the high-dimensional feature space. The instruction dependency graph is constructed based on the data flow dependency and control flow dependency. The nodes in the instruction dependency graph are subjected to feature aggregation to obtain instruction dependency features. Based on the state transition relationship, the state transition features of the input instruction are extracted by forward traversal and backward traversal respectively, and then concatenated to obtain the instruction state transition features; Extract the execution time interval between adjacent instructions from the instruction dependency features, calculate the transition rate of state variables in the instruction state transition features, and calculate the transition risk degree based on the execution time interval and the transition rate; The resource utilization rate constraint is constructed by the ratio of the resource occupancy rate of the electric vehicle controller to the preset resource threshold, and the response delay constraint is constructed by the maximum allowable execution time of the input instruction. The transfer risk degree is corrected based on the resource utilization rate constraint and the response delay constraint to obtain the execution deviation probability. A command verification matrix is constructed based on the rated parameters and the riding status parameters. The command verification matrix is used to verify the input commands whose execution deviation probability is higher than a preset deviation threshold, and to determine whether they are abnormal commands. After detecting an abnormal instruction, the abnormal instruction is stored in an isolation sandbox. Based on the instruction dependency graph, instructions related to the abnormal instruction are identified and formed into an instruction cluster. The expected state of the instruction cluster is simulated in the isolation sandbox. Based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated, the compensation control sequence is superimposed on the instruction set and divided into multiple execution batches, and the execution batches are reordered using a dynamic programming algorithm. The reordered execution batch is subjected to functional completeness verification and anomaly verification. When the verification passes and there are no anomalies, the electric vehicle controller executes the reordered execution batch, deletes the abnormal instructions in the isolation sandbox, and completes the interception of abnormal instructions.
2. The method of claim 1, wherein, A command verification matrix is constructed based on the rated parameters and the riding state parameters. The command verification matrix is used to verify input commands whose execution deviation probability is higher than a preset deviation threshold. Determining whether a command is abnormal includes: Based on the rated parameters, establish parameter safety threshold constraints, construct dynamic riding stability constraints based on the riding state parameters, calculate the rate of change and acceleration of change of the riding state parameters within a preset sampling period and combine them to obtain riding state parameter change characteristics, and cross-map the parameter safety threshold constraints, the dynamic riding stability constraints and the riding state parameter change characteristics to obtain the instruction verification matrix. The input instructions whose execution deviation probability is higher than a preset deviation threshold are mapped to the feature space corresponding to the instruction verification matrix. The feature values and feature vectors in the feature space are extracted. The L2 norm of the feature values and the feature vectors are calculated and multiplied to obtain the parameter deviation value. Obtain a preset number of historical instructions preceding the input instruction, calculate the Euclidean distance between the input instruction and the historical instructions, and perform a Gaussian mapping on the Euclidean distance to obtain an instruction state consistency value; The parameter deviation value is combined with the instruction status consistency value to obtain an anomaly determination value, and the input instruction is determined to be an abnormal instruction based on the anomaly determination value.
3. The method of claim 1, wherein, The abnormal instructions are stored in an isolation sandbox. Instructions related to the abnormal instructions are identified based on the instruction dependency graph and grouped into an instruction family. The expected state of the instruction family is simulated within the isolation sandbox, including: The abnormal instruction is stored in the isolation sandbox, which has independent memory space and independent computing resources; The instruction dependency graph is traversed using a depth-first search algorithm. The correlation between the abnormal instruction and other input instructions is calculated. Based on the correlation, related instructions of the abnormal instruction are selected and stored in the isolation sandbox. The abnormal instruction and the related instructions are sorted according to their temporal dependencies to form the instruction cluster. The instruction execution parameters and instruction control quantities are extracted from the instruction set and substituted into the Kalman filter algorithm to obtain the state prediction value at the next time step. Based on the execution characteristics of the instruction set, the corresponding instruction interference amount is extracted from the riding state parameters to construct an interference influence matrix; In the isolated sandbox, the instructions in the instruction cluster are executed one by one, and the state change after each instruction is executed is recorded. The state change is compared with the state prediction value at the next moment to obtain the state deviation. The state deviation is corrected according to the interference influence matrix. Based on the corrected state deviation, the instruction execution parameters and instruction control quantities of subsequent instructions are adjusted until all instructions in the instruction cluster are executed, and the expected state of the instruction cluster is obtained.
4. The method according to claim 1, characterized in that, Based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated. This compensation control sequence is then superimposed onto the instruction set and divided into multiple execution batches. The execution batches are then reordered using a dynamic programming algorithm, including: The expected state is compared with the current state of the electric vehicle controller to obtain a state error vector. The state error vector is then sampled in real time, integrated, and differentiated to obtain a proportional term, an integral term, and a differential term, which are then combined to obtain the compensation control sequence. The error compensation gain is calculated based on the magnitude of the state error vector. The compensation control sequence is multiplied by the error compensation gain and then superimposed with the instruction set to obtain the total control sequence. The time window scale is determined based on the control cycle and response delay of the electric vehicle controller. The total control sequence is divided into multiple execution batches according to the time window scale. The state transition cost of the execution batch is constructed, which includes energy loss, execution delay and power fluctuation between adjacent execution batches. Based on the dynamic programming algorithm, the execution batches are reordered by minimizing the state transition cost.
5. The method of claim 4, wherein, Constructing the state transition cost of the execution batch, the state transition cost includes energy loss, execution delay, and power fluctuation terms between adjacent execution batches. Based on the dynamic programming algorithm, reordering the execution batches by minimizing the state transition cost includes: Establish state transition relationships between adjacent batches of the execution batch; The motor energy consumption is calculated based on the control command sequence of the adjacent batches, and the energy loss item is obtained based on the motor energy consumption and the transmission system efficiency in the rated parameters. The scheduling time of the adjacent batches is calculated based on the processing frequency of the electric vehicle controller, and the scheduling time is superimposed with the execution time of the control instructions of the adjacent batches to obtain the execution delay item; The output power curve is calculated based on the control command sequence of the adjacent batches, and the power fluctuation term is obtained by performing variance calculation on the output power curve. The state transition cost is obtained by superimposing the energy loss term, the execution delay term, and the power fluctuation term. The initial batch of the execution batch is set as the starting state. A state space graph is constructed by traversing the state transition relationship. Based on the state transition cost, the cumulative value of the state transition cost from the starting state to each reachable state is calculated in a step-by-step recursive manner. The path with the smallest cumulative value of the state transition cost is backtracked from the state space graph, and the batch sequence corresponding to the path is used as the reordering result.
6. The method of claim 1, wherein, The reordered execution batches undergo functional completeness verification and anomaly verification. When the verification passes and no anomalies are found, the electric vehicle controller executes the reordered execution batches, including: Obtain multiple control function types of the abnormal instruction, construct a function feature vector by the type identifier and control parameters of each control function type, and concatenate the function feature vectors corresponding to all control function types to form the function feature matrix of the abnormal instruction; The same method was used to obtain the functional feature matrix of the reordered execution batch; The matching degree of the two functional feature matrices is calculated to obtain the functional coverage rate, which is then used as the functional completeness verification result. Calculate the execution deviation probability of the reordered execution batch, and perform anomaly verification using the instruction verification matrix based on the execution deviation probability to obtain the anomaly verification result; Based on the functional completeness verification result and the anomaly verification result, it is determined whether the reordered execution batch meets the execution conditions. When the execution conditions are met, the reordered execution batch is migrated from the isolation sandbox to the instruction execution queue of the electric vehicle controller and waits for execution.
7. An electric vehicle controller anomaly instruction recognition and interception system for implementing the method of any one of claims 1-6, characterized by, include: The first unit is used to obtain the input commands, rated parameters, and riding status parameters of the electric vehicle controller; The second unit is used to construct an instruction dependency graph and an instruction state transition feature based on the execution order and state transition relationship of the input instruction, and to calculate the execution deviation probability of the input instruction based on the instruction dependency graph and the instruction state transition feature. A command verification matrix is constructed based on the rated parameters and the riding status parameters. The command verification matrix is used to verify the input commands whose execution deviation probability is higher than a preset deviation threshold, and to determine whether they are abnormal commands. The third unit is used to store the abnormal instruction into an isolation sandbox after detecting the abnormal instruction, identify the instructions related to the abnormal instruction based on the instruction dependency graph and form an instruction cluster, and simulate the expected state of the instruction cluster in the isolation sandbox. Based on the state error between the expected state and the current state of the electric vehicle controller, a compensation control sequence is calculated, the compensation control sequence is superimposed on the instruction set and divided into multiple execution batches, and the execution batches are reordered using a dynamic programming algorithm. The fourth unit is used to perform functional completeness verification and anomaly verification on the reordered execution batch. When the verification is successful and there are no anomalies, the electric vehicle controller executes the reordered execution batch, deletes the abnormal instructions in the isolation sandbox, and completes the interception of abnormal instructions.
8. An electronic device, comprising: include: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having stored thereon computer program instructions, wherein, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 6.
Citation Information
Patent Citations
Cross-chip platform compiling tool chain method
CN119322619A
Temperature control method and system for hot working process and storage medium
CN120178984A