Disclosure of Invention
The invention provides an automatic driving task execution method, an automatic driving task execution device, electronic equipment and a storage medium, which are used for solving the defect that the data transmission frequency cannot be further optimized by transmitting data through a timing trigger mechanism in the prior art, realizing further optimization of the average delay of a system and ensuring that the overall delay maximum value of an automatic driving system is controllable.
The invention provides an automatic driving task execution method, which comprises the following steps:
receiving first data, wherein the first data is one of subscription data depending on the first task when executing;
searching for a first task dependent on the first data;
executing the first task in response to all subscription data relied upon by the execution of the first task being received;
and executing the first task in response to the fact that all subscription data relied on by the execution of the first task are not received, and the time length of the current time stamp from the time stamp of the last execution of the first task exceeds a first threshold.
According to the method for executing the automatic driving task provided by the invention, the first task is executed in response to the fact that all subscription data relied on when the first task is executed is received, and the method comprises the following steps:
receiving the subscription data on which the first task depends when executed;
after all the subscription data are received, judging whether to execute the first task or not based on a preset rule corresponding to the first task, wherein the preset rule is a judgment rule set by a user.
According to the method for executing the automatic driving task provided by the invention, the executing of the first task comprises the following steps:
and processing the subscription data based on a callback function, and sending the processed data, wherein the callback function is a function preset by a user.
According to the method for executing the automatic driving task provided by the invention, the first task is executed, and then the method comprises the following steps:
updating the current time stamp of the execution of the first task.
According to the method for executing the automatic driving task provided by the invention, the first task is executed in response to the fact that all subscription data relied on when the first task is executed is received, and the method comprises the following steps:
setting the ready state corresponding to the received subscription data as true;
and checking the ready states corresponding to all the subscription data, if the ready states are true, checking the state returned by the confirmation ready judging function corresponding to the first task, and if the ready states are true, executing the first task, wherein the confirmation ready judging function is based on a judging rule set by a user.
According to the method for executing the automatic driving task provided by the invention, the method for checking the state returned by the confirmation ready judging function corresponding to the first task comprises the following steps:
based on whether the delay of the subscription data judged by the confirmation ready judging function is smaller than a second threshold value and whether the time difference of different subscription data receiving moments is smaller than a third threshold value, if yes, the state returned by the confirmation ready judging function is true; otherwise, the return state of the ready judging function is false.
According to the method for executing the automatic driving task provided by the invention, the first task is executed, and then the method comprises the following steps:
and resetting the ready state corresponding to all subscription data relied by the first task execution to false.
The invention also provides an automatic driving task execution device, which comprises:
the receiving module is used for receiving first data, wherein the first data is one of subscription data depending on the execution of the first task;
the searching module is used for searching a first task depending on the first data;
the first response module is used for responding to the fact that all subscription data relied on when the first task is executed are received, and executing the first task;
and the second response module is used for executing the first task in response to that all subscription data relied by the execution of the first task are not received completely and the time length of the current time stamp from the time stamp of the last execution of the first task exceeds a first threshold value.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method for executing the automatic driving task as described above when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of automatic driving task execution as described in any of the above.
According to the automatic driving task execution method, the automatic driving task execution device, the electronic equipment and the storage medium, the task which depends on the subscription data is searched according to the received subscription data, and the task is executed when all other subscription data which depends on the task execution are received (which is equivalent to a real-time trigger mechanism), so that the minimum delay of the task execution is effectively optimized. When all other subscription data on which the task is executed are not completely received and the time length of the current moment from the last execution time of the task exceeds a first time threshold, the fact that the subscription data on which the task is dependent has delay or other special conditions causes incapability of timely receiving is indicated, and in order to ensure timeliness of the task, when the time length of the current moment from the last execution time of the task exceeds the first time threshold, the task is executed (which is equivalent to a timing trigger mechanism), so that the trigger delay of the task is controlled within an acceptable range. According to the method, the real-time trigger mechanism is combined on the basis of the timing trigger mechanism, so that the receiving condition of subscription data on which a task depends is judged rapidly and effectively, the average delay of the system is reduced, and the integral delay maximum value of the automatic driving system is ensured to be controllable.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The task execution method, apparatus, electronic device, and storage medium of the present invention are described below with reference to fig. 1 to 7.
As shown in fig. 1, in one embodiment, an automatic driving task execution method includes the steps of:
step S110, receiving first data, wherein the first data is one of subscription data depending on the execution of the first task.
Specifically, taking a software module in the autopilot system as an example, the software module includes tasks and subscription data on which the tasks depend when executing, the first task is one of the tasks, and the first data is one of the subscription data on which the first task depends. Wherein the tasks have one or more, and each task has one or more dependent subscription data. The first task can be executed only after all subscription data on which the first task depends are received.
In step S120, a first task dependent on the first data is found.
Wherein the purpose of searching for the first task via the first data is that by searching for the first task, it is possible to determine other subscription data on which the first task depends
Specifically, since the execution of the task depends on at least one subscription data, when the subscription data is received, all the subscription data on which the task depends is determined by reversely searching the corresponding task which depends on the subscription data and further by changing the corresponding task. One subscription data may correspond to a plurality of tasks, at which time all subscription data on which different tasks depend need to be determined separately for each task.
Step S130, executing the first task in response to the received all subscription data relied upon by the execution of the first task.
Specifically, the current task is found according to the received subscription data, and because the execution of the task usually requires a plurality of subscription data as parameters required by the subsequent data processing process, before executing the task, whether all subscription data relied on by the task are received is required to be judged, and when other subscription data relied on by the task are also received, the current task is executed.
And step S140, executing the first task in response to that all subscription data relied on by the execution of the first task is not received, and the time length of the current time stamp from the time stamp of the last execution of the first task exceeds a first threshold.
Specifically, if the current task is found according to the received subscription data and other subscription data relied on by the current task are not completely received, in order to avoid the situation that the subscription data cannot be received in time due to delay or other special conditions, and thus the triggering of the current task is affected, the execution time period of the current task needs to be judged, and when the duration of the last execution time of the current time from the task exceeds a first threshold value, the current task is executed.
According to the automatic driving task execution method, the task which depends on the subscription data is searched according to the received subscription data, and the task is executed when all other subscription data which depends on the task execution are received (which is equivalent to a real-time trigger mechanism), so that the minimum delay of the task execution is effectively optimized. When all other subscription data on which the task is executed are not completely received and the time length of the current moment from the last execution time of the task exceeds a first time threshold, the fact that the subscription data on which the task is dependent has delay or other special conditions causes incapability of timely receiving is indicated, and in order to ensure timeliness of the task, when the time length of the current moment from the last execution time of the task exceeds the first time threshold, the task is executed (which is equivalent to a timing trigger mechanism), so that the trigger delay of the task is controlled within an acceptable range. According to the method, the real-time trigger mechanism is combined on the basis of the timing trigger mechanism, so that the receiving condition of subscription data on which a task depends is judged rapidly and effectively, the average delay of the system is reduced, and the integral delay maximum value of the automatic driving system is ensured to be controllable.
As shown in fig. 2, in one embodiment, in response to all subscription data relied upon by the execution of the first task having been received, the first task is executed comprising the steps of:
step S210, receiving subscription data relied on by the first task when executing.
Step S220, after all the subscription data are received, judging whether to execute the first task based on a preset rule corresponding to the first task, wherein the preset rule is a judgment rule set by a user.
After all the subscription data depended on by the first task are received, whether the first task is continuously executed or not can be determined through a preset rule defined by a user, wherein the preset rule is a judging rule corresponding to the first task. For example, in general, not all received subscription data satisfy the sending condition, the user may define a preset rule, determine the validity of the subscription data based on the preset rule, execute the first task when the determination result is valid, and if the determination result is invalid, need to discard the subscription data.
In one embodiment, performing the first task includes the steps of: and processing subscription data based on the callback function, and sending the processed data, wherein the callback function is a function preset by a user.
Specifically, subscription data on which the task depends is processed based on the callback function, control instruction data required by automatic driving or subscription data required by other tasks are obtained, and the obtained data is sent to an appointed receiver.
In one embodiment, the first task is performed, followed by the steps of: the current timestamp of the execution of the first task is updated.
Specifically, the updated execution time stamp of the task is used for providing a judging basis for periodic execution of the task, when the time length of the latest execution time stamp of the task from the current time exceeds a first time threshold, the latest execution time stamp of the task indicates that subscription data relied on by the task is delayed or cannot be received in time due to other special conditions, and in order to ensure timeliness of the task, the task is executed, so that the trigger delay of the task is controlled within an acceptable range.
As shown in fig. 3 and 6, in one embodiment, in response to all subscription data relied upon by the execution of the first task having been received, the first task is executed comprising the steps of:
in step S310, the ready state corresponding to the received subscription data is set to true.
Specifically, a ready (pre-ready) state corresponding to the received subscription data is set to true (true). The pre-ready state of the subscription data includes true and false, which are used to indicate whether the subscription data is received upstream, respectively, when the subscription data is received, the pre-ready state of the subscription data is set to true, otherwise, false.
Step S320, checking the ready states corresponding to all subscription data, if both are true, checking the state returned by the confirmation ready judging function corresponding to the first task, if true, executing the first task, the confirmation ready judging function being specific based on the judging rule set by the user, checking the ready state corresponding to all subscription data, if both are true, checking the state returned by the confirmation ready (confirm-ready) judging function corresponding to the first task, if true, executing the first task, and normally, the default returned value of the state of the confirm-ready judging function is true, and being rewritable by the user.
In this embodiment, checking the state of the return of the validation ready judgment function corresponding to the first task includes:
judging whether the delay of the subscription data is smaller than a second threshold value and whether the time difference of different subscription data receiving moments is smaller than a third threshold value or not based on the confirmation ready judging function, if so, confirming that the state returned by the ready judging function is true; otherwise, the return state of the ready judging function is confirmed to be false.
That is, when the delay of the subscription data is judged not to be smaller than the second threshold value or the time difference of the different subscription data reception timings is judged not to be smaller than the third threshold value based on the confirmation ready judgment function, the state returned by the confirmation ready judgment function is false.
Specifically, for example, the fusion module needs to receive sensor data such as camera, lidar, radar, etc., and before transmitting the sensor data, it needs to determine whether the delay of the data is excessive and whether the time difference between the acquisition times of the plurality of sensor data is within a predetermined time range, and if the delay is excessive or the time difference is not within the predetermined time range, it determines that the predetermined rule is not satisfied, and it needs to discard the subscription data. The user may override the preset rules, if necessary, to attach new execution conditions for the execution of the first task.
In one embodiment, the first task is performed, followed by the steps of: and resetting the ready state corresponding to all subscription data relied by the execution of the first task to false.
Specifically, the task is reset after being executed, and the pre-ready state of all subscription data on which the task is executed is reset to false, so that the task is used for setting the state of the subscription data on which the task is dependent when the task is executed next time.
As shown in fig. 5, in this embodiment, taking a certain software module a in the autopilot system as an example, task1 (Task 1) included in the module depends on three subscription data (Subscriber 1-3). Task1 exists in the form of a Callback function (Callback) that mainly contains the process of processing data and sending data.
The implementation steps are as follows:
1. in the configuration file corresponding to the module A, defining all Task (Task) related information:
a) Defining the dependency relationship of Task1 on subscription data thereof;
b) Defining a unique callback id corresponding to the Task 1;
c) Defining an execution period of Task1, wherein the execution period is the duration of a first threshold value;
d) Defining a mode in which Task1 is triggered, defaulting to an event mode: the data is ready to trigger immediately.
2. When the module A is started, initializing all data structures and judging logic:
a) Initializing a pre-ready state corresponding to all the dependent data of the Task into false;
b) And defining corresponding confirm-ready judging functions for all tasks, returning true by default, and enabling a user to rewrite.
In general, not all received data satisfies the transmission condition, and if necessary, the user may override default implementation, and make specific judgment on the content such as the validity of the data in the function. For example, a fusion module needs to receive sensor data such as camera, lidar, radar, etc., and before calculating a transmission result based on the data, it needs to determine whether the data delay is excessive, whether a plurality of sensor data time differences are within a predetermined range, etc.;
c) Initializing call time corresponding to all tasks to 0;
d) Initializing the dependency relationship between all subscription data (Subscriber) and Task (callback) according to the configuration file corresponding to the module A;
3. when subscription data is received by subscore 1 of module a:
a) Searching a corresponding data structure, finding out a Task1 of which the downstream depends on the data, setting a pre-ready state corresponding to the subscnriber 1 on which the Task1 depends as true, and other subscnribers and the like;
b) Checking all subscription data (subscore) states on which the Task1 depends, if both are true, continuing to check the confirm-ready state of the Task1, and if the confirm-ready state is also true, marking the callback id of the Task1 as an executable state when the state is as shown in fig. 6;
c) And immediately triggering Task1 (callback) according to the judgment result of the last step, and simultaneously updating the latest execution time stamp of the current Task 1.
d) If there is a dependency between the tasks, refer to the above steps;
after the Task1 (callback) is executed, resetting the pre-ready state corresponding to all subsribers on which the Task1 depends to false;
5. when the module A is started, a high-frequency timer is set, the module A runs once every a short period of time (20 ms for example), whether the time for last execution of all the tasks (Task 1) exceeds the transmission period specified by the Task1 or not is checked, if so, the callback id of the Task1 is recorded and immediately triggered once. The high-frequency timer actually plays a role of protecting the bottom, ensures the maximum time interval of downstream received data, and ensures that the whole delay maximum value of the system is controllable.
According to the automatic driving task execution method, the advantages of real-time triggering and timing triggering tasks are combined, through real-vehicle testing, the overall delay from the data end to the data end of the system is effectively reduced, the performance is remarkably improved, meanwhile, the maximum delay is controlled within a certain range, and the reliability and the safety of the system are ensured. The method provides a simple and practical data state representation method, is highly automatic, provides custom expansion capability, can automatically judge a certain task dependent data state, and can facilitate a user to join in custom judgment rules, thereby meeting the actual requirements of each software module in an automatic driving system.
The task execution device provided by the invention is described below, and the task execution device described below and the task execution method described above can be referred to correspondingly.
As shown in fig. 4, in one embodiment, an automatic driving task performing apparatus includes a receiving module 410, a searching module 420, a first responding module 430, and a second responding module 440.
The receiving module 410 is configured to receive first data, where the first data is one of subscription data that is relied upon when the first task is executed.
The searching module 420 is configured to search for a first task that depends on the first data.
The first response module 430 is configured to execute the first task in response to all subscription data that is relied upon when the first task is executed having been received.
The second response module 440 is configured to execute the first task in response to that all subscription data that is relied upon when the first task is executed is not received, and a duration of a current timestamp from a timestamp of a last execution of the first task exceeds a first threshold.
In one embodiment, the first response module 430 is specifically configured to receive subscription data that is relied upon by the first task when executing; judging the validity of the subscription data based on preset rules, wherein the preset rules comprise a judging function set by a user; and after all the subscription data are received and all the subscription data accord with preset rules, executing a first task.
In one embodiment, the first response module 430 is specifically configured to process the subscription data based on a callback function, and send the processed data, where the callback function is a function preset by a user.
In one embodiment, the automatic driving task performing device further comprises an updating module for updating a time stamp of the current first task execution.
In one embodiment, the first response module 430 is specifically configured to set the ready state corresponding to the received subscription data to true; and checking the ready states corresponding to all subscription data, if the ready states are true, checking the returned states of the confirmation ready judging function corresponding to the first task, and if the ready states are true, executing the first task, wherein the confirmation ready judging function is based on the judging rule set by the user.
In one embodiment, checking the status returned by the validation ready determination function corresponding to the first task includes:
based on whether the delay of the subscription data judged by the confirmation ready judging function is smaller than a second threshold value and whether the time difference of different subscription data receiving moments is smaller than a third threshold value, if so, confirming that the state returned by the ready judging function is true; otherwise, the return state of the ready judging function is confirmed to be false.
In one embodiment, the automatic driving task execution device further includes a reset module, configured to reset the readiness state corresponding to all subscription data that is relied upon when the first task is executed to false.
Fig. 7 illustrates a physical schematic diagram of an electronic device, as shown in fig. 7, which may include: processor 810, communication interface (Communications Interface) 820, memory 830, and communication bus 840, wherein processor 810, communication interface 820, memory 830 accomplish communication with each other through communication bus 840. The processor 810 may invoke logic instructions in the memory 830 to perform an autopilot task execution method comprising:
receiving first data, wherein the first data is one of subscription data depending on the first task when executing;
searching for a first task dependent on the first data;
executing the first task in response to all subscription data relied upon by the execution of the first task being received;
and executing the first task in response to the fact that all subscription data relied on by the execution of the first task are not received completely and the time length of the current time stamp from the time stamp of the last execution of the first task exceeds a first threshold.
Further, the logic instructions in the memory 830 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of executing the method of performing an automatic driving task provided by the methods described above, the method comprising:
receiving first data, wherein the first data is one of subscription data depending on the first task when executing;
searching for a first task dependent on the first data;
executing the first task in response to all subscription data relied upon by the execution of the first task being received;
and executing the first task in response to the fact that all subscription data relied on by the execution of the first task are not received completely and the time length of the current time stamp from the time stamp of the last execution of the first task exceeds a first threshold.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the method for performing an automatic driving task provided by the above methods, the method comprising:
receiving first data, wherein the first data is one of subscription data depending on the first task when executing;
searching for a first task dependent on the first data;
executing the first task in response to all subscription data relied upon by the execution of the first task being received;
and executing the first task in response to the fact that all subscription data relied on by the execution of the first task are not received completely and the time length of the current time stamp from the time stamp of the last execution of the first task exceeds a first threshold.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.