Install PyBullet via pip
masterFor improved support for robotics, reinforcement learning, and VR, it is highly recommended to use the PyBullet Python bindings. You can install them using pip.
pip3 install pybullet --upgrade --userrepository·master·Indexed 28 days ago
https://github.com/bulletphysics/bullet3A 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.
For improved support for robotics, reinforcement learning, and VR, it is highly recommended to use the PyBullet Python bindings. You can install them using pip.
pip3 install pybullet --upgrade --userTo 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)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 bullet3Convex collision hulls for meshes (such as those used in the kuka_lwr arm) can be created using the convex_decomposition and ivcon tools.
convex_decomposition to generate the decomposed convex parts from an .obj mesh.ivcon to convert the resulting convex mesh into .obj and .stlb formats.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; \
}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.txtEnsure 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.shUse 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
makeExecute the xcode4 command:
./premake_osx xcode4The 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)CVRSystem class provides high-level access to core VR functionality, including projection matrices, tracking poses, device properties, and event polling. It includes specialized handling for macOS and Unix platforms to ensure correct data packing for PollNextEvent and GetControllerState.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:
SetWorkingPhysicalBoundsInfo and SetWorkingCollisionBoundsInfo to define boundaries, and GetLivePhysicalBoundsInfo or GetLiveCollisionBoundsInfo to retrieve them.SetWorkingPlayAreaSize to set dimensions.SetWorkingSeatedZeroPoseToRawTrackingPose, GetLiveSeatedZeroPoseToRawTrackingPose, etc.ReloadFromDisk to reload configuration or ExportLiveToBuffer and ImportFromBufferToWorking to serialize/deserialize the current state.vr::IVRDriverManager interface allows you to query the number of installed drivers and retrieve the name of a specific driver by its ID.