A time synchronization method, device, equipment and storage medium

By adopting distributed mounting and time synchronization message communication methods in the sensor system, the problems of complex sensor wiring and large load of mounting objects in the sensor system are solved, and efficient time synchronization of sensor data is achieved.

CN115441975BActive Publication Date: 2024-10-29BEIJING ORION STAR TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110614891.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-02
Publication Date
2024-10-29
Estimated Expiration
2041-06-02

AI Technical Summary

Technical Problem

In the existing technology, in order to ensure the time synchronization between sensors in the sensor system, all sensors need to be mounted on the same mounting object, which results in complex sensor wiring, difficulty in expansion, and a heavy load on the mounting object.

Method used

By introducing a distributed method of mounting sensors in the sensor system, the server and the client communicate with time synchronization messages, calculate and determine the system time difference, and add timestamps to the collected data of the sensors mounted on the client based on the time difference. , to achieve time synchronization of each sensor.

Benefits of technology

It simplifies the wiring of sensors, improves the scalability of the system, reduces the load on mounted objects, and ensures that the timestamp of data collected by each sensor is consistent with the server system time, improving time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115441975B_ABST
    Figure CN115441975B_ABST
Patent Text Reader

Abstract

The present application discloses a time synchronization method, apparatus, device and storage medium, and the time synchronization method is applied to a sensor system including a server and at least one client. In the sensor system, the server and each client mount multiple sensors in a distributed manner to simplify the wiring of the sensors, improve the scalability of the sensors, and reduce the load of the mounted objects, and the server uses its own system time to add a timestamp to the collected data of the sensors mounted by itself. In the time synchronization method, the client communicates with the server to determine the system time difference between itself and the server, and adds a timestamp to the collected data of the sensors mounted by itself based on the system time difference to achieve time synchronization of the collected data of each sensor. In this way, it is equivalent to adding a timestamp to the collected data of each sensor using the system time of the server as the clock source, so the time synchronization between the collected data of each sensor is better.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a time synchronization method, device, equipment and storage medium. Background Art

[0002] Generally, a sensor system includes multiple sensors, and the collected data of these multiple sensors need to be fused in time. In order to ensure the accuracy of the fused data, it is required that these multiple sensors have good time synchronization.

[0003] In the related art, in order to ensure good time synchronization between sensors in the sensor system, all sensors are mounted on the same mounting object such as a controller, and then the system time of the mounting object is used to add a timestamp to the collected data of all sensors. In this way, although the time consistency of the collected data of each sensor can be guaranteed, the wiring of the sensor is relatively complicated, difficult to expand, and the load of the mounting object is also relatively large. Summary of the invention

[0004] The embodiments of the present application provide a time synchronization method, apparatus, device and storage medium to solve the problem in the related art that in order to ensure the time synchronization between sensors in the sensor system, each sensor is mounted on the same mounting object, resulting in complex sensor wiring, difficulty in expansion, and a heavy load on the mounting object.

[0005] In a first aspect, an embodiment of the present application provides a time synchronization method, which is applied to a sensor system, wherein the sensor system includes a server and at least one client, wherein the server and each client are distributedly mounted with multiple sensors, and the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the method is applied to the client, including:

[0006] Sending at least one first time synchronization message to the server;

[0007] Receive a response message to each first time synchronization message sent by the server, wherein the response message includes a first time parameter of the first time synchronization message, and the first time parameter includes a time when the server receives the first time synchronization message and a time when the server sends a response message to the first time synchronization message;

[0008] Calculating a system time difference between the client and the server according to a time parameter of each first time synchronization message, wherein the time parameter of each first time synchronization message includes a first time parameter and a second time parameter, and the second time parameter includes a time when the client sends the first time synchronization message and a time when the client receives a response message to the first time synchronization message;

[0009] Based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

[0010] In some possible implementations, calculating the system time difference between the client and the server according to the time parameter of each first time synchronization message includes:

[0011] Calculate, according to the time parameter of each first time synchronization message, a total transmission delay from when the client sends the first time synchronization message to when the client receives a response message to the first time synchronization message;

[0012] Selecting a target transmission delay from each total transmission delay;

[0013] The first time synchronization message corresponding to the target transmission delay is used as the target time synchronization message, and the system time difference between the client and the server is calculated according to the time parameter of the target time synchronization message.

[0014] In some possible implementations, selecting a target transmission delay from each total transmission delay includes:

[0015] The minimum total transmission delay is selected from each total transmission delay as the target transmission delay.

[0016] In some possible implementations, before selecting the target transmission delay from the total transmission delays, the method further includes:

[0017] Calculate the average value of each total transmission delay;

[0018] It is determined that the average value is less than a set transmission delay, where the set transmission delay is determined according to a communication bus between the client and the server.

[0019] In some possible implementations, the system time difference t' between the client and the server is calculated according to the following formula:

[0020]

[0021] Among them, T1' represents the time when the client sends the target time synchronization message, T2' represents the time when the server receives the target time synchronization message, T3' represents the time when the server sends the response message of the target time synchronization message, and T4' represents the time when the client receives the response message of the target time synchronization message.

[0022] In a second aspect, an embodiment of the present application provides a time synchronization method, which is applied to a sensor system, wherein the sensor system includes a server and at least one client, wherein the server and each client are distributedly mounted with multiple sensors, and the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the method is applied to the client, including:

[0023] Sending a second time synchronization message to the server, where the second time synchronization message includes the time when the client sends the second time synchronization message, and receiving a system time difference between the client and the server sent by the server, where the system time difference is calculated by the server according to the time when the second time synchronization message is received and the time when the client sends the second time synchronization message; or,

[0024] Receive a third time synchronization message sent by the server, where the third time synchronization message includes the time when the server sends the third time synchronization message, and calculate the system time difference between the client and the server according to the time when the third time synchronization message is received and the time when the server sends the third time synchronization message;

[0025] Based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

[0026] In a third aspect, an embodiment of the present application provides a sensor system, the sensor system comprising a server and at least one client, the server and each client mounting a plurality of sensors in a distributed manner, wherein:

[0027] The server adds a timestamp to the collected data of the sensor mounted on the server using the system time of the server;

[0028] Each client uses any of the above-mentioned time synchronization methods to add a timestamp to the collected data of the sensor mounted on the client.

[0029] In a fourth aspect, an embodiment of the present application provides a simultaneous positioning and mapping device, including the above-mentioned sensor system, and the collected data of each sensor is used for simultaneous positioning and mapping.

[0030] In a fifth aspect, an embodiment of the present application provides a time synchronization device, which is applied to a sensor system, wherein the sensor system includes a server and at least one client, wherein the server and each client are distributedly mounted with multiple sensors, and the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the device is applied to the client, including:

[0031] A sending module, used to send at least one first time synchronization message to the server;

[0032] A receiving module, used to receive a response message to each first time synchronization message sent by the server, wherein the response message includes a first time parameter of the first time synchronization message, and the first time parameter includes a time when the server receives the first time synchronization message and a time when the server sends a response message to the first time synchronization message;

[0033] A time difference determination module, configured to calculate the system time difference between the client and the server according to the time parameters of each first time synchronization message, wherein the time parameters of each first time synchronization message include a first time parameter and a second time parameter, and the second time parameter includes the time when the client sends the first time synchronization message and the time when the client receives a response message to the first time synchronization message;

[0034] The adding module is used to add a timestamp to the collected data of the sensor mounted on the client based on the system time difference, so as to achieve time synchronization of the collected data of each sensor.

[0035] In some possible implementations, the time difference determination module is specifically used to:

[0036] Calculate, according to the time parameter of each first time synchronization message, a total transmission delay from when the client sends the first time synchronization message to when the client receives a response message to the first time synchronization message;

[0037] Selecting a target transmission delay from each total transmission delay;

[0038] The first time synchronization message corresponding to the target transmission delay is used as the target time synchronization message, and the system time difference between the client and the server is calculated according to the time parameter of the target time synchronization message.

[0039] In some possible implementations, the time difference determination module is specifically used to:

[0040] The minimum total transmission delay is selected from each total transmission delay as the target transmission delay.

[0041] In some possible implementations, the time difference determination module is further used to:

[0042] Before selecting a target transmission delay from the total transmission delays, calculating an average value of the total transmission delays;

[0043] It is determined that the average value is less than a set transmission delay, where the set transmission delay is determined according to a communication bus between the client and the server.

[0044] In some possible implementations, the time difference determination module is specifically configured to calculate the system time difference t' between the client and the server according to the following formula:

[0045]

[0046] Among them, T1' represents the time when the client sends the target time synchronization message, T2' represents the time when the server receives the target time synchronization message, T3' represents the time when the server sends the response message of the target time synchronization message, and T4' represents the time when the client receives the response message of the target time synchronization message.

[0047] In a sixth aspect, an embodiment of the present application provides a time synchronization device, which is applied to a sensor system, wherein the sensor system includes a server and at least one client, wherein the server and each client are distributedly mounted with multiple sensors, and the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the device is applied to the client, including:

[0048] A time difference determination module, used for sending a second time synchronization message to the server, wherein the second time synchronization message includes the time when the client sends the second time synchronization message, and receiving a system time difference between the client and the server sent by the server, wherein the system time difference is calculated by the server according to the time when the second time synchronization message is received and the time when the client sends the second time synchronization message; or, used for receiving a third time synchronization message sent by the server, wherein the third time synchronization message includes the time when the server sends the third time synchronization message, and calculating the system time difference between the client and the server according to the time when the third time synchronization message is received and the time when the server sends the third time synchronization message;

[0049] The adding module is used to add a timestamp to the collected data of the sensor mounted on the client based on the system time difference, so as to achieve time synchronization of the collected data of each sensor.

[0050] In a seventh aspect, an embodiment of the present application provides a client, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein:

[0051] The memory stores instructions that can be executed by at least one processor. The instructions are executed by the at least one processor so that the at least one processor can perform the above-mentioned time synchronization method.

[0052] In an eighth aspect, an embodiment of the present application provides a storage medium. When the instructions in the storage medium are executed by a processor of a client, the client is able to execute the above-mentioned time synchronization method.

[0053] The time synchronization method in the embodiment of the present application is applied to a sensor system including a server and at least one client. In the sensor system, the server and each client mount multiple sensors in a distributed manner, instead of mounting all sensors on the same mounting object, so as to simplify the wiring of the sensor, improve the scalability of the sensor, and reduce the load of the mounting object, and the server uses its own system time to add a timestamp to the collected data of the sensor mounted by itself. In the time synchronization method, the client communicates with the server to determine the system time difference between itself and the server, and adds a timestamp to the collected data of the sensor mounted by itself based on the system time difference to achieve time synchronization of the collected data of each sensor. In this way, the timestamps of the collected data of each sensor can be kept consistent with the system time of the server, which is equivalent to adding a timestamp to the collected data of each sensor using the system time of the server as the clock source, so the time synchronization between the collected data of each sensor is better. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0055] Figure 1 A schematic diagram of the structure of a sensor system provided in an embodiment of the present application;

[0056] Figure 2 A flowchart of a time synchronization method provided in an embodiment of the present application;

[0057] Figure 3 A schematic diagram of a process of sending messages between a client and a server provided in an embodiment of the present application;

[0058] Figure 4 A flowchart for determining the system time difference between a client and a server provided in an embodiment of the present application;

[0059] Figure 5A flowchart of another time synchronization method provided in an embodiment of the present application;

[0060] Figure 6 A flowchart of another time synchronization method provided in an embodiment of the present application;

[0061] Figure 7 A schematic diagram of the structure of a time synchronization device provided in an embodiment of the present application;

[0062] Figure 8 A schematic diagram of the structure of a time synchronization device provided in an embodiment of the present application;

[0063] Fig. 9 A schematic diagram of the hardware structure of a client for implementing a time synchronization method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0064] In order to solve the problem in the related art that in order to ensure the time synchronization between sensors in a sensor system, each sensor is mounted on the same mounting object, which results in complex sensor wiring, difficulty in expansion, and a heavy load on the mounting object, the embodiments of the present application provide a time synchronization method, apparatus, device and storage medium.

[0065] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0066] It should be noted that the terms "first", "second", "third", etc. in the specification, claims, and drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0067] Figure 1 A structural diagram of a sensor system provided in an embodiment of the present application includes a server, clients client1, client2 and client3. The server and each client may be connected via a communication bus or wirelessly.

[0068] exist Figure 1In the sensor system shown, the server and each client mounts each sensor in a distributed manner, and the server uses its own system time to add a timestamp to the collected data of the sensor mounted on it. The client can communicate with the server to determine the system time difference between itself and the server, and use the system time difference between itself and the server and its own system time to add a timestamp to the collected data of the sensor mounted on it, so as to achieve time synchronization of the collected data of each sensor.

[0069] In this way, the timestamp of the collected data of each sensor can be kept consistent with the system time of the server, which is equivalent to adding a timestamp to the collected data of each sensor using the system time of the server as the clock source, so the time synchronization between the collected data of each sensor is better.

[0070] It should be noted that the server can be any client selected from the clients, and the mounting conditions of the sensors in the server and the clients can be determined by the technicians according to actual needs without limiting the mounting conditions.

[0071] The time synchronization method provided in the embodiment of the present application is introduced below with reference to the accompanying drawings.

[0072] Figure 2 A flowchart of a time synchronization method provided in an embodiment of the present application, the method is applied to Figure 1 In a client, the method includes the following steps.

[0073] In step S201, the client sends at least one first time synchronization message to the server.

[0074] In step S202, a response message for each first time synchronization message sent by the server is received, wherein the response message includes a first time parameter of the first time synchronization message, and the first time parameter includes the time when the server receives the first time synchronization message and the time when the server sends the response message to the first time synchronization message.

[0075] In step S203, the system time difference between the client and the server is calculated based on the time parameters of each first time synchronization message, wherein the time parameters of each first time synchronization message include a first time parameter and a second time parameter, the second time parameter including the time when the client sends the first time synchronization message, and the time when the client receives a response message to the first time synchronization message.

[0076] In specific implementation, it can be based on Figure 3 The process shown calculates the system time difference between the client and the server, and the process includes the following steps.

[0077] In step S301a, the total transmission delay from when the client sends the first time synchronization message to when the client receives a response message to the first time synchronization message is calculated according to the time parameter of each first time synchronization message.

[0078] See also Figure 4 , assuming that the time when the client sends a first time synchronization message is T1, the time when the server receives the first time synchronization message is T2, the time when the server sends a response message of the first time synchronization message is T3, and the time when the client receives the response message of the first time synchronization message is T4.

[0079] Let d1 be the transmission delay of the first time synchronization message from the client to the server, d2 be the transmission delay of the response message of the first time synchronization message from the server to the client, t be the system time deviation between the client and the server, and d be the total transmission delay from when the client sends the first time synchronization message to when the client receives the response message of the first time synchronization message, then:

[0080]

[0081] According to the above formula, d and t can be obtained as:

[0082]

[0083] In step S302a, the average value of each total transmission delay is calculated.

[0084] In step S303a, it is determined whether the average value of each total transmission delay is less than the set transmission delay. If not, the process proceeds to S304a. If yes, the process proceeds to S305a.

[0085] The transmission delay is set according to a specific communication method between the client and the server, and the transmission delay is set to represent the delay of the communication method between the client and the server under normal circumstances.

[0086] In this embodiment, the server and each client are connected via a communication bus, and the transmission delay is set according to the specific communication bus between the client and the server. The transmission delay is set to characterize the delay of the communication bus between the client and the server under normal circumstances.

[0087] Generally, different types of communication buses, such as Universal Serial Bus (USB) and Controller Area Network (CAN) bus, have different delays, but for the same type of communication bus, d1 and d2 are basically the same under normal circumstances.

[0088] In step S304a, the calculation of the system time difference between the client and the server is stopped, and an alarm message indicating that an abnormality has occurred in the transmission between the client and the server is sent.

[0089] In step S305a, a target transmission delay is selected from each total transmission delay.

[0090] According to the above calculation formula of t, the calculation error of t lies in the two values ​​of d1 and d2. If d1≈d2, there is a simplified formula:

[0091]

[0092] Since the value range of d1 and d2 is both (0, d), the maximum error of t calculated using the simplified formula above is d / 2.

[0093] Because the set transmission delay can represent the delay of the communication bus between the client and the server under normal circumstances, when the average value of each total transmission delay is less than the set transmission delay, it can be considered that the communication bus between the current client and the server is normal and d1≈d2. Subsequently, the simplified formula can be used to calculate the system time difference between the client and the server.

[0094] Since the maximum error when calculating t using the simplified formula is d / 2, the minimum total transmission delay can be selected from the total transmission delays as the target transmission delay in step S305a to minimize the error of the system time difference between the client and the server that is finally calculated.

[0095] In step S306a, the first time synchronization message corresponding to the target transmission delay is used as the target time synchronization message, and the system time difference between the client and the server is calculated according to the time parameter of the target time synchronization message.

[0096] That is, the final calculated system time difference t' between the client and the server is:

[0097]

[0098] Among them, T1' is the time when the client sends the target time synchronization message, T2' is the time when the server receives the target time synchronization message, T3' is the time when the server sends the response message of the target time synchronization message, and T4' is the time when the client receives the response message of the target time synchronization message.

[0099] In step S204, based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

[0100] For example, the client sums the system time difference and its own system time, and uses the summed time to add a timestamp to the collected data of the sensor mounted on itself, so that the timestamp added by the client to the collected data of the sensor is also based on the system time of the server.

[0101] In this time synchronization method, the influence of the communication bus delay on the system time difference between the client and the server is taken into account, so the accuracy of the system time difference finally determined is relatively high, which can further improve the time synchronization of the collected data of each sensor.

[0102] Figure 5 A flowchart of another time synchronization method provided in an embodiment of the present application, the method is applied to Figure 1 In the client, the method includes the following steps.

[0103] In step S501, the client sends a second time synchronization message to the server, wherein the second time synchronization message includes the time when the client sends the second time synchronization message.

[0104] In step S502, a system time difference between the client and the server is received from the server, wherein the system time difference is calculated by the server according to the time when the second time synchronization message is received and the time when the second time synchronization message is sent by the client.

[0105] For example, the server calculates the time difference between the time when the second time synchronization message is received and the time when the client sends the second time synchronization message, and obtains the system time difference between the client and the server.

[0106] In step S503, based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

[0107] For example, the client sums the system time difference and its own system time, and uses the summed time to add a timestamp to the collected data of the sensor mounted on itself, so that the timestamp added by the client to the collected data of the sensor is also based on the system time of the server.

[0108] See also Figure 4 It can be seen that this time synchronization method is equivalent to the system time difference between the client and the server calculated by T2-T1. When the transmission delay of the communication bus between the client and the server is relatively small, the calculation of this time synchronization method is relatively simple and the error will not be too large.

[0109] Figure 6 A flowchart of another time synchronization method provided in an embodiment of the present application, the method is applied to Figure 1In the client, the method includes the following steps.

[0110] In step S601, the client receives a third time synchronization message sent by the server, wherein the third time synchronization message includes the time when the server sends the third time synchronization message.

[0111] In step S602, the system time difference between the client and the server is calculated according to the time when the third time synchronization message is received and the time when the server sends the third time synchronization message.

[0112] For example, the time difference between the time when the third time synchronization message is received and the time when the server sends the third time synchronization message is calculated to obtain the system time difference between the client and the server.

[0113] In step S603, based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

[0114] For example, the client sums the system time difference and its own system time, and uses the summed time to add a timestamp to the collected data of the sensor mounted on itself, so that the timestamp added by the client to the collected data of the sensor is also based on the system time of the server.

[0115] See also Figure 4 It can be seen that this time synchronization method is equivalent to the system time difference between the client and the server calculated by T4-T3. Similarly, when the transmission delay of the communication bus between the client and the server is relatively small, the calculation of this time synchronization method is relatively simple and the error will not be too large.

[0116] The first time synchronization method mentioned above has higher accuracy, and the latter two time synchronization methods are relatively simple. The specific time synchronization method to be used can be determined by technical personnel based on actual needs.

[0117] In addition, it should be noted that in the embodiments of the present application, no matter which time synchronization method is used, the purpose of transmitting messages between the client and the server is to calculate the system time difference between the client and the server, rather than to adjust the client time to be consistent with the server. Therefore, the server does not need to synchronize time with the client at a high frequency (i.e., send time synchronization messages), such as once every 3 nanoseconds. Instead, the client can synchronize time with the server at a low frequency, such as once every minute, to save the bandwidth and load of the sensor system.

[0118] The embodiment of the present application further provides a sensor system, including a server and at least one client, wherein the server and each client are distributedly mounted with multiple sensors, wherein:

[0119] The server uses the server's system time to add a timestamp to the collected data of the sensor mounted on the server;

[0120] Each client uses any of the aforementioned time synchronization methods to add a timestamp to the collected data of the sensor mounted on the client.

[0121] In this way, each sensor in the sensor system adds a timestamp to the collected data based on the time of the server, so the time synchronization between the sensors is relatively good.

[0122] An embodiment of the present application also provides a synchronous positioning and mapping device, including the above-mentioned sensor system, and the collected data of each sensor in the sensor system is used for synchronous positioning and mapping.

[0123] The synchronous positioning and mapping device may be, but is not limited to, a robot.

[0124] In specific implementation, each client in the sensor system can communicate with the server to determine the system time difference between itself and the server, and use the system time difference between itself and the server and its own system time to add a timestamp to the collected data of the sensor mounted on itself. Only the preset client can obtain the collected data required for synchronous positioning and mapping, and perform synchronous positioning and mapping based on the timestamps of each collected data. In addition, the preset client can be all clients or some clients, and this application does not limit this.

[0125] In actual applications, the server and each client have many sensors mounted on them, and the data collected by each sensor is relatively comprehensive. However, the sensor data collected by a client for synchronous positioning and mapping at different times is different. Therefore, the client may only obtain the collected data required for synchronous positioning and mapping from itself at certain times, obtain the collected data required for synchronous positioning and mapping from itself and other clients at certain times, and obtain the collected data required for synchronous positioning and mapping from itself, the server and other clients at certain times.

[0126] In addition, it should be noted that when a client needs to obtain collected data from another client, it can communicate with the other client directly to obtain the corresponding collected data, or communicate with the other client through a server to obtain the corresponding collected data. This application does not limit this.

[0127] When the method provided in the embodiments of the present application is implemented by software or hardware or a combination of software and hardware, the client may include multiple functional modules, and each functional module may include software, hardware or a combination thereof.

[0128] Based on the same inventive concept, Figure 7 A structural diagram of a time synchronization device provided in an embodiment of the present application includes a sending module 701, a receiving module 702, a time difference determination module 703, and an adding module 704.

[0129] The sending module 701 is used to send at least one first time synchronization message to the server;

[0130] A receiving module 702 is configured to receive a response message to each first time synchronization message sent by the server, wherein the response message includes a first time parameter of the first time synchronization message, and the first time parameter includes a time when the server receives the first time synchronization message and a time when the server sends a response message to the first time synchronization message;

[0131] A time difference determination module 703 is used to calculate the system time difference between the client and the server according to the time parameters of each first time synchronization message, wherein the time parameters of each first time synchronization message include a first time parameter and a second time parameter, and the second time parameter includes the time when the client sends the first time synchronization message and the time when the client receives a response message of the first time synchronization message;

[0132] The adding module 704 is used to add a timestamp to the collected data of the sensor mounted on the client based on the system time difference, so as to achieve time synchronization of the collected data of each sensor.

[0133] In some possible implementations, the time difference determination module 703 is specifically configured to:

[0134] Calculate, according to the time parameter of each first time synchronization message, a total transmission delay from when the client sends the first time synchronization message to when the client receives a response message to the first time synchronization message;

[0135] Selecting a target transmission delay from each total transmission delay;

[0136] The first time synchronization message corresponding to the target transmission delay is used as the target time synchronization message, and the system time difference between the client and the server is calculated according to the time parameter of the target time synchronization message.

[0137] In some possible implementations, the time difference determination module 703 is specifically configured to:

[0138] The minimum total transmission delay is selected from each total transmission delay as the target transmission delay.

[0139] In some possible implementations, the time difference determination module 703 is further configured to:

[0140] Before selecting a target transmission delay from the total transmission delays, calculating an average value of the total transmission delays;

[0141] It is determined that the average value is less than a set transmission delay, where the set transmission delay is determined according to a communication bus between the client and the server.

[0142] In some possible implementations, the time difference determination module 703 is specifically configured to calculate the system time difference t' between the client and the server according to the following formula:

[0143]

[0144] Among them, T1' represents the time when the client sends the target time synchronization message, T2' represents the time when the server receives the target time synchronization message, T3' represents the time when the server sends the response message of the target time synchronization message, and T4' represents the time when the client receives the response message of the target time synchronization message.

[0145] Based on the same inventive concept, Figure 8 A structural diagram of another time synchronization device provided in an embodiment of the present application includes a time difference determination module 801 and an adding module 802.

[0146] A time difference determination module 801 is used to send a second time synchronization message to the server, where the second time synchronization message includes the time when the client sends the second time synchronization message, and receive a system time difference between the client and the server sent by the server, where the system time difference is calculated by the server according to the time when the second time synchronization message is received and the time when the client sends the second time synchronization message; or, to receive a third time synchronization message sent by the server, where the third time synchronization message includes the time when the server sends the third time synchronization message, and calculate the system time difference between the client and the server according to the time when the third time synchronization message is received and the time when the server sends the third time synchronization message;

[0147] The adding module 802 is used to add a timestamp to the collected data of the sensor mounted on the client based on the system time difference, so as to achieve time synchronization of the collected data of each sensor.

[0148] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional modules in the embodiments of the present application may be integrated in a processor, or may exist physically separately, or two or more modules may be integrated in one module. The coupling between the modules may be achieved through some interfaces, which are usually electrical communication interfaces, but it is not excluded that they may be mechanical interfaces or other forms of interfaces. Therefore, the modules described as separate components may or may not be physically separated, and may be located in one place or distributed to different locations of the same or different devices. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0149] Fig. 9 A schematic diagram of the structure of a client provided in an embodiment of the present application, the client includes a transceiver 901 and a physical device such as a processor 902, wherein the processor 902 can be a central processing unit (CPU), a microprocessor, a dedicated integrated circuit, a programmable logic circuit, a large-scale integrated circuit, or a digital processing unit, etc. The transceiver 901 is used for data transmission and reception between the client and other devices.

[0150] The client may also include a memory 903 for storing software instructions executed by the processor 902, and of course, some other data required by the client, such as identification information of the client, encryption information of the client, user data, etc. The memory 903 may be a volatile memory (Volatile Memory), such as a random access memory (Random-Access Memory, RAM); the memory 903 may also be a non-volatile memory (Non-Volatile Memory), such as a read-only memory (Read-Only Memory, ROM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, HDD) or a solid-state drive (Solid-State Drive, SSD), or the memory 903 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 903 may be a combination of the above memories.

[0151] The specific connection medium between the processor 902, the memory 903 and the transceiver 901 is not limited in the embodiment of the present application. Fig. 9 In the example, the memory 903, the processor 902 and the transceiver 901 are connected via the bus 904. Fig. 9The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0152] The processor 902 can be dedicated hardware or a processor that runs software. When the processor 902 can run software, the processor 902 reads the software instructions stored in the memory 903 and, driven by the software instructions, executes any time synchronization method involved in the aforementioned embodiments.

[0153] An embodiment of the present application further provides a storage medium. When instructions in the storage medium are executed by a processor of a client, the client can execute any time synchronization method involved in the aforementioned embodiments.

[0154] In some possible implementations, various aspects of any time synchronization method provided in the present application may also be implemented in the form of a program product, which includes a program code. When the program product is run on a client, the program code is used to enable the client to execute any time synchronization method involved in the aforementioned embodiments.

[0155] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0156] The program product for time synchronization in the embodiment of the present application may adopt a CD-ROM and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0157] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0158] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.

[0159] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network such as a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0160] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0161] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0162] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0163] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0164] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0165] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0166] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0167] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A time synchronization method, applied to a sensor system, characterized in that: The sensor system includes a server and at least one client, the server and the clients are connected via a communication bus, the server is a client selected from the clients, the server and the clients are distributedly mounted with multiple sensors to simplify sensor wiring, the collected data of the multiple sensors are used for synchronous positioning and mapping, the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the method is applied to the client, including: Sending at least one first time synchronization message to the server; Receive a response message to each first time synchronization message sent by the server, wherein the response message includes a first time parameter of the first time synchronization message, and the first time parameter includes a time when the server receives the first time synchronization message and a time when the server sends a response message to the first time synchronization message; Calculating a system time difference between the client and the server according to a time parameter of each first time synchronization message, wherein the time parameter of each first time synchronization message includes a first time parameter and a second time parameter, and the second time parameter includes a time when the client sends the first time synchronization message and a time when the client receives a response message to the first time synchronization message; Based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

2. The method according to claim 1, characterized in that Calculating the system time difference between the client and the server according to the time parameter of each first time synchronization message includes: Calculate, according to the time parameter of each first time synchronization message, a total transmission delay from when the client sends the first time synchronization message to when the client receives a response message to the first time synchronization message; Selecting a target transmission delay from each total transmission delay; The first time synchronization message corresponding to the target transmission delay is used as the target time synchronization message, and the system time difference between the client and the server is calculated according to the time parameter of the target time synchronization message.

3. The method according to claim 2, characterized in that Select a target transmission delay from various total transmission delays, including: The minimum total transmission delay is selected from each total transmission delay as the target transmission delay.

4. The method according to claim 2, characterized in that Before selecting the target transmission delay from the total transmission delays, the following steps are also included: Calculate the average value of each total transmission delay; It is determined that the average value is less than a set transmission delay, where the set transmission delay is determined according to a communication bus between the client and the server.

5. The method according to any one of claims 2 to 4, characterized in that: The system time difference t' between the client and the server is calculated according to the following formula: Among them, T1' represents the time when the client sends the target time synchronization message, T2' represents the time when the server receives the target time synchronization message, T3' represents the time when the server sends the response message of the target time synchronization message, and T4' represents the time when the client receives the response message of the target time synchronization message.

6. A time synchronization method, applied to a sensor system, characterized in that: The sensor system includes a server and at least one client, the server and the clients are connected via a communication bus, the server is a client selected from the clients, the server and the clients are distributedly mounted with multiple sensors to simplify sensor wiring, the collected data of the multiple sensors are used for synchronous positioning and mapping, the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the method is applied to the client, including: Sending a second time synchronization message to the server, where the second time synchronization message includes the time when the client sends the second time synchronization message, and receiving a system time difference between the client and the server sent by the server, where the system time difference is calculated by the server according to the time when the second time synchronization message is received and the time when the client sends the second time synchronization message; or, Receive a third time synchronization message sent by the server, where the third time synchronization message includes the time when the server sends the third time synchronization message, and calculate the system time difference between the client and the server according to the time when the third time synchronization message is received and the time when the server sends the third time synchronization message; Based on the system time difference, a timestamp is added to the collected data of the sensor mounted on the client to achieve time synchronization of the collected data of each sensor.

7. A sensor system, characterized in that: The sensor system includes a server and at least one client, wherein the server and the clients are connected via a communication bus, wherein the server is a client selected from the clients, and the server and the clients are distributedly mounted with multiple sensors to simplify sensor wiring, and the collected data of the multiple sensors are used for synchronous positioning and mapping, wherein: The server adds a timestamp to the collected data of the sensor mounted on the server using the system time of the server; Each client adds a timestamp to the collected data of the sensor mounted on the client using the time synchronization method as described in any one of claims 1 to 6.

8. A time synchronization device, applied to a sensor system, characterized in that: The sensor system includes a server and at least one client, the server and the clients are connected via a communication bus, the server is a client selected from the clients, the server and the clients are distributedly mounted with multiple sensors to simplify sensor wiring, the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the device is applied to the client, including: A sending module, used to send at least one first time synchronization message to the server; A receiving module, used to receive a response message to each first time synchronization message sent by the server, wherein the response message includes a first time parameter of the first time synchronization message, and the first time parameter includes a time when the server receives the first time synchronization message and a time when the server sends a response message to the first time synchronization message; A time difference determination module, configured to calculate the system time difference between the client and the server according to the time parameters of each first time synchronization message, wherein the time parameters of each first time synchronization message include a first time parameter and a second time parameter, and the second time parameter includes the time when the client sends the first time synchronization message and the time when the client receives a response message to the first time synchronization message; The adding module is used to add a timestamp to the collected data of the sensor mounted on the client based on the system time difference, so as to achieve time synchronization of the collected data of each sensor.

9. A time synchronization device, applied to a sensor system, characterized in that: The sensor system includes a server and at least one client, the server and the clients are connected via a communication bus, the server is a client selected from the clients, the server and the clients are distributedly mounted with multiple sensors to simplify sensor wiring, the server uses the system time of the server to add a timestamp to the collected data of the sensor mounted on the server, and the device is applied to the client, including: A time difference determination module, used for sending a second time synchronization message to the server, wherein the second time synchronization message includes the time when the client sends the second time synchronization message, and receiving a system time difference between the client and the server sent by the server, wherein the system time difference is calculated by the server according to the time when the second time synchronization message is received and the time when the client sends the second time synchronization message; or, used for receiving a third time synchronization message sent by the server, wherein the third time synchronization message includes the time when the server sends the third time synchronization message, and calculating the system time difference between the client and the server according to the time when the third time synchronization message is received and the time when the server sends the third time synchronization message; The adding module is used to add a timestamp to the collected data of the sensor mounted on the client based on the system time difference, so as to achieve time synchronization of the collected data of each sensor.

10. A client, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor, wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 6.

11. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of the client, the client can execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Distributed interactive method for large-scale wireless sensor network

    CN102111796A

  • Time synchronization method and device and electronic equipment

    CN112532334A