Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Overview

Travis Build Status Appveyor Build status

Bullet Physics SDK

This is the official C++ source code repository of the Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

PyBullet

PyBullet

New in Bullet 2.85: pybullet Python bindings, improved support for robotics and VR. Use pip install pybullet and checkout the PyBullet Quickstart Guide.

Installation is simple:

pip3 install pybullet --upgrade --user
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

If you use PyBullet in your research, please cite it like this:

@MISC{coumans2019,
author =   {Erwin Coumans and Yunfei Bai},
title =    {PyBullet, a Python module for physics simulation for games, robotics and machine learning},
howpublished = {\url{http://pybullet.org}},
year = {2016--2019}
}

Requirements for Bullet Physics C++

A C++ compiler for C++ 2003. The library is tested on Windows, Linux, Mac OSX, iOS, Android, but should likely work on any platform with C++ compiler. Some optional demos require OpenGL 2 or OpenGL 3, there are some non-graphical demos and unit tests too.

Contributors and Coding Style information

https://docs.google.com/document/d/1u9vyzPtrVoVhYqQOGNWUgjRbfwfCdIts_NzmvgiJ144/edit

Requirements for experimental OpenCL GPGPU support

The entire collision detection and rigid body dynamics can be executed on the GPU.

A high-end desktop GPU, such as an AMD Radeon 7970 or NVIDIA GTX 680 or better. We succesfully tested the software under Windows, Linux and Mac OSX. The software currently doesn't work on OpenCL CPU devices. It might run on a laptop GPU but performance will not likely be very good. Note that often an OpenCL drivers fails to compile a kernel. Some unit tests exist to track down the issue, but more work is required to cover all OpenCL kernels.

License

All source code files are licensed under the permissive zlib license (http://opensource.org/licenses/Zlib) unless marked differently in a particular folder/file.

Build instructions for Bullet using vcpkg

You can download and install Bullet using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install bullet3

The Bullet port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Build instructions for Bullet using premake. You can also use cmake instead.

Windows

Click on build_visual_studio_vr_pybullet_double.bat and open build3/vs2010/0_Bullet3Solution.sln When asked, convert the projects to a newer version of Visual Studio. If you installed Python in the C:\ root directory, the batch file should find it automatically. Otherwise, edit this batch file to choose where Python include/lib directories are located.

Windows Virtual Reality sandbox for HTC Vive and Oculus Rift

Build and run the App_SharedMemoryPhysics_VR project, preferably in Release/optimized build. You can connect from Python pybullet to the sandbox using:

import pybullet as p
p.connect(p.SHARED_MEMORY) #or (p.TCP, "localhost", 6667) or (p.UDP, "192.168.86.10",1234)

Linux and Mac OSX gnu make

Make sure cmake is installed (sudo apt-get install cmake, brew install cmake, or https://cmake.org)

In a terminal type:

./build_cmake_pybullet_double.sh

This script will invoke cmake and build in the build_cmake directory. You can find pybullet in Bullet/examples/pybullet. The BulletExampleBrowser binary will be in Bullet/examples/ExampleBrowser.

You can also build Bullet using premake. There are premake executables in the build3 folder. Depending on your system (Linux 32bit, 64bit or Mac OSX) use one of the following lines Using premake:

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

Then

	cd gmake
	make

Note that on Linux, you need to use cmake to build pybullet, since the compiler has issues of mixing shared and static libraries.

Mac OSX Xcode

Click on build3/xcode4.command or in a terminal window execute

./premake_osx xcode4

Usage

The App_ExampleBrowser executables will be located in the bin folder. You can just run it though a terminal/command prompt, or by clicking it.

[--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)

You can use mouse picking to grab objects. When holding the ALT or CONTROL key, you have Maya style camera mouse controls. Press F1 to create a series of screenshots. Hit ESCAPE to exit the demo app.

Check out the docs folder and the Bullet physics forums for further information.

Comments
  • Add multiclip loading and reward

    Add multiclip loading and reward

    I tried to implement the multi-clip reward described in the DeepMimic paper. In this pull request you will find:

    • loading of multiple clips and multiple kinematic characters
    • downsampling (using random sampling) and upsampling (using SLERP) of clips in case of multiple clips with different duration
    • selection of the maximum reward among all the clips, as described in the paper
    • train and run files to use as arguments
    • motions file to try the training and evaluation
    • a script to visualize the train and test return from output/agent0_log.txt

    I chose create new files as I am not 100% sure about the implementation. At the moment, I managed to train the character with multiple walking clips, but it limps. However, if a single clip is provided, it works exactly as the current version of train_humanoid3d_walk.txt and all the others single clip instances.

    I am putting this out there so that someone else can try it out as well. The only significant difference is that in the configuration file, instead of indicating a file containing the motion data, you can indicate the folder containing the motion data.

    opened by tfederico 35
  • Availability of pybullet on conda-forge

    Availability of pybullet on conda-forge

    NOTE: I am sure this has been asked before but I have not found a completely clear explanation on closed issues.


    I find it very confusing that it is seemingly impossible to cleanly install pybullet as a conda/conda-forge package. Here's what I find confusing:

    1. conda-forge has a bullet package and installing it actually installs pybullet
    2. regardless of that, it's been mentioned often that "bullet is not the same as pybullet" (eg here), and while they are not the same, the package installs pybullet, so, I don't understand the clarification.
    3. after having installed conda install bullet, running pip install pybullet overrides the installation instead of finding it as already satisfied requirement (which is what happens with mostly every other package out there).

    Finally, the conda-forge package has not been updated in about 10 months, while the pip has had very frequent updates in the same period. Normally, conda-forge bot automatically takes care of creating a PR when a new release is detected, so it's not clear to me what this doesn't happen in this case.

    opened by gonzalocasas 34
  • Steps for running gym examples?

    Steps for running gym examples?

    I saw the greatly expanded gym examples the selection looks nice! I checked the pybullet docs and I tried running them, but the path doesn't seem to work as-is, and it seems spaces is missing.

    opened by ahundt 31
  • Install pybullet library

    Install pybullet library

    I saw the announcement about pybullet in the 2.84 prerelease, and I went to tinker with it, but I noticed that it doesn't install libpybullet.so. It would be nice to install it like the other libraries I think. I'm not sure how other packages would find it though.

    opened by scpeters 30
  • Simple Neural Network 3D Walkers example

    Simple Neural Network 3D Walkers example

    tl;dr Check summary comments below

    Hello!

    I created a basic example of walkers that get a random Neural network initialization that enables them to walk (or not). The walker's body parts all have sensors, which get linked to the joint motors of each walker by randomized connection weights, which leads to non-random movement behavior. My next ideas would be to implement an optimization strategy like evolution (hence the folder name evolution) to find a fit walker. Alternatively, I could look into OpenGym-like Deep Reinforcement learning to make it work with Tensor flow. Any suggestions? I just wanted to publish early to have a basis for discussion before I go too far into the details of either one.

    opened by benelot 29
  • Add nearly all gym environments using pybullet together with the…

    Add nearly all gym environments using pybullet together with the…

    ...latest tf model from the roboschool model zoo. All my examples try to connect to an already running ExampleBrowser and run headless if no browser is open (if somebody just wants the recording or the scores etc.).

    For some reason, the model zoo version of reacher does not perform well at all. I will look into it again and otherwise just pull-request it here too since the env as such looks ok. If you want me to integrate the other gym envs you have into the same structure, just tell me. I can propose some structure for the gym stuff in general. Furthermore, I will soon pull-request my training pipeline so that people can also train stuff with the Example Browser.

    opened by benelot 26
  • Threading for Bullet2 using OpenMP, TBB, or PPL

    Threading for Bullet2 using OpenMP, TBB, or PPL

    Adds a multithreading demo to the example browser which uses either OpenMP, Intel TBB or Microsoft PPL to provide task scheduling. (issue #126) Demo allows task scheduler API to be changed on the fly. On my quad-core machine the bullet part of the demo (ignoring rendering, etc) runs about 3 times faster with threading enabled than in single-threaded mode.

    Also makes Dvbt rayTest threadsafe (issue #254, #258) Discussion (here)[http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=10232]

    Areas that run in parallel:

    narrowphase (dispatchAllPairs) discreteDynamicsWorld solve islands (each island is a separate task) discreteDynamicsWorld predictUnconstraintMotion discreteDynamicsWorld createPredictiveContacts discreteDynamicsWorld integrateTransforms

    There were some significant changes to how the btSimulationIslandManager works, so that islands could be dispatched in parallel to different solvers. Based on an earlier (pull request)[https://github.com/bulletphysics/bullet3/pull/303]. This version has been collapsed into fewer commits and many dead ends were stripped out. All of the previous patch's changes in the sequential impulse constraint solver were dropped, it is simpler and more effective to run islands of constraints in parallel.

    opened by lunkhound 26
  • pybullet transform debug tools

    pybullet transform debug tools

    Two tools would be extremely helpful for pybullet:

    1. A way to add arbitrary poses/coordinate systems with optional visualization, like an unlimited version of CoodinateSystemDemo.
    2. A useful companion would be a way to get arbitrary transforms between any two objects, including what is loaded from files like URDF.

    Is there a transform object with a vector + quaternion or are position and orientation always stored separately at the moment?

    Here is my first pass at an API, which will need some refinement:

    import pybullet as p
    
    # create/modify a pose object
    id = p.setPoseObject(transform,
                         itemUniqueId=None # create by default
                         relativeToId=WorldFrameId, 
                         parentFrameId=WorldFrameId, 
                         ballOpacity=1, 
                         triadOpacity=1, 
                         name="PoseObject####",
                         color="yellow")
    
    # move any object to an arbitrary position relative to an arbitrary frame
    success = setTransform(itemUniqueId, 
                           transform, 
                           relativeToId=WorldFrameId)
    
    # change the frame within which the specified frame moves
    success = setParentFrame(itemUniqueId, parentUniqueId)
    
    # get the id of the parent frame
    parentId = getParent(itemUniqueId)
    
    # get the transform between two arbitrary objects
    transform = getTransform(itemUniqueId, relativeToId=WorldFrameId)
    
    # get separate v,q (maybe not necessary if the transform above is [v,q]
    v, q = getTransformVectorQuaternion(itemUniqueId, relativeToId=WorldFrameId)
    

    It would be important that any frame moves along with its parent, for example if you were setting a tool point on a gripper, the frame should move with the gripper. If the world frame is the parent, it should remain static.

    Why is this important? It will be extremely useful for debugging, defining goals and visualizing them, etc.

    opened by ahundt 25
  • Wrong depth reported between sphere and trimesh collision

    Wrong depth reported between sphere and trimesh collision

    Overview

    This issue was found on godot engine, while I was checking what was happening here: https://github.com/godotengine/godot/issues/17960

    I've noticed that when my kinematic body was using a sphere shape, sometimes the engine was returning me a positive depth result even if the shape is penetrated.

    Details

    To check the collision between kinematic body with sphere shape and trimesh shape I'm using this algorithm: https://github.com/godotengine/godot/blob/master/modules/bullet/space_bullet.cpp#L1100-L1136

    and here the manifold result class to collect the data: https://github.com/godotengine/godot/blob/master/modules/bullet/godot_result_callbacks.cpp#L258-L268

    Problem

    As you can see from the addContactPoint function from the ManifoldResult callback (link above) I've this like of code:

    if (m_penetration_distance > depth) { // Has penetration?

    That check if there was penetration, since the depth is negative if penetration happens m_penetration_distance value is more than depth value (initially m_penetration_distance is 0).

    Even if the shape is penetrated for some reason the depth is positive. This start happening after a bit while I'm moving the kinematic body on certain area of this trimesh shape, and more important thing is that if I change the kinematic shape from sphere to capsule this problem never happens.

    Run the project:

    Compile godot engine from master branch and open this project: https://github.com/godotengine/godot/files/1874984/godot-desert-physics_collision_error.zip

    Move the camera using W-A-S-D and arrows of keyboards, move the kinematic body using T-F-G-H

    Images

    In this images the kinematic body is stuck The blue line is the normal of contact point

    Screenshot from the above screenshot from 2018-04-04 10-54-57

    Screenshot from the below to assert that there's penetration screenshot from 2018-04-04 10-55-02

    Screenshot from the above more close screenshot from 2018-04-04 10-55-18

    opened by AndreaCatania 24
  • Implement custom shape, Ray

    Implement custom shape, Ray

    What I need:

    I'm implementing bullet wrapper for Godot and I need to implement a custom shape "ray". This shape is basically a ray that push the body in the opposite direction where it points.

    What I does:

    Here a video difference from the Godot shape to the shape that I already implemented: https://www.youtube.com/watch?v=Ff0qlG55t_E&feature=youtu.be

    As you can see the shape can receive lateral forces.

    This is how I've implemented it: Header: https://github.com/AndreaCatania/godot/blob/59ac2999ea4af77cc36c65c9da904616d9eb832b/modules/bullet/btRayShape.h CPP: https://github.com/AndreaCatania/godot/blob/59ac2999ea4af77cc36c65c9da904616d9eb832b/modules/bullet/btRayShape.cpp

    As you can see I've extended the convex shape to implement the RayShape, and this allowed me to easily implement it, but its behaviour is not what I need.

    I need that the shape respond to the direction of ray only and for doing this I think that I need to create all algorithms to find the collisions in the narrowphase against all shapes.

    My question:

    Since do and maintain it could be not so easy, There's a way to customize the shape response in an easier way (in order to clamp forces to ray direction)?


    Related godot issue: https://github.com/godotengine/godot/issues/12156

    opened by AndreaCatania 24
  • [WIP] Adding joint limits to pybullet.getJointInfo(...).

    [WIP] Adding joint limits to pybullet.getJointInfo(...).

    I am trying to add the joint limits to the pybullet.getJointInfo(...), but it still segfaults when I load a URDF (discussed here #959 ). I am working on it. All help welcome.

    opened by benelot 24
  • The deformable_torus example appears to be broken due to a vtk/urdf import error

    The deformable_torus example appears to be broken due to a vtk/urdf import error

    Running import pybullet_examples.deformable_torus leads to starting a pybullet GUI window with a torus, and then a crash with the following message:

    b3Printf: b3Warning[examples/SharedMemory/../Importers/ImportURDFDemo/UrdfFindMeshFile.h,102]:
    
    b3Printf: : cannot find 'torus.vtk' in any directory in urdf path
    
    Nodes:  0
    Links:  0
    Faces:  0
    Tetras: 0
    b3Printf: b3Warning[examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h,102]:
    
    b3Printf: /usr/local/lib/python3.8/dist-packages/pybullet_data/torus_deform.urdf:12: cannot find 'torus.vtk' in any directory in urdf path
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.8/dist-packages/pybullet_examples/deformable_torus.py", line 22, in <module>
        bunny2 = p.loadURDF("torus_deform.urdf", [0,1,0.2], flags=p.URDF_USE_SELF_COLLISION)
    pybullet.error: Cannot load URDF file.
    
    

    Note that commenting out the lines in the source file associated with torus.vtk, torus_deform.urdf, and bunny2 eliminates the crashing issue but this likely changes the desired behavior of the example

    opened by danielpmorton 0
  • Added warning Buffer Limit

    Added warning Buffer Limit

    For addressing situations like Issue #4386.

    I am working on a fix in removeGraphicsInstance behaviour but I think I should modify OpenGL buffers also for not producing breaking changes, I can commit the solution I have until now and have some feedback from @erwincoumans

    opened by ManuCorrea 0
  • How to properly generate .vtk file from .obj file?

    How to properly generate .vtk file from .obj file?

    I want to load deformable object in PyBullet with function "loadSoftBody". I know that PyBullet offers example object file "torus.obj" and "torus.vtk". It works well. However, when I try to generate .vtk file by myself from .obj with the following steps, PyBullet crashes down:

    1. open .obj file in Blender in Windows and export .stl file
    2. generate .msh file in TetWild (https://github.com/Yixin-Hu/TetWild) in Ubuntu with command in terminal: $ ./TetWild --input torus.stl --output torus.msh
    3. open .msh file in Gmsh in Windows and export .vtk file
    4. run the following Python script:
    import pybullet as p
    from time import sleep
    import pybullet_data
    
    physicsClient = p.connect(p.GUI)
    
    p.setAdditionalSearchPath(pybullet_data.getDataPath())
    
    p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD)
    p.setGravity(0, 0, -10)
    
    planeId = p.loadURDF("plane.urdf", [0,0,0])
    
    # original .vtk file ------- success
    # softBodyId1 = p.loadSoftBody("original files/torus.vtk", basePosition = [0,0,5])
    # generated .vtk file ------- fail
    softBodyId2 = p.loadSoftBody("generated files/torus.vtk", basePosition = [0,0,5])
    
    p.setRealTimeSimulation(0)
    
    while p.isConnected():
    p.stepSimulation()
    

    Then PyBullet crashes down.

    pybullet build time: May 20 2022 19:44:17
    startThreads creating 1 threads.
    starting thread 0
    started thread 0
    argc=2
    argv[0] = --unused
    argv[1] = --start_demo_name=Physics Server
    ExampleBrowserThreadFunc started
    X11 functions dynamically loaded using dlopen/dlsym OK!
    X11 functions dynamically loaded using dlopen/dlsym OK!
    Creating context
    Created GL 3.3 context
    Direct GLX rendering context obtained
    Making context current
    GL_VENDOR=VMware, Inc.
    GL_RENDERER=SVGA3D; build: RELEASE; LLVM;
    GL_VERSION=4.1 (Core Profile) Mesa 21.2.6
    GL_SHADING_LANGUAGE_VERSION=4.10
    pthread_getconcurrency()=0
    Version = 4.1 (Core Profile) Mesa 21.2.6
    Vendor = VMware, Inc.
    Renderer = SVGA3D; build: RELEASE; LLVM;
    b3Printf: Selected demo: Physics Server
    startThreads creating 1 threads.
    starting thread 0
    started thread 0
    MotionThreadFunc thread started
    ven = VMware, Inc.
    ven = VMware, Inc.
    Segmentation fault (core dumped)
    

    All the files are attached in the files.zip Folder "original files" are files provided by PyBullet git repository. Folder "generated files" are files generated by myself. I search for the solution online and issue #2726 but still cannot solve this problem.

    opened by ProgrammingElite 1
  • saveState / restoreState leading to non-determinism when using composite collision objects

    saveState / restoreState leading to non-determinism when using composite collision objects

    When using objects that have composite collision objects (e.g. created via vhacd), then the simulation after save/restoreState is not deterministic anymore.

    To reproduce this error, I simply used the existing TestPybulletSaveRestoreMethods and replaced cube_small.urdf with duck_vhacd.urdf.

    See code
    import unittest
    import pybullet as p
    import math, time
    import difflib, sys
    
    from utils import allclose, dot
    
    
    class TestPybulletSaveRestoreMethods(unittest.TestCase):
    
      def setupWorld(self):
        numObjects = 50
    
        maximalCoordinates = False
    
        p.resetSimulation()
        p.setPhysicsEngineParameter(deterministicOverlappingPairs=1)
        p.loadURDF("planeMesh.urdf", useMaximalCoordinates=maximalCoordinates)
        kukaId = p.loadURDF("kuka_iiwa/model_free_base.urdf", [0, 0, 10],
                            useMaximalCoordinates=maximalCoordinates)
        for i in range(p.getNumJoints(kukaId)):
          p.setJointMotorControl2(kukaId, i, p.POSITION_CONTROL, force=0)
        for i in range(numObjects):
          cube = p.loadURDF("duck_vhacd.urdf", [0, i * 0.02, (i + 1) * 0.2])
          #p.changeDynamics(cube,-1,mass=100)
        p.stepSimulation()
        p.setGravity(0, 0, -10)
    
      def dumpStateToFile(self, file):
        for i in range(p.getNumBodies()):
          pos, orn = p.getBasePositionAndOrientation(i)
          linVel, angVel = p.getBaseVelocity(i)
          txtPos = "pos=" + str(pos) + "\n"
          txtOrn = "orn=" + str(orn) + "\n"
          txtLinVel = "linVel" + str(linVel) + "\n"
          txtAngVel = "angVel" + str(angVel) + "\n"
          file.write(txtPos)
          file.write(txtOrn)
          file.write(txtLinVel)
          file.write(txtAngVel)
    
      def compareFiles(self, file1, file2):
        diff = difflib.unified_diff(
            file1.readlines(),
            file2.readlines(),
            fromfile='saveFile.txt',
            tofile='restoreFile.txt',
        )
        numDifferences = 0
        for line in diff:
          numDifferences = numDifferences + 1
          sys.stdout.write(line)
        self.assertEqual(numDifferences, 0)
    
      def testSaveRestoreState(self):
        numSteps = 500
        numSteps2 = 30
    
        verbose = 0
        self.setupWorld()
    
        for i in range(numSteps):
          p.stepSimulation()
        p.saveBullet("state.bullet")
        if verbose:
          p.setInternalSimFlags(1)
        p.stepSimulation()
        if verbose:
          p.setInternalSimFlags(0)
          print("contact points=")
          for q in p.getContactPoints():
            print(q)
    
        for i in range(numSteps2):
          p.stepSimulation()
    
        file = open("saveFile.txt", "w")
        self.dumpStateToFile(file)
        file.close()
    
        #################################
        self.setupWorld()
    
        #both restore from file or from in-memory state should work
        p.restoreState(fileName="state.bullet")
        stateId = p.saveState()
    
        if verbose:
          p.setInternalSimFlags(1)
        p.stepSimulation()
        if verbose:
          p.setInternalSimFlags(0)
          print("contact points restored=")
          for q in p.getContactPoints():
            print(q)
        for i in range(numSteps2):
          p.stepSimulation()
    
        file = open("restoreFile.txt", "w")
        self.dumpStateToFile(file)
        file.close()
    
        p.restoreState(stateId)
        if verbose:
          p.setInternalSimFlags(1)
        p.stepSimulation()
        if verbose:
          p.setInternalSimFlags(0)
          print("contact points restored=")
          for q in p.getContactPoints():
            print(q)
        for i in range(numSteps2):
          p.stepSimulation()
    
        file = open("restoreFile2.txt", "w")
        self.dumpStateToFile(file)
        file.close()
    
        file1 = open("saveFile.txt", "r")
        file2 = open("restoreFile.txt", "r")
        self.compareFiles(file1, file2)
        file1.close()
        file2.close()
    
        file1 = open("saveFile.txt", "r")
        file2 = open("restoreFile2.txt", "r")
        self.compareFiles(file1, file2)
        file1.close()
        file2.close()
    
    
    #while (p.getConnectionInfo()["isConnected"]):
    #	time.sleep(1)
    
    if __name__ == '__main__':
      p.connect(p.DIRECT)
      unittest.main()
    

    The bug exists for both cases: restoring from file or from in-memory state. I used pybullet 3.2.5 for testing.

    opened by cornerfarmer 0
  • URDF visual is not shown after removing and re-creating the object several times

    URDF visual is not shown after removing and re-creating the object several times

    What I am doing: I am repeating the following cycle: (1) load an object from a URDF file, (2) interact with it with a robot, (3) then delete it. Problem: After iteration number 125 (after creating and removing the object 125 times), the object visual is not shown. However, I can see the collision shape by pressing w, and I can interact with the object with the cursor. No problem if: There is no problem if I load the URDF once and reset its position. Expectation: The visual of the object would not be affected by the number of load/removal times. Recording of the mentioned effect: https://youtu.be/4bPfYZ6zjK8 Sample code:

    import os
    import time
    
    import pybullet as p
    import pybullet_data
    
    p.connect(p.GUI)
    p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0)
    p.resetDebugVisualizerCamera(1.5, 0, -40, [0.55, -0.35, 0.2])
    
    
    robot = p.loadURDF(os.path.join(pybullet_data.getDataPath(), "franka_panda/panda.urdf"), useFixedBase=True)
    table = p.loadURDF(os.path.join(pybullet_data.getDataPath(), "plane_transparent.urdf"))
    
    it = 0
    while True:
        it += 1
        p.resetJointState(robot, 0, 0)
        p.resetJointState(robot, 1, 0.307)
        p.resetJointState(robot, 2, 0)
        p.resetJointState(robot, 3, -2.7)
        p.resetJointState(robot, 4, 0)
        p.resetJointState(robot, 5, 3)
        p.resetJointState(robot, 6, -2.356)
        p.resetJointState(robot, 9, 0.01)
        p.resetJointState(robot, 10, 0.01)
    
        obj = p.loadURDF(os.path.join(pybullet_data.getDataPath(), "soccerball.urdf"), [0.6, 0., 0.05], globalScaling=0.1)
        # p.stepSimulation()
    
        joints = p.calculateInverseKinematics(robot, 11, [0.4, 0., 0.05])
        for _ in range(50):
            p.setJointMotorControlArray(robot, [0, 1, 2, 3, 4, 5, 6], p.POSITION_CONTROL, targetPositions=joints[:-2])
            p.stepSimulation()
            if it > 120:
                time.sleep(1/240)
        joints = p.calculateInverseKinematics(robot, 11, [0.6, 0., 0.05])
        for _ in range(50):
            p.setJointMotorControlArray(robot, [0, 1, 2, 3, 4, 5, 6], p.POSITION_CONTROL, targetPositions=joints[:-2])
            p.stepSimulation()
            if it > 120:
                time.sleep(1/240)
        p.removeBody(obj)
        print(it)
    
    opened by alper111 1
  • VSCode Terminal Shutdowns Example Browser

    VSCode Terminal Shutdowns Example Browser

    I tried to run this simple code in vscode terminal and the pop up example browser shutdowns immediately. I don't know what is causing this to happen. I looked around and didn't see similar problem I was wondering if anyone can help. The code runs perfectly in anaconda environment. But I cannot run in the terminal - here's the proof that it shutdowns immediately:

    import pybullet as p
    
    p.connect(p.GUI)
    p.setPhysicsEngineParameter(enableFileCaching=0)
    plane_shape = p.createCollisionShape(p.GEOM_PLANE)
    floor = p.createMultiBody(plane_shape,plane_shape)
    box_shape = p.createCollisionShape(p.GEOM_BOX, halfExtents = [1, 1, 1])
    box_object1 = p.createMultiBody(box_shape,box_shape)
    box_object2 = p.createMultiBody(box_shape,box_shape)
    p.setGravity(0,0,-10)
    

    Here's what the console shows:

    pybullet build time: Dec 22 2022 20:13:02 starting thread 0 started testThreads thread 0 with threadHandle 0000000000000484 argc=2 argv[0] = --unused argv[1] = --start_demo_name=Physics Server ExampleBrowserThreadFunc started Version = 4.6.0 NVIDIA 527.56 Vendor = NVIDIA Corporation Renderer = NVIDIA GeForce GTX 1080/PCIe/SSE2 b3Printf: Selected demo: Physics Server starting thread 0 started MotionThreads thread 0 with threadHandle 00000000000006F8 MotionThreadFunc thread started numActiveThreads = 0 stopping threads Thread with taskId 0 with handle 00000000000006F8 exiting Thread TERMINATED finished numActiveThreads = 0 btShutDownExampleBrowser stopping threads Thread with taskId 0 with handle 0000000000000484 exiting Thread TERMINATED

    opened by Razgaleh 0
Releases(3.24)
  • 3.24(Apr 24, 2022)

    Another fix from 3.24: avoid memory buildup when using createMultiBody, thanks to Jason Peng for the report and reproduction case. Minor fix, related to issue with debug line drawing, introduced in addUserDebugPoints patch. Also, remove C++11 'override'.

    See fast debug point rendering for point clouds in this PR: https://github.com/bulletphysics/bullet3/pull/3996

    There is a zip file with an example how to use it. debug_points

    Source code(tar.gz)
    Source code(zip)
  • 3.17(Nov 26, 2020)

    This updated Bullet Physics release was used for the "Learning Agile Robotic Locomotion Skills by Imitating Animals" research., led by Jason Peng.

    motion_imitation2

    See also https://xbpeng.github.io/projects/Robotic_Imitation/index.html And a video here: https://www.youtube.com/watch?v=lKYh6uuCwRY There is also an example of model-predictive-control (MPC) for quadruped locomotion. See the repository here: https://github.com/google-research/motion_imitation Install PyBullet using: pip3 install pybullet --user --upgrade

    Source code(tar.gz)
    Source code(zip)
  • 3.06(Sep 24, 2020)

    This updated Bullet Physics release was used for the "Learning Agile Robotic Locomotion Skills by Imitating Animals" research., led by Jason Peng.

    motion_imitation2

    See also https://xbpeng.github.io/projects/Robotic_Imitation/index.html And a video here: https://www.youtube.com/watch?v=lKYh6uuCwRY There is also an example of model-predictive-control (MPC) for quadruped locomotion. See the repository here: https://github.com/google-research/motion_imitation Install PyBullet using: pip3 install pybullet --user --upgrade

    Source code(tar.gz)
    Source code(zip)
  • 2.89(Dec 21, 2019)

    Bullet 2.89 includes a new implementation of volumetric deformable objects and cloth based on the Finite Element Method, thanks to Xuchen Han. Two-way coupling between deformables and rigid/multi body is achieved using a unified constraint solver.

    PyBullet is improved for robotics sim-to-real with realistic models of Laikago quadruped and an implementation of Deep Mimic.

    pip3 install pybullet python3 -m pybullet_envs.examples.laikago python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt

    image Video of Deep Mimic backflip: https://www.youtube.com/watch?v=aiWxIjtMMFI See also the PyBullet Quickstart Guide

    Finite Element Deformable kept in a grasp using friction: image

    Source code(tar.gz)
    Source code(zip)
  • 2.88(Dec 31, 2018)

    A lot of work this year went into improving PyBullet for robotics and reinforcement learning research. The SDK was used in several published research papers by Google Brain Robotics, including our RSS 2018 paper "Sim-to-Real: Learning Agile Locomotion For Quadruped Robots" , see the video here img Some of the improvements are related to maintaining determinism when saving and restoring a simulation, and improving the accuracy of GJK convex collision detection and btMultiBody.

    Source code(tar.gz)
    Source code(zip)
  • 2.87(Sep 29, 2017)

    Bullet 2.87 has improved support for robotics, reinforcement learning and VR. In particular, see the "Reinforcement Learning" section in the pybullet quickstart guide at http://pybullet.org . There are also preliminary C# bindings to allow the use of pybullet inside Unity 3D for robotics and reinforcement learning.

    Here are some videos:

    Some example training the pybullet_pendulum using TensorFlow Agents PPO: pip install pybullet, agents, tensorflow, gym

    python -m pybullet_envs.agents.train_ppo --config=pybullet_pendulum --logdir=pendulum tensorboard --logdir=pendulum --port=2222 python -m pybullet_envs.agents.visualize_ppo --logdir=pendulum/xxxxx --outdir=pendulum_video

    image

    Tensorboard training progress image for the Minitaur locomotion: minitaur

    Source code(tar.gz)
    Source code(zip)
  • 2.86.1(Feb 19, 2017)

    The Bullet 2.86 has improved Python bindings, pybullet, for robotics, machine learning and VR, see the pybullet quickstart guide.

    Furthermore, the PGS LCP constraint solver has a new option to terminate as soon as the residual (error) is below a specified tolerance (instead of terminating after a fixed number of iterations). There are optional multithreaded optimizations, thanks to lunkhound. There is preliminary support to load some MuJoCo MJCF xml files (see data/mjcf),see Bullet VR haptic experiments with a VR glove:

    https://www.youtube.com/watch?v=0JC-yukK-jo

    app_sharedmemoryphysics_vr_vs20 2017-01-26 10-12-45-16

    Source code(tar.gz)
    Source code(zip)
  • 2.85.1(Oct 15, 2016)

    Bullet 2.85 (previously known as 2.84) introduces pybullet, easy to use Python bindings, as well as Virtual Reality support for HTC Vice and Oculus Rift. In addition, there is support for Inverse Kinematics and Inverse Dynamics. This release is marked as 'prerelease' until the documentation is updated. See also this video: https://www.youtube.com/watch?v=VMJyZtHQL50 img

    Source code(tar.gz)
    Source code(zip)
    bullet-2.84_vr_win32_executable.zip(14.37 MB)
  • 2.83.7(Jan 12, 2016)

    Bullet Physics SDK 2.83 is a first release using the new example browser. See the docs/BulletQuickstart.pdf how to get started.

    bullet2 83

    Note that the example browser needs a bit more work and some old demos are not in the new example structures yes, this is a todo for a future release.

    Source code(tar.gz)
    Source code(zip)
Owner
Bullet Physics SDK
Bullet Physics development team
Bullet Physics SDK
C++ library for multi-physics simulation

Project CHRONO Project Chrono represents a community effort aimed at producing a physics-based modelling and simulation infrastructure based on a plat

null 1.6k Jan 6, 2023
Box2D is a 2D physics engine for games

Build Status Box2D Box2D is a 2D physics engine for games. Contributing Please do not submit pull requests with new features or core library changes.

Erin Catto 6.1k Jan 7, 2023
2D physics engine for games

LiquidFun Version 1.1.0 Welcome to LiquidFun! LiquidFun is a 2D physics engine for games. Go to our landing page to browse our documentation and see s

Google 4.5k Jan 5, 2023
High-performance C++ multibody dynamics/physics library for simulating articulated biomechanical and mechanical systems like vehicles, robots, and the human skeleton.

Simbody Simbody is a high-performance, open-source toolkit for science- and engineering-quality simulation of articulated mechanisms, including biomec

Simbody Project 2k Dec 25, 2022
A fast and lightweight 2D game physics library.

NEW IN CHIPMUNK 7 Chipmunk 7 is complete and now includes the ARM NEON optimizations, the autogeometry code, and the mulithreaded solver. The latest p

Scott Lembcke 1.9k Dec 30, 2022
NVIDIA PhysX SDK 3.4

NVIDIA PhysX SDK 3.4 Copyright (c) 2018 NVIDIA Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without mo

NVIDIA GameWorks 2.3k Jan 4, 2023
Natively multithreaded physics for threejs with PhysX.

Three-Physx Natively multithreaded physics for threejs with PhysX and an easy interface. Credit to Milkshake inc, physx-js, three-ammo, three-to-canno

XR Foundation 12 Jun 6, 2022
Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Bullet Physics SDK 10.1k Jan 7, 2023
A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.

Jolt Physics Library A multi core friendly rigid body physics and collision detection library suitable for games and VR applications. A YouTube video

null 2.5k Dec 31, 2022
A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.

A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.

null 2.5k Jan 4, 2023
BEST Robotics Code for BEST Robotics - RedShift Robotics

RedShift_BEST_2021 BEST Robotics Code for BEST Robotics - RedShift Robotics Sourced From RedShift Robotics Engineering Notebook: Software Design Every

null 1 Nov 6, 2021
Real-time multi-physics simulation with an emphasis on medical simulation.

Introduction SOFA is an open source framework primarily targeted at real-time simulation, with an emphasis on medical simulation. It is mainly intende

SOFA Framework 676 Dec 22, 2022
Video stabilization is a software-based approach in real-time to eliminating environmental effects (wind, heavy vehicle etc.) and enhance the visual performance that degrade video streaming quality.

Video Stabilization Contents General Info Installation To Do General Info Video stabilization is a software-based approach in real-time to eliminating

null 7 Nov 23, 2022
ORB-SLAM3 is the first real-time SLAM library able to perform Visual, Visual-Inertial and Multi-Map SLAM with monocular, stereo and RGB-D cameras, using pin-hole and fisheye lens models.

Just to test for my research, and I add coordinate transformation to evaluate the ORB_SLAM3. Only applied in research, and respect the authors' all work.

B.X.W 5 Jul 11, 2022
A 2D collision detection and physics library written in C.

A 2D collision detection and physics library written in C. WARNING: This library is in an early alpha stage, use it at your own risk. Documentation —

c-krit 85 Dec 24, 2022
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

This is the Vowpal Wabbit fast online learning code. Why Vowpal Wabbit? Vowpal Wabbit is a machine learning system which pushes the frontier of machin

Vowpal Wabbit 8.1k Dec 30, 2022
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.

The Algorithms - C # {#mainpage} Overview The repository is a collection of open-source implementation of a variety of algorithms implemented in C and

The Algorithms 15.3k Jan 5, 2023
Best practices, conventions, and tricks for ROS. Do you want to become a robotics master? Then consider graduating or working at the Robotics Systems Lab at ETH in Zürich!

ROS Best Practices, Conventions and Tricks Best practices for ROS2 in the making. See the Foxy branch in the meanwhile. This is a loose collection of

Robotic Systems Lab - Legged Robotics at ETH Zürich 1.2k Jan 5, 2023
Enabling services on your device 81 Jan 6, 2023