Method for acquiring point cloud road surface height in Unity
Technical Field
The invention discloses a method for obtaining point cloud road surface height when editing vector information by using a point cloud map, and belongs to the technical field of automatic driving simulation.
Background
The success of autonomous driving of automobiles involves a number of technologies such as high-precision maps, real-time positioning, and obstacle detection, and LiDAR (LiDAR) is a device that emits a laser beam in a given direction and detects a return beam to obtain data such as a target position. The common laser radar in the field of automatic driving is a multi-beam mechanical rotary laser radar, and is one of automatic driving core positioning and detecting equipment due to the advantages of accurate positioning, low algorithm implementation difficulty, no influence of day and night and the like. During the running process of the unmanned vehicle, the LiDAR rotates at a constant speed at a certain angular speed, and laser is continuously emitted and information of a reflection point is collected during the process, so that all-directional environmental information can be obtained. LiDAR also records the time and horizontal angle (Azimuth) at which the point occurred during the collection of the distance to the reflecting point, and each laser emitter has a number and a fixed vertical angle from which we can calculate the coordinates of all the reflecting points. The collection of all the collected coordinates of the reflection points for each revolution of the LiDAR forms a point cloud.
When the point cloud map is used for editing vector information, the height information of the point cloud pavement needs to be acquired, and the cloud height cannot be completely leveled when a map is built usually, so that the height information of the existing point cloud pavement is acquired by manpower, the automation degree is not high, and phenomena such as missing detection, wrong detection, missing drawing, wrong drawing and the like occur occasionally.
Disclosure of Invention
The purpose of the invention is as follows: the invention fully utilizes the advantages of the Unity engine and provides a method for automatically acquiring the height information of the point cloud pavement from the point cloud map in the Unity engine with high efficiency.
The technical scheme is as follows: in order to solve the technical problem, the method for automatically acquiring the point cloud road surface height information provided by the invention comprises the following steps:
step one, acquiring a point cloud map of a whole scene;
secondly, segmenting the point cloud map to obtain a plurality of blocks, namely segmenting the point cloud of the whole scene into small point clouds according to the blocks;
step three, carrying out point cloud height calculation on each block point cloud; the method comprises the following specific steps:
1) using IJobParallelFor type parallel processing, the indices of all points of each block are obtained, the pseudo code is as follows:
indices[index]= math.floor(data[index].xy / b);
wherein b is the sampling grid side length
2) Using IJobParallelFor type parallel processing, the index and corresponding point data are filled into a map of the native MultiHashMap < int3, float4> type, the pseudo code is as follows:
map[index].add(indices[index],data[index]);
3) index consistent points are processed in map using the ijobnative multishashmapmultiply sharedkeryindeces type Job process and get the nadir height fill in the array native array < float3> bottom, pseudo code as follows:
ExecuteFirst: height [index]= data[index].z;
ExecuteNext: if(bottom [firstIndex].z>data[index].z)
bottom [firstIndex].z = data[index].z;
step four, outputting the result
And (4) the bottom processed in the third step only comprises point clouds with the lowest points, and the height information of the point clouds is derived to obtain the height information required by the road surface.
Preferably, after the fourth step is completed, the height information of each point cloud in the bottom is derived to form a height map or drawn into a grid.
When the road surface height information is obtained, a large memory is needed for processing a single large scene, so that the point cloud is preferentially cut into blocks, namely the large scene is cut into a plurality of blocks, the large scene is processed in small blocks, the small blocks are processed each time, resources are released after the processing is finished, and the memory occupation is reduced. The invention fully utilizes the advantages of the Unity engine, can quickly and accurately generate the point cloud ground height information, accelerates the data stream processing by utilizing some parallel processing methods, can ensure that the subsequently added road surface elements can be automatically attached to the road surface, greatly reduces the workload required by manual adjustment, and also reduces the probability of generating artificial errors
In addition, as the point cloud of the whole scene is segmented, the hardware cost is also high, the segmentation of the block is only used as a precondition for height calculation, and in practical application, the segmented block can be obtained by at least the following two methods:
(1) and completing block segmentation in a point cloud map export stage, and exporting a small-block point cloud map file (usually a pcd file).
(2) The method comprises the following steps of utilizing a Unity engine to segment a point cloud map to obtain a plurality of blocks, wherein the method specifically comprises the following steps:
1) using IJobParallelFor type parallel processing to obtain the index of all point clouds, the pseudo code is as follows:
indices[index]= math.floor(data[index].xy / b);
wherein, b is the side length of the currently selected block;
2) using IJobParallelFor type parallel processing, the index and corresponding point data are filled into a map of the native MultiHashMap < int3, float4> type, the pseudo code is as follows:
map[index].add(indices[index],data[index]);
3) the inordinate data in map is inserted into the queue native queue < float4> queue using the Job procedure of type Job:
queue.Enqueue(data[index]);
4) converting native queue into native array, and keeping continuous information;
5) using IJobParalleFor type parallel processing to obtain the initial index NativeArray < int > startIndex of each block, wherein the pseudo code is as follows:
If(array[index]== array[index - 1])
startIndex[index]= index;
else
startIndex[index]= 0;
6) using IJobParallelForFilter type parallel processing to screen out indexes which are not 0 in each block, wherein the indexes are initial indexes of each block in array; and circularly reading the point data corresponding to the initial index in each block to obtain the point data of each block after being cut into blocks.
The technical problems, technical features constituting the technical solutions and advantages brought by the technical features of the technical solutions described above are not all the more. In order to make the objects, technical solutions and advantages of the present invention clearer, other technical problems, other technical features included in the technical solutions and advantages brought by the technical features which can be solved by the present invention will be described more clearly and completely with reference to the accompanying drawings in the embodiments of the present invention.
Drawings
FIG. 1 is a schematic flow diagram of an embodiment of the present invention;
FIG. 2 is a schematic diagram of block slicing;
FIG. 3 is a schematic diagram illustrating height information of a point cloud for a block according to an embodiment of the present invention;
fig. 4 is a schematic diagram of fig. 3 after being visualized into a grid.
Detailed Description
Example (b):
the Unity is used as a general graphic engine, a third-party physical engine is integrated inside the Unity, and the requirements of physics and image simulation in the field of automatic driving can be met. Thanks to these advantages, we can implement a new method for efficiently acquiring lidar point cloud in newer version Unity, whose implementation flow is shown in fig. 1, and includes the following steps:
step one, acquiring a point cloud map of the whole scene.
And secondly, segmenting the point cloud map to obtain a plurality of blocks, namely segmenting the point cloud of the whole scene into small point clouds according to the blocks as shown in FIG. 2.
The segmented block can be obtained generally by at least two methods: (1) and completing block segmentation in a point cloud map export stage, and exporting a small-block point cloud map file (usually a pcd file).
(2) The method comprises the following steps of utilizing a Unity engine to segment a point cloud map to obtain a plurality of blocks, wherein the specific method comprises the following steps:
1) using IJobParallelFor type parallel processing to obtain the index of all point clouds, the pseudo code is as follows:
indices[index]= math.floor(data[index].xy / b);
wherein, b is the side length of the currently selected block, can be set as required, and can be 1 meter generally;
2) using IJobParallelFor type parallel processing, the index and corresponding point data are filled into a map of the native MultiHashMap < int3, float4> type, the pseudo code is as follows:
map[index].add(indices[index],data[index]);
3) the inordinate data in map is inserted into the queue native queue < float4> queue using the Job procedure of type Job:
queue.Enqueue(data[index]);
4) converting native queue into native array, and keeping continuous information;
5) using IJobParalleFor type parallel processing to obtain the initial index NativeArray < int > startIndex of each block, wherein the pseudo code is as follows:
If(array[index]== array[index - 1])
startIndex[index]= index;
else
startIndex[index]= 0;
6) using IJobParallelForFilter type parallel processing to screen out indexes which are not 0 in each block, wherein the indexes are initial indexes of each block in array; and circularly reading the point data corresponding to the initial index in each block to obtain the point data of each block after being cut into blocks.
Step three, carrying out point cloud height calculation on each block point cloud; the method comprises the following specific steps:
1) using IJobParallelFor type parallel processing, the indices of all points of each block are obtained, the pseudo code is as follows:
indices[index]= math.floor(data[index].xy / b);
wherein b is the side length of the sampling grid, and can be 1 meter as in the second step;
2) using IJobParallelFor type parallel processing, the index and corresponding point data are filled into a map of the native MultiHashMap < int3, float4> type, the pseudo code is as follows:
map[index].add(indices[index],data[index]);
3) index consistent points are processed in map using the ijobnative multishashmapmultiply sharedkeryindeces type Job process and get the nadir height fill in the array native array < float3> bottom, pseudo code as follows:
ExecuteFirst: height [index]= data[index].z;
ExecuteNext: if(bottom [firstIndex].z>data[index].z)
bottom [firstIndex].z = data[index].z;
step four, outputting the result
The bottom processed in the third step only contains the point clouds with the lowest points, and the height information of the point clouds is derived to obtain the height information required by the road surface, which is the height information of a certain block as shown in fig. 3.
The embodiment can be further modified as follows: and after the fourth step is finished, exporting the height information of each point cloud in the bottom to form a height map or drawing the height map into a grid, as shown in fig. 4, namely drawing the grid into the grid.
The invention fully utilizes the advantages of the Unity engine, can quickly and accurately generate the point cloud ground height information, accelerates the data stream processing by utilizing some parallel processing methods, can automatically acquire the point cloud road surface height information, and avoids the phenomena of missing detection, wrong detection, missing drawing, wrong drawing and the like. And the point cloud pavement height information can be automatically acquired, and subsequently added pavement elements can be automatically attached to the pavement, so that the workload required by manual adjustment is greatly reduced, and the probability of generating human errors is also reduced.
In addition, as the point cloud of the whole scene is segmented, the hardware cost is high, the block segmentation is only used as a precondition of height calculation, and the block segmentation is completed in a point cloud map derivation stage during actual application.
The invention provides a brand-new thought and method for generating the environmental point cloud map in the field of automatic driving simulation, and the method and the way for realizing the technical scheme are many. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the detailed description of the embodiments of the invention presented in the drawings is not intended to limit the scope of the invention as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.