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

By constructing a full binary BVH tree and adaptively expanding the depth on the GPU, the minimum distance calculation of the three-dimensional discrete model is optimized, which solves the problem of time-consuming calculation in the existing technology and realizes efficient rigid body obstacle avoidance and real-time interaction.

CN119129376BActive Publication Date: 2025-09-30ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing technologies for calculating the minimum distance between three-dimensional discrete models, especially in the fields of physical simulation and virtual reality, suffer from long computational times and difficulty in efficiently utilizing the parallel computing capabilities of GPUs. In particular, when rigid bodies interact with obstacles, it is difficult to quickly prune branches that do not contain minimum distance patches.

Method used

A GPU-based full binary BVH tree construction and adaptive depth expansion method are adopted, combined with narrow stage and wide stage distance calculation. A full binary tree is constructed through a greedy algorithm, the bounding box pruning strategy is optimized, and the PQP algorithm is used to calculate the minimum distance of triangles. The algorithm is executed in parallel on the GPU to achieve efficient minimum distance calculation.

Benefits of technology

It improves the efficiency of calculating the minimum distance between 3D models, realizes real-time obstacle avoidance, improves GPU load balancing and computing performance, and is suitable for complex simulation scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129376B_ABST
    Figure CN119129376B_ABST
Patent Text Reader

Abstract

The present invention discloses a rigid body obstacle avoidance method based on three-dimensional discrete model distance calculation. In the preprocessing stage, the method constructs a BVH for the rigid body and obstacle model and ensures that it is a full binary tree. At the same time, two buffers are initialized to record the upper bounds of the minimum distances between the BVTT front and the two bounding boxes. The method iteratively expands the BVTT nodes in the buffer until all BVH nodes in the BVTT are leaf nodes, and calculates the minimum distance between the primitives of the leaf nodes; in each iteration, an adaptive expansion depth is calculated according to the size of the current buffer, and then all BVTT nodes in the existing buffer are expanded and stored in another buffer, and then the two BVTT buffers are switched using a double buffer mechanism; and it is determined whether the rigid body should avoid obstacles based on the minimum distance. The present invention is conducive to improving the efficiency of bounding box culling, and applies the minimum distance calculation to rigid body simulation scenes to achieve efficient real-time obstacle avoidance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present 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] Computing the maximum and minimum distances between discrete three-dimensional models plays a crucial role in fields such as physical simulation, digital human technology, computer-aided design (CAD), virtual reality (VR), and augmented reality (AR). In physical simulation, accurate and real-time calculation of the relative distances between rigid bodies and other entities in the environment (including people and objects) is essential to adapt to a wider range of complex tasks and enable interaction with real obstacles. A crucial step in this minimum distance calculation is how to quickly prune branches that do not contain minimum-distance patches. CPU-based algorithms employ a depth-first traversal approach, traversing two bounding volume hierarchies (BVHs) and calculating the upper bound on the minimum distance between bounding boxes. If the minimum distance between the current bounding box is less than the upper bound, the traversal continues to its child nodes. Upon reaching a leaf node of the two BVHs, the minimum distance between the primitives within the leaf node is calculated. If the obtained value is less than the current minimum, the distance is updated. However, this step is computationally intensive and time-consuming. In recent years, graphics processing units (GPUs), with their powerful parallel computing capabilities, have been widely used to accelerate various computationally intensive tasks. 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 shortcomings of the prior art, the purpose 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 object 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. On the CPU side, the three-dimensional discrete models of the rigid body and the obstacle are read separately, and the vertex arrays of the models are reordered;

[0006] 2. Construct 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. Iteratively expand the calculation to adaptively expand the depth, expand all BVTT nodes in the existing buffer zone and perform 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 preset safety threshold, calculate a new movement path and generate an obstacle avoidance action.

[0011] Further, the specific steps of step 1 are as follows:

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

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

[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, the specific steps of step 2 are 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, the specific steps of step 3 are as follows: Transfer the BVH information in step 2 to the GPU through the built-in functions of Cuda, 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 distance of the bounding box, 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 to satisfy 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 in 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 tighter bounding box minimum distance upper bound. Specifically, for a BVH tree, when the bounding box of a BVH leaf node is a tight bounding box, the bounding box of each internal node is also tight. In the process of calculating the upper bound, a tighter 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 distributed 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 present invention provides the following beneficial effects: Based on the BVTT frontier and adaptive expansion algorithm, the present invention directly calculates the minimum distance between two 3D models on a GPU. This invention proposes an enhanced upper bound on the minimum distance, which helps improve the efficiency of bounding box culling and applies the minimum distance calculation to rigid body simulation scenarios, achieving 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 the minimum distance upper bound of a general bounding box, and (b) is a schematic diagram of the optimized minimum distance upper bound;

[0025] Figure 3 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 will be described in detail below with reference to 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: In the first frame of the simulation, read the vertex position and facet information of the rigid body and obstacle. Note the rigid body model as A and the obstacle model as B. During the read phase, a vertex array is generated based on the number of facets read in. The length of this vertex array is three times the number of facets. Then, the index array is traversed, and the vertex information of the triangle facets corresponding to the index information is stored in the generated vertex array.

[0030] Step 2: Figure 3 As shown in Figure 1, 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 coordinates 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 so, 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 within the current range, and select the dimension with the largest difference as the partitioning dimension for 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 full BVH tree's role 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 to left and right child nodes, which makes node thread allocation on the GPU difficult. However, a full binary tree can conveniently 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 the 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 depths of rigid body model A and 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 culling, 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 the obstacle, and then calculate the upper bound of the minimum distance of the bounding box of the child node. Figure 2 As shown in the figure, 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 a custom atomic operation is used to compare it with the global minimum value. At the same time, the next series of nodes obtained by expanding the current buffer is saved in another buffer. 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, typically set to 1024×256. When k is less than 1, it is forcibly set to 1.

[0048] Meanwhile, the present invention proposes a BVTT node allocation strategy. When the BVTT nodes are too few, in order to fully utilize the parallelism of the GPU, the four pairs of BVH node pairs contained 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 contained in all BVTTs and saves the minimum value to the minimum distance array corresponding to that thread. In the single narrow-phase distance calculation method, since the BVTT nodes are fewer, the 4 pairs of primitive pairs to be calculated contained in the BVTT nodes are allocated to 4 threads to fully utilize the high throughput advantage of the GPU. Then, the distance calculation is performed for all the triangles, the minimum value is obtained, and it is output to the minimum distance array. Then, the Reduce method is used to calculate the real-time minimum value of the rigid body and the obstacle.

[0050] Step 6. Compare the calculated minimum distance value of the rigid body and the obstacle with the pre-set 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] The GPU-based maximum and minimum distance algorithm flow has been detailed. The present invention has implemented the entire algorithm flow and has been implemented in actual engineering projects. Furthermore, the present invention has been compared with existing CPU distance calculation methods and the calculation results have been fully tested.

[0052] Those skilled in the art will understand that the foregoing descriptions are merely preferred embodiments of the invention and are not intended to limit the invention. Although the invention has been described in detail with reference to the foregoing examples, those skilled in the art will still be able to modify the technical solutions described in the foregoing examples or substitute equivalents for some of the technical features therein. Any modifications, equivalent substitutions, etc. made within the spirit and principles of the invention shall be included within the scope of protection 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 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, construction of double buffer and initialization of the upper bound of the minimum distance of the model; (4) Iterative expansion calculates the adaptive expansion depth, expands all BVTT nodes in the existing buffer zone 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 pre-set 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 as follows: (1.1) Read the face array of the model and generate the vertex array and index array; (1.2) Based on the vertex array and 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; (1.3) Record the x, y, z values ​​of the AABB bounding box center coordinates and their corresponding ids in an array respectively; (1.4) Sort the center array in ascending order and sort the id array by the corresponding key value.

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, ensuring 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 a 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: Method for expanding BVTT nodes in step (4): Calculate the expansion depth in each iteration. If the number of currently expanded BVTTs is greater than the preset maximum number of BVTTs, exit the loop 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 upper bound of the distance by calculating the distance of the 36 face combinations 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; otherwise, the corresponding four pairs of BVH node pairs in the BVTT are distributed 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.