Time synchronization method, apparatus, electronic device and vehicle

By analyzing and adjusting the clock deviation between the slave clock and the master clock in autonomous vehicles, the time jump problem is solved and data timeliness and user experience are improved.

WO2024174940A1PCT designated stage expired Publication Date: 2024-08-29BEIJING CO WHEELS TECH CO LTD

Patent Information

Application Number
PCT/CN2024/077403
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-23
Filing Date
2024-02-18
Publication Date
2024-08-29

AI Technical Summary

Technical Problem

In autonomous vehicles, clock synchronization issues cause time jumps, affecting data timeliness and user experience.

Method used

By obtaining the clock deviation between the slave clock and the master clock, query the latest collected data timestamp in the business service history, analyze and adjust the clock deviation correction value to ensure the synchronization of the slave clock time and the master clock time.

Benefits of technology

This avoids time jumps, improves data timeliness, reduces abnormal exits of the autonomous driving function, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024077403_29082024_PF_FP_ABST
    Figure CN2024077403_29082024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of communications. Disclosed are a time synchronization method, an apparatus, an electronic device and a vehicle. The method comprises: acquiring the clock deviation of a first node with respect to a second node; if it is determined on the basis of the clock deviation that a first clock time of the first node is later than a second clock time of the second node, querying a third clock time of the latest acquisition in the history of a business service of data collected by the first node; comparing the first clock time with the third clock time, and analyzing a clock deviation correction value of the first node; and then performing an adjustment to increase the first clock time with respect to the second clock time. Introducing the third clock time related to the business service and adjusting the clock time of the first node according to the analyzed clock deviation correction value enable the clock time at which the business service acquires again the data collected by the first node not to be earlier than the third clock time, thereby avoiding the occurrence of time regression, and improving data timeliness.
Need to check novelty before this filing date? Find Prior Art

Description

Time synchronization method, device, electronic equipment and vehicle

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 23, 2023, with application number 2023101905255 and application name “A time synchronization method, device, electronic device and vehicle”, and claims priority to the Chinese patent application filed with the China Patent Office on February 23, 2023, with application number 2023101622538 and application name “A time synchronization method, device, electronic device and vehicle”, the entire contents of which are incorporated by reference into the application. Technical Field

[0002] 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

[0003] With the rapid development of new energy vehicles, their use is becoming increasingly prevalent. Many of these vehicles include autonomous driving capabilities. These functions require sensors to collect real-time data, then generate models based on high-definition maps. The resulting data is then used to control vehicle operations. To ensure the timeliness of the data collected during modeling, all controllers within the vehicle must be synchronized.

[0004] Currently, controllers equipped with slave clocks synchronize their time based on the time recorded in the master clock. The autonomous driving service periodically or irregularly acquires data collected by these controllers. After collecting the data, these controllers timestamp the data and send it to the autonomous driving service for modeling. Each time the autonomous driving service performs modeling, it verifies the timestamp of the collected data and compares it with the timestamp of the data collected by the controller during the previous modeling run. If the timestamp of the data collected by controller A during the current modeling run is earlier than the timestamp of the data collected by controller A during the previous modeling run, it is considered a time jump. This will cause controller A equipped with the slave clock to stop synchronizing its time and instead use its own timing based on the local crystal oscillator. The autonomous driving function will abnormally exit, affecting the user experience.

[0005] Summary of the Invention

[0006] 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 that occurs in autonomous driving and improve data timeliness.

[0007] In a first aspect, the present application provides a time synchronization method, comprising:

[0008] 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;

[0009] 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, querying the business service history to obtain the third clock time of the data collected by the first node for the most recent time;

[0010] comparing the first clock time with the third clock time, and analyzing a clock deviation correction value of the first node;

[0011] According to the clock deviation correction value, the first clock time is adjusted to the second clock time by adding time.

[0012] In a second aspect, the present application provides another time synchronization method, including:

[0013] 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;

[0014] 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, obtaining the clock frequency deviation between the first node and the second node, and querying the business service history for the third clock time of the most recent acquisition of data collected by the first node;

[0015] analyzing a clock frequency correction parameter corresponding to the clock frequency deviation and a clock deviation correction value corresponding to the third clock time and the first clock time;

[0016] According to the clock frequency correction parameter and the clock deviation correction value, the frequency and time of the slave clock of the first node are corrected toward the master clock.

[0017] In a third aspect, the present application provides a time synchronization device, comprising:

[0018] an acquiring 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;

[0019] a processing unit configured to, when 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 a third clock time of the data collected by the first node for the most recent time;

[0020] 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;

[0021] A synchronization unit is used to adjust the first clock time to the second clock time by adding time according to the clock deviation correction value.

[0022] In a fourth aspect, the present application provides another time synchronization device, comprising:

[0023] an acquiring 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;

[0024] a determining unit, configured to determine, based on the clock deviation, that a first clock time of the first node is later than a second clock time of the second node, obtain the clock frequency deviation between the first node and the second node, and query a business service history for a third clock time at which data collected by the first node was most recently obtained;

[0025] a processing unit, configured to analyze a clock frequency correction parameter corresponding to the clock frequency deviation, and a clock deviation correction value corresponding to the third clock time and the first clock time;

[0026] A synchronization unit is used to correct the frequency and time of the slave clock of the first node to the master clock according to the clock frequency correction parameter and the clock deviation correction value.

[0027] In a fifth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the time synchronization method described in the first aspect or the second aspect.

[0028] In a sixth 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 or the second aspect when executing the computer program.

[0029] In a seventh aspect, the present application provides a vehicle comprising: the device as described in the third aspect or the fourth aspect, or the electronic device as described in the sixth aspect.

[0030] 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

[0031] 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.

[0032] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0033] FIG1 shows a schematic diagram of an in-vehicle network model provided in an embodiment of the present application;

[0034] FIG2 shows a schematic flow chart of a time synchronization method provided in an embodiment of the present application;

[0035] FIG3 shows a schematic flow chart of another time synchronization method provided in an embodiment of the present application;

[0036] FIG4 shows a flow chart of a method for calculating link delay provided in an embodiment of the present application;

[0037] FIG5 is a schematic diagram showing a flow chart of another time synchronization method provided in an embodiment of the present application;

[0038] FIG6 is a schematic diagram showing a flow chart of a method for calculating clock deviation provided in an embodiment of the present application;

[0039] FIG7 shows a schematic flow chart of a time synchronization method provided in an embodiment of the present application;

[0040] FIG8 shows a schematic diagram of an example provided by an embodiment of the present application;

[0041] FIG9 shows a schematic diagram of an example process provided by an embodiment of the present application;

[0042] FIG10 shows a schematic structural diagram of a time synchronization device provided in an embodiment of the present application;

[0043] FIG11 shows a schematic structural diagram of another time synchronization device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that, in the absence of conflict, the embodiments of the present application and the features therein can be combined with each other.

[0045] Many vehicles now have autonomous driving capabilities. These functions are based on a variety of sensors installed on the vehicle, such as radar, cameras, integrated positioning systems, and global positioning systems (GPS). Data from these sensors is collected in real time, combined with high-definition maps to create a model, and the vehicle's actual operation is controlled based on the processed data. As shown in Figure 1, an in-vehicle network model is provided, including a vehicle controller 101, a cockpit controller 102, and an autonomous driving controller 103. The vehicle controller 101 is responsible for vehicle power control; the cockpit controller 102 provides and responds to cockpit human-machine interaction functions. The cockpit controller 102 serves as the vehicle's internal clock source. Its built-in GPS receiver acquires the current time from GPS satellites and synchronizes this time to the vehicle controller 101 and autonomous driving controller 103 via the Precise Time Protocol (PTP). The autonomous driving controller 103 is responsible for making intelligent driving decisions based on this information. The autonomous driving controller 103 also communicates with sensing devices, which collect environmental data about the vehicle and may include radar 104, cameras 105, and an integrated positioning system 106. The number of radars 104 and cameras 105 can be multiple, and the type and number of sensing devices can be determined based on the actual application scenario. Furthermore, after the sensing devices collect vehicle environmental data, the underlying driver of the autonomous driving controller 103 adds a timestamp to this data and transmits it to the autonomous driving controller 103. The autonomous driving controller 103 then combines this data with a high-definition map to create a model and ultimately controls the actual operation of the vehicle based on the processed results.

[0046] 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 of each sensor must be within an allowable error. This requires that all sensors in the vehicle be time synchronized. Currently, the PTP protocol is generally used for time synchronization in vehicle networks. However, during implementation, since the protocol itself is not associated with specific services, anomalies 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 during modeling. If the timestamp is earlier than the time of the previously received data, 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 thus exit the autonomous driving mode.

[0047] In specific implementations, the system generally includes a network card driver and interfaces for manipulating the network card's time, such as the adjtime interface for adjusting the time offset, the adjfreq interface for adjusting the frequency offset, the gettime interface for obtaining the current network card time, and the settime interface for setting the network card time. During network card initialization, settime is called to set an initial time. When upper-layer applications need time, gettime is called to obtain the current time. After calculating the offset between the master and slave times, adjtime is called to adjust the time. If a frequency deviation between the master and slave clocks is detected, adjfreq is called to adjust the network card's frequency.

[0048] To solve the technical problem of time rewind in the aforementioned autonomous driving, this embodiment provides a time synchronization method, as shown in FIG2 , including:

[0049] S201: Obtain a clock deviation between a first node and a second node.

[0050] The first node is equipped with a slave clock, and the second node is equipped 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 with the master clock. The clock deviation of the first node compared to the second node can be the difference in clock time between the slave clock and the master clock. This clock deviation can be positive or negative.

[0051] For example, as shown in Figure 1, the first node can be considered as one of the sensors such as radar 104, camera 105, and integrated positioning system 106. The second node can be considered as the cockpit controller 102, which serves as the clock source for the entire vehicle domain and has a built-in GPS receiver to obtain the current time from GPS satellites.

[0052] 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.

[0053] The business service can be a service that periodically or irregularly obtains data collected by the first node, so as to provide corresponding business services based on the collected data. The third clock time when the business service most recently obtained the data collected by the first node is recorded. For example, each time the business service obtains data collected by the first node, the most recent timestamp of the data is recorded.

[0054] For example, as shown in Figure 1, the business service may be an autonomous driving service corresponding to the autonomous driving controller 103, which may periodically or irregularly obtain data collected by sensors such as the radar 104, the camera 105, and the combined positioning system 106. These data may have corresponding timestamps. This embodiment may query the timestamp (i.e., the third clock time) of the most recent data obtained by the autonomous driving service, such as the data collected by the radar 104.

[0055] S203: Compare the first clock time with the third clock time, and analyze the clock deviation correction value of the first node.

[0056] In autonomous driving or other scene-related businesses, the requirements for time are relatively strict. These businesses 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), it will cause the subsequent execution strategy to be unable to be judged. Therefore, in order to avoid this situation, this 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 no earlier than the third clock time, thereby avoiding the occurrence of time jumps.

[0057] S204: According to the clock deviation correction value, the first clock time of the first node is adjusted to the second clock time of the second node by increasing the time.

[0058] 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 add time to the second clock 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 data timeliness, reducing abnormal exits of business service functions, and improving the user's business service experience.

[0059] 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.

[0060] 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 after 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.

[0061] In some examples, before step 204, the method of this embodiment further includes: obtaining a clock frequency deviation between the first node and the second node; and then reducing 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 still later than the second clock time after the reduction, adjusting the first clock time of the first node toward the second clock time by adding time according to the clock deviation correction value.

[0062] 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 can be lowered and adjusted 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 can be adjusted to the second clock time by adding time according to the clock deviation correction value. In this way, the efficiency and accuracy of time synchronization can be improved, and the occurrence of time jumps can be reduced.

[0063] 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 calculating a hash value after combining the first node identifier and the second node identifier. Accordingly, step 204 may specifically include: in response to the calculated hash value being stored in a preset storage location, adjusting the first clock time of the first node to the second clock time by adding a time according to the clock deviation correction value, wherein the preset storage location stores hash values ​​corresponding to different node combinations that allow time synchronization.

[0064] For example, in actual situations, multiple nodes may be involved, such as different sensors and controllers in a car. To avoid time synchronization errors, this embodiment can pre-count the different node combinations that are allowed for time synchronization, and then calculate the corresponding hash value based on 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.). For example, the hash value of each group of node combinations is calculated in sequence according to the master-slave order and saved in the preset storage location. When time synchronization is required, the node identifiers of the two nodes are first obtained, and then the two node identifiers are combined in the master-slave order to calculate the hash value, and it is determined whether the calculated hash value exists in the preset storage location. If the corresponding hash value exists, it indicates that time synchronization between the two nodes is allowed, and the adjustment process shown in step 204 can be executed. If the corresponding hash value does not exist, it indicates that time synchronization between the two nodes is not allowed, 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.

[0065] Optionally, step 201 may specifically include analyzing message information exchanged between the first node and the second node to obtain a clock offset. The message information includes the message sending time and message receiving time during each exchange between the first node and the second node. This optional approach allows accurate analysis and determination of the clock offset between the first node and the second node.

[0066] Compared with the current existing technology, this embodiment 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, queries the business service history to obtain the third clock time of the data collected by the first node. Then, based on the first clock time and the third clock time, the clock deviation correction value of the first node is analyzed and determined, 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. This embodiment introduces the historical clock time (third clock time) of the data collected by the first node that is most recently obtained in relation 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 from the analysis, so that the clock time of the data collected by the first node obtained by the business service again is not 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.

[0067] 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 shown in Figure 3, including:

[0068] 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.

[0069] 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 to the second node.

[0070] Wherein, m is a positive integer.

[0071] 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. By calculating the clock deviation, it 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.

[0072] A feasible implementation method for obtaining clock deviation is given below, which can be specifically combined with Figure 6, where node S represents the slave node and node M represents the 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 sent the Sync message. Finally, the clock deviation of the slave node compared to the master node is obtained by 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 the difference ts between the receiving time of the Sync message received by the slave node.

[0073] Optionally, obtaining the link delay between the first node and the second node includes: 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.

[0074] Refer to Figure 4, which describes the link delay acquisition process. In the figure, S represents a slave node and M represents a master node. First, node S sends a Pdelay_Req event message to node M and records the message sending timestamp ta. After receiving the Pdelay_Req message from node S, node M records the message receiving timestamp tb. Node M packages the information containing timestamp tb into a Pdelay_Resp event message, sends it to node S, and records the sending timestamp tc. Node M packages timestamp tc into a Pdelay_Resp_Follow_Up message, and sends it to node S. Thus, after node S receives the Pdelay_Resp event message from 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 from 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.

[0075] This embodiment provides a method for obtaining the link delay between a master and a slave node. Essentially, the link delay is obtained by sending a message from the master node to the slave node, and then from the slave node to the master node, adding the two transmission times and averaging them. Incorporating link delay into the calculation of the master-slave time offset makes the resulting data more accurate.

[0076] 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 the clock deviation correction value.

[0077] This embodiment also describes a scenario where, when clock deviation is determined, the first clock time of the first node is earlier than the second clock time of the second node. In this case, the slave clock time is less than the master clock time, and clock backslip does not occur. In this case, the clock deviation value can be used directly as the clock deviation correction value to adjust the clock time of the first node, preventing time backslip.

[0078] As shown in FIG5 , a time synchronization method provided by this embodiment is shown, including:

[0079] S501: Calculate the link delay D.

[0080] S502: Calculate a clock deviation between the first node and the second node.

[0081] 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.

[0082] S5041: Use the clock deviation value as a clock deviation correction value.

[0083] 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.

[0084] S5051: Subtract the first clock time from the third clock time to obtain a clock deviation correction value.

[0085] S5052: Use the clock deviation value as a clock deviation correction value.

[0086] S506: Adjust the clock time of the first node to align with the clock time of the second node according to the clock deviation correction value.

[0087] 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 relative 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 clock deviation value 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 a third clock time. If so, the clock deviation value is used as the clock deviation correction value. If not, the first clock time is subtracted 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 align with the clock time of the second node, such as by adding time to the clock time of the first node according to the clock deviation correction value.

[0088] By analyzing the first clock time and the third clock time to analyze and determine the clock deviation correction value of the first node, 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 enhancing users' business service experience.

[0089] Specifically, in practical applications, we know that the purpose of time synchronization is to provide accurate time to upper-layer applications. For example, in an in-vehicle network, autonomous driving services need to collect data from various sensors at the same time. To prevent the autonomous driving service from detecting time jumps, each time the autonomous driving service calls gettime to obtain the current time, it needs to record this time and save it to a global variable last_time. When calling the adjtime interface to adjust the time offset, the offset cannot be used directly as a parameter. The offset needs to be transformed. Assuming that a new time offset variable is defined as new_offset, the specific transformation rules are as follows:

[0090] When offset>=0, set new_offset=offset. In this case, the first clock time of the first node is not later than the second clock time of the second node, and the clock offset value offset is used as the clock offset correction value new_offset.

[0091] When offset < 0, it is necessary to read the current time again, current_time = gettime(), and then compare the magnitudes of the values of current_time and last_time. At this time, that is, the first clock time of the first node is later than the second clock time of the second node, and it is necessary to obtain the third clock time current_time.

[0092] If current_time + offset >= last_time, set new_offset = offset

[0093] If current_time + offset < last_time, set new_offset = last_time - current_time

[0094] Finally, call the adjtime(new_offset) interface to set the time deviation of the slave clock.

[0095] Optionally, the time synchronization method further includes: if it is determined that the first clock time of the first node is later than the second clock time of the second node based on the clock deviation, obtain the clock frequency deviation between the first node and the second node; process the clock frequency deviation between the first node and the second node and the currently used clock frequency of the first node to obtain the target clock frequency; adjust the clock frequency of the first node downward according to the target clock frequency.

[0096] In this embodiment, a method for synchronizing the slave clock and the master clock frequency by frequency modulation is also given. Using the clock frequency relationship between the first node and the second node, calculate the target clock frequency that the first node needs to adjust to. Then, adjust the clock frequency of the first node downward so that it gradually approaches the clock frequency of the second node, thereby making the clock frequencies of the two closer and improving the data timeliness.

[0097] For example, if the time of the slave node is before the time of the master node, at this time, obtain the clock frequency deviation between the slave clock and the master clock. Then, multiply the clock frequency deviation by the current clock frequency of the slave node as the target clock frequency. Finally, gradually adjust the clock frequency of the slave node to the target clock frequency.

[0098] The specific way to obtain the clock frequency deviation is as follows: First, the slave node obtains the first time interval t1 between the k-th message and the (k - n)-th message received from the master node. Then, the slave node obtains the second time interval t2 between the master node sending the k-th message and the (k - n)-th message. Divide the second interval time t2 by the first interval time t1 to obtain the clock frequency deviation. Here, 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.

[0099] In this embodiment, the clock frequency deviation between the two nodes is calculated in the above manner, so that the slave node's clock frequency is gradually adjusted toward the target clock frequency. The target clock frequency is obtained by the frequency ratio of the master and slave nodes. Therefore, the adjusted slave node's clock frequency is more closely aligned with the master node's clock frequency, making the two clock frequencies closer and improving data timeliness.

[0100] It's also important to note that if the two clocks are synchronized only by adjusting the frequency of the slave clock, the convergence process will be slow, preventing the master and slave clocks from synchronizing quickly. Therefore, the optimal approach is to adjust the slave clock's clock deviation in addition to frequency modulation. This combined approach of adjusting the clock's frequency deviation and time deviation resolves the time-jump issue caused by "the acquired data timestamp is earlier than the previously received data," thereby improving data timeliness. The above-described embodiment has been verified in real vehicles with significant results.

[0101] Furthermore, this embodiment provides a time synchronization method, as shown in FIG7 , which includes:

[0102] S601: Obtain a clock deviation between a first node and a second node.

[0103] The first node is equipped with a slave clock, and the second node is equipped 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 with the master clock. The clock deviation of the first node compared to the second node can be the difference in clock time between the slave clock and the master clock. This clock deviation can be positive or negative.

[0104] For example, as shown in Figure 1, the first node can be considered as one of the sensors such as radar 104, camera 105, and integrated positioning system 106. The second node can be considered as the cockpit controller 102, which serves as the clock source for the entire vehicle domain and has a built-in GPS receiver to obtain the current time from GPS satellites.

[0105] S602: 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, the clock frequency deviation between the first node and the second node is obtained, and the third clock time of the data collected by the first node is obtained for the most recent time in the query business service history.

[0106] The clock frequency deviation between the first node and the second node may be a clock frequency deviation between the slave clock and the master clock.

[0107] The business service can be a service that periodically or irregularly obtains data collected by the first node, so as to provide corresponding business services based on the collected data. The third clock time when the business service most recently obtained the data collected by the first node is recorded. For example, each time the business service obtains data collected by the first node, the most recent timestamp of the data is recorded.

[0108] For example, as shown in Figure 1, the business service may be an autonomous driving service corresponding to the autonomous driving controller 103, which may periodically or irregularly obtain data collected by sensors such as the radar 104, the camera 105, and the combined positioning system 106. These data may have corresponding timestamps. This embodiment may query the timestamp (i.e., the third clock time) of the most recent data obtained by the autonomous driving service, such as the data collected by the radar 104.

[0109] S603: Analyze the clock frequency correction parameter corresponding to the clock frequency deviation, and the clock deviation correction value (or time deviation correction parameter, etc.) corresponding to the third clock time and the first clock time.

[0110] In this embodiment, the clock frequency deviation between the first and second nodes can be analyzed to obtain a clock frequency correction parameter corresponding to the clock frequency deviation. The clock frequency of the slave clock of the first node can then be adjusted based on the clock frequency correction parameter to achieve time synchronization with the master clock. Simultaneously, the clock deviation correction value corresponding to the third clock time and the first clock time can also be analyzed to further adjust the slave clock time.

[0111] S604: Correct the frequency and time of the slave clock of the first node toward the master clock according to the clock frequency correction parameter and the clock deviation correction value.

[0112] In this embodiment, the clock deviation is first obtained. Then, when the first clock time of the first node is later than the second clock time of the second node, the clock frequency deviation between the first node and the second node is obtained, and the third clock time of the data collected by the first node is queried in the business service history. Then, based on the first clock time, the third clock time, and the clock frequency deviation, the clock frequency correction parameter and the clock deviation correction value are determined, and then the slave clock of the first node is corrected. In this embodiment, the clock frequency deviation is obtained and processed to obtain the clock frequency correction parameter of the first node, thereby correcting the slave clock frequency of the first node to the master clock of the second node. On the other hand, by introducing the third clock time of the data collected by the first node in the history related to the business service (such as services in the field of autonomous driving) and adjusting the clock time of the first node according to the clock deviation correction value obtained by analysis, the clock time of the first node can be adjusted so that the clock time of the data collected by the first node is no earlier than the third clock time, thereby avoiding the occurrence of time jump, improving data timeliness, reducing abnormal exit of business service functions, and improving the user's business service experience.

[0113] Furthermore, in autonomous driving or other scene-related businesses, the requirements for time are relatively strict. The business here includes 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 collected at this moment is earlier than the time point obtained last time), it will cause the subsequent execution strategy to be unable to be judged. Therefore, in order to avoid this situation, it is necessary to obtain the third clock time of the data collected by the first node in the history of the business service when a clock deviation occurs, and obtain the clock deviation correction value, so that 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.

[0114] It should be noted that if the clocks of the two are synchronized only by adjusting the frequency of the slave clock or only adjusting the time deviation, the convergence process will be relatively slow, and the master and slave clocks cannot be synchronized quickly. Therefore, the best way is to combine the two, and adjust the clock deviation of the slave clock on the basis of frequency modulation, thereby avoiding the time jump caused by the slave clock being faster than the master clock, and by adjusting the time deviation, solving the time jump problem caused by "the acquired timestamp is earlier than the previously received data time", thereby improving the timeliness of the data. The above embodiment has been verified in real vehicles and the effect is significant.

[0115] Optionally, the above S603 may specifically include: performing calculations on the clock frequency currently used by the first node according to the clock frequency deviation to obtain a clock frequency correction parameter; and analyzing the clock deviation correction value by comparing the sum of the first clock time and the clock deviation with the third clock time.

[0116] In this embodiment, the clock frequency correction parameter is calculated based on the clock frequency deviation and the clock frequency currently used by the current first node. The correction parameter of the time deviation is determined by comparing the size relationship between the third clock time and the first clock time. Since the clock frequency deviation is obtained, the clock frequency currently used by the first node is also combined, so that the calculated clock frequency correction parameter can make the clock frequency of the first node closer to the clock frequency of the second node. At the same time, the third clock time of the data collected by the first node is obtained for the latest time related to the business service (such as services in the field of autonomous driving) and the clock time of the first node is adjusted according to the clock deviation correction value obtained by analysis, so that 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 jump.

[0117] Optionally, the above process of analyzing the clock deviation correction value by comparing the sum obtained by adding the first clock time and the clock deviation with the third clock time may specifically include: when the sum is greater than or equal to the third clock time, determining the clock deviation as the clock deviation correction value; and when the sum is less than the third clock time, subtracting the first clock time from the third clock time to obtain the clock deviation correction value.

[0118] For example, when the sum of the first clock time and the clock deviation is greater than or equal to the third clock time, the clock deviation is determined 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, the first clock time is subtracted from the third clock time to obtain the clock deviation correction value.

[0119] 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 after 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.

[0120] 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 the clock deviation correction value.

[0121] This embodiment also describes a scenario where, when clock deviation is determined, the first clock time of the first node is earlier than the second clock time of the second node. In this case, the slave clock time is less than the master clock time, and clock backslip does not occur. In this case, the clock deviation value can be used directly as the clock deviation correction value to adjust the clock time of the first node, preventing time backslip.

[0122] Specifically, in practical applications, we know that the purpose of time synchronization is to provide accurate time to upper-layer applications. For example, in an in-vehicle network, autonomous driving services need to collect data from various sensors at the same time. To prevent the autonomous driving service from detecting time jumps, each time the autonomous driving service calls gettime to obtain the current time, it needs to record this time and save it to a global variable last_time. When calling the adjtime interface to adjust the time offset, the time offset cannot be directly used as a parameter. The offset needs to be transformed. Assuming that a clock offset correction value is defined as new_offset, the specific transformation rules are as follows:

[0123] When offset>=0, set new_offset=offset. In this case, the first clock time of the first node is not later than the second clock time of the second node, and the clock offset value offset is used as the clock offset correction value new_offset.

[0124] When offset < 0, it is necessary to read the current time again, current_time = gettime(), and then compare the values of current_time and last_time. At this time, that is, the first clock time of the first node is later than the second clock time of the second node, and it is necessary to obtain the third clock time current_time.

[0125] If current_time + offset >= last_time, set new_offset = offset;

[0126] If current_time + offset < last_time, set new_offset = last_time - current_time;

[0127] Finally, call the adjtime(new_offset) interface to set the time deviation of the slave clock.

[0128] Optionally, obtaining the clock frequency deviation between the first node and the second node includes: obtaining the first interval time between the k-th message and the (k - n)-th message received by the first node from the second node; dividing the second interval time by the first interval time to obtain the clock frequency ratio between the second node and the first node as the clock frequency deviation, where the second interval time is the interval time between the k-th message and the (k - n)-th message sent by the second node to the first node, where 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.

[0129] In this embodiment, first, the slave node obtains the first time interval between the k-th message and the (k - n)-th message sent by the master node. Further, the slave node obtains the second time interval between the k-th message and the (k - n)-th message sent by the master node. Dividing the second interval time by the first interval time gives the clock frequency ratio. This clock frequency ratio is used as the clock frequency deviation between the two. Here, 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. By calculating the clock frequency deviation between the two in the above manner, it is convenient to obtain the clock frequency correction parameter subsequently, so as to adjust the clock frequency of the slave node.

[0130] For example, when n=1, in this case, the master node sends two messages to the slave node continuously. The slave node first uses the time interval between the two messages received as the first time interval, and then obtains the time interval between the two messages sent by the master node. The clock frequency ratio obtained by dividing the second interval by the first interval is used as the clock frequency deviation between the two. It should be emphasized here that, ideally, when the frequencies of the master node and the slave node are consistent, the first interval may be equal to the second interval, so that the clock frequency ratio is 1. However, in actual situations, since the clock frequencies of the two are inconsistent, that is, the first interval is not equal to the second interval, the frequency ratio of the two can be calculated in the above way and used as the clock frequency deviation between the two, which is convenient for subsequent acquisition of clock frequency correction parameters.

[0131] When n is not 1, this situation means that the method of calculating the clock frequency ratio may not be through two consecutive messages. For example, the time interval between the kth and k-4th messages (k>4) received by the slave node is taken as the first time interval, and the time interval between the kth and k-4th messages sent by the master node is taken as the second time interval. The clock frequency ratio of the two can also be obtained.

[0132] Among them, the slave node obtains the second time interval between the kth message and the knth message sent by the master node by the master node sending a message containing the second time interval to the slave node so that the slave node can obtain the information. The specific method is not limited here.

[0133] Figure 8 illustrates the process of obtaining the clock frequency deviation between a first node (slave node) and a second node (master node). In the figure, the master clock sends a Sync(k) message to the slave clock at time tm(k), and the slave clock receives the Sync(k) message at time ts(k). Furthermore, the master clock sends a Sync(k+1) message to the slave clock at time tm(k+1), and the slave clock receives the Sync(k+1) message at time ts(k+1). Therefore, the first interval duration is ts(k+1)-ts(k); the second interval duration is tm(k+1)-tm(k). The clock frequency ratio is [tm(k+1)-tm(k)] / [ts(k+1)-ts(k)], which is used as the clock frequency deviation.

[0134] Furthermore, in some examples, the above-mentioned operation and processing of the clock frequency currently used by the first node according to the clock frequency deviation to obtain the clock frequency correction parameter may specifically include: multiplying the clock frequency ratio by the clock frequency currently used by the first node to obtain the clock frequency correction parameter.

[0135] This embodiment provides a method for obtaining a clock frequency correction parameter. The resulting clock frequency ratio is multiplied by the current clock frequency of the primary node to obtain the clock frequency correction parameter, which is then used to set the new frequency of the slave clock via the adjfreq interface. By combining the clock frequency ratio between the slave and master nodes and ultimately multiplying it by the slave's clock frequency, the resulting clock frequency correction parameter more closely matches the frequencies of both nodes, allowing the slave clock to gradually converge to the master clock frequency, improving data timeliness and accuracy.

[0136] Optionally, in some examples, S604 may specifically include: correcting the clock frequency of the slave clock to lower the frequency toward the clock frequency of the master clock according to the clock frequency correction parameter; and correcting the clock time of the slave clock to increase the time toward the clock time of the master clock according to the clock deviation correction value.

[0137] In this embodiment, correction involves aligning the slave clock's frequency and clock time with those of the master clock to improve and resolve the aforementioned time bounce issue. Because the clock frequency correction parameter incorporates the frequency ratio of the slave and master clocks, the calculation of the clock deviation correction value also incorporates a third clock time related to the service. Correcting the first node based on the clock frequency correction parameter and the clock deviation correction value ensures that the clock time of the second node is aligned, thereby improving data timeliness.

[0138] Optionally, obtaining the clock deviation of the first node compared to the second node includes: obtaining the link delay between the first node and the second node, and obtaining 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 in the message information interacted between the first node and the second node; subtracting 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 to the second node; wherein the message information includes the message sending time and the message receiving time when the first node interacts with the second node, and m is a positive integer.

[0139] Clock deviation refers to the difference between the master node clock and the slave node clock. It can be calculated by the send time of a message sent by the sender, the reception time of the message received by the receiver, and 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 send time of the mth message sent by the master node and the reception time of the mth message received by the slave node. Then, the sum of the link delay and the send time of the mth message sent by the master node is subtracted from the reception time of the mth message received by the slave node to obtain the clock deviation of the slave node compared to the master node.

[0140] As shown in FIG9 , a time synchronization method provided by this embodiment is shown. In this method, the hardware first sets the initial time through settime, calculates the link delay D, and the method for obtaining the link delay can be the same as the method described in the above embodiment, which will not be repeated here. Then, the frequency deviation ratio F and the clock deviation offset of the first node and the second node are calculated. It is worth noting that since clock synchronization is always in progress when the device is running, there is no restriction here that the frequency deviation ratio F must be calculated only when the clock deviation offset is less than 0 (the slave clock exceeds the master clock), but it is adjusted in real time. Then, the frequency deviation ratio is used as the clock frequency deviation, the clock frequency correction parameter new_freq is calculated, and the frequency is adjusted according to the clock frequency correction parameter new_freq, so that the slave clock gradually approaches the clock frequency of the master clock, thereby improving the timeliness and accuracy of the data.

[0141] On the other hand, regarding time offset adjustment, since clock synchronization is performed simultaneously with device operation, adjustment is not required only when the clock offset is less than 0. Furthermore, when obtaining the clock offset correction value, new_offset, the value is determined based on the value of offset. When offset is greater than or equal to 0, offset is used as the clock offset correction value, i.e., new_offset = offset. If offset is less than 0, the third clock time, current_time, of the most recently acquired data collected by the first node in the query service history is obtained and compared with the first clock time, last_time. If current_time + offset > = last_time, new_offset = offset; if not, new_offset is set to the maximum of last_time - current_time. Finally, the time offset is adjusted using the adjtime function (new_offset). This ensures that the clock time of the data collected by the first node when the service service obtains it again is no earlier than the third clock time, thus avoiding time backslides. This improves data timeliness, reduces abnormal service function exits, and enhances the user experience. The methods for other steps such as obtaining the frequency deviation ratio F and obtaining the clock deviation offset may refer to the methods provided in the above embodiments and will not be described in detail here.

[0142] As a specific implementation of the method shown in FIG. 2 to FIG. 6 , this embodiment provides a time synchronization device. As shown in FIG. 10 , the device includes: an acquisition module 701 , a processing unit 702 , a comparison unit 703 , and a synchronization unit 704 .

[0143] 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;

[0144] The processing unit 702 is configured to query the business service history to obtain a third clock time of the 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 based on the clock deviation;

[0145] 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;

[0146] The synchronization unit 704 is configured 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.

[0147] 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.

[0148] In a specific application scenario, the acquiring unit 701 is specifically configured to analyze message information exchanged between the first node and the second node each time to obtain the clock deviation.

[0149] 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.

[0150] 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 the 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.

[0151] 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; 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 adjustment, adjust the first clock time of the first node to the second clock time by increasing the time according to the clock deviation correction value.

[0152] 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 and the second node identifier to 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.

[0153] 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 the corresponding descriptions in Figures 2 to 6, which will not be repeated here.

[0154] As a specific implementation of the method shown in FIG. 7 to FIG. 9 , this embodiment provides another time synchronization device. As shown in FIG. 11 , the device includes: an acquisition unit 801 , a judgment unit 802 , a processing unit 803 , and a synchronization unit 804 .

[0155] An acquiring unit 801 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;

[0156] Processing unit 802 is configured to determine, based on the clock deviation, that a first clock time of the first node is later than a second clock time of the second node, obtain the clock frequency deviation between the first node and the second node, and query a business service history for a third clock time of the most recently acquired data collected by the first node;

[0157] A comparing unit 803 is configured to analyze a clock frequency correction parameter corresponding to the clock frequency deviation and a clock deviation correction value corresponding to the third clock time and the first clock time;

[0158] The synchronization unit 804 is configured to perform frequency and time correction on the slave clock of the first node toward the master clock according to the clock frequency correction parameter and the clock deviation correction value.

[0159] In a specific application scenario, the processing unit 802 is specifically configured to perform calculations on the clock frequency currently used by the first node according to the clock frequency deviation to obtain the clock frequency correction parameter; and to analyze the clock deviation correction value by comparing the sum obtained by adding the first clock time to the clock deviation with the third clock time.

[0160] In a specific application scenario, the comparison unit 803 is further configured to, when the sum is greater than or equal to the third clock time, determine the clock deviation as the clock deviation correction value; and when the sum is less than the third clock time, subtract the first clock time from the third clock time to obtain the clock deviation correction value.

[0161] In a specific application scenario, the acquisition unit 801 is further configured to obtain the first interval time between the first node receiving the kth message and the knth message sent by the second node; divide the second interval time by the first interval time to obtain the clock frequency ratio of the second node and the first node as the clock frequency deviation, and the second interval time is the interval time between the second node sending the kth message and the knth message to the first node, 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; and multiply the clock frequency ratio by the clock frequency currently used by the first node to obtain the clock frequency correction parameter.

[0162] In a specific application scenario, the synchronization unit 804 is further configured to correct the clock frequency of the slave clock to the clock frequency of the master clock according to the clock frequency correction parameter; and to correct the clock time of the slave clock to the clock time of the master clock according to the clock deviation correction value.

[0163] In a specific application scenario, the acquisition unit 801 is further configured to obtain the link delay between the first node and the second node in the message information interacted 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; 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 the message information includes the message sending time and the message receiving time when the first node interacts with the second node, and m is a positive integer.

[0164] In a specific application scenario, the acquisition unit 801 is further configured to determine the link delay through 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 the 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.

[0165] It should be noted that for other corresponding descriptions of the functional units involved in the time synchronization device provided in this embodiment, reference may be made to the corresponding descriptions in FIG. 7 to FIG. 9 , which will not be repeated here.

[0166] Based on the above methods shown in FIG. 2 to FIG. 9 , this 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 methods shown in FIG. 2 to FIG. 9 are implemented.

[0167] 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.), and includes 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.

[0168] Based on the above-mentioned methods shown in Figures 2 to 9, and the virtual device embodiments shown in Figures 10 or 11, in order to achieve the above-mentioned purposes, the embodiments of the present application also provide an electronic device that 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 implement the above-mentioned methods shown in Figures 2 to 9.

[0169] Optionally, the physical device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a Wi-Fi module, and the like. The user interface may include a display, an input unit such as a keyboard, and the like. Optional user interfaces may also include a USB interface, a card reader interface, and the like. The network interface may optionally include a standard wired interface, a wireless interface (such as a Wi-Fi interface), and the like.

[0170] Those skilled in the art will understand 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 component arrangements.

[0171] 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 physical device, supporting the execution of information processing programs and other software and / or programs. The network communication module is used to enable communication between components within the storage medium, as well as with other hardware and software within the physical information processing device.

[0172] Based on the above electronic device, an embodiment of the present application further provides a vehicle, which may specifically include: the device shown in Figure 10 or Figure 11 or the above electronic device. The vehicle may specifically be a new energy vehicle or a traditional vehicle.

[0173] 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 a necessary general hardware platform, or by hardware. By introducing the clock time (third clock time) of the latest historical data collected by the first node related to the business service (such as services in the field of autonomous driving) 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 can be obtained by the business service again 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.

[0174] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any 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 that includes 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 presence of other identical elements in the process, method, article or device that includes the elements.

[0175] The foregoing is merely a list of specific embodiments of the present application, intended to enable those skilled in the art to understand and implement the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments described herein, but is intended to conform to the broadest scope consistent with the principles and novel features of the present application.

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; 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. time; tc represents the sending time of the message containing tb information fed back by the second node to the first node, and td represents the receiving time of the message containing tb information received by the first node.

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 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 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, the clock frequency deviation between the first node and the second node is obtained, and the third clock time of the data collected by the first node is most recently obtained in the business service history; analyzing a clock frequency correction parameter corresponding to the clock frequency deviation and a clock deviation correction value corresponding to the third clock time and the first clock time; According to the clock frequency correction parameter and the clock deviation correction value, the frequency and time of the slave clock of the first node are corrected toward the master clock.

9. The method according to claim 8, characterized in that The analyzing the clock frequency correction parameter corresponding to the clock frequency deviation and the clock deviation correction value corresponding to the third clock time and the first clock time includes: Performing calculation processing on the clock frequency currently used by the first node according to the clock frequency deviation to obtain the clock frequency correction parameter; and, The clock deviation correction value is analyzed by comparing a sum of the first clock time and the clock deviation with the third clock time.

10. The method according to claim 9, characterized in that The step of comparing the sum of the first clock time and the clock deviation with the third clock time to analyze the clock deviation correction value comprises: In a case where the sum is greater than or equal to the third clock time, determining the clock deviation as the clock deviation correction value; When the sum 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.

11. The method according to claim 9, characterized in that The obtaining of the clock frequency deviation between the first node and the second node includes: Obtaining a first interval time between the first node receiving a kth message and a knth message sent by the second node; Dividing a second interval by the first interval to obtain a clock frequency ratio between the second node and the first node as the clock frequency deviation, the second interval being an interval between the second node sending the kth message and the knth message to the first node, where 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; The step of performing calculation processing on the clock frequency currently used by the first node according to the clock frequency deviation to obtain the clock frequency correction parameter includes: The clock frequency correction parameter is obtained by multiplying the clock frequency ratio by the clock frequency currently used by the first node.

12. The method according to claim 11, characterized in that The correcting the frequency and time of the slave clock of the first node to the master clock according to the clock frequency correction parameter and the clock deviation correction value includes: According to the clock frequency correction parameter, the clock frequency of the slave clock is corrected to be lowered toward the clock frequency of the master clock; and, According to the clock deviation correction value, the clock time of the slave clock is corrected to the clock time of the master clock by adding time.

13. The method according to claim 12, characterized in that The obtaining of the clock deviation of the first node compared with the second node includes: In the message information exchanged 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 then added to the Subtracting the reception time of the mth message received by a node to obtain a clock deviation of the first node compared with the second node; The message information includes a message sending time and a message receiving time when the first node interacts with the second node, and m is a positive integer.

14. The method according to claim 13, 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.

15. 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.

16. 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 judgment unit, configured to determine, based on the clock deviation, that a first clock time of the first node is later than a second clock time of the second node, obtain the clock frequency deviation between the first node and the second node, and query the business service history for the third clock time of the data collected by the first node that was most recently obtained; a processing unit, configured to analyze a clock frequency correction parameter corresponding to the clock frequency deviation, and a clock deviation correction value corresponding to the third clock time and the first clock time; The synchronization unit is used to correct the frequency and time of the slave clock of the first node to the master clock according to the clock frequency correction parameter and the clock deviation correction value.

17. 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 14 is implemented.

18. A vehicle, characterized in that: include: The device according to any one of claims 15 to 16, or the electronic device according to claim 17.

Citation Information

Patent Citations

  • Clock synchronization error compensation method of FC network

    CN103684728A

  • Method and device for dynamically calibrating real-time clock

    CN114489239A

  • Synchronizing a slave timer with a master timer

    DE102020202690B3

  • Method for time synchronization of a plurality of auxiliary devices of autonomous vehicle, vehicle, computer device, and storage medium

    WO2021232260A1

  • Time synchronization method, network device, and storage medium

    WO2022257447A1

Cited By

  • Clock synchronization method of time sensitive network

    CN119743224A