Bullet Physics SDK Documentation

repository·master·Indexed 28 days ago

https://github.com/bulletphysics/bullet3

A real-time collision detection and multi-physics simulation engine for VR, games, robotics, and machine learning. It features a high-performance C++ core and Python bindings via PyBullet. The SDK includes tools for convex collision hull generation and extensive VR integration capabilities through interfaces like IVRSystem, IVRCompositor, and IVRApplications for tracking, frame submission, and hardware management.

Tokens
13.6K
Snippets
12
Records
100
Agent score
97%

What's inside Bullet Physics SDK

  1. Build Bullet Physics on Windows

    master

    To build the C++ library on Windows, use the provided batch file which opens the Visual Studio solution.

    Note: If Python is not in the C:\ root directory, you must edit the batch file to specify the correct Python include and lib directories.

    VR Sandbox Connection: If building the Windows VR sandbox (HTC Vive/Oculus Rift), you can connect from Python pybullet using p.SHARED_MEMORY, p.TCP, or p.UDP.

    import pybullet as p
    p.connect(p.SHARED_MEMORY) #or (p.TCP, "localhost", 6667) or (p.UDP, "192.168.86.10",1234)
  2. Install Bullet Physics C++ using vcpkg

    master

    You can manage the Bullet Physics C++ dependency using the vcpkg dependency manager.

    git clone https://github.com/Microsoft/vcpkg.git
    cd vcpkg
    ./bootstrap-vcpkg.sh
    ./vcpkg integrate install
    ./vcpkg install bullet3
  3. Initialize a Server Driver Context

    master

    When writing a driver, you must initialize the driver context to access SteamVR interfaces. You can use the provided macros to handle initialization and cleanup of the COpenVRDriverContext.

    Macros:

    • VR_INIT_SERVER_DRIVER_CONTEXT(pContext): Initializes the server driver context using the provided IVRDriverContext. Returns an error if initialization fails.
    • VR_CLEANUP_SERVER_DRIVER_CONTEXT(): Cleans up the driver context.
    • VR_INIT_WATCHDOG_DRIVER_CONTEXT(pContext): Initializes the watchdog driver context.
    • VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT(): Cleans up the watchdog driver context.
    #define VR_INIT_SERVER_DRIVER_CONTEXT(pContext)                          
    	{\                                                                    
    		vr::EVRInitError eError = vr::InitServerDriverContext(pContext); \                                
    		if (eError != vr::VRInitError_None)                              \                                
    			return eError;                                               \                                
    	}
  4. Run PyBullet examples

    master

    After installing PyBullet, you can run various built-in examples using the python module syntax. Examples include TF Ant and Humanoid environments, as well as deep mimic reinforcement learning tests.

    python3 -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may
    python3 -m pybullet_envs.examples.enjoy_TF_HumanoidFlagrunHarderBulletEnv_v1_2017jul
    python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt
  5. Build Bullet Physics on Linux and Mac OSX

    master

    Linux and Mac OSX (using CMake)

    Ensure gcc and cmake are installed. On Linux, use the provided shell script to invoke cmake, as the compiler has issues mixing shared and static libraries when building pybullet.

    ./build_cmake_pybullet_double.sh

    Linux and Mac OSX (using Premake)

    Use the premake executables in the build3 folder depending on your architecture:

    cd build3
    ./premake4_linux --double gmake
    ./premake4_linux64 --double gmake
    ./premake4_osx --double --enable_pybullet gmake
    
    cd gmake
    make

    Mac OSX (using Xcode)

    Execute the xcode4 command:

    ./premake_osx xcode4
  6. Use App_ExampleBrowser CLI arguments

    master

    The App_ExampleBrowser executables (found in the bin folder) support several command-line arguments for configuring the demo environment.

    [--start_demo_name="Demo Name"]     Start with a selected demo  
    [--mp4=moviename.mp4]               Create a mp4 movie of the window, requires ffmpeg installed
    [--mouse_move_multiplier=0.400000]  Set the mouse move sensitivity
    [--mouse_wheel_multiplier=0.01]     Set the mouse wheel sensitivity
    [--background_color_red= 0.9]      Set the red component for background color. Same for green and blue
    [--fixed_timestep= 0.0]             Use either a real-time delta time (0.0) or a fixed step size (0.016666)
  7. Manage Chaperone Setup with IVRChaperoneSetup

    master

    The vr::IVRChaperoneSetup interface allows developers to manage the Chaperone system, including physical and collision bounds, play area sizes, and zero poses.

    Key tasks include:

    • Managing Bounds: Use SetWorkingPhysicalBoundsInfo and SetWorkingCollisionBoundsInfo to define boundaries, and GetLivePhysicalBoundsInfo or GetLiveCollisionBoundsInfo to retrieve them.
    • Configuring Play Area: Use SetWorkingPlayAreaSize to set dimensions.
    • Handling Zero Poses: Set or get the seated or standing zero poses relative to raw tracking using SetWorkingSeatedZeroPoseToRawTrackingPose, GetLiveSeatedZeroPoseToRawTrackingPose, etc.
    • Data Persistence: Use ReloadFromDisk to reload configuration or ExportLiveToBuffer and ImportFromBufferToWorking to serialize/deserialize the current state.