Gradient detection method and device, computer equipment and storage medium
By collecting vehicle sensor data and using target filtering algorithms and fitting coefficients for slope calculation, the problem of instability of hardware sensor data is solved, and the accuracy and stability of slope detection are improved.
Patent Information
- Application Number
- CN202411289122.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-02-21
AI Technical Summary
In the prior art, hardware sensors are affected by environmental factors when detecting vehicle slopes, resulting in unstable data, thereby reducing the accuracy of slope detection.
By collecting data from vehicle sensors, using the target filtering algorithm for attitude calculation, the initial slope value is obtained, and the initial slope value is calibrated by preset fit coefficients to obtain the target slope value.
It improves the accuracy and stability of slope detection, reduces the risk of interruption in the vehicle control system, and ensures the real-time and reliability of slope value output.
Smart Images

Figure CN119492359A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of detection technology, and in particular to a slope detection method, device, computer equipment, storage medium and computer program product. Background Art
[0002] In the field of new energy heavy trucks, the slope detection system plays a vital role. It is used to monitor the slope and inclination of the vehicle during driving to provide key data to the driver and vehicle control system, thereby affecting the shift strategy of new energy heavy trucks, the torque output of the motor, the energy recovery of the whole vehicle, etc., to ensure driving safety and efficiency. The accuracy and stability of the slope detection system are crucial to the performance of the vehicle.
[0003] In the related technology, hardware sensors and related control circuits are usually used to realize slope detection, specifically, the slope and inclination angle of the vehicle are detected through physical measurement. Since the hardware sensors are sensors integrated on heavy trucks, they will be affected by temperature, vibration and other environmental factors. The sensor data will be unstable, resulting in low accuracy of the detected slope. Summary of the invention
[0004] Based on this, it is necessary to provide a slope detection method, device, computer equipment, computer-readable storage medium and computer program product that can detect accuracy in order to solve the above technical problems.
[0005] In a first aspect, the present application provides a slope detection method. The method comprises:
[0006] Collecting sensor data from vehicle sensors;
[0007] When it is determined that the vehicle sensor and the sensor data meet a preset validity condition, performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value;
[0008] The initial slope value is calibrated by a preset fitting coefficient to obtain a target slope value.
[0009] In one embodiment, collecting sensor data from vehicle sensors includes:
[0010] The sensor data of the vehicle sensor is collected via the target communication bus.
[0011] In one embodiment, the method further comprises:
[0012] Determine the number of read and write times corresponding to collecting the sensor data;
[0013] If it is determined that the number of read and write times is less than or equal to a preset read and write number threshold, and it is determined that the vehicle sensor passes the validity check, and it is determined that the sensor data passes the validity check, then it is determined that the vehicle sensor and the sensor data meet the preset validity conditions.
[0014] In one embodiment, the method further comprises:
[0015] If the number of read and write times is greater than the preset read and write times threshold, the target communication bus is restored, and the register corresponding to the communication bus is restored. After the restoration is completed, the step of collecting sensor data of the vehicle sensor is re-executed.
[0016] In one of the embodiments, after the step of determining that the number of read and write times is less than or equal to a preset read and write times threshold, the method further includes:
[0017] If it is determined that the value corresponding to the first register inside the vehicle sensor has not changed, and the value corresponding to the second register inside the vehicle sensor has not changed, it is determined that the vehicle sensor has passed the validity check.
[0018] In one embodiment, the method further comprises:
[0019] If it is determined that the vehicle sensor fails the validity check, the vehicle sensor is reset, and after the reset is completed, the step of collecting sensor data of the vehicle sensor is re-executed.
[0020] In one embodiment, the method further includes: after the step of determining that the vehicle sensor passes the validity check, the method further includes:
[0021] Obtaining a target position corresponding to the sensor data;
[0022] If the target position corresponding to the sensor data does not meet the preset mutation condition, it is determined that the sensor data passes the validity check.
[0023] In one embodiment, the method further comprises:
[0024] If it is determined that the sensor data fails the validity check, the last valid data corresponding to the sensor data is obtained, and based on the last valid data, the step of performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value is performed.
[0025] In one embodiment, the initial slope value is calibrated by a preset fitting coefficient to obtain a target slope value, including:
[0026] Acquire multiple groups of fitting sensor data corresponding to the vehicle sensor at multiple positions and postures;
[0027] Perform fitting based on the actual slope value and each of the fitting sensor data to obtain a preset fitting coefficient, wherein the preset fitting coefficient includes a cubic term coefficient, a quadratic term coefficient, a linear term coefficient and a constant term coefficient;
[0028] A target slope value is obtained by performing calculation based on the cubic term coefficient, the quadratic term coefficient, the linear term coefficient, the constant term coefficient, and the initial slope value.
[0029] In a second aspect, the present application also provides a slope detection device. The device comprises:
[0030] A first acquisition module, used to acquire sensor data from vehicle sensors;
[0031] A first determination module is used to calculate the posture of the sensor data by a target filtering algorithm to obtain an initial slope value when it is determined that the vehicle sensor and the sensor data meet a preset validity condition;
[0032] The calibration module is used to calibrate the initial slope value by using a preset fitting coefficient to obtain a target slope value.
[0033] In one embodiment, the first acquisition module is specifically used for:
[0034] The sensor data of the vehicle sensor is collected via the target communication bus.
[0035] In one embodiment, the device further comprises:
[0036] A second determination module is used to determine the number of read and write times corresponding to the collection of the sensor data;
[0037] The third determination module is used to determine that the vehicle sensor and the sensor data meet the preset validity conditions if it is determined that the read and write times are less than or equal to a preset read and write times threshold, and that the vehicle sensor passes the validity check, and that the sensor data passes the validity check.
[0038] In one embodiment, the device further comprises:
[0039] A recovery module is used to recover the target communication bus and the register corresponding to the communication bus if the number of read and write times is greater than the preset read and write times threshold, and after the recovery is completed, re-execute the step of collecting sensor data of the vehicle sensor.
[0040] In one of the embodiments, after the step of determining that the number of read and write times is less than or equal to a preset read and write times threshold, the device further includes:
[0041] The fourth determination module is used to determine that the vehicle sensor passes the validity check if it is determined that the value corresponding to the first register inside the vehicle sensor has not changed and the value corresponding to the second register inside the vehicle sensor has not changed.
[0042] In one embodiment, the device further comprises:
[0043] The reset module is used to reset the vehicle sensor if it is determined that the vehicle sensor fails the validity check, and after the reset is completed, re-execute the step of collecting sensor data of the vehicle sensor.
[0044] In one embodiment, after the step of determining that the vehicle sensor passes the validity check, the device further includes:
[0045] A second acquisition module, used to acquire a target position corresponding to the sensor data;
[0046] The fifth determination module is used to determine that the sensor data passes the validity check if the target position corresponding to the sensor data does not meet the preset mutation condition.
[0047] In one embodiment, the device further comprises:
[0048] The sixth determination module is used to obtain the last valid data corresponding to the sensor data if it is determined that the sensor data has not passed the validity check, and execute the step of performing posture calculation on the sensor data through the target filtering algorithm based on the last valid data to obtain an initial slope value.
[0049] In one embodiment, the calibration module is specifically used for:
[0050] Acquire multiple groups of fitting sensor data corresponding to the vehicle sensor at multiple positions and postures;
[0051] Perform fitting based on the actual slope value and each of the fitting sensor data to obtain a preset fitting coefficient, wherein the preset fitting coefficient includes a cubic term coefficient, a quadratic term coefficient, a linear term coefficient and a constant term coefficient;
[0052] A target slope value is obtained by performing calculation based on the cubic term coefficient, the quadratic term coefficient, the linear term coefficient, the constant term coefficient, and the initial slope value.
[0053] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0054] Collecting sensor data from vehicle sensors;
[0055] When it is determined that the vehicle sensor and the sensor data meet a preset validity condition, performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value;
[0056] The initial slope value is calibrated by a preset fitting coefficient to obtain a target slope value.
[0057] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0058] Collecting sensor data from vehicle sensors;
[0059] When it is determined that the vehicle sensor and the sensor data meet a preset validity condition, performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value;
[0060] The initial slope value is calibrated by a preset fitting coefficient to obtain a target slope value.
[0061] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0062] Collecting sensor data from vehicle sensors;
[0063] When it is determined that the vehicle sensor and the sensor data meet a preset validity condition, performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value;
[0064] The initial slope value is calibrated by a preset fitting coefficient to obtain a target slope value.
[0065] The above-mentioned slope detection method, device, computer equipment, storage medium and computer program product, wherein the method comprises: collecting sensor data of a vehicle sensor; when determining that the vehicle sensor and the sensor data meet a preset validity condition, performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value; calibrating the initial slope value through a preset fitting coefficient to obtain a target slope value. By adopting this method, the real-time output of the slope value can be guaranteed, and the data output by the sensor can be processed based on the filtering algorithm to ensure the stability and reliability of the calculated slope value, improve the accuracy of slope detection, and reduce the risk of interruption of the vehicle control system. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 A diagram showing an application environment of a slope detection method in an embodiment;
[0067] Figure 2 is a schematic flow chart of a slope detection method in one embodiment;
[0068] Figure 3 A schematic diagram of a flow chart of a validity verification step in an embodiment;
[0069] Figure 4 A schematic diagram of a flow chart of a validity verification step in an embodiment;
[0070] Figure 5 is a schematic flow diagram of a fitting step in one embodiment;
[0071] Figure 6 is a flow chart of a slope detection method in another embodiment;
[0072] Figure 7a is a schematic diagram of a slope value output curve in one embodiment;
[0073] Figure 7b A schematic diagram of a time-consuming output curve in one embodiment;
[0074] Figure 8a is a schematic diagram of a conventional slope value output curve in one embodiment;
[0075] Figure 8b A schematic diagram of a conventional time-consuming curve in one embodiment;
[0076] Fig. 9 is a structural block diagram of a slope detection device in one embodiment;
[0077] Fig.10 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0079] The slope detection method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. The terminal 102 can communicate with the sensor 104 through a communication bus. The terminal can be a single-chip microcomputer, for example, a high-performance, low-power single-chip microcomputer, for example, a single-chip microcomputer applied to a vehicle control system; the sensor can be a sensor integrated on a heavy truck, for example, a six-axis sensor for measuring three-axis acceleration and three-axis gyroscope data. In one example, the six-axis sensor can be an MPU6050 sensor; the communication bus can be an IIC communication bus for data transmission between the single-chip microcomputer and the sensor.
[0080] In one embodiment, Figure 2 As shown, a slope detection method is provided. This embodiment uses the method applied to a single chip microcomputer in a vehicle control system as an example for illustration. It can be understood that the method can also be applied to other terminal devices, and the above-mentioned terminals can be but are not limited to various personal computers, laptops, smart phones, tablet computers, Internet of Things devices, smart vehicle-mounted devices, etc. In this embodiment, the slope detection method includes the following steps:
[0081] Step 202: Collect sensor data from vehicle sensors.
[0082] Among them, the vehicle sensor can be a six-axis sensor integrated in the vehicle, which is used to collect six-axis data of the vehicle, including three-axis acceleration data and three-axis gyroscope data; the six-axis sensor can be an MPU6050 six-axis sensor; the single-chip microcomputer in the vehicle control system can be an XC2000 series single-chip microcomputer, which is a high-performance, low-power and strong communication capability single-chip microcomputer.
[0083] Specifically, the single chip microcomputer can collect sensor data of the vehicle through the vehicle sensors, for example, it can collect three-axis acceleration data and three-axis gyroscope data of the vehicle.
[0084] Step 204 , when it is determined that the vehicle sensor and the sensor data meet the preset validity conditions, the sensor data is subjected to posture calculation by a target filtering algorithm to obtain an initial slope value.
[0085] Among them, the preset validity condition can be that the vehicle sensor meets the preset validity condition, and the sensor data corresponding to the vehicle sensor also meets the preset validity condition; the target filtering algorithm can be a Kalman filtering algorithm or a sliding window filtering algorithm; in an example, the microcontroller can also perform posture calculation by transplanting the DMP library.
[0086] Specifically, the single-chip microcomputer determines whether the preset validity conditions are met based on the vehicle sensor and the sensor data corresponding to the vehicle sensor. When the single-chip microcomputer determines that the vehicle sensor and the sensor data meet the preset validity conditions, the single-chip microcomputer can calculate the attitude angle based on the sensor data and the target filtering algorithm, that is, process the six-axis data through the target filtering algorithm to calculate the slope value, that is, the initial slope value.
[0087] Step 206, calibrating the initial slope value by using a preset fitting coefficient to obtain a target slope value.
[0088] Among them, the preset fitting coefficient can be obtained by fitting the data of the vehicle sensor at different positions and postures, and the error of the target slope value obtained after calibrating the initial slope value based on the preset fitting coefficient is small.
[0089] Specifically, the single chip microcomputer can perform fitting processing based on the data of the vehicle sensor at different positions and postures to obtain a preset fitting coefficient, and calibrate the calculated initial slope value based on the preset fitting coefficient to obtain the final target slope value. In an example, the data of the vehicle sensor at different positions and postures may include data of the sensor at a horizontal position and posture, data of the vehicle sensor at an upward tilted position and posture, and data of the vehicle sensor at a downward tilted position and posture, etc.
[0090] In the above slope detection method, sensor data of the vehicle sensor is collected. When it is determined that the vehicle sensor and the sensor data meet the preset validity conditions, the sensor data is subjected to posture calculation by the target filtering algorithm to obtain the initial slope value. The initial slope value is calibrated by the preset fitting coefficient to obtain the target slope value. By adopting this method, the real-time output of the slope value can be guaranteed. By processing the data output by the sensor based on the filtering algorithm, the stability and reliability of the calculated slope value can be guaranteed, the accuracy of slope detection can be improved, and the risk of interruption of the vehicle control system can be reduced.
[0091] In one embodiment, the specific processing process of the step of "collecting sensor data from vehicle sensors" includes:
[0092] Sensor data from vehicle sensors is collected via the target communication bus.
[0093] Among them, the target communication bus (Inter-Integrated Circuit, integrated circuit bus).
[0094] Specifically, the microcontroller can transmit data with the vehicle sensor through the target communication bus. For example, it can read the data of the internal register of the vehicle sensor through the target communication bus, that is, read the six-axis data of the vehicle detected by the vehicle sensor, including three-axis acceleration data and three-axis gyroscope data, etc.
[0095] In this embodiment, the data of the vehicle sensors are collected through the IIC communication bus, which can ensure the efficiency of data interaction.
[0096] In one embodiment, Figure 3 As shown, the slope detection method also includes:
[0097] Step 302, determining the number of read and write times corresponding to the collected sensor data.
[0098] The number of read and write times corresponding to the sensor data may be the number of times the single-chip microcomputer reads the data of the vehicle sensor through the target communication bus.
[0099] Specifically, after the single chip microcomputer reads the sensor data of the vehicle sensor through the IIC communication bus, it can count to obtain the number of times the single chip microcomputer reads the sensor data of the vehicle sensor.
[0100] In one example, after the microcontroller reads the sensor data of the vehicle sensor through the IIC communication bus, the microcontroller can add 1 to the cumulative count and store the cumulative count. When the microcontroller determines that the cumulative count does not exceed the preset read and write number threshold, the microcontroller can maintain the target flag corresponding to the read and write times as a non-error flag; when the microcontroller determines that the cumulative count is greater than the preset read and write number threshold, the microcontroller can change the target flag corresponding to the read and write times from a non-error flag to an error flag.
[0101] Step 304: If it is determined that the number of read and write times is less than or equal to the preset read and write number threshold, and it is determined that the vehicle sensor passes the validity check, and it is determined that the sensor data passes the validity check, then it is determined that the vehicle sensor and the sensor data meet the preset validity conditions.
[0102] The preset read / write times threshold may be a predetermined counting threshold.
[0103] Specifically, after determining the number of read and write times, the single-chip microcomputer can obtain the target flag corresponding to the current number of read and write times. When the target flag corresponding to the number of read and write times is a non-error flag, the single-chip microcomputer can determine that the current number of read and write times is less than or equal to the preset number of read and write times threshold. After the single-chip microcomputer determines that the number of read and write times is less than or equal to the preset number of read and write times threshold, the single-chip microcomputer can determine whether the vehicle sensor has passed the validity check. After determining that the vehicle sensor has passed the validity check, it can continue to determine whether the sensor data has passed the validity check.
[0104] If the single-chip microcomputer determines that the vehicle sensor passes the validity check, and the sensor data corresponding to the vehicle sensor also passes the validity check, the single-chip microcomputer can determine that the vehicle sensor and the sensor data meet the preset validity conditions.
[0105] In this embodiment, the accuracy of the output target slope value can be ensured by performing validity verification on the vehicle sensor and the sensor data.
[0106] In one embodiment, the slope detection method further includes:
[0107] If the number of read and write times is greater than a preset read and write number threshold, the target communication bus is restored, and the register corresponding to the communication bus is restored. After the restoration is completed, the step of collecting sensor data of the vehicle sensor is re-executed.
[0108] Specifically, after determining the number of read and write times, the single-chip microcomputer can obtain the target flag corresponding to the current number of read and write times. When the target flag corresponding to the number of read and write times is an error flag, the single-chip microcomputer can determine that the current number of read and write times is greater than the preset read and write number threshold. In other words, when the single-chip microcomputer determines that the target flag is an error flag, it can determine that the current number of read and write times has exceeded the limit, and the single-chip microcomputer can restore the target communication bus and restore the register corresponding to the communication bus, that is, restore the register inside the single-chip microcomputer. When the target communication bus is restored and the register inside the single-chip microcomputer is restored, it can return to re-execute the step of collecting sensor data of the vehicle sensor.
[0109] In one example, each time the microcontroller reads the internal register of the slave device MPU6050 through the IIC bus, it will perform a cumulative count. When the value corresponding to the cumulative count exceeds the preset read and write number threshold, it will trigger the error flag of the read and write data timeout. That is to say, if the microcontroller determines that the current read and write times are greater than the preset read and write times threshold, the microcontroller can stop reading and writing data and execute the steps of automatically restoring the IIC bus. Specifically, the microcontroller can flip the data bus or the clock line based on the current state of the IIC bus. The registers inside the microcontroller can be the first register (U0C1_DX0CR) and the second register (U0C1_DX1CR). The first register represents the state of the data line, and the second register represents the state of the clock line. The microcontroller can flip the first register and the second register to realize the transition of the IIC bus from an occupied state to an idle state; based on this, the microcontroller can modify the value of the PCSR (protocol status clear register) based on the state of the PSR (protocol status register) to restore the PSR register to the correct state, and then modify the value of the FMRL (flag modification register L) according to the values of the TCSRH (transmit control / status register H) and TCSRL (transmit control / status register L) to restore the TCSRH and TCSRL registers to the correct state, and finally prohibit the data line from flipping, thereby restoring the internal register state of the microcontroller and restoring the normal IIC communication state.
[0110] In this embodiment, by promptly performing recovery processing on the communication bus and the registers inside the microcontroller when the number of read and write times exceeds the preset read and write times threshold, automatic restart and automatic recovery of the bus can be achieved, which can quickly respond to system errors and failures, reduce the risk of interruption of the vehicle control system, and improve the reliability of the system.
[0111] In one embodiment, after the step of determining that the number of read and write times is less than or equal to a preset read and write times threshold, the slope detection method further includes:
[0112] If it is determined that the value corresponding to the first register inside the vehicle sensor has not changed, and the value corresponding to the second register inside the vehicle sensor has not changed, it is determined that the vehicle sensor passes the validity check.
[0113] Among them, the first register and the second register inside the vehicle sensor can be registers for setting the sensor range inside the vehicle sensor. For example, the first register can be 0X1B and the second register can be 0X1C.
[0114] Specifically, the single-chip microcomputer can determine whether the vehicle sensor has passed the validity check based on the value corresponding to the register inside the vehicle sensor; specifically, the single-chip microcomputer can obtain the value corresponding to the first register inside the current vehicle sensor, and the value corresponding to the second register inside the vehicle sensor. When it is determined that the value corresponding to the first register has not changed, and the value corresponding to the second register has not changed, the single-chip microcomputer can determine that the vehicle sensor has passed the validity check.
[0115] In one example, the single-chip microcomputer can obtain the numerical value corresponding to the first register at the previous moment and the numerical value corresponding to the second register. If the single-chip microcomputer determines that the numerical value corresponding to the first register at the previous moment is consistent with the numerical value corresponding to the first register at the current moment, it is determined that the numerical value corresponding to the first register has not changed; similarly, if the single-chip microcomputer determines that the numerical value corresponding to the second register at the previous moment is consistent with the numerical value corresponding to the second register at the current moment, it is determined that the numerical value corresponding to the second register has not changed, that is, the single-chip microcomputer can determine that the data inside the vehicle sensor has not been modified incorrectly, that is, the vehicle sensor has passed the validity check.
[0116] In this embodiment, whether the vehicle sensor is valid is judged by the values corresponding to the first register and the second register inside the vehicle sensor, which can be well adapted to the slope value detection scenario of heavy trucks and provide a reliable data basis for the subsequent accurate calculation of the slope value.
[0117] In one embodiment, the slope detection method further includes:
[0118] If it is determined that the vehicle sensor has not passed the validity check, the vehicle sensor is reset, and after the reset is completed, the step of collecting sensor data of the vehicle sensor is re-executed.
[0119] Specifically, the single-chip microcomputer can obtain the value corresponding to the first register inside the current vehicle sensor, and the value corresponding to the second register inside the vehicle sensor. If the single-chip microcomputer determines that the value corresponding to the first register has changed, the single-chip microcomputer can determine that the vehicle sensor has failed the validity check; if the single-chip microcomputer determines that the value corresponding to the second register has changed, the single-chip microcomputer can determine that the vehicle sensor has failed the validity check; in another example, if the single-chip microcomputer determines that the value of the first register has changed, and the value corresponding to the second register has changed, the single-chip microcomputer can determine that the vehicle sensor has failed the validity check.
[0120] When the single-chip microcomputer determines that the vehicle sensor has passed the validity check, the single-chip microcomputer can reset the vehicle sensor, initialize the first register and the second register inside the vehicle sensor, and after the vehicle sensor is reset, re-execute the above steps of collecting sensor data of the vehicle sensor.
[0121] In this embodiment, whether the vehicle sensor is valid is judged by the values corresponding to the first register and the second register inside the vehicle sensor, which can be well adapted to the slope value detection scenario of heavy trucks, providing a reliable data basis for the subsequent accurate calculation of the slope value. If it is determined that the validity check has not passed, the reset processing is performed in time, which improves the risk resistance ability of the vehicle control system and provides a basis for the stable output of the slope value.
[0122] In one embodiment, Figure 4 As shown, after determining that the vehicle sensor passes the validity verification step, the slope detection method further includes:
[0123] Step 402: Obtain the target position corresponding to the sensor data.
[0124] The target position may be the upper eight-bit position corresponding to the sensor data.
[0125] Specifically, the single chip microcomputer can obtain sensor data corresponding to the target position from the sensor data.
[0126] Step 404: If the target position corresponding to the sensor data does not satisfy the preset mutation condition, it is determined that the sensor data passes the validity check.
[0127] The preset mutation condition may be data distortion or data mutation.
[0128] Specifically, if the single-chip microcomputer determines that the data corresponding to the upper eight bits of the read sensor data has not mutated, it determines that the sensor data does not meet the preset mutation condition. The single-chip microcomputer can then determine that the current sensor passes the validity check, that is, determines that the current sensor data is valid, that is, determines that the current six-axis data collected by the vehicle sensor is valid.
[0129] In this embodiment, judging whether the vehicle sensor is valid is based on whether the sensor data undergoes a sudden change, which can be well adapted to the slope value detection scenario of heavy trucks and provide a reliable data basis for the subsequent accurate calculation of the slope value.
[0130] In one embodiment, the slope detection method further includes:
[0131] If it is determined that the sensor data fails the validity check, the last valid data corresponding to the sensor data is obtained, and based on the last valid data, a step of performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value is performed.
[0132] Specifically, if the single-chip microcomputer determines that the data corresponding to the upper eight bits of the read sensor data has mutated, then it determines that the sensor data meets the preset mutation condition. The single-chip microcomputer can obtain the previous valid data corresponding to the previous moment of the current moment, and use the previous valid data as the sensor data, and re-execute the step of performing posture calculation on the sensor data through the target filtering algorithm in the above embodiment to obtain the initial slope value.
[0133] In this embodiment, the calculation of the slope value is implemented based on the last valid data, which can ensure the stability of the slope value output and balance the accuracy of the slope value and the timeliness of the output.
[0134] In one embodiment, Figure 5 As shown in FIG. 1 , the specific processing process of the step “calibrating the initial slope value by the preset fitting coefficient to obtain the target slope value” includes:
[0135] Step 502: Acquire multiple groups of fitting sensor data corresponding to the vehicle sensors at multiple positions and postures.
[0136] Among them, the vehicle sensor in multiple positions and postures may include the vehicle sensor in a flat position and posture, the vehicle sensor in an upward tilted position and posture, and the vehicle sensor in a downward tilted position and posture, etc.
[0137] Specifically, the single chip microcomputer can set the vehicle sensor to a variety of positions and postures, and respectively collect sensor data corresponding to the vehicle sensor in various positions and postures.
[0138] Step 504 , performing fitting based on the actual slope value and each fitting sensor data to obtain a preset fitting coefficient.
[0139] The preset fitting coefficients include a cubic term coefficient, a quadratic term coefficient, a linear term coefficient and a constant term coefficient.
[0140] Specifically, the single chip microcomputer can collect multiple sets of sensor data from the vehicle sensor at different positions and postures, and perform fitting based on the multiple sets of sensor data and the preset actual slope value to obtain preset fitting coefficients including cubic term coefficients, quadratic term coefficients, linear term coefficients and constant term coefficients.
[0141] Step 506, performing calculation based on the cubic term coefficient, the quadratic term coefficient, the linear term coefficient, the constant term coefficient, and the initial slope value to obtain a target slope value.
[0142] Specifically, the single chip microcomputer can calibrate the cubic term based on the cubic term coefficient, calibrate the quadratic term based on the quadratic term coefficient, calibrate the linear term based on the linear term coefficient, and calibrate the constant term based on the constant term coefficient to obtain the target slope value. Among them, each linear term, quadratic term, cubic term and constant term is obtained based on the initial slope value.
[0143] In this embodiment, a combination of Kalman filtering and sliding filtering is used to process the output data of the sensor. By adjusting the parameters of the filtering system, the system has high precision and real-time performance is guaranteed.
[0144] The specific implementation process of the above slope detection method is described in detail below in conjunction with a specific embodiment:
[0145] The single-chip microcomputer in the slope detection method provided in this embodiment can be an XC2000 series single-chip microcomputer, which is famous for its high performance, low power consumption and strong communication capability, using the XC2000 series single-chip microcomputer as the core controller; the vehicle sensor in this embodiment can be an MPU6050 six-axis sensor, which can simultaneously measure three-axis acceleration and three-axis gyroscope data to ensure that the vehicle's tilt angle can be accurately calculated. Specifically, the XC2000 series single-chip microcomputer and the MPU6050 sensor can transmit data through the IIC communication protocol, which can provide high-speed and reliable data transmission, ensuring the timeliness and accuracy of the data.
[0146] In one embodiment, the slope detection method provided in this embodiment adopts a switch branch structure and an interruption combined architecture to replace the traditional polling or interruption single architecture, which not only ensures the stability of the system operation, but also makes the entire system run at a speed of no more than 1ms; it also has the function of detecting whether an error occurs in the IIC bus. By monitoring the error flag during communication, the system can quickly detect any potential communication problems, so as to make corresponding strategy modifications; if the system detects that the register state of the single-chip microcomputer MCU is abnormal, it can automatically self-recover the register state to ensure normal data transmission with MPU605 and ensure the normal operation of the system; when an IIC bus error occurs, the system can automatically try to re-establish a communication connection to restore the acquisition of sensor data; if the MPU6050 sensor is abnormal, the system has the ability to restart the sensor to ensure continuous data acquisition; it also includes a data validity check function to ensure that the data obtained from the sensor is accurate and reliable. This helps prevent erroneous data from being used in the vehicle control system; after calibrating the MPU6050, the system performs cubic fitting on the collected data, so that the final result and the actual slope value differ by less than 1%, achieving high-precision slope acquisition.
[0147] like Figure 6 As shown, specifically, the single-chip microcomputer can be a single-chip microcomputer of the XC2267 series, using a switch branch structure, IIC communication to read the MPU6050 (vehicle sensor) data, and determine whether the number of read and write times exceeds the limit. When it is determined that the number of read and write times does not exceed the limit, it is determined whether the internal register data of the MPU6050 is valid. When it is determined that the internal register data of the MPU6050 is valid, the validity of the six-axis data is checked. When it is determined that the six-axis data is valid, the Kalman filter is used for attitude calculation, the slope value after settlement is calibrated in cubic terms, and the slope value is output.
[0148] If it is determined that the number of read and write times has exceeded the limit, the IIC bus can be restored, and the internal registers of the XC2267 can be restored, and the step "IIC communication to read MPU6050 (vehicle sensor) data" can be returned to be re-executed; if it is determined that the data in the internal registers of the MPU6050 is invalid, the MPU6050 is reset; if the six-axis data is found to be invalid, the step "Using Kalman filtering for attitude calculation" is executed using the last valid value.
[0149] Specifically, the cubic term calibration can be performed using the following formula:
[0150] Q=(PRM_P3*(VAL)*(VAL)(VAL)+PRM_P2*(VAL)(VAL)+PRM_P1*(VAL)+PRM_P0
[0151] Wherein, Q can be the target slope value.
[0152] Specifically, a command to read the internal data of MPU6050 is sent through the IIC bus and then the rest of the program is executed. When MPU6050 replies to the MCU, the receive flag is set through an interrupt. After the system detects that the receive flag is set, it continues to send the remaining read and write commands. In this way, the entire system will not run slowly due to the long communication time between the MCU and the peripherals, and the system will have high operating efficiency.
[0153] In one example, each time the microcontroller reads the internal register of the slave device MPU6050 through the IIC bus, it will perform a cumulative count. When the value corresponding to the cumulative count exceeds the preset read and write number threshold, it will trigger the error flag of the read and write data timeout. That is to say, if the microcontroller determines that the current read and write times are greater than the preset read and write times threshold, the microcontroller can stop reading and writing data and execute the steps of automatically restoring the IIC bus. Specifically, the microcontroller can flip the data bus or the clock line based on the current state of the IIC bus. The registers inside the microcontroller can be the first register (U0C1_DX0CR) and the second register (U0C1_DX1CR). The first register represents the state of the data line, and the second register represents the state of the clock line. The microcontroller can flip the first register and the second register to realize the transition of the IIC bus from an occupied state to an idle state; based on this, the microcontroller can modify the value of the PCSR (protocol status clear register) based on the state of the PSR (protocol status register) to restore the PSR register to the correct state, and then modify the value of the FMRL (flag modification register L) according to the values of the TCSRH (transmit control / status register H) and TCSRL (transmit control / status register L) to restore the TCSRH and TCSRL registers to the correct state, and finally prohibit the data line from flipping, thereby restoring the internal register state of the microcontroller and restoring the normal IIC communication state.
[0154] After the microcontroller successfully reads the internal data of MPU6050, it first judges the internal registers 0X1B and 0X1C of MPU6050. 0X1B and 0X1C are the registers for setting the sensor range in MPU6050. When the values of these two registers change, it means that the internal registers of MPU6050 have been modified incorrectly, and the read data is also unusable. At this time, it is necessary to reset MPU6050 and reinitialize the internal registers of MPU6050 so that it can work normally.
[0155] Specifically, after determining that the register data is valid, it is also necessary to determine whether the read six-axis data is valid. Generally, the upper eight bits of the read data will not mutate during driving, so the validity of the data is determined by determining whether the upper eight bits of the data have mutated. If the data is determined to be invalid, the last valid data is used. If it is determined to be valid, the current six-axis data is updated and the data is saved to determine the valid value of the next data.
[0156] After obtaining valid six-axis sensor data (x-axis acceleration, y-axis acceleration and z-axis acceleration, x-axis angular velocity, y-axis angular velocity and z-axis angular velocity), the Kalman filter function is used to obtain the vehicle slope value, and then the vehicle slope value is calibrated with the coefficients after cubic fitting to output the final vehicle slope value. The cubic fitting mainly involves placing the sensor flat, tilting it upward, and tilting it downward, taking 10 sets of collected data, and then fitting it with the actual sensor slope value, and finally obtaining each coefficient so that the error of the calibrated slope value is within 1%.
[0157] The microcontroller can obtain the preset actual slope value and the initial slope value calculated based on the detection data of the vehicle sensor. Based on this, the microcontroller can fit the cubic term (y=a*x^3+b*x^2+c*x+d) to obtain the four parameters in the parameter copy area, that is, the corresponding abcd values, that is, the preset fitting coefficients.
[0158] Among them, the fitting method may include: measuring multiple sets of data, including positive and negative. Fitting the angle value measured by the mobile phone software with the slope value read by the VCU. Assigning the cubic term coefficient to the global variable PRM P3 in the MPU6050h file, the quadratic term coefficient to PRM P2, the linear term coefficient to PRM P1, and the constant term to PRM PO.
[0159] The slope collected by the slope collection system of the slope detection method provided in this embodiment is as follows: Figure 7a As shown in 7b; the slope collected by the slope collection system in the prior art is as follows Figure 8a As shown in 8b, by comparison: Figure 7a as well as Figure 8a The upper line in the figure represents the collected slope value, and the lower line represents the simulated IIC bus communication failure. The slope value in this embodiment changes stably and can automatically recover after encountering interference. The data collected using the conventional method obviously fluctuates greatly, and errors of different sizes appear. Moreover, when encountering interference, it will not automatically recover, resulting in the system being unable to operate normally.
[0160] Figure 7b as well as Figure 8b The line in the figure represents the growth of the system's running time. The faster the system's running time grows, the faster the program runs. It can be clearly seen that the slope of the growth of the system's running time using the architecture of this embodiment is significantly faster than that of conventional polling collection, which makes the system more efficient.
[0161] The slope detection method provided in this embodiment can detect IIC communication and slope value during the process of collecting slope. When an abnormal slope is detected, the system will perform corresponding error processing to always ensure that the vehicle runs in a stable and safe manner. In one example, when the single-chip microcomputer determines that the target slope value currently output is greater than the normal threshold, it can output abnormal prompt information to ensure the safe driving of the vehicle.
[0162] The slope detection method provided in this embodiment has the function of automatically restarting and restoring the IIC bus and sensor. When a system abnormality is detected, errors and faults can be quickly responded to, reducing the risk of vehicle control system interruption and improving system reliability. The slope detection method provided in this embodiment uses a combination of Kalman filtering and sliding filtering to process the output data of the sensor. By adjusting the parameters of the filtering system, the system has high accuracy (less than 1%) while also ensuring real-time performance.
[0163] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0164] Based on the same inventive concept, the embodiment of the present application also provides a slope detection device for implementing the slope detection method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more slope detection device embodiments provided below can refer to the limitations of the slope detection method above, and will not be repeated here.
[0165] In one embodiment, Fig. 9 As shown, a slope detection device 900 is provided, comprising:
[0166] A first acquisition module 902, used to acquire sensor data from vehicle sensors;
[0167] A first determination module 904 is used to calculate the attitude of the sensor data by a target filtering algorithm to obtain an initial slope value 906 when it is determined that the vehicle sensor and the sensor data meet the preset validity condition;
[0168] The calibration module 908 is used to calibrate the initial slope value by using a preset fitting coefficient to obtain a target slope value.
[0169] In one embodiment, the first acquisition module is specifically used for:
[0170] Sensor data from vehicle sensors is collected via the target communication bus.
[0171] In one embodiment, the device further comprises:
[0172] The second determination module is used to determine the number of read and write times corresponding to the collected sensor data;
[0173] The third determination module is used to determine that the vehicle sensor and the sensor data meet the preset validity conditions if it is determined that the number of read and write times is less than or equal to the preset read and write number threshold, and the vehicle sensor passes the validity check, and the sensor data passes the validity check.
[0174] In one embodiment, the device further comprises:
[0175] The recovery module is used to recover the target communication bus and the register corresponding to the communication bus if the number of read and write times is greater than a preset read and write time threshold, and after the recovery is completed, re-execute the step of collecting sensor data of the vehicle sensor.
[0176] In one of the embodiments, after the step of determining that the number of read and write times is less than or equal to a preset read and write times threshold, the device further includes:
[0177] The fourth determination module is used to determine that the vehicle sensor passes the validity check if it is determined that the value corresponding to the first register inside the vehicle sensor has not changed and the value corresponding to the second register inside the vehicle sensor has not changed.
[0178] In one embodiment, the device further comprises:
[0179] The reset module is used to reset the vehicle sensor if it is determined that the vehicle sensor has not passed the validity check, and after the reset is completed, re-execute the step of collecting sensor data of the vehicle sensor.
[0180] In one embodiment, after determining that the vehicle sensor passes the validity verification step, the device further includes:
[0181] A second acquisition module, used to acquire a target position corresponding to the sensor data;
[0182] The fifth determination module is used to determine that the sensor data passes the validity check if the target position corresponding to the sensor data does not meet the preset mutation condition.
[0183] In one embodiment, the device further comprises:
[0184] The sixth determination module is used to obtain the last valid data corresponding to the sensor data if it is determined that the sensor data has not passed the validity check, and execute the step of performing posture calculation on the sensor data through the target filtering algorithm based on the last valid data to obtain an initial slope value.
[0185] In one embodiment, the calibration module is specifically used for:
[0186] Acquire multiple groups of fitting sensor data corresponding to the vehicle sensor at multiple positions and postures;
[0187] Perform fitting based on the actual slope value and each of the fitting sensor data to obtain a preset fitting coefficient, wherein the preset fitting coefficient includes a cubic term coefficient, a quadratic term coefficient, a linear term coefficient and a constant term coefficient;
[0188] A target slope value is obtained by performing calculation based on the cubic term coefficient, the quadratic term coefficient, the linear term coefficient, the constant term coefficient, and the initial slope value.
[0189] Each module in the above-mentioned slope detection device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0190] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.10 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store sensor data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a slope detection method is implemented.
[0191] Those skilled in the art will understand that Fig.10The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0192] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0193] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0194] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0195] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0196] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0197] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0198] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A slope detection method, characterized in that: The method comprises: Collecting sensor data from vehicle sensors; When it is determined that the vehicle sensor and the sensor data meet a preset validity condition, performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value; The initial slope value is calibrated by a preset fitting coefficient to obtain a target slope value.
2. The method according to claim 1, characterized in that The collecting of sensor data of vehicle sensors includes: The sensor data of the vehicle sensor is collected via the target communication bus.
3. The method according to claim 2, characterized in that The method further comprises: Determine the number of read and write times corresponding to collecting the sensor data; If it is determined that the number of read and write times is less than or equal to a preset read and write number threshold, and it is determined that the vehicle sensor passes the validity check, and it is determined that the sensor data passes the validity check, then it is determined that the vehicle sensor and the sensor data meet the preset validity conditions.
4. The method according to claim 3, characterized in that The method further comprises: If the number of read and write times is greater than the preset read and write times threshold, the target communication bus is restored, and the register corresponding to the communication bus is restored. After the restoration is completed, the step of collecting sensor data of the vehicle sensor is re-executed.
5. The method according to claim 3, characterized in that: After the step of determining that the number of read and write times is less than or equal to a preset read and write times threshold, the method further includes: If it is determined that the value corresponding to the first register inside the vehicle sensor has not changed, and the value corresponding to the second register inside the vehicle sensor has not changed, it is determined that the vehicle sensor has passed the validity check.
6. The method according to claim 5, characterized in that The method further comprises: If it is determined that the vehicle sensor fails the validity check, the vehicle sensor is reset, and after the reset is completed, the step of collecting sensor data of the vehicle sensor is re-executed.
7. The method according to claim 5, characterized in that After the step of determining that the vehicle sensor passes the validity check, the method further includes: Obtaining a target position corresponding to the sensor data; If the target position corresponding to the sensor data does not meet the preset mutation condition, it is determined that the sensor data passes the validity check.
8. The method according to claim 7, characterized in that The method further comprises: If it is determined that the sensor data fails the validity check, the last valid data corresponding to the sensor data is obtained, and based on the last valid data, the step of performing posture calculation on the sensor data through a target filtering algorithm to obtain an initial slope value is performed.
9. The method according to claim 1, characterized in that: The step of calibrating the initial slope value by using a preset fitting coefficient to obtain a target slope value includes: Acquire multiple groups of fitting sensor data corresponding to the vehicle sensor at multiple positions and postures; Perform fitting based on the actual slope value and each of the fitting sensor data to obtain a preset fitting coefficient, wherein the preset fitting coefficient includes a cubic term coefficient, a quadratic term coefficient, a linear term coefficient and a constant term coefficient; A target slope value is obtained by performing calculation based on the cubic term coefficient, the quadratic term coefficient, the linear term coefficient, the constant term coefficient, and the initial slope value.
10. A slope detection device, characterized in that: The device comprises: A first acquisition module, used to acquire sensor data from vehicle sensors; A first determination module is used to calculate the posture of the sensor data by a target filtering algorithm to obtain an initial slope value when it is determined that the vehicle sensor and the sensor data meet a preset validity condition; The calibration module is used to calibrate the initial slope value by using a preset fitting coefficient to obtain a target slope value.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.