5.3 Integration into the Physics Engine Bullet
5.3.2 Integration Interfaces
The following structures were modified by adding references to the VPS re-implementation from this work: btBulletCollisionCommon.h, btBroadphaseProxy, and btDefault- CollisionConfiguration. The appropriate algorithm is assigned to each shape type in the last interface.
As shown in Figure 5.10, the abstract collision shape interface was additionally in- herited and extended to represent the data structures introduced in Chapter 3. Since the VPS requires two different data structures for each colliding pair, a mixed structure containing both structures for each object was defined. The structure which is used is selected automatically online: the object with less points will be the Pointshell. The inertia matrix and some other features required by Bullet, such as bounding volumes, are automatically created with the methods integrated in the data structures from this work.
In the broadphase, bounding spheres of the highest pointshell hierarchy level are checked against the distance fields. Colliding pairs are handled by the dispatcher, which calls the proximity query from Algorithm 3.1explained in Chapter 3. The result of the query is a contact manifold M containing colliding points with their respective normal vectors and penetration values (see Section3.3.1.2).
If the segmented hierarchical traverse is performed (see Section 3.3.1.5), this list is already segmented in m clusters and for each one a btPersistentManifold is created with the point in the cluster that has the deepest penetration value. In case the regular hierarchical traverse is carried out, a unique btPersistentManifold is filled with the contact points, starting with the deepest point, and adding points so that the manifold area maximizes. Note that the size of the manifold is limited to four points in Bullet, although this constant value can be modified before compilation.
Figure 5.11: Height of the center of mass of the bouncing ball (radius 0.5 m) using different coefficients of restitution c. The pointshell of the sphere is composed of 275 (low resolution) and 25880 (high resolu- tion) points. The plane’s voxelmap has a resolution (voxel edge size) of 5 mm. The black dashed line rep- resents the ideal maximum height after the first collision.
0 0.5 1 y (m) c=0.1 VPS Low−res VPS High−res Bullet 0 0.5 1 y (m) c=0.5 50 100 150 200 250 300 0 0.5 1 y (m) Simulation Steps c=0.9
5.3.3 Experiments and Results
In this section, first, the results of simple experiments are shown to prove the validity of the VPS re-implementation, which is compared to the default algorithms in Bullet. Afterwards, the VPS is compared with the fastest collision detection algorithm in Bullet in more challenging scenarios, using the Stanford Bunny as the benchmark object. All tests were carried out using a PC running SUSE Linux Enterprise Edition 11 with an Intel Xeon CPU at 4 × 2.80 GHz.
The following video shows the benchmarking experiments with the Stanford Bunny: Integration of a Haptic Rendering Algorithm Based on Voxelized and Point-Sampled Structures into the Physics Engine Bullet@ Vimeo
https://vimeo.com/89910579
5.3.3.1 Tests with a Bouncing Ball
In this scenario, the height of a sphere dropped onto a plane as well as its maximum penetration are analyzed. The sphere, with a radius of 0.5 m and a mass of 1 kg, was dropped from a height of 1 m. The gravity was considered to be 10 m/s2and the frequency
of the simulation was 200 Hz. Given the geometries, the re-implemented VPS delivered at each time step one colliding point. For this type of scenarios, Bullet calls a simple algorithm called btSphereBoxCollisionAlgorithm.
The results show that the height profile of the center of mass of the ball for the VPS re-implementation roughly matches the one yielded by using Bullet’s algorithm. The discrepancies between the VPS and Bullet’s values are due to Bullet having higher
Table 5.1: Maximum penetration errors (mm) in the bouncing ball experiment using Bullet and the VPS re-implementation in this work. Two resolutions are considered for the VPS algorithm: low resolution with 275 points and high resolution with 25880 points.
Restitution coefficient [-]
Penetration error[mm] Bullet VPS low res. VPS high res.
0.1 42.5 6.8 3.5
0.5 42.5 9.5 4.0
0.9 42.5 20.1 19.2
penetration errors (see Table 5.1), which delay the rebound and increase the period of the bouncing. Having pointshell objects with much higher resolutions seems to provide lower penetration errors, but the benefits are not substantial.
Alongside the bouncing ball experiment, the stacking of similar objects was also tested. Stacking spheres and disabling freezing of the objects will cause them to collapse, eventually. As the resolution of the pointshell representation of the sphere is increased, the stack gets more and more stable. Using a coarser sampling grid to generate the pointshells intrinsically adds some quantization noise to the modeled object; that could explain its apparently more realistic behavior.
5.3.3.2 Tests with the Stanford Bunny
In this section, the VPS re-implementation is compared against other available algo- rithms in Bullet, varying the resolution of the Stanford Bunny or its segmentation level. Figure5.14 illustrates some of the used data structures.
General Comparison with Bullet Algorithms Varying Resolution
Figure5.13 shows computation time and linear velocity diagrams produced by the VPS re-implementation from this work, Bullet’s convex decomposition, and Bullet’s GImpact implementation, which is used with arbitrary non-convex triangle meshes. In the experi- ment, a Stanford Bunny (35606 vertices) was dropped onto a horizontal plane, as shown in Figure5.12.
During full operation (Figure5.13, steps 250 to 600), the VPS algorithm is 137× faster than GImpact and requires on average 0.71 ms for each check using the fine resolution (34892 points). The bunny is simplified to a convex hull composed of only 42 vertices in the Bullet’s GJK implementation and to 8 convex hulls with 100 vertices each in the convex decomposition approach (equivalent to the pointshell in the VPS low resolution
Figure 5.12: Successive frames of a Stanford Bunny dropped onto a plane. This experiment corre- sponds to Section 5.3.3.2 and Fig- ure5.13. In the case of Figure5.13, the frames match with the follow- ing steps: (a) Step ∼ 50, (b) Step ∼ 175, (c) Step ∼ 200, and (d) Step ∼ 300. (a) (b) (c) (d) 0 200 400 600 800 1000 1200 1400 1600 1800 2000 101 103 105 Comp. Time ( µ s) 0 200 400 600 800 1000 1200 1400 1600 1800 2000 10−6 10−4 10−2 100 Simulation steps Lin. Velocity (m/s) VPS (fine grid) VPS (coarse grid) GImpact Convex Decomposition
Figure 5.13: Computation time (µsec) and linear velocity (m/sec) curves in logarithmic scale for the testing scenario in which a Stanford Bunny with 35606 vertices is dropped onto a plane (see Fig- ure 5.12). The pointshell of the bunny is composed of 799 (coarse/low res.) and 35596 (fine/high res.) points, and the voxelmap with 306 × 305 × 282 voxels. The decomposed bunny consists of 8 convex hulls with 100 vertices each. Note that Bullet de-activates collision detection under certain kinetic conditions causing sudden steps in the computation time curves.
case). In these conditions, GJK is 339× faster than the VPS with a fine resolution (34892 points), but the convex decomposition is only 1.3× faster than the VPS with a coarse resolution (799 points).
Therefore, the integrated VPS re-implementation leads to similar computation times and higher accuracies compared to the Bullet’s tested ones with low resolutions, whereas it outperforms them when the resolution is increased.
Segmented Collision Detection
In this section the segmented collision detection method introduced in Section 3.3.1.5
is validated. The experiments used a desktop-sized Stanford Bunny of low (799 points) and high resolutions (35596 points) with a mass of 1 kg and a diagonal inertia tensor JB = (4.79, 4.46, 6.38)10−3kgm2, which was dropped from a height of 0.5 m onto a plane,
as shown in Figure5.12.
Table 5.2: Computation time (µs) of the VPS when supplying different number of contact points according to the level of the point-sphere tree selected for the segmentation. Low resolution: 799 points; high resolution: 35596 points. Point-sphere hierarchies had a branching factor of NK = 4 children per cluster.
Resolution Level, L
1 2 3 4 5
Low (799 points) 102.2 102.1 104.2 102.3 102.8 High (35596 points) 1387.9 1477.5 1407.4 1449.6 1494.3
Figure 5.14: Different rep- resentations of the Stanford Bunny used in the tests of Sec-
tion 5.3.3.2: (a) Convex hull
created with Bullet; (b) Con- vex decomposition created us- ing Bullet [MG09]; (c) The segmented point representa- tion from Section 3.3.1.5 en-
coded by colors. (a) (b) (c)
was measured. For that, the bunny was dropped with 10 random orientations, calculating the average time during the interval between steps 200 − 600, i. e, full operation or worst case. Note that for L > 1, the number of segments m is close to LNK, being NK the
branching factor (see Section3.3.1.5); additionally, the number of segments m equals to the number of possible points in the contact manifold.
The results in Table 5.2 show that the computation times are very similar for all levels. Therefore, collision computation time is barely affected when segmented collision computation is employed.
The same experiment was performed at frequencies lower than 50 Hz using the Stan- ford Bunny, and the penetration errors were observed. When performing the test for L = 1 (one colliding point) the algorithm was able to maintain the bunny above the plane until ∼ 30 Hz were reached. Operating at a lower frequency would lead to the bunny falling through the plane after the initial collision was detected. The same ex- periment was done using L = 4 and L = 5 and the bunny was maintained above the plane for frequencies of simulation down to ∼ 10 Hz, where the penetration errors were minimized if a higher level L was chosen.