Demos

From Physics Simulation Wiki

Jump to: navigation, search

Contents

Bullet Physics Library Demos

The Bullet SDK includes a series of sample demos all included into an Example Browser. However, the demos can also be run headless and standalone with OpenGL. They can be found in the Bullet/examples folder.

Examples

In the following sections, all examples are described in detail.

Basic Example

A basic rigid body collision simulation. Creates some rigid bodies using box collision shapes on a flat surface. This is a good example to familiarize with the basic initialization of Bullet.

Controls

 left mouse button: grab and drag any of the cubes on the screen
 right mouse button (or .): fire new (smaller) cube onto screen, mouse location determines direction
 i: pause/play simulation
 s (while paused): step forward one frame
 z: zoom in
 x: zoom out
 r: rotate screen right
 l: rotate screen left
 h: show/hide program statistics
 w: show/hide wireframe
 d: show/hide auto-deactivation of the simulation

Notes

The Basic Example can also be compiled without graphical user interface, as a console application.

Sources

BasicExample on Github

The basic example is implemented within the following sources:

Rolling Friction

Damping is often not good enough to keep rounded objects from rolling down a sloped surface. Instead, you can set the rolling friction of a rigid body. Generally it is best to leave the rolling friction to zero, to avoid artifacts.

Constraints

Shows the use of the various constraints in Bullet.

Controls

Press the L key to visualize the constraint limits. Press the C key to visualize the constraint frames.

Motorized Hinge

Use of a btHingeConstraint. You can adjust the first slider to change the target velocity, and the second slider to adjust the maximum impulse applied to reach the target velocity. Note that the hinge angle can reach beyond -360 and 360 degrees.

Test Hinge Torque Example

Apply a torque in the hinge axis. This example uses a btHingeConstraint and btRigidBody. The setup is similar to the multi body example TestJointTorque.",

6DofSpring2 Example

Show the use of the btGeneric6DofSpring2Constraint. This is a replacement of the btGeneric6DofSpringConstraint, it has various improvements on stability, however, it is slower than its predecessor. This includes improved spring implementation and better control over the restitution (bounce) when the constraint hits its limits.

Motor Demo

Dynamic control the target velocity of a motor of a btHingeConstraint. This demo makes use of the 'internal tick callback'.

Controls

You can press W for wireframe, C and L to visualize constraint frame and limits.

Gyroscopic Example

Show the Dzhanibekov effect using various settings of the gyroscopic term.

Notes

You can select the gyroscopic term computation using btRigidBody::setFlags, with arguments BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT (using explicit integration, which adds energy and can lead to explosions), BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD, BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY. If you don't set any of these flags, there is no gyroscopic term used.

RigidBody Soft Contact Example

Using the error correction parameter (ERP) and constraint force mixing (CFM) values for contacts to simulate compliant contact.

Featherstone btMultibody Creation Example

Create a basic btMultiBody with 3-DOF spherical joints (mobilizers). The demo uses a fixed base or a floating base at restart.

Featherstone btMultibody JointTorque

Apply a torque to a btMultiBody with 1-DOF joints (mobilizers). This setup is similar to the TestHingeTorque.

TestPendulum

Simulate a pendulum using btMultiBody with a constant joint torque applied.

Notes

The same code is also used as a unit test comparing Bullet with the numerical solution of second-order non-linear differential equation stored in pendulum_gold.h

Constraint Feedback Example

The example shows how to receive joint reaction forces in a btMultiBody. Also the applied impulse is available for a btMultiBodyJointMotor separately.

Inverted Pendulum PD Control Example

Keep an inverted pendulum up using open loop PD control.

MultiBody Soft Contact

Using the error correction parameter (ERP) and constraint force mixing (CFM) values for contacts to simulate compliant contact.

MultiBody Inverse Dynamics URDF Example

Create a btMultiBody from URDF. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets.

MultiBody Inverse Dynamics Programmatic Example

Create a btMultiBody programatically. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets.

Constant Velocity Tutorial Example

Free moving rigid body, without external or constraint forces.

Gravity Acceleration Tutorial Example

Motion of a free falling rigid body under constant gravitational acceleration.

Contact Computation Tutorial Example

Discrete Collision Detection for sphere-sphere.

Solve Contact Constraint Tutorial Example

Compute and apply the impulses needed to satisfy non-penetrating contact constraints.

Spring constraint Tutorial Example

A rigid body with a spring constraint attached.

Spheres & Plane C-API (Bullet2)

Collision C-API using Bullet 2.x backend.

Spheres & Plane C-API (Bullet3)

Collision C-API using Bullet 3.x backend.

Cloth Example

Simulate a patch of cloth.

Softbody Pressure Constraint Example

Simulate 3D soft body using a pressure constraint.

Softbody Volume Constraint Example

Simulate 3D soft body using a volume constraint.

Softbody Rope Example

Simulate ropes using a soft body.

Rope Attach Example

Simulate a rigid body connected to a rope.

Cloth Attach Example

A rigid body attached to a cloth.

Sticks Example

Show simulation of ropes fixed to the ground.

Capsule Collision Example

Collision detection between a capsule shape and cloth.

Softbody Collide Example

Soft bodies colliding.

Softbody Collide 2 Example

Soft bodies colliding.

Softbody Collide 3 Example

Soft bodies colliding.

Softbody Impact Example

Soft body impact

Softbody Aero Simulation Example

Rudimentary aero dynamics simulation

Softbody Aero 2 Simulation Example

Rudimentary aero dynamics simulation.

Softbody Friction Example

Simulate soft body friction with friction coefficients ranging from 0 to 1.

Softbody Torus Example

Simulate a soft body torus.

Softbody Torus Example

Simulate a soft body torus using shape matching.

Softbody Bunny Example

Simulate the Stanford bunny as deformable object.

Softbody Bunny (Shape Match) Example

Simulate the Stanford bunny as deformable object including shape matching.

Softbody Cutting Example

Allow cutting of the soft body, by clicking on the cloth.

Softbody Cluster Deform Example

Collision detection using convex collision clusters.

Softbody Cluster Collide1 Example

Collision detection between soft bodies using convex collision clusters.

Softbody Cluster Collide2 Example

Collision detection between soft bodies using convex collision clusters.

Softbody Cluster Socket Example

Soft bodies connected by a point to point (ball-socket) constraints. This requires collision clusters, in order to define a frame of reference for the constraint.

Softbody Cluster Hinge Example

Soft bodies connected by a hinge constraints. This requires collision clusters, in order to define a frame of reference for the constraint.

Softbody Cluster Combine Example

Simulate soft bodies using collision clusters.

Softbody Cluster Car Example

Simulate the Stanford bunny by multiple soft bodies connected by constraints.

Softbody Cluster Robot Example

A rigid body base connected by soft body wheels, connected by constraints.

Softbody Cluster Stack Example

Stacking of soft bodies.

Softbody-Rigidbody Cluster Stack Example

Stacking of soft bodies and rigid bodies.

Tetra Cube Example

Simulate a volumetric soft body cube defined by tetrahedra.

Tetra Bunny Example

Simulate a volumetric soft body Stanford bunny defined by tetrahedra.

3000 boxes Benchmark Example

Benchmark a stack of 3000 boxes. It will stress the collision detection, a specialized box-box implementation based on the separating axis test, and the constraint solver.

1000 stack Benchmark Example

Benchmark a stack of 1000 boxes. It will stress the collision detection, a specialized box-box implementation based on the separating axis test, and the constraint solver.

Ragdolls Benchmark Example

"Benchmark the performance of the ragdoll constraints, btHingeConstraint and btConeTwistConstraint, in addition to capsule collision detection.

Convex stack Benchmark Example

Benchmark the performance and stability of rigid bodies using btConvexHullShape.

Prim vs Mesh Benchmark Example

Benchmark the performance and stability of rigid bodies using primitive collision shapes (btSphereShape, btBoxShape), resting on a triangle mesh, btBvhTriangleMeshShape.

Convex vs Mesh Benchmark Example

Benchmark the performance and stability of rigid bodies using convex hull collision shapes (btConvexHullShape), resting on a triangle mesh, btBvhTriangleMeshShape.

Raycast Benchmark Example

Benchmark the performance of the btCollisionWorld::rayTest. Note that currently the rays are not rendered.

Import .bullet Example

Load a binary .bullet file. The serialization mechanism can deal with versioning, differences in endianess, 32 and 64bit, double/single precision. It is easy to save a .bullet file, see the examples/Importers/ImportBullet/SerializeDemo.cpp for a code example how to export a .bullet file.

Import Wavefront Obj Example

Import a Wavefront .obj file.

Import Quake BSP Example

Import a Quake .bsp file.

Import COLLADA dae Example

Import the geometric mesh data from a COLLADA file. This is used as part of the URDF importer. This loader can also be used to import collision geometry in general.

Import STL Example

Import the geometric mesh data from a STL file. This is used as part of the URDF importer. This loader can also be used to import collision geometry in general.

Import URDF (RigidBody) Example

Import a URDF file, and create rigid bodies (btRigidBody) connected by constraints.

Import URDF (MultiBody) Example

Import a URDF file and create a single multibody (btMultiBody) with tree hierarchy of links (mobilizers).

---

Todo: describe each of the demos here, and also in the Bullet User Manual

Personal tools