Time synchronization method and device, electronic equipment and vehicle
By analyzing and adjusting the clock deviation in the autonomous driving system, the time bounce problem is solved and data timeliness and user experience are improved.
Patent Information
- Application Number
- CN202310162253.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-23
AI Technical Summary
In autonomous driving systems, clock synchronization issues lead to time jumps, affecting data timeliness and user experience.
By obtaining the clock deviation of the first node and the second node, query the latest clock time obtained in the business service history, analyze the clock deviation correction value, and adjust the clock time of the first node based on this value to ensure that it is not earlier than the second node. The node's clock time to avoid time jumps.
It effectively avoids time jumps, improves data timeliness, reduces abnormal exits of business service functions, and improves user experience.
Smart Images

Figure CN118540004A
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a time synchronization method, device, electronic equipment and vehicle. Background Art
[0002] With the vigorous development of new energy vehicles, the use of new energy vehicles is becoming more and more popular. Most of these models have autonomous driving functions, which require sensors to collect data in real time, then build models based on high-definition maps, and finally control the actual operation of the vehicle based on the processing results. In order to ensure the timeliness of the data collected during modeling, the time synchronization of each controller in the vehicle is required.
[0003] At present, controllers equipped with slave clocks will synchronize time according to the time recorded in the master clock. The autonomous driving service will obtain the data collected by these controllers regularly or irregularly. After collecting the data, these controllers will timestamp the data and send it to the autonomous driving service for modeling. The autonomous driving service will check the timestamp of the collected data every time it does modeling, and compare it with the timestamp of the data collected by the controller during the previous modeling. If the timestamp of the data collected by controller A during the current modeling is earlier than the timestamp of the data collected by controller A during the previous modeling, it is considered that a time jump has occurred, which will cause the controller A equipped with the slave clock to no longer synchronize time, and only time itself based on the local crystal oscillator. The autonomous driving function will exit abnormally, affecting the user experience. Summary of the invention
[0004] In view of this, the present application provides a time synchronization method, device, electronic device and vehicle, the main purpose of which is to solve the time jump problem occurring in autonomous driving and improve data timeliness.
[0005] In a first aspect, the present application provides a time synchronization method, comprising:
[0006] Obtaining a clock deviation of a first node compared to a second node, wherein the first node is provided with a slave clock and the second node is provided with a master clock;
[0007] If it is determined according to the clock deviation that the first clock time of the first node is later than the second clock time of the second node, querying the business service history to obtain the third clock time of the data collected by the first node for the most recent time;
[0008] comparing the first clock time with the third clock time, and analyzing a clock deviation correction value of the first node;
[0009] According to the clock deviation correction value, the first clock time is adjusted to the second clock time by adding time.
[0010] In a second aspect, the present application provides a time synchronization device, comprising:
[0011] An acquisition unit, configured to acquire a clock deviation of a first node compared to a second node, wherein the first node is provided with a slave clock and the second node is provided with a master clock;
[0012] A processing unit, configured to query the business service history for the latest acquisition of a third clock time of data collected by the first node when it is determined that the first clock time of the first node is later than the second clock time of the second node according to the clock deviation;
[0013] a comparing unit, configured to compare the first clock time with the third clock time, and analyze a clock deviation correction value of the first node;
[0014] A synchronization unit is used to adjust the first clock time toward the second clock time by adding time according to the clock deviation correction value.
[0015] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the time synchronization method described in the first aspect.
[0016] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the time synchronization method described in the first aspect when executing the computer program.
[0017] In a fifth aspect, the present application provides a vehicle, comprising: the device as described in the second aspect, or the electronic device as described in the fourth aspect.
[0018] By means of the above technical scheme, the present application provides a time synchronization method, device, electronic device and vehicle. Compared with the current prior art, the present application first obtains the clock deviation of the first node and the second node, and then, when the first clock time of the first node is later than the second clock time of the second node, the third clock time of the data collected by the first node is queried for the latest acquisition in the business service history. Then, the clock deviation correction value of the first node is analyzed and determined according to the first clock time and the third clock time, and then the clock time of the first node is adjusted in the direction of the clock time of the second node according to the clock deviation correction value. The present application introduces the clock time (third clock time) of the data collected by the first node that is latest acquired in the history related to the business service (such as services in the field of autonomous driving) for comparative analysis, and adjusts the clock time of the first node according to the clock deviation correction value obtained by the analysis, so that the clock time of the data collected by the first node is not earlier than the third clock time when the business service obtains it again, thereby avoiding the occurrence of time jump, improving the timeliness of data, reducing the abnormal exit of business service functions, and improving the business service experience of users.
[0019] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0022] Figure 1 A schematic diagram of a vehicle network model provided in an embodiment of the present application is shown;
[0023] Figure 2 A schematic diagram of a time synchronization method provided in an embodiment of the present application is shown;
[0024] Figure 3 A schematic diagram of a process flow of another time synchronization method provided in an embodiment of the present application is shown;
[0025] Figure 4A schematic diagram of a process for calculating link delay provided in an embodiment of the present application is shown;
[0026] Figure 5 A schematic diagram of a process flow of another time synchronization method provided in an embodiment of the present application is shown;
[0027] Figure 6 A schematic diagram of a process for calculating clock deviation provided in an embodiment of the present application is shown;
[0028] Figure 7 A schematic structural diagram of a time synchronization device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0029] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0030] At present, many cars have the function of autonomous driving. The autonomous driving function is based on a variety of sensors installed on the car, such as radar, camera, combined positioning system, global navigation system (GPS), etc. The data of these sensors are collected in real time, and then modeled in combination with high-definition maps, and finally the actual operation of the vehicle is controlled according to the processing results. Figure 1 As shown, a vehicle network model is provided, including a vehicle controller 101, a cockpit controller 102 and an automatic driving controller 103. Among them, the vehicle controller 101 is used for vehicle power control; the cockpit controller 102 is used to provide and respond to the human-computer interaction function of the cockpit. The cockpit controller 102 is used as a clock source in the vehicle domain. Its built-in GPS receiver is used to obtain the current time from the GPS satellite, and synchronize the time to the vehicle controller 101 and the automatic driving controller 103 through the Precise Time Protocol (PTP); the automatic driving controller 103 is used to make intelligent driving decisions based on information. The automatic driving controller 103 also communicates data with the sensing device, which is used to collect environmental data of the vehicle, and specifically may include a radar 104, a camera 105 and a combined positioning system 106. Among them, the number of radars 104 and cameras 105 can be multiple, and the type and number of sensing devices can be set according to the actual application scenario. Furthermore, after the sensing device collects the environmental data of the vehicle, the underlying driver of the autonomous driving controller 103 adds a timestamp to the data and sends the data to the autonomous driving controller 103. The autonomous driving controller 103 combines the data with the high-definition map for modeling, and finally controls the actual operation of the vehicle based on the processing results.
[0031] Among them, in order to ensure the timeliness of the data collected during modeling, all sensors are required to collect data at the same time, or at least the collection time points of each sensor must be within an allowable error, which requires the time synchronization of each sensor in the car. At present, the PTP protocol is generally used for time synchronization in vehicle networks, but in the implementation process, since the protocol itself is not associated with specific services, exceptions may occur in some scenarios. For example, when performing real-time scene modeling, time jumps are not allowed. The autonomous driving service will check the timestamps of the data collected by these sensors when modeling. If the timestamp is earlier than the previous data received, it is considered that a time jump has occurred. Once a time jump occurs, it means that the vehicle has returned to a certain point in the past, which will cause confusion in the modeling and exit the autonomous driving mode.
[0032] In a specific implementation, it generally includes a network card driver and an interface for operating the network card time, such as an interface for adjusting the time offset adjtime, an interface for adjusting the frequency offset adjfreq, an interface for obtaining the current time of the network card gettime, an interface for setting the network card time settime, etc. When the network card is initialized, settime will be called to set an initial time. When the upper-layer application needs time, gettime will be called to obtain the current time. After calculating the master and slave time offset offset, adjtime can be called to adjust the time. If a frequency deviation is detected between the master and slave clocks, adjfreq will be called to adjust the frequency of the network card.
[0033] In order to solve the technical problem of time reversal in the above-mentioned autonomous driving, this embodiment provides a time synchronization method, such as Figure 2 As shown, the method includes:
[0034] S201: Obtain a clock deviation of a first node compared to a second node.
[0035] The first node is provided with a slave clock, and the second node is provided with a master clock. The time recorded by the master clock can be considered as the time reference, and the slave clock needs to synchronize time with the master clock. The clock deviation of the first node compared to the second node can be the deviation of the clock time between the slave clock and the master clock, and the clock deviation can be a positive value or a negative value.
[0036] For example, Figure 1 As shown, the first node can be considered as one of the sensors such as radar 104, camera 105 and combined positioning system 106. The second node can be considered as the cockpit controller 102, which serves as a clock source in the vehicle domain, and its built-in GPS receiver is used to obtain the current time from the GPS satellite.
[0037] S202: If it is determined based on the clock deviation that the first clock time of the first node is later than the second clock time of the second node, query the business service history to obtain the third clock time of the data collected by the first node for the most recent time.
[0038] The business service may be a service for obtaining the data collected by the first node at regular or irregular intervals, so as to provide corresponding business services based on the collected data. The third clock time when the business service obtains the data collected by the first node for the latest time will be recorded, such as each time the business service obtains the data collected by the first node, the latest timestamp of the data will be recorded.
[0039] For example, Figure 1 As shown, the business service may be the autonomous driving service corresponding to the autonomous driving controller 103, which may obtain data collected by sensors such as the radar 104, the camera 105 and the combined positioning system 106 at regular or irregular intervals. These data may carry corresponding timestamps. This embodiment may query the timestamp (i.e., the third clock time) of the most recent acquisition of data collected by the autonomous driving service, such as the radar 104.
[0040] S203: Compare the first clock time with the third clock time, and analyze the clock deviation correction value of the first node.
[0041] In autonomous driving or other scene-related services, the requirements for time are relatively strict. These services include obtaining radar data, vehicle speed data, and performing speed control or executing other functional strategies based on these data. If a time jump occurs at this time (the time point corresponding to the data collected at this moment is earlier than the time point obtained last time), the subsequent execution strategy will be unable to be judged. Therefore, in order to avoid this situation, the present embodiment can obtain the third clock time of the data collected by the first node in the history of the business service for the most recent time, and by comparing the third clock time with the first clock time, a more appropriate clock deviation correction value is obtained through analysis, so that after adjustment according to this clock deviation value, the clock time when the business service obtains the data collected by the first node again is not earlier than the third clock time, thereby avoiding the occurrence of time jumps.
[0042] S204: According to the clock deviation correction value, adjust the first clock time of the first node toward the second clock time of the second node by increasing the time.
[0043] In this embodiment, the clock deviation correction value of the first node is analyzed and determined by analyzing the first clock time and the third clock time, and the clock time of the first node is adjusted according to the clock deviation correction value obtained by the analysis. It should be emphasized here that the purpose of obtaining the clock deviation correction value and adjusting the clock time is to make the clock time of the slave clock and the master clock more consistent. Therefore, by adjusting the clock time of the first node to fit the clock time of the second node, such as adjusting the first clock time of the first node to increase the time according to the clock deviation correction value. Through this time synchronization method, the clock time of the data collected by the first node can be obtained by the business service again, which is no earlier than the third clock time, thereby avoiding the occurrence of time jumps, improving the timeliness of data, reducing abnormal exits of business service functions, and improving the user's business service experience.
[0044] Further, as a specific example of the above embodiment, optionally, step 203 may specifically include: when the sum of the first clock time and the clock deviation is greater than or equal to the third clock time, determining the clock deviation as the clock deviation correction value; when the sum of the first clock time and the clock deviation is less than the third clock time, subtracting the first clock time from the third clock time to obtain the clock deviation correction value.
[0045] In this embodiment, how to analyze the clock deviation correction value later is introduced. When the sum of the first clock time and the clock deviation is greater than or equal to the third clock time, it means that the current clock deviation can be directly used to adjust the first clock time, so the value of the clock deviation is directly taken as the clock deviation correction value. When the sum of the first clock time and the clock deviation is less than the third clock time, it means that the clock deviation cannot be directly selected for correction at this time. At this time, the value obtained by subtracting the first clock time from the third clock time is used as the clock deviation correction value. This ensures that the clock time when the business service obtains the data collected by the first node again is no earlier than the third clock time, thereby avoiding the occurrence of time jumps, improving data timeliness, reducing abnormal exits of business service functions, and improving the user's business service experience.
[0046] In some examples, before step 204, the method of this embodiment further includes: obtaining the clock frequency deviation between the first node and the second node; and then reducing and adjusting the clock frequency currently used by the first node according to the clock frequency deviation. Accordingly, step 204 may specifically include: in response to the first clock time being later than the second clock time after the reduction and adjustment, adjusting the first clock time of the first node to increase the time toward the second clock time according to the clock deviation correction value.
[0047] For example, there may be a clock deviation between the slave clock of the first node and the master clock of the second node because their clock frequencies are different. Therefore, in this embodiment, the clock frequency currently used by the first node may be first adjusted to be lowered according to the clock frequency deviation. If, after the clock frequency adjustment, the first clock time of the first node is still later than the second clock time of the second node, the first clock time of the first node may be adjusted to increase the time toward the second clock time according to the clock deviation correction value. In this way, the efficiency and accuracy of time synchronization may be improved, and the occurrence of time jumps may be reduced.
[0048] In some examples, before step 204, the method of this embodiment further includes: obtaining a first node identifier of the first node and a second node identifier of the second node; and then performing hash value calculation after combining the first node identifier and the second node identifier. Accordingly, step 204 may specifically include: in response to the presence of the calculated hash value in the preset storage location, adjusting the first clock time of the first node to the second clock time by adding time according to the clock deviation correction value, wherein the preset storage location stores the hash values corresponding to different node combinations that allow time synchronization.
[0049] For example, in actual situations, multiple nodes may be involved, such as different sensors and controllers in a car. In order to avoid time synchronization errors, this embodiment can pre-count different node combinations that allow time synchronization, and then calculate the corresponding hash value according to the node identifier of each group of node combinations, and save it in a preset storage location (such as a preset database, data table, cache, etc.), such as calculating the hash value of each group of node combinations in the order of master and slave, and saving it in the preset storage location. When time synchronization is required, first obtain the node identifiers of the two nodes, then combine the two node identifiers in the order of master and slave to calculate the hash value, and determine whether the calculated hash value exists in the preset storage location. If there is a corresponding hash value, it means that time synchronization is allowed between the two nodes, and the adjustment process shown in step 204 can be executed at this time. If there is no corresponding hash value, it means that time synchronization is not allowed between the two nodes, and the adjustment process shown in step 204 can be canceled. Through this optional method, the time synchronization process of different nodes can be accurately controlled to meet different business needs.
[0050] Optionally, step 201 may specifically include: analyzing the message information of each interaction between the first node and the second node to obtain the clock deviation. The message information includes the message sending time and the message receiving time when the first node interacts with the second node. Through this optional method, the clock deviation of the first node compared to the second node can be accurately analyzed.
[0051] Furthermore, the clock deviation is obtained by analyzing the message information of each interaction between the first node and the second node. The specific steps are as follows: Figure 3 As shown, including:
[0052] S301, by analyzing the message information of each interaction between the first node and the second node, obtain the link delay between the first node and the second node, as well as the sending time of the mth message sent by the second node and the receiving time of the mth message received by the first node.
[0053] S302, subtract the sum of the link delay and the sending time of the mth message sent by the second node from the receiving time of the mth message received by the first node to obtain the clock deviation of the first node compared with the second node.
[0054] Wherein, m is a positive integer.
[0055] Clock deviation refers to the difference between the master node clock and the slave node clock, which can be calculated by the sending time of a message sent by the sender and the receiving time of the message received by the receiver, as well as the link delay between the two. In this embodiment, obtaining the clock deviation requires calculating the link delay between the master node and the slave node, and obtaining the sending time of the mth message sent by the master node and the receiving time of the mth message received by the slave node. Then, the sum of the link delay and the sending time of the mth message sent by the master node is subtracted from the receiving time of the mth message received by the slave node to obtain the clock deviation of the slave node compared to the master node. The calculated clock deviation can be used to determine whether the first clock time of the first node is later than the second clock time of the second node.
[0056] A feasible implementation method for obtaining clock deviation is given below. Figure 6 As shown, node S represents a slave node and node M represents a master node. First, node M sends a Sync message to node S, and node S receives the Sync message and records the reception time ts of the message. Then node M sends the sending time tm of the Sync message to node S, so that node S can obtain the time when node M sends the Sync message. Finally, through the formula offset = tm + D-ts (D is the link delay), that is, the sum of the link delay and the sending time tm of the Sync message sent by the master node, and then subtract ts from the reception time of the Sync message received by the slave node, the clock deviation of the slave node compared to the master node is obtained.
[0057] Optionally, the link delay between the first node and the second node is obtained, including: formula D = [(td-ta)-(tc-tb)] / 2, to determine the link delay; wherein D represents the link delay between the first node and the second node, ta represents the sending time of any message sent by the first node to the second node, and tb represents the receiving time of any message received by the second node; tc represents the sending time of the message with tb information fed back by the second node to the first node, and td represents the receiving time of the message with tb information received by the first node.
[0058] See also Figure 4 , introduces the process of obtaining link delay. In the figure, S represents the slave node and M represents the master node. First, node S sends a Pdelay_Req event message to node M and records the message sending timestamp ta. After node M receives the Pdelay_Req message sent by node S, it records the message receiving timestamp tb. Node M packs the information containing the timestamp tb into the Pdelay_Resp event message, sends it to node S, and records the sending timestamp tc. Node M packs the timestamp tc into the Pdelay_Resp_Follow_Up message and sends it to node S. In this way, after node S receives the Pdelay_Resp event message sent by node M, it records the receiving timestamp td and extracts the timestamp tb contained in the Pdelay_Resp event message; after node S receives the Pdelay_Resp_Follow_UP message sent by node M, it extracts the timestamp tc contained in the Pdelay_Resp_Follow_Up message. In this way, the node S can determine the link delay through the above formula D=[(td-ta)-(tc-tb)] / 2.
[0059] In this embodiment, a method for obtaining the link delay between the master and slave nodes is provided. In essence, the link delay is obtained by sending a message from the master node to the slave node and from the slave node to the master node, and then adding the two transmission times and averaging them. The link delay is included in the calculation of the time deviation between the master and slave nodes, so that the obtained data is more accurate.
[0060] Optionally, after obtaining the clock deviation of the first node compared to the second node, the method of this embodiment also includes: if it is determined based on the clock deviation that the first clock time of the first node is earlier than the second clock time of the second node, then adjusting the clock time of the first node according to the value of the clock deviation as a clock deviation correction value.
[0061] In this embodiment, a situation is also given, that is, when the clock deviation is determined, the first clock time of the first node is earlier than the second clock time of the second node, that is, the time of the slave clock is less than the time of the master clock, and the clock jump will not occur. Then the value of the clock deviation can be directly used as the clock deviation correction value to adjust the clock time of the first node, and the time jump will not occur.
[0062] like Figure 5 As shown, a time synchronization method provided by this embodiment is shown, including:
[0063] S501: Calculate link delay D.
[0064] S502: Calculate a clock deviation between the first node and the second node.
[0065] S503, determine whether the first clock time of the first node is later than the second clock time of the second node. If not, proceed to S5041; if so, proceed to S5042.
[0066] S5041: Use the clock deviation value as the clock deviation correction value.
[0067] S5042, determine whether the sum of the first clock time and the clock deviation is greater than or equal to the third clock time. If not, proceed to S4051; if so, proceed to S5052.
[0068] S5051, subtract the first clock time from the third clock time to obtain a clock deviation correction value.
[0069] S5052: Use the clock deviation value as the clock deviation correction value.
[0070] S506: Adjust the clock time of the first node to match the clock time of the second node according to the clock deviation correction value.
[0071] In this embodiment, a method for obtaining a clock deviation correction value is provided. First, the link delay is calculated to pave the way for the subsequent acquisition of the clock deviation. Then, the clock deviation of the first node compared to the second node is calculated. If the first clock time of the first node is earlier than the clock time of the second node, the value of the clock deviation is used as the clock deviation correction value. If the first clock time of the first node is earlier than the clock time of the second node, it is necessary to determine whether the sum of the first clock time and the clock deviation is greater than or equal to the third clock time. If so, the value of the clock deviation is used as the clock deviation correction value. If not, it is necessary to subtract the first clock time from the third clock time to obtain the clock deviation correction value. Finally, according to the obtained clock deviation correction value, the clock time of the first node is adjusted to fit the clock time of the second node, such as adjusting the clock time of the first node by increasing the time according to the clock deviation correction value.
[0072] By analyzing the first clock time and the third clock time, the clock deviation correction value of the first node is analyzed and determined, and the clock time of the first node is adjusted according to the obtained clock deviation correction value, so that the business service can obtain the clock time of the data collected by the first node no earlier than the third clock time, thereby avoiding the occurrence of time backtracking, improving data timeliness, reducing abnormal exits of business service functions, and enhancing the user's business service experience.
[0073] Specifically, in the actual application method, we know that the purpose of time synchronization is to provide accurate time for upper-layer applications. For example, in a vehicle network, the autonomous driving service needs to collect data from various sensors at the same moment. To avoid the autonomous driving service detecting time backtracking, the time needs to be recorded each time the autonomous driving service calls gettime to obtain the current time and saved to a global variable last_time. When calling the adjtime interface to adjust the time offset, the offset cannot be directly used as a parameter, and the offset needs to be transformed. Suppose a new time offset variable is defined as new_offset, and the specific transformation rules are as follows:
[0074] When offset >= 0, set new_offset = offset. That is, the first clock time of the first node is not later than the second clock time of the second node, and the clock deviation value offset is used as the clock deviation correction value new_offset.
[0075] When offset < 0, it is necessary to read the current time again, current_time = gettime(), and then compare the magnitudes of current_time and last_time. That is, the first clock time of the first node is later than the second clock time of the second node, and the third clock time current_time needs to be obtained.
[0076] If current_time + offset >= last_time, set new_offset = offset
[0077] If current_time + offset < last_time, set new_offset = last_time - current_time
[0078] Finally, call the adjtime(new_offset) interface to set the time deviation of the slave clock.
[0079] Optionally, the time synchronization method also includes: if it is determined based on the clock deviation that the first clock time of the first node is later than the second clock time of the second node, then obtaining the clock frequency deviation between the first node and the second node; processing the clock frequency deviation between the first node and the second node and the clock frequency currently used by the first node to obtain a target clock frequency; and reducing the clock frequency of the first node according to the target clock frequency.
[0080] In this embodiment, a method for synchronizing the slave clock and the master clock frequency by frequency modulation is also provided. The target clock frequency to which the first node needs to be adjusted is calculated by using the relationship between the clock frequencies of the first node and the second node. Then, the clock frequency of the first node is lowered and adjusted to gradually fit the clock frequency of the second node, so that the clock frequencies of the two nodes are closer, thereby improving the timeliness of data.
[0081] For example, if the time of a slave node is ahead of the time of the master node, the clock frequency deviation between the slave clock and the master clock is obtained. Then the clock frequency deviation is multiplied by the current clock frequency of the slave node to obtain the target clock frequency. Finally, the clock frequency of the slave node is slowly adjusted toward the target clock frequency.
[0082] The specific method of obtaining the clock frequency deviation can be as follows: first, the slave node obtains the first time interval t1 between the kth message and the knth message sent by the master node. Then, the slave node obtains the second time interval t2 between the kth message and the knth message sent by the master node. The second interval t2 is divided by the first interval t1 to obtain the clock frequency deviation. Wherein, k is a natural number greater than or equal to 2, n is a natural number greater than or equal to 1, and n<k.
[0083] In this embodiment, the clock frequency deviation between the two is calculated in the above manner, so that the clock frequency of the slave node is slowly adjusted to the target clock frequency. The target clock frequency is obtained by the frequency ratio of the master and slave nodes, so the adjusted clock frequency of the slave node is more aligned with the clock frequency of the master node, making the clock frequencies of the two nodes closer, thereby improving data timeliness.
[0084] It is also necessary to note that if the clocks of the two are synchronized only by adjusting the frequency of the slave clock, the convergence process will be slow and the master and slave clocks cannot be synchronized quickly. Therefore, the best way is to adjust the clock deviation of the slave clock on the basis of frequency modulation, thereby solving the time jump problem caused by "the acquired data timestamp is earlier than the previously received data time" by adjusting the frequency deviation and time deviation of the clock in a comprehensive manner, thereby improving the timeliness of the data. The above embodiments have been verified in real vehicles with significant results.
[0085] As Figures 2 to 6The specific implementation of the method shown in this embodiment provides a time synchronization device, such as Figure 7 As shown, the device includes: an acquisition module 701, a processing unit 702, a comparison unit 703, and a synchronization unit 704.
[0086] An acquiring unit 701 is configured to acquire a clock deviation of a first node compared to a second node, wherein the first node is provided with a slave clock and the second node is provided with a master clock;
[0087] The processing unit 702 is configured to query the business service history to obtain the third clock time of the data collected by the first node for the most recent time, if it is determined that the first clock time of the first node is later than the second clock time of the second node according to the clock deviation;
[0088] A comparing unit 703, configured to compare the first clock time with the third clock time, and analyze a clock deviation correction value of the first node;
[0089] The synchronization unit 704 is used to adjust the first clock time of the first node to the second clock time by adding time according to the clock deviation correction value.
[0090] In a specific application scenario, the comparison unit 703 is specifically used to determine the clock deviation as the clock deviation correction value when the sum of the first clock time and the clock deviation is greater than or equal to the third clock time; and to subtract the first clock time from the third clock time to obtain the clock deviation correction value when the sum of the first clock time and the clock deviation is less than the third clock time.
[0091] In a specific application scenario, the acquisition unit 701 is specifically used to analyze the message information of each interaction between the first node and the second node to obtain the clock deviation.
[0092] In a specific application scenario, the acquisition unit 701 is further used to analyze the message information of each interaction between the first node and the second node, obtain the link delay between the first node and the second node, and obtain the sending time of the mth message sent by the second node and the receiving time of the mth message received by the first node; the sum of the link delay and the sending time of the mth message sent by the second node is subtracted from the receiving time of the mth message received by the first node to obtain the clock deviation of the first node compared to the second node; wherein m is a positive integer.
[0093] In a specific application scenario, the acquisition unit 701 is further used to determine the link delay according to the formula D=[(td-ta)-(tc-tb)] / 2; wherein D represents the link delay between the first node and the second node, ta represents the sending time of any message sent by the first node to the second node, and tb represents the receiving time of the second node receiving any message; tc represents the sending time of the message with tb information fed back by the second node to the first node, and td represents the receiving time of the message with tb information received by the first node.
[0094] In a specific application scenario, the synchronization unit 704 is also used to obtain the clock frequency deviation between the first node and the second node; to reduce and adjust the clock frequency currently used by the first node according to the clock frequency deviation; in response to the first clock time being later than the second clock time after the reduction and adjustment, to increase the time of the first clock time of the first node toward the second clock time according to the clock deviation correction value.
[0095] In a specific application scenario, the synchronization unit 704 is also used to obtain the first node identifier of the first node and the second node identifier of the second node; combine the first node identifier with the second node identifier and perform a hash value calculation; in response to the calculated hash value existing in a preset storage location, adjust the first clock time of the first node to the second clock time by adding time according to the clock deviation correction value, wherein the preset storage location stores the hash values corresponding to different node combinations that allow time synchronization.
[0096] It should be noted that for other corresponding descriptions of the functional units involved in the time synchronization device provided in this embodiment, reference can be made to Figures 2 to 6 The corresponding description in will not be repeated here.
[0097] Based on the above Figures 2 to 6 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figures 2 to 6 The method shown.
[0098] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0099] Based on the above Figures 2 to 6 The method shown, and Figure 7 In order to achieve the above-mentioned purpose, the embodiment of the present application further provides an electronic device, which can be configured on a computer side or a vehicle side, etc. The device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figures 2 to 6 The method shown.
[0100] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0101] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0102] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0103] Based on the above electronic device, the embodiment of the present application further provides a vehicle, which may specifically include: Figure 7 The device shown in the figure or the electronic device as described above. The vehicle can be a new energy vehicle or a traditional vehicle.
[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware platforms, or by hardware. By introducing the latest historical clock time (third clock time) related to business services (such as services in the field of autonomous driving) to obtain the data collected by the first node for comparative analysis, and adjusting the clock time of the first node according to the clock deviation correction value obtained by the analysis, the clock time of the data collected by the first node obtained by the business service again can be no earlier than the third clock time, thereby avoiding the occurrence of time jumps, improving data timeliness, reducing abnormal exits of business service functions, and improving users' business service experience.
[0105] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0106] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A time synchronization method, characterized in that: include: Obtaining a clock deviation of a first node compared to a second node, wherein the first node is provided with a slave clock and the second node is provided with a master clock; If it is determined according to the clock deviation that the first clock time of the first node is later than the second clock time of the second node, querying the business service history to obtain the third clock time of the data collected by the first node for the most recent time; comparing the first clock time with the third clock time, and analyzing a clock deviation correction value of the first node; According to the clock deviation correction value, the first clock time is adjusted to the second clock time by adding time.
2. The method according to claim 1, characterized in that The comparing the first clock time with the third clock time and analyzing the clock deviation correction value of the first node includes: In a case where the sum of the first clock time and the clock deviation is greater than or equal to the third clock time, determining the clock deviation as the clock deviation correction value; When the sum of the first clock time and the clock deviation is smaller than the third clock time, the first clock time is subtracted from the third clock time to obtain the clock deviation correction value.
3. The method according to claim 1, characterized in that: The obtaining of the clock deviation of the first node compared with the second node includes: Analyze the message information exchanged between the first node and the second node each time to obtain the clock deviation; The message information includes a message sending time and a message receiving time when the first node interacts with the second node.
4. The method according to claim 3, characterized in that The analyzing the message information exchanged between the first node and the second node each time to obtain the clock deviation includes: Analyze the message information of each interaction between the first node and the second node, obtain the link delay between the first node and the second node, and obtain the sending time of the mth message sent by the second node and the receiving time of the mth message received by the first node; Subtract the sum of the link delay and the sending time of the mth message sent by the second node from the receiving time of the mth message received by the first node to obtain the clock deviation of the first node compared with the second node; Wherein, m is a positive integer.
5. The method according to claim 4, characterized in that The obtaining a link delay between the first node and the second node includes: The link delay is determined by the formula D=[(td-ta)-(tc-tb)] / 2; Among them, D represents the link delay between the first node and the second node, ta represents the sending time of any message sent by the first node to the second node, and tb represents the receiving time when the second node receives any message; tc represents the sending time of the message with tb information fed back by the second node to the first node, and td represents the receiving time when the first node receives the message with tb information.
6. The method according to any one of claims 1 to 5, characterized in that Before adjusting the first clock time of the first node to increase the time toward the second clock time according to the clock deviation correction value, the method further includes: Obtaining a clock frequency deviation between the first node and the second node; Lowering and adjusting the clock frequency currently used by the first node according to the clock frequency deviation; The adjusting, according to the clock deviation correction value, adding time to the clock time of the first node toward the clock time of the second node includes: In response to the first clock time being still later than the second clock time after the downward adjustment, the first clock time of the first node is adjusted to increase the time toward the second clock time according to the clock deviation correction value.
7. The method according to any one of claims 1 to 5, characterized in that Before adjusting the first clock time of the first node to increase the time toward the second clock time according to the clock deviation correction value, the method further includes: Obtain a first node identifier of the first node and a second node identifier of the second node; The first node identifier and the second node identifier are combined and then a hash value is calculated; The adjusting, according to the clock deviation correction value, the first clock time of the first node to the second clock time by adding time includes: In response to the calculated hash value existing in a preset storage location, the first clock time of the first node is adjusted to the second clock time by increasing the time according to the clock deviation correction value, wherein the preset storage location stores the hash values corresponding to different node combinations allowing time synchronization.
8. A time synchronization device, characterized in that: include: An acquisition unit, configured to acquire a clock deviation of a first node compared to a second node, wherein the first node is provided with a slave clock and the second node is provided with a master clock; A processing unit, configured to query the business service history for the latest acquisition of a third clock time of data collected by the first node when it is determined that the first clock time of the first node is later than the second clock time of the second node according to the clock deviation; a comparing unit, configured to compare the first clock time with the third clock time, and analyze a clock deviation correction value of the first node; A synchronization unit is used to adjust the first clock time toward the second clock time by adding time according to the clock deviation correction value.
9. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A vehicle, characterized in that: include: The device as claimed in claim 8, or the electronic device as claimed in claim 9.
Citation Information
Cited By
Time-frequency joint calibration method based on carrier frequency offset and terminal equipment
CN121568205A
