Method for testing autonomous-driving algorithm, and related device
The method includes: obtaining N obstacles from an obstacle set based on a test function of the autonomous-driving algorithm, and storing an ID and initial motion information of each of the N obstacles to an obstacle resource pool; obtaining motion information of a surrounding obstacle of a first obstacle from the obstacle resource pool based on an ID of the first obstacle, and controlling moving of the first obstacle based on the motion information of the surrounding obstacle of the first obstacle, to obtain motion information of the first obstacle; storing the motion information to the obstacle resource pool; obtaining a result of interaction between an ego vehicle and n obstacles from the obstacle resource pool based on location information of the ego vehicle; and determining a test result of the autonomous-driving algorithm based on the interaction result.
1 . A method for testing an autonomous-driving algorithm, comprising:
obtaining N obstacles from an obstacle set based on a test function of the autonomous-driving algorithm, wherein the N obstacles comprise an obstacle of an ego vehicle and a surrounding obstacle of the obstacle of the ego vehicle, including one or more of: a refined track obstacle, a navigation-type obstacle, a macro traffic flow, or a real road test obstacle; and N is an integer greater than 0;
storing an ID and initial motion information of each of the N obstacles to an obstacle resource pool, wherein the obstacle resource pool comprises a first cache and a second cache, and storing the ID and the initial motion information of each of the N obstacles includes:
storing the initial motion information of each of the N obstacles to a storage space indicated by an ID hash value of the obstacle in the first cache, wherein the initial motion information is obtained from configuration information of the respective obstacle; and
storing, by using initial location information of each of the N obstacles as an index, the ID and the initial location information of the obstacle to the second cache;
obtaining initial motion information of a surrounding obstacle of a first obstacle from the obstacle resource pool based on the ID of the first obstacle, and controlling moving of the first obstacle based on the initial motion information of the surrounding obstacle of the first obstacle, to obtain first motion information of the first obstacle, wherein the first motion information includes a speed, a heading angle, and a location of the first obstacle;
updating initial motion information of the first obstacle in the obstacle resource pool to the first motion information, wherein the first obstacle is any one of the N obstacles;
obtaining first motion information of n obstacles from the obstacle resource pool based on location information of the ego vehicle, wherein the n obstacles are obstacles of the ego vehicle, and n is less than or equal to N;
obtaining a result of interaction between the ego vehicle and the n obstacles based on the first motion information of the n obstacles; and
determining a test result of the autonomous-driving algorithm based on the interaction result.
2 . The method according to claim 1 , wherein the initial motion information comprises the initial location information, and wherein the method further comprises:
performing hash processing on the ID of each of the N obstacles, to obtain the ID hash value of each obstacle.
3 . The method according to claim 1 , wherein the obtaining initial motion information of the surrounding obstacle of the first obstacle from the obstacle resource pool based on the ID of the first obstacle comprises:
obtaining the initial motion information of the first obstacle from the first cache based on the ID hash value of the first obstacle, wherein the initial motion information comprises the initial location information, and wherein the ID hash value of the first obstacle is obtained by performing hash processing on the ID of the first obstacle;
obtaining IDs of S obstacles from the second cache based on the initial location information of the first obstacle, wherein the S obstacles are located in a preset area of the first obstacle, wherein the preset area of the first obstacle is determined based on the initial location information of the first obstacle, and wherein S is less than or equal to N;
determining the surrounding obstacle of the first obstacle from the S obstacles based on a motion mode of the first obstacle, wherein the surrounding obstacle of the first obstacle is among the S obstacles and that potentially interacts with the first obstacle when the first obstacle moves in the motion mode; and
obtaining the initial motion information of the surrounding obstacle from the first cache based on an ID hash value of the surrounding obstacle of the first obstacle, wherein the ID hash value of the surrounding obstacle of the first obstacle is obtained by performing hash processing on the ID of the surrounding obstacle.
4 . The method according to claim 3 , wherein the first motion information comprises first location information, and wherein the updating initial motion information of the first obstacle in the obstacle resource pool to the first motion information comprises:
determining, from the second cache based on the initial location information of the first obstacle, an ID corresponding to the initial location information of the first obstacle, and updating the initial location information of the first obstacle in the second cache to the first location information of the first obstacle if the ID corresponding to the initial location information of the first obstacle is the ID of the first obstacle, and
updating the initial motion information of the first obstacle in the first cache to the first motion information based on the ID hash value of the first obstacle.
5 . The method according to claim 2 , wherein the first motion information comprises first location information, and wherein the obtaining first motion information of n obstacles from the obstacle resource pool based on the location information of the ego vehicle comprises:
determining IDs and first location information of M obstacles from the second cache based on the location information of the ego vehicle, wherein the M obstacles are located within a preset range of the ego vehicle, wherein the preset range of the ego vehicle is determined based on the location information of the ego vehicle, and wherein M is a positive integer less than or equal to N;
determining the n obstacles from the M obstacles based on a preset interaction manner and the first location information of the M obstacles, wherein the n obstacles potentially interact with the ego vehicle; and
determining the first motion information of each of the n obstacles from the first cache based on an ID hash value of each of the n obstacles.
6 . A simulation test apparatus, comprising:
an obtaining unit, configured to obtain N obstacles from an obstacle set based on a test function of an autonomous-driving algorithm, wherein the N obstacles comprise an obstacle of an ego vehicle and a surrounding obstacle of the obstacle of the ego vehicle, including one or more of: a refined track obstacle, a navigation-type obstacle, a macro traffic flow, or a real road test obstacle; and N is an integer greater than 0;
a storage unit, configured to store an ID and initial motion information of each of the N obstacles to an obstacle resource pool, wherein the obstacle resource pool comprises a first cache and a second cache, and storing the ID and the initial motion information of each of the N obstacles includes:
store the initial motion information of each of the N obstacles to a storage space indicated by an ID hash value of the obstacle in the first cache, wherein the initial motion information is obtained from configuration information of the respective obstacle for a test scenario; and
store, by using initial location information of each of the N obstacles as an index, the ID and the initial location information of the obstacle to the second cache; and
a simulation test unit, configured to: obtain motion information of a surrounding obstacle of a first obstacle from the obstacle resource pool based on the ID of the first obstacle, and control moving of the first obstacle based on the motion information of the surrounding obstacle of the first obstacle, to obtain first motion information of the first obstacle, wherein the first motion information includes a speed, a heading angle, and a location of the first obstacle; update initial motion information of the first obstacle in the obstacle resource pool to the first motion information; obtain first motion information of n obstacles from the obstacle resource pool based on location information of the ego vehicle, wherein the n obstacles are obstacles of the ego vehicle, and n is less than or equal to N; obtain a result of interaction between the ego vehicle and the n obstacles based on the first motion information of the n obstacles; and determine a test result of the autonomous-driving algorithm based on the interaction result.
7 . The apparatus according to claim 6 , wherein the initial motion information comprises the initial location information, and wherein the apparatus further comprises:
a processing unit, configured to perform hash processing on the ID of each of the N obstacles, to obtain the ID hash value of each obstacle.
8 . The apparatus according to claim 6 , and wherein the obtain motion information of the surrounding obstacle of the first obstacle from the obstacle resource pool based on the ID of the first obstacle, the simulation test unit is configured to:
obtain the initial motion information of the first obstacle from the first cache based on the ID hash value of the first obstacle, wherein the initial motion information comprises the initial location information, and wherein the ID hash value of the first obstacle is obtained by performing hash processing on the ID of the first obstacle;
obtain IDs of S obstacles from the second cache based on the initial location information of the first obstacle, wherein the S obstacles are located in a preset area of the first obstacle, wherein the preset area of the first obstacle is determined based on the initial location information of the first obstacle, and wherein S is less than or equal to N;
determine the surrounding obstacle of the first obstacle from the S obstacles based on a motion mode of the first obstacle, wherein the surrounding obstacle of the first obstacle is among the S obstacles and that potentially interacts with the first obstacle when the first obstacle moves in the motion mode; and
obtain the initial motion information of the surrounding obstacle from the first cache based on an ID hash value of the surrounding obstacle of the first obstacle, wherein the ID hash value of the surrounding obstacle of the first obstacle is obtained by performing hash processing on the ID of the surrounding obstacle.
9 . The apparatus according to claim 8 , wherein the first motion information comprises first location information, and wherein the update initial motion information of the first obstacle in the obstacle resource pool to the first motion information, the simulation test unit is configured to:
determine, from the second cache based on the initial location information of the first obstacle, an ID corresponding to the initial location information of the first obstacle, and update the initial location information of the first obstacle in the second cache to the first location information of the first obstacle if the ID corresponding to the initial location information of the first obstacle is the ID of the first obstacle; and
update the initial motion information of the first obstacle in the first cache to the first motion information based on the ID hash value of the first obstacle.
10 . The apparatus according to claim 7 , wherein the first motion information comprises first location information, and wherein the obtain first motion information of n obstacles from the obstacle resource pool based on the location information of the ego vehicle, the simulation test unit is configured to:
determine IDs and first location information of M obstacles from the second cache based on the location information of the ego vehicle, wherein the M obstacles are located within a preset range of the ego vehicle, the preset range of the ego vehicle is determined based on the location information of the ego vehicle, and M is a positive integer less than or equal to N;
determine the n obstacles from the M obstacles based on a preset interaction manner and the first location information of the M obstacles, wherein the n obstacles potentially interact with the ego vehicle; and
determine the first motion information of each of the n obstacles from the first cache based on the ID hash value of each of the n obstacles.
11 . A simulation test apparatus, comprising:
a processor, and
a memory coupled with the processor to store instructions; which when executed by the processor, cause the processor to perform operations, the operations comprising:
obtaining N obstacles from an obstacle set based on a test function of an autonomous-driving algorithm, wherein the N obstacles comprise an obstacle of an ego vehicle and a surrounding obstacle of the obstacle of the ego vehicle, including one or more of: a refined track obstacle, a navigation-type obstacle, a macro traffic flow, or a real road test obstacle; and N is an integer greater than 0;
storing an ID and initial motion information of each of the N obstacles to an obstacle resource pool, wherein the obstacle resource pool comprises a first cache and a second cache, and storing the ID and the initial motion information of each of the N obstacles includes:
storing the initial motion information of each of the N obstacles to a storage space indicated by an ID hash value of the obstacle in the first cache, wherein the initial motion information is obtained from configuration information of the respective obstacle for a test scenario; and
storing, by using initial location information of each of the N obstacles as an index, an ID and the initial location information of the obstacle to the second cache;
obtaining initial motion information of a surrounding obstacle of a first obstacle from the obstacle resource pool based on an ID of the first obstacle, and controlling moving of the first obstacle based on the initial motion information of the surrounding obstacle of the first obstacle, to obtain first motion information of the first obstacle, wherein the first motion information includes a speed, a heading angle, and a location of the first obstacle;
updating initial motion information of the first obstacle in the obstacle resource pool to the first motion information, wherein the first obstacle is any one of the N obstacles;
obtaining first motion information of n obstacles from the obstacle resource pool based on location information of the ego vehicle, wherein the n obstacles are obstacles of the ego vehicle, and n is less than or equal to N;
obtaining a result of interaction between the ego vehicle and the n obstacles based on the first motion information of the n obstacles; and
determining a test result of the autonomous-driving algorithm based on the interaction result.
12 . A chip system, wherein the chip system is used in an electronic device; the chip system comprises one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through a line; the interface circuit is configured to receive a signal from a memory of the electronic device, and send the signal to the processor, wherein the signal comprises computer instructions stored in the memory; and when the processor executes the computer instructions, the electronic device performs the method according to claim 1 .
13 . A non-transitory machine-readable storage medium having instructions stored therein, which when executed by a processor, cause the processor to perform operations, the operations comprising:
obtaining N obstacles from an obstacle set based on a test function of an autonomous-driving algorithm, wherein the N obstacles comprise an obstacle of an ego vehicle and a surrounding obstacle of the obstacle of the ego vehicle, including one or more of: a refined track obstacle, a navigation-type obstacle, a macro traffic flow, or a real road test obstacle; and N is an integer greater than 0;
storing an ID and initial motion information of each of the N obstacles to an obstacle resource pool, wherein the obstacle resource pool comprises a first cache and a second cache, and storing the ID and the initial motion information of each of the N obstacles includes:
storing the initial motion information of each of the N obstacles to a storage space indicated by an ID hash value of the obstacle in the first cache, wherein the initial motion information is obtained from configuration information of the respective obstacle for a test scenario; and
storing, by using initial location information of each of the N obstacles as an index, the ID and the initial location information of the obstacle to the second cache;
obtaining initial motion information of a surrounding obstacle of a first obstacle from the obstacle resource pool based on an ID of the first obstacle, and controlling moving of the first obstacle based on the initial motion information of the surrounding obstacle of the first obstacle, to obtain first motion information of the first obstacle, wherein the first motion information includes a speed, a heading angle, and a location of the first obstacle;
updating initial motion information of the first obstacle in the obstacle resource pool to the first motion information, wherein the first obstacle is any one of the N obstacles;
obtaining first motion information of n obstacles from the obstacle resource pool based on location information of the ego vehicle, wherein the n obstacles are obstacles of the ego vehicle, and n is less than or equal to N;
obtaining a result of interaction between the ego vehicle and the n obstacles based on the first motion information of the n obstacles; and
determining a test result of the autonomous-driving algorithm based on the interaction result.
14 . A computer program product, comprising computer instructions, and when the computer instructions are run on an electronic device, the electronic device is enabled to perform the method according to claim 1 .
15 . The non-transitory machine-readable storage medium according to claim 13 , wherein the initial motion information comprises the initial location information, and wherein the operations further comprises:
performing hash processing on the ID of each of the N obstacles, to obtain the ID hash value of each obstacle.
16 . The non-transitory machine-readable storage medium according to claim 13 , wherein the obtaining initial motion information of the surrounding obstacle of the first obstacle from the obstacle resource pool based on the ID of the first obstacle comprises:
obtaining the initial motion information of the first obstacle from the first cache based on an ID hash value of the first obstacle, wherein the initial motion information comprises the initial location information, and wherein the ID hash value of the first obstacle is obtained by performing hash processing on the ID of the first obstacle;
obtaining IDs of S obstacles from the second cache based on the initial location information of the first obstacle, wherein the S obstacles are located in a preset area of the first obstacle, wherein the preset area of the first obstacle is determined based on the initial location information of the first obstacle, and wherein S is less than or equal to N;
determining the surrounding obstacle of the first obstacle from the S obstacles based on a motion mode of the first obstacle, wherein the surrounding obstacle of the first obstacle is among the S obstacles and that potentially interacts with the first obstacle when the first obstacle moves in the motion mode; and
obtaining the initial motion information of the surrounding obstacle from the first cache based on the ID hash value of the surrounding obstacle of the first obstacle, wherein the ID hash value of the surrounding obstacle of the first obstacle is obtained by performing hash processing on the ID of the surrounding obstacle.
17 . The non-transitory machine-readable storage medium according to claim 16 , wherein the first motion information comprises first location information, and wherein the updating initial motion information of the first obstacle in the obstacle resource pool to the first motion information comprises:
determining, from the second cache based on the initial location information of the first obstacle, an ID corresponding to the initial location information of the first obstacle, and updating the initial location information of the first obstacle in the second cache to the first location information of the first obstacle if the ID corresponding to the initial location information of the first obstacle is the ID of the first obstacle, and
updating the initial motion information of the first obstacle in the first cache to the first motion information based on the ID hash value of the first obstacle.
18 . The non-transitory machine-readable storage medium according to claim 15 , wherein the first motion information comprises first location information, and wherein the obtaining first motion information of n obstacles from the obstacle resource pool based on the location information of the ego vehicle comprises:
determining IDs and first location information of M obstacles from the second cache based on the location information of the ego vehicle, wherein the M obstacles are located within a preset range of the ego vehicle, wherein the preset range of the ego vehicle is determined based on the location information of the ego vehicle, and wherein M is a positive integer less than or equal to N;
determining the n obstacles from the M obstacles based on a preset interaction manner and the first location information of the M obstacles, wherein the n obstacles potentially interact with the ego vehicle; and
determining the first motion information of each of the n obstacles from the first cache based on the ID hash value of each of the n obstacles.