Electronic control unit clock
Techniques for generating and/or updating a timekeeping mechanism for an ECU are described herein. Monotonic and/or global time sources may be used to generate and/or update a real time clock used by component(s) of an autonomous vehicle. In some examples, a clock manager may receive a monotonic time value from a monotonic clock and a global time value from a global clock. The clock manager may use the monotonic time value and the global time value to generate an adjustment factor. In some instances, the clock manager may store the adjustment factor in a read-only shared memory location. In such instances, vehicle component may determine a predicted current time based on reading the adjustment factor from the shared memory and the monotonic time value. Upon determining the predicted current time, the vehicle component may synchronize a real time clock of the vehicle component according to the predicted current time.
1 . A system comprising:
one or more processors; and
one or more non-transitory computer-readable media storing computer-executable instructions that, when executed, cause the one or more processors to perform operations comprising:
receiving, from a monotonic time source associated with an autonomous vehicle, a first time value, wherein the monotonic time source is updated at a first frequency;
receiving, based at least in part on a global positioning system associated with the autonomous vehicle, a second time value, wherein the second time value is updated at a second frequency that is different than the first frequency;
generating, by a computing system associated with the autonomous vehicle and based at least in part on the first time value and the second time value, a time adjustment offset according to a third frequency that is different than an operating system update frequency;
storing, in a shared memory, the time adjustment offset for read access by a user component of the autonomous vehicle, wherein the user component is prevented from writing to the shared memory at a location where the time adjustment offset is stored;
determining, by the user component and based at least in part on the time adjustment offset, a predicted current time; and
performing an action on the autonomous vehicle based at least in part on the predicted current time.
2 . The system of claim 1 , wherein the user component determines the predicted current time based at least in part on the time adjustment offset and a local clock of the system.
3 . The system of claim 2 , wherein the local clock is the monotonic time source.
4 . The system of claim 1 , the operations further comprise:
causing the time adjustment offset to be updated at a modified frequency, while retaining a scheduler frequency of a scheduler operating on the autonomous vehicle.
5 . The system of claim 1 , wherein the monotonic time source is based on a counter associated with a central processing unit of the autonomous vehicle.
6 . The system of claim 1 , wherein determining the predicted current time is based at least in part on accessing the time adjustment offset from the shared memory.
7 . The system of claim 1 , wherein updating the monotonic time source includes incrementing the monotonic time source according to the first frequency.
8 . One or more non transitory computer readable media storing instructions executable by one or more processors, wherein the instructions, when executed, cause the one or more processors to perform operations comprising:
receiving, from a monotonic time source associated with a robot, a first time value, wherein the monotonic time source includes a first frequency;
receiving, from a global time source associated with the robot, a second time value, wherein the global time source includes a second frequency that is different than the first frequency;
generating, by a computing system associated with the robot and based at least in part on the first time value and the second time value, a time adjustment offset according to a third frequency that is different than an operating system update frequency; and
storing, in a shared memory, the time adjustment offset for read access by a user component of the robot.
9 . The one or more non transitory computer readable media of claim 8 , wherein a clock value associated with the user component is generated based at least in part on the time adjustment offset and a local clock source of the robot.
10 . The one or more non transitory computer readable media of claim 8 , wherein:
the operating system associated with the robot includes a scheduler operating at a scheduler frequency; and
the scheduler frequency is different than the first frequency.
11 . The one or more non transitory computer readable media of claim 10 , the operations further comprise:
causing the time adjustment offset to be updated at a modified frequency different from the scheduler frequency, while retaining the scheduler frequency of the scheduler.
12 . The one or more non transitory computer readable media of claim 8 , wherein the monotonic time source is based on a counter associated with a central processing unit of the robot.
13 . The one or more non transitory computer readable media of claim 8 , the operations further comprise:
determining, by the user component, based on accessing the monotonic time source, a third time value; and
adding, by the user component, the time adjustment offset to the third time value to determine a current global time value.
14 . The one or more non transitory computer readable media of claim 8 , wherein the user component lacks permissions to modify the time adjustment offset in the shared memory.
15 . The one or more non transitory computer readable media of claim 8 , wherein:
a clock manager component of the robot generates the time adjustment offset;
a user component of the robot reads the time adjustment offset modifying value from the shared memory; and
the clock manager component has a higher priority than the user component such that the clock manager's generation of the time adjustment offset takes precedence by a scheduling component over the user component's reading of the time adjustment offset.
16 . A method comprising:
receiving, from a monotonic time source associated with a robot, a first time value, wherein the monotonic time source includes a first frequency;
receiving, from a global time source associated with the robot, a second time value, wherein the global time source includes a second frequency that is different than the first frequency;
generating, by a computing system associated with the robot and based at least in part on the first time value and the second time value, a time adjustment offset according to a third frequency that is different than an operating system update frequency; and
storing, in a shared memory, the time adjustment offset for read access by a user component of the robot.
17 . The method of claim 16 , wherein a clock value associated with the user component is generated based at least in part on the time adjustment offset and a local clock source of the robot.
18 . The method of claim 16 , wherein:
the operating system associated with the robot includes a scheduler operating at a scheduler frequency; and
the scheduler frequency is different than the first frequency.
19 . The method of claim 18 , further comprising:
causing the time adjustment offset to be updated at a modified frequency different from the scheduler frequency, while retaining the scheduler frequency of the scheduler.
20 . The method of claim 16 , wherein the user component lacks permissions to modify the time adjustment offset in the shared memory.