Rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation

By building an algorithm with full binary tree and adaptive expansion depth on the GPU, combining narrow stage and wide stage distance calculation, the problem of low calculation efficiency of minimum distance between three-dimensional discrete models is solved, and efficient real-time obstacle avoidance and calculation speed improvement is achieved.

CN119129376AActive Publication Date: 2024-12-13ZHEJIANG UNIV

Patent Information

Application Number
CN202411084054.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-07-26
Filing Date
2024-08-08
Publication Date
2024-12-13
Estimated Expiration
2044-08-08

AI Technical Summary

Technical Problem

The prior art has the problem of low computing efficiency in the calculation of minimum distance between three-dimensional discrete models, especially in the fields of physical simulation and computer-aided design. In particular, the depth-first traversal algorithm is time-consuming and difficult to make full use of the graphics processing unit. Parallel computing power of (GPU).

Method used

Using a GPU-based full binary tree (BVH) structure and an adaptive extension depth algorithm, reordering the vertex array and building a full binary tree, optimized distance calculation, and combined with narrow and wide stage distance calculation, combining PQP algorithm and adaptive BVTT expansion Strategy to improve computing efficiency.

Benefits of technology

It realizes efficient calculation of the minimum distance between three-dimensional models on the GPU, improves the efficiency of bounding box removal, realizes real-time obstacle avoidance in rigid body simulation scenarios, and significantly improves the computing speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129376A_ABST
    Figure CN119129376A_ABST
Patent Text Reader

Abstract

The invention discloses a rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation, and the method comprises the steps: building a BVH for a rigid body and an obstacle model in a preprocessing stage, guaranteeing the BVH to be a full binary tree, and initializing two buffer regions to record a BVTT front line and the minimum distance upper bound of two bounding boxes; the method comprises the following steps: iteratively expanding BVTT nodes in a buffer area until all BVH nodes in the BVTT are leaf nodes, and calculating the minimum distance of primitives between the leaf nodes; in each iteration, a self-adaptive extension depth is calculated according to the size of the current buffer area, then all BVTT nodes in the existing buffer area are extended and stored in another buffer area, and then two BVTT buffer areas are switched by using a double-buffer area mechanism; and judging whether the rigid body performs obstacle avoidance according to the minimum distance. According to the method, the bounding box elimination efficiency is improved, minimum distance calculation is applied to a rigid body simulation scene, and efficient real-time obstacle avoidance is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of physical simulation, and in particular to a rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation. Background Art

[0002] The calculation of the maximum and minimum distances between three-dimensional discrete models plays an important role in the fields of physical simulation, digital human technology, computer-aided design (CAD), virtual reality (VR) and augmented reality (AR). In physical simulation, in order to adapt to more extensive and complex task requirements and to achieve interaction with real obstacles, it is necessary to accurately and in real time calculate the relative distance between the rigid body and other entities in the environment (including people and objects). In the minimum distance calculation, how to prune and quickly remove the branches that do not contain the minimum distance patch is a very critical step in the minimum distance calculation. The CPU-based algorithm uses a depth-first traversal method to traverse two bounding volume hierarchies (BVHs) and calculate the minimum distance upper bound between the bounding boxes. If the minimum distance of the current bounding box is less than the minimum distance upper bound, then continue to traverse its child nodes. When reaching the leaf nodes of the two BVHs, the minimum distance of the primitives in them is calculated. When the obtained value is less than the current minimum value, it is updated. However, this step is a computationally intensive task and is time-consuming. In recent years, graphics processing units (GPUs) have been widely used to accelerate various computationally intensive tasks with their powerful parallel computing capabilities. Such as tessellation, collision detection, ray tracing, etc. However, despite these advances, developing efficient GPU algorithms specifically for distance calculations remains an unsolved challenge. Summary of the invention

[0003] In view of the deficiencies of the prior art, an object of the present invention is to provide a rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation, which is used to calculate the minimum distance between a rigid body and an obstacle in a simulation environment.

[0004] The objective of the present invention is achieved through the following technical solution: a rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation, the specific steps are as follows:

[0005] 1. Read the three-dimensional discrete models of the rigid body and the obstacle on the CPU side respectively, and reorder the vertex arrays of the models;

[0006] 2. Build a full binary BVH tree (F12BVH) suitable for GPU data reading;

[0007] 3. GPU data initialization, double buffer construction and initialization of the model minimum distance upper bound;

[0008] 4. Iterative expansion calculates adaptive expansion depth, expands all BVTT nodes in the existing buffer and performs wide-stage distance calculation;

[0009] 5. Perform narrow-phase distance calculation and obtain the minimum distance between models;

[0010] 6. When the minimum distance between the rigid body and the obstacle is less than the pre-set safety threshold, calculate a new movement path and generate an obstacle avoidance action.

[0011] Further, step 1 is specifically as follows:

[0012] 1.1. Read the face array of the model and generate a vertex array and an index array;

[0013] 1.2. According to the vertex array and the index array, calculate the axis-aligned bounding box (AABB) of the triangle corresponding to the index array and the depth of the BVH to be constructed;

[0014] 1.3. Record the x, y, z values of the center coordinates of the AABB bounding box and their corresponding ids in an array respectively;

[0015] 1.4. Sort the center array in ascending order and sort the id array according to the corresponding key values.

[0016] Further, step 2 is specifically as follows: Sort the x, y, and z values of the center coordinates of the AABB bounding box obtained in step 1 in ascending order respectively, and construct a BVH based on the greedy algorithm to ensure that the BVH is a full binary tree, and each child node contains one or two primitives.

[0017] Further, step 3 is specifically as follows: Pass the BVH information in step 2 to the GPU through the Cuda built-in function, calculate the minimum distance of the bounding boxes of the root nodes of the two BVHs, initialize the double buffer, set the minimum value in the buffer to the minimum bounding box distance, set the length of the first buffer to 1, and the other to 0.

[0018] Further, the adaptive expansion depth calculation method in step 4 is as follows: When the buffer contains n BVTT nodes, calculate the expansion depth k so that it satisfies 2 2k n < C, where C is a constant. For a general model, C is set to 1024×256; when the obtained k value is less than 1, set k to 1.

[0019] Further, the method for expanding BVTT nodes in step 4: Calculate the expansion depth for each iteration. If the number of currently expanded BVTTs is greater than the maximum number of BVTTs of the preset value, exit the loop in advance for narrow-phase distance calculation.

[0020] Furthermore, step 4 also includes: adopting a more compact upper bound of the minimum distance of the bounding box, specifically, for a BVH tree, when the bounding box of the BVH leaf node is a compact bounding box, the bounding box of each of its internal nodes is also compact, and in the process of calculating the upper bound, a more compact distance upper bound is obtained by calculating the distance of the 36 face combinations of the two bounding boxes.

[0021] Furthermore, the step 5 is specifically as follows: when executing the narrow stage distance calculation, if the wide stage distance calculation is exited early in step 5, each thread uses the PQP algorithm to calculate the minimum distance of triangles in the leaf nodes contained in the two BVH nodes in the BVTT in pairs; otherwise, the corresponding four pairs of BVH node pairs in the BVTT are allocated to four different threads, and each thread uses the PQP algorithm to calculate the minimum distance of triangles in a pair of BVH leaf nodes.

[0022] The beneficial effect of the present invention is that: based on the BVTT front and adaptive expansion algorithm, the present invention directly calculates the minimum distance between two three-dimensional models on the GPU. The present invention proposes an enhanced minimum distance upper bound, which is conducive to improving the efficiency of bounding box culling, and applies the minimum distance calculation to the rigid body simulation scene to achieve efficient real-time obstacle avoidance. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 is a flow chart of a method in an embodiment of the present invention;

[0024] Figure 2 Schematic diagram of the minimum distance upper bound in an embodiment of the present invention, wherein (a) is a schematic diagram of a general bounding box minimum distance upper bound, and (b) is a schematic diagram of an optimized minimum distance upper bound;

[0025] Figure 3 This is a schematic diagram of f12BVH in an embodiment of the present invention;

[0026] Figure 4 Schematic diagram of adaptive BVTT extension and buffer in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] The present invention is described in detail below in conjunction with the accompanying drawings and embodiments.

[0028] like Figure 1 As shown, a rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation includes the following steps:

[0029] Step 1, model reading: read the vertex position information and face information of the rigid body and obstacle in the first frame of the simulation, record the rigid body model as A, and the obstacle model as B. In the reading stage, generate a vertex array according to the number of facets read in, and the length of the vertex array is 3 times the number of facets. After that, traverse the index array and store the vertex information of the triangular facets corresponding to the index information in the generated vertex array.

[0030] Step 2: Figure 3 As shown, based on the information obtained in step 1, a full binary tree suitable for GPU access is constructed through a greedy algorithm, including the following sub-steps:

[0031] 2.1. For the patch array read in step 1, calculate its AABB bounding box and the depth of the BVH to be constructed.

[0032] 2.2. Create three arrays to store the coordinate values ​​of the center of the bounding box on the x, y, and z axes. Use the id array to record the triangle id corresponding to the center coordinates, and sort the three arrays in ascending order.

[0033] 2.3. Construct a BVH tree based on a greedy algorithm. Each time it is executed, first check whether the current depth has reached the maximum depth. If it has, mark the current node as a leaf node and store the range of the leaf node. If the maximum depth has not been reached, calculate the difference between the three center coordinate arrays in the current range, and select the dimension with the largest difference as the division dimension of the current node. Then, call the reorder function to re-sort the id arrays of the other two dimensions in ascending order within this range. Finally, recursively call the build function for the left and right halves. After the BVH is constructed, the constructed bounding box information is transferred to the GPU using the CUDA built-in function as the BVH on the GPU.

[0034] The role of the full BVH tree in GPU distance calculation is mainly reflected in the following aspects:

[0035] Efficiently obtain k-generation child nodes: The conventional task of finding k-generation child nodes requires pointers based on left and right child nodes, which makes node thread allocation on the GPU difficult. The full binary tree can easily access k-generation child nodes directly through bit operations.

[0036] Construction based on a full binary tree only requires storing bounding box information on the GPU, without storing information about left and right child nodes.

[0037] In practice, the number of BVTT layers expanded simultaneously is often large. Therefore, adjacent threads mainly process adjacent nodes of BVH nodes contained in the same BVTT, which helps to efficiently execute in parallel on the GPU.

[0038] Step 3: GPU data initialization, including the following sub-steps:

[0039] 3.1. Calculate the maximum BVH depth of the rigid body model A and the obstacle model B, denoted as deepA and deepB respectively. Initialize the update flag and pre-calculate the extended depth. Compare the BVH depths of A and B. If deepA is greater than deepB, swap the traversal order of the two.

[0040] 3.2. Initialize two buffers buffer1 and buffer2, representing the BVTT front and the initial estimate of the upper bound of the minimum distance between two AABBs: The BVTT structure mainly contains the index array and the minimum distance array of the two bounding box leaf nodes.

[0041] 3.3. In the simulation process of each subsequent frame, update the vertex information and bounding box information.

[0042] Step 4: Iteratively expand the buffer and perform wide-stage BVTT elimination, including the following sub-steps:

[0043] 4.1. Set the loop condition to the current depth deepNow is less than the maximum depth deepMax.

[0044] 4.2. Before each iteration loop, the adaptive expansion depth is calculated based on the number of BVTTs in the current buffer.

[0045] 4.3. Determine the relationship between the current depth deepNow, deepA, and deepB, and perform different wide-stage distance calculations. If the current depth deepNow is less than deepA and deepB, expand A and B by k / 2 layers respectively, otherwise expand B by k layers. The wide-stage distance calculation method is implemented as follows: If the minimum distance of the current BVTT node is greater than the existing upper bound or the thread ID exceeds the number of BVTT nodes, perform the pruning operation directly; otherwise, according to the adaptive depth calculated in the previous step, obtain the k-generation child nodes in the node on the BVH of the rigid body and obstacles, and then calculate the upper bound of the minimum distance of the bounding box of the child node. Figure 2 As shown in FIG. 1 , the present invention uses a tighter minimum distance upper bound based on the original bounding box upper bound based on the bounding box diagonal. For each thread block, the reduction operator is used to calculate the minimum value within the thread block, and then the minimum value is compared with the global minimum value using a custom atomic operation. At the same time, the next series of nodes obtained by expanding the current buffer is saved in another buffer. Specifically, Figure 4 shown.

[0046] 4.4. If the length of the current buffer BVTT is greater than the preset value, directly exit the current loop and set the earlyExit parameter to true.

[0047] The present invention proposes an adaptive BVTT expansion strategy for accelerating the culling of distance calculations. For traditional BVTT expansion methods, the expansion depth is 1, resulting in fewer generated nodes and prone to causing uneven GPU load. While fixedly expanding multiple layers of BVTT is likely to lead to too many BVTT nodes during the expansion process, generating computational redundancy. Therefore, the present invention proposes an adaptive BVTT expansion method. Specifically, when the buffer contains n BVTT nodes, this method calculates an expansion depth k such that 2 2k n < C, where C is a custom constant, generally set to 1024×256. When k is less than 1, it is forced to be set to 1.

[0048] Meanwhile, the present invention proposes a BVTT node allocation strategy. When there are too few BVTT nodes, in order to fully utilize the parallelism of the GPU, the four pairs of BVH node pairs included in all BVTTs are respectively placed in four threads for calculation.

[0049] Step 5. Perform narrow-phase BVTT distance calculation: There are two execution methods for narrow-phase distance calculation. If earlyExit is set to true in step 4, then execute the large-batch narrow-phase distance calculation method; otherwise, execute the single narrow-phase distance calculation method. The difference between the two is that for the large-batch narrow-phase distance calculation method, since the number of BVTT nodes to be processed is greater than the maximum number of threads contained in the GPU, multiple BVTT nodes need to be allocated to each thread. Each thread calculates the minimum distance for the triangles of the BVH leaf nodes included in all BVTTs and saves the minimum value to the minimum distance array corresponding to the thread. In the single narrow-phase distance calculation method, since there are fewer BVTT nodes, the 4 pairs of primitive pairs to be calculated included in the BVTT nodes are allocated to 4 threads to fully utilize the high throughput advantage of the GPU. Then, distance calculations are performed on all the triangles therein to obtain the minimum value and output it to the minimum distance array. Then, the Reduce method is used to calculate the real-time minimum value between the rigid body and the obstacle.

[0050] Step 6. Compare the calculated minimum distance value between the rigid body and the obstacle with the preset safety threshold. If it is greater than the safety threshold, the rigid body continues the simulation. When it is less than the safety threshold, use the RRT algorithm to re-plan the motion path of the rigid body and calculate a new transformation matrix at the same time.

[0051] So far, the maximum and minimum distance algorithm flow based on GPU of the present invention has been given in detail, and the present invention has realized and implemented the whole algorithm flow in actual engineering projects. At the same time, the present invention has also been compared with the existing CPU distance calculation method and the calculation results have been fully tested.

[0052] Those skilled in the art can understand that the above are only preferred examples of the invention and are not intended to limit the invention. Although the invention is described in detail with reference to the above examples, those skilled in the art can still modify the technical solutions recorded in the above examples or replace some of the technical features therein with equivalents. Any modification, equivalent replacement, etc. made within the spirit and principle of the invention shall be included in the protection scope of the invention.

Claims

1. A rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation, characterized in that: The steps include: (1) Reading the three-dimensional discrete models of the rigid body and the obstacle respectively on the CPU side, and reordering the vertex arrays of the models; (2) Construct a full binary BVH tree suitable for GPU data reading; (3) GPU data initialization, double buffer construction and initialization of the model minimum distance upper bound; (4) Iterative expansion calculates the adaptive expansion depth, expands all BVTT nodes in the existing buffer and performs wide-stage distance calculation; (5) Perform narrow stage distance calculation and obtain the minimum distance between models; (6) When the minimum distance between the rigid body and the obstacle is less than the preset safety threshold, a new moving path is calculated and an obstacle avoidance action is generated.

2. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The step (1) is specifically: (1.1) Read the face array of the model and generate vertex array and index array; (1.2) According to the vertex array and the index array, the axis-aligned bounding box AABB of the triangle corresponding to the index array and the depth of the BVH to be constructed are calculated; (1.3) Record the x, y, z values ​​of the center coordinates of the AABB bounding box and their corresponding ids in an array respectively; (1.4) Sort the center array in ascending order and sort the id array by corresponding key values.

3. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The step (2) is specifically as follows: constructing a BVH based on a greedy algorithm to ensure that the BVH is a full binary tree, and each child node contains one or two primitives.

4. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The step (3) is specifically as follows: passing the BVH information in step (2) to the GPU through the Cuda built-in function, calculating the minimum distance between the bounding boxes of the root nodes of the two BVHs, initializing the double buffer, setting the minimum value in the buffer to the minimum distance of the bounding boxes, setting the length of the first buffer to 1, and the other to 0.

5. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The adaptive expansion depth calculation method described in step (4) is as follows: when the buffer contains n BVTT nodes, calculate the expansion depth k such that 2 2k n < C, where C is a constant; for the general model, C is set to 1024 × 256; when the obtained value of k is less than 1, set k to 1.

6. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The method for expanding BVTT nodes described in step (4) is as follows: the expansion depth is calculated in each iteration. If the number of currently expanded BVTTs is greater than the preset maximum number of BVTTs, the loop is exited early to perform narrow stage distance calculation.

7. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The step (4) further includes: in the process of calculating the upper bound, obtaining a tighter distance upper bound by calculating the distance of the combination of 36 faces of the two bounding boxes.

8. The rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation according to claim 1, characterized in that: The step (5) is specifically as follows: when executing the narrow stage distance calculation, if the wide stage distance calculation is exited in advance, each thread uses the PQP algorithm to calculate the minimum distance of triangles in the leaf nodes contained in the two BVH nodes in the BVTT in pairs; otherwise, the corresponding four pairs of BVH node pairs in the BVTT are allocated to four different threads, and each thread uses the PQP algorithm to calculate the minimum distance of triangles in a pair of BVH leaf nodes.

Citation Information

Patent Citations

  • Adaptive distance field construction method based on bounding volume hierarchy

    CN116310119A

  • Method for detecting collision relation of components in three-dimensional building and electronic equipment

    CN116563468A

  • Lightweight method of digital twin model

    CN116681822A

  • Bounded volume hierarchy (BVH) tree traversal using spatial division

    US20210383591A1

Cited By

  • Parallel BVH minimum distance query algorithm based on CUDA

    CN119917683A

  • CUDA-Based Parallel BVH Minimum Distance Query Method

    CN119917683B