A method of obtaining point cloud pavement-height in Unity
Technical field
The method that point cloud pavement-height is obtained when a kind of point of use cloud map edit Vector Message of the invention, belongs to and drives automatically
Sail simulation technical field.
Background technique
The success of autonomous driving vehicle is related to high-precision map, the in real time multinomial technology such as positioning and detection of obstacles, swashs
Optical radar (LiDAR) be it is a kind of emit laser beam to assigned direction and detect Returning beam obtain the dress of the data such as target position
It sets.The common laser radar in automatic Pilot field is multi-thread beam machinery rotating type laser radar, and due to its accurate positioning, algorithm is real
Existing difficulty is low, not by influencing round the clock many advantages, such as, become one of the positioning of automatic Pilot core and detection device.In unmanned garage
During sailing, LiDAR constantly issues laser in this process and collects anti-simultaneously with certain angular speed uniform rotation
The information of exit point, to obtain comprehensive environmental information.LiDAR can also be recorded simultaneously during collecting reflection point distance
The time and level angle (Azimuth) that the lower point occurs, and each laser emitter has the vertical angle of number and fixation
Degree, according to these data, we can calculate the coordinate of all reflection points.LiDAR often rotate a circle be collected into it is all anti-
The set of exit point coordinate is formed a cloud.
It in point of use cloud map edit Vector Message, needs to obtain cloud pavement-height information, and usually builds figure time point
Cloud level degree will not be substantially flat, therefore existing cloud pavement-height information multi-pass manually obtains excessively, and the degree of automation is not high, leakage
It surveys, wrong survey, leak picture, wrong phenomena such as drawing happens occasionally.
Summary of the invention
Goal of the invention: the present invention makes full use of the advantage of Unity engine, provide one kind in Unity engine efficiently from
Automatically the method for point cloud pavement-height information is obtained in point cloud map.
Technical solution: in order to solve the above technical problems, provided by the invention cloud pavement-height automatic acquisition of scientific information method,
The following steps are included:
Step 1: obtaining the point cloud map of entire scene;
Step 2: carrying out cutting to cloud map obtains multiple blocks, i.e., by the point cloud of entire scene according to place block cutting
At fritter point cloud;
It is calculated Step 3: carrying out a cloud level degree to each block point cloud;It is specific as follows:
1) parallel processing of IJobParallelFor type is used, obtains the index of each block all the points, pseudocode is as follows:
indices[index] = math.floor(data[index].xy / b);
Wherein, b is sampling grids side length
2) parallel processing of IJobParallelFor type is used, index is inserted with corresponding point data
NativeMultiHashMap<int3, float4>type map, pseudocode are as follows:
map[index].add(indices[index],data[index]);
3) it is handled in map using IJobNativeMultiHashMapMergedSharedKeyIndices type Job process
It indexes consistent point and obtains minimum point height filling array NativeArray<float3>bottom, pseudocode is as follows:
ExecuteFirst: height [index] = data[index].z;
ExecuteNext: if(bottom [firstIndex].z> data[index].z)
bottom [firstIndex].z = data[index].z;
Step 4: output result
It is only included the point cloud of minimum point in step 3 treated bottom, the elevation information for exporting these clouds obtains
Elevation information required for road surface.
Preferably, step 4 execute after the completion of, the elevation information of each cloud in bottom is exported to be formed height map or
Person is depicted as grid.
When obtaining pavement-height information, single large scene processing needs very big memory, therefore the present invention preferentially cuts a cloud
Block is handled in fritter that is, by the multiple blocks of large scene cutting poplar, executes the processing of a fritter every time, and processing is completed
After discharge resource, reduce EMS memory occupation.The present invention makes full use of the advantage of Unity engine, can rapidly and accurately generate a little
Cloud ground level information, and Data Stream Processing is accelerated using some method for parallel processing, the road surface of subsequent addition can be made
Element, can automatic attaching to road surface, reduce manually adjust required workload greatly, decrease generate human error probability
Cutting is carried out additionally, due to the point cloud to entire scene and still needs very big hardware spending, therefore here only by block
Cutting is used as the precondition that height calculates, in practical application, can obtain cutting using at least following two method
Block:
(1) block cutting is completed in a cloud map export stage, and exports point cloud map file (the usually pcd text of fritter
Part).
(2) cutting is carried out to cloud map using Unity engine and obtains multiple blocks, specific as follows:
1) parallel processing of IJobParallelFor type is used, the index of all the points cloud is obtained, pseudocode is as follows:
indices[index] = math.floor(data[index].xy / b);
Wherein, b is the block side length currently chosen;
2) parallel processing of IJobParallelFor type is used, index is inserted with corresponding point data
NativeMultiHashMap<int3, float4>type map, pseudocode are as follows:
map[index].add(indices[index],data[index]);
3) it will be indexed in map using IJobNativeMultiHashMapMergedSharedKeyIndices type Job process
Consistent data are inserted into queue NativeQueue<float4>queue, and pseudocode is as follows:
queue.Enqueue(data[index]);
4) NativeArray array is converted by NativeQueue queue, keeps continuous information;
5) parallel processing of IJobParallelFor type is used, starting index NativeArray < int of each block is got
> startIndex, pseudocode are as follows:
If(array[index] == array[index - 1])
startIndex[index] = index;
else
startIndex[index] = 0;
6) use the parallel processing of IJobParallelForFilter type, filter out in each block be not 0 index, these
Index is exactly the initial index of each block in array;Circulation read in each block the corresponding point data of initial index to get
The point data of each block after to stripping and slicing.
The technical issues of invention described above solution, constitutes the technical characteristic of technical solution and by these technical sides
Outside advantage brought by the technical characteristic of case.It, below will knot to keep the object of the invention, technical scheme and beneficial effects clearer
The attached drawing in the embodiment of the present invention is closed, to other skills for including in the other technologies problem of the invention that can solve, technical solution
The advantages of art feature and these technical characteristics are brought does apparent, complete description.
Detailed description of the invention
Fig. 1 is the flow diagram of the embodiment of the present invention;
Fig. 2 is the schematic diagram of block cutting;
Fig. 3 is the point cloud elevation information schematic diagram of a certain block in the embodiment of the present invention;
Fig. 4 is to visualize Fig. 3 at the schematic diagram after grid.
Specific embodiment
Embodiment:
Unity has been internally integrated third party's physical engine as general graphical engine, can satisfy the physics in automatic Pilot field
With image simulation demand.Have benefited from these advantages, we can realize effective acquisition laser radar in the Unity of more recent version
The new method of point cloud, it is as shown in Figure 1 to implement main-process stream, comprising the following steps:
Step 1: obtaining the point cloud map of entire scene.
Step 2: carrying out cutting to cloud map obtains multiple blocks, i.e., as shown in Fig. 2, the point cloud of entire scene is pressed
Fritter point cloud is cut into according to place block.
The block of cutting can be usually obtained using at least following two method: (1) being completed in a cloud map export stage
Block cutting, and export the point cloud map file (usually pcd file) of fritter.
(2) cutting is carried out to cloud map using Unity engine and obtains multiple blocks, the specific method is as follows:
1) parallel processing of IJobParallelFor type is used, the index of all the points cloud is obtained, pseudocode is as follows:
indices[index] = math.floor(data[index].xy / b);
Wherein, b is the block side length currently chosen, and can be set as needed, usually 1 meter desirable;
2) parallel processing of IJobParallelFor type is used, index is inserted with corresponding point data
NativeMultiHashMap<int3, float4>type map, pseudocode are as follows:
map[index].add(indices[index],data[index]);
3) it will be indexed in map using IJobNativeMultiHashMapMergedSharedKeyIndices type Job process
Consistent data are inserted into queue NativeQueue<float4>queue, and pseudocode is as follows:
queue.Enqueue(data[index]);
4) NativeArray array is converted by NativeQueue queue, keeps continuous information;
5) parallel processing of IJobParallelFor type is used, starting index NativeArray < int of each block is got
> startIndex, pseudocode are as follows:
If(array[index] == array[index - 1])
startIndex[index] = index;
else
startIndex[index] = 0;
6) use the parallel processing of IJobParallelForFilter type, filter out in each block be not 0 index, these
Index is exactly the initial index of each block in array;Circulation read in each block the corresponding point data of initial index to get
The point data of each block after to stripping and slicing.
It is calculated Step 3: carrying out a cloud level degree to each block point cloud;It is specific as follows:
1) parallel processing of IJobParallelFor type is used, obtains the index of each block all the points, pseudocode is as follows:
indices[index] = math.floor(data[index].xy / b);
Wherein, b is sampling grids side length, usually can use 1 meter as in step 2;
2) parallel processing of IJobParallelFor type is used, index is inserted with corresponding point data
NativeMultiHashMap<int3, float4>type map, pseudocode are as follows:
map[index].add(indices[index],data[index]);
3) it is handled in map using IJobNativeMultiHashMapMergedSharedKeyIndices type Job process
It indexes consistent point and obtains minimum point height filling array NativeArray<float3>bottom, pseudocode is as follows:
ExecuteFirst: height [index] = data[index].z;
ExecuteNext: if(bottom [firstIndex].z> data[index].z)
bottom [firstIndex].z = data[index].z;
Step 4: output result
It is only included the point cloud of minimum point in step 3 treated bottom, the elevation information for exporting these clouds obtains
Elevation information required for road surface, the as shown in Figure 3 elevation information of as a certain block.
The present embodiment can also make following improve: after the completion of step 4 executes, the height of each cloud in bottom being believed
Breath export forms height map or is depicted as grid, as shown in figure 4, being depicted as grid.
The present invention makes full use of the advantage of Unity engine, can rapidly and accurately generate cloud ground level information, and
Accelerate Data Stream Processing using some method for parallel processing, cloud pavement-height information can be obtained automatically, avoid test leakage,
The generation of picture, wrong phenomena such as drawing is surveyed, leaked to mistake.And cloud pavement-height information can be obtained automatically, the road surface member of subsequent addition
Element, can automatic attaching to road surface, reduce manually adjust required workload greatly, decrease generate human error probability.
Cutting is carried out additionally, due to the point cloud to entire scene and still needs very big hardware spending, therefore only will here
Block cutting is used as the precondition that height calculates, and is cut in practical application, completing block in a cloud map export stage
Point.
The present invention generates for the environment point cloud map that automatic Pilot emulates field and provides a kind of completely new thinking and method,
There are many method and the approach for implementing the technical solution, and described embodiments are some of the embodiments of the present invention, rather than
Whole embodiments.The component of embodiments of the present invention, which are generally described and illustrated herein in the accompanying drawings can be matched with a variety of different
It sets to arrange and design.Therefore, requirement is not intended to limit to the detailed description of the embodiment of the present invention provided in attached drawing to protect
The scope of the present invention of shield, but it is merely representative of selected embodiment of the invention.Based on the embodiments of the present invention, this field is general
Logical technical staff every other embodiment obtained without creative efforts belongs to what the present invention protected
Range.