From 97add36b9fda8d76396ff84a9cf1567cfb508b30 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 25 Feb 2021 16:32:39 -0800 Subject: [PATCH 1/4] update bullet_client.py to accept options p.connect(p.GUI, options="--background_color_red=1 --background_color_blue=1 --background_color_green=1") If you use bullet_client.py, you can use: p = bc.BulletClient(connection_mode=pybullet.GUI,options="--background_color_red=1 --background_color_blue=1 --background_color_green=1") --mouse_move_multiplier=0.4 --mouse_wheel_multiplier=0.01 --mp4=moviename.mp4 --- examples/pybullet/gym/pybullet_utils/bullet_client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/pybullet/gym/pybullet_utils/bullet_client.py b/examples/pybullet/gym/pybullet_utils/bullet_client.py index f4995d3b5..6543313d0 100644 --- a/examples/pybullet/gym/pybullet_utils/bullet_client.py +++ b/examples/pybullet/gym/pybullet_utils/bullet_client.py @@ -9,7 +9,7 @@ import pybullet class BulletClient(object): """A wrapper for pybullet to manage different clients.""" - def __init__(self, connection_mode=None, hostName=None): + def __init__(self, connection_mode=None, hostName=None, options=''): """Creates a Bullet client and connects to a simulation. Args: @@ -22,15 +22,15 @@ class BulletClient(object): """ self._shapes = {} if connection_mode is None: - self._client = pybullet.connect(pybullet.SHARED_MEMORY) + self._client = pybullet.connect(pybullet.SHARED_MEMORY, options=options) if self._client >= 0: return else: connection_mode = pybullet.DIRECT if hostName is None: - self._client = pybullet.connect(connection_mode) + self._client = pybullet.connect(connection_mode, options=options) else: - self._client = pybullet.connect(connection_mode, hostName=hostName) + self._client = pybullet.connect(connection_mode, hostName=hostName, options=options) def __del__(self): """Clean up connection if not already done.""" From adcaa75777f09ddc018a168416a0b391a2e2cf52 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 1 Mar 2021 14:03:48 -0800 Subject: [PATCH 2/4] enable v-hacd in cmake for BulletRobotics and pybullet build (use cmake -DENABLE_VHACD=OFF .. to disable) cmake: enable stable PD plugin (-DDSTATIC_LINK_SPD_PLUGIN) btMultibody, make some args const in mulMatrix --- CMakeLists.txt | 2 ++ Extras/BulletRobotics/CMakeLists.txt | 21 +++++++++++++++++++ examples/pybullet/CMakeLists.txt | 14 ++++++++----- .../Featherstone/btMultiBody.cpp | 2 +- src/BulletDynamics/Featherstone/btMultiBody.h | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7860f1552..d2a0c2556 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,8 @@ OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF) OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" ON) OPTION(USE_OPENVR "Use OpenVR for virtual reality" OFF) +OPTION(ENABLE_VHACD "Use VHACD in BulletRobotics and pybullet" ON) + OPTION(BULLET2_MULTITHREADING "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF) IF (BULLET2_MULTITHREADING) OPTION(BULLET2_USE_OPEN_MP_MULTITHREADING "Build Bullet 2 with support for multi-threading with OpenMP (requires a compiler with OpenMP support)" OFF) diff --git a/Extras/BulletRobotics/CMakeLists.txt b/Extras/BulletRobotics/CMakeLists.txt index 2442f6efc..641300fb1 100644 --- a/Extras/BulletRobotics/CMakeLists.txt +++ b/Extras/BulletRobotics/CMakeLists.txt @@ -7,6 +7,9 @@ INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src ) +ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN) + + SET(BulletRobotics_INCLUDES ../../examples/CommonInterfaces/Common2dCanvasInterface.h @@ -156,8 +159,26 @@ SET(BulletRobotics_SRCS ${BulletRobotics_INCLUDES} ../../examples/MultiThreading/b3PosixThreadSupport.cpp ../../examples/MultiThreading/b3Win32ThreadSupport.cpp ../../examples/MultiThreading/b3ThreadSupportInterface.cpp + + ) +IF(ENABLE_VHACD) +ADD_DEFINITIONS(-DBT_ENABLE_VHACD) +SET(BulletRobotics_SRCS ${BulletRobotics_SRCS} + ../../Extras/VHACD/test/src/main_vhacd.cpp + ../../Extras/VHACD/src/VHACD.cpp + ../../Extras/VHACD/src/vhacdICHull.cpp + ../../Extras/VHACD/src/vhacdManifoldMesh.cpp + ../../Extras/VHACD/src/vhacdMesh.cpp + ../../Extras/VHACD/src/vhacdVolume.cpp +) +INCLUDE_DIRECTORIES( + ../../Extras/VHACD/inc + ../../Extras/VHACD/public +) +ENDIF(ENABLE_VHACD) + IF(BUILD_CLSOCKET) ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET) ENDIF(BUILD_CLSOCKET) diff --git a/examples/pybullet/CMakeLists.txt b/examples/pybullet/CMakeLists.txt index 1a7f0d5f2..5ee71645e 100644 --- a/examples/pybullet/CMakeLists.txt +++ b/examples/pybullet/CMakeLists.txt @@ -13,15 +13,19 @@ IF(BUILD_PYBULLET_NUMPY) ) ENDIF() -ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN) +ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN ) -SET(pybullet3_SRCS - pybullet.c - ) +IF(ENABLE_VHACD) +ADD_DEFINITIONS(-DBT_ENABLE_VHACD) + +INCLUDE_DIRECTORIES( + ../../Extras/VHACD/inc + ../../Extras/VHACD/public +) +ENDIF(ENABLE_VHACD) SET(pybullet_SRCS pybullet.c - ) IF(BUILD_CLSOCKET) diff --git a/src/BulletDynamics/Featherstone/btMultiBody.cpp b/src/BulletDynamics/Featherstone/btMultiBody.cpp index 7cb92fa3b..dfc4f92a3 100644 --- a/src/BulletDynamics/Featherstone/btMultiBody.cpp +++ b/src/BulletDynamics/Featherstone/btMultiBody.cpp @@ -1411,7 +1411,7 @@ void btMultiBody::solveImatrix(const btSpatialForceVector &rhs, btSpatialMotionV } } -void btMultiBody::mulMatrix(btScalar *pA, btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const +void btMultiBody::mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const { for (int row = 0; row < rowsA; row++) { diff --git a/src/BulletDynamics/Featherstone/btMultiBody.h b/src/BulletDynamics/Featherstone/btMultiBody.h index 5a3efc941..9cf1ceb5a 100644 --- a/src/BulletDynamics/Featherstone/btMultiBody.h +++ b/src/BulletDynamics/Featherstone/btMultiBody.h @@ -745,7 +745,7 @@ private: } } - void mulMatrix(btScalar * pA, btScalar * pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const; + void mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const; private: btMultiBodyLinkCollider *m_baseCollider; //can be NULL From 3963f077fc4e36809eed33b65117315d9610e3aa Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Thu, 4 Mar 2021 09:13:22 -0800 Subject: [PATCH 3/4] Fix memory leak in EGL / GUI mode, resetSimulation with textures in GUI mode. Fixes Issue #3285 --- examples/OpenGLWindow/GLInstancingRenderer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index 3754c4a9e..81f9ec8c6 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -397,6 +397,15 @@ void GLInstancingRenderer::removeAllInstances() m_graphicsInstances.clear(); m_data->m_publicGraphicsInstances.exitHandles(); m_data->m_publicGraphicsInstances.initHandles(); + + for (int i=0;im_textureHandles.size();i++) + { + InternalTextureHandle& h = m_data->m_textureHandles[i]; + glDeleteTextures(1, &h.m_glTexture); + } + + m_data->m_textureHandles.clear(); + } GLInstancingRenderer::~GLInstancingRenderer() From 201f3dd7d81a694f12af8616ef9b8a844c81aae5 Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Thu, 4 Mar 2021 09:55:35 -0800 Subject: [PATCH 4/4] cmake: move stable pd files from BulletRoboticsGUI to BulletRobotics. --- Extras/BulletRobotics/CMakeLists.txt | 127 +++++++++++++----------- Extras/BulletRoboticsGUI/CMakeLists.txt | 15 --- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/Extras/BulletRobotics/CMakeLists.txt b/Extras/BulletRobotics/CMakeLists.txt index 641300fb1..7287c1437 100644 --- a/Extras/BulletRobotics/CMakeLists.txt +++ b/Extras/BulletRobotics/CMakeLists.txt @@ -97,68 +97,83 @@ SET(BulletRobotics_INCLUDES ) SET(BulletRobotics_SRCS ${BulletRobotics_INCLUDES} - ../../examples/OpenGLWindow/SimpleCamera.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h + ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.h + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.h + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.h + ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h + ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.h + ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h + + ../../examples/OpenGLWindow/SimpleCamera.cpp - ../../examples/TinyRenderer/geometry.cpp - ../../examples/TinyRenderer/model.cpp - ../../examples/TinyRenderer/tgaimage.cpp - ../../examples/TinyRenderer/our_gl.cpp - ../../examples/TinyRenderer/TinyRenderer.cpp + ../../examples/TinyRenderer/geometry.cpp + ../../examples/TinyRenderer/model.cpp + ../../examples/TinyRenderer/tgaimage.cpp + ../../examples/TinyRenderer/our_gl.cpp + ../../examples/TinyRenderer/TinyRenderer.cpp - ../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp - ../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp - ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp - ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp - ../../examples/SharedMemory/IKTrajectoryHelper.cpp - ../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp - ../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp - ../../examples/SharedMemory/InProcessMemory.cpp - ../../examples/SharedMemory/PhysicsClient.cpp - ../../examples/SharedMemory/PhysicsServer.cpp - ../../examples/SharedMemory/PhysicsServerSharedMemory.cpp - ../../examples/SharedMemory/PhysicsDirect.cpp - ../../examples/SharedMemory/PhysicsDirectC_API.cpp - ../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp - ../../examples/SharedMemory/b3PluginManager.cpp - ../../examples/SharedMemory/PhysicsClientSharedMemory.cpp - ../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp - ../../examples/SharedMemory/PhysicsClientC_API.cpp - ../../examples/SharedMemory/Win32SharedMemory.cpp - ../../examples/SharedMemory/PosixSharedMemory.cpp + ../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp + ../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp + ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp + ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp + ../../examples/SharedMemory/IKTrajectoryHelper.cpp + ../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp + ../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp + ../../examples/SharedMemory/InProcessMemory.cpp + ../../examples/SharedMemory/PhysicsClient.cpp + ../../examples/SharedMemory/PhysicsServer.cpp + ../../examples/SharedMemory/PhysicsServerSharedMemory.cpp + ../../examples/SharedMemory/PhysicsDirect.cpp + ../../examples/SharedMemory/PhysicsDirectC_API.cpp + ../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp + ../../examples/SharedMemory/b3PluginManager.cpp + ../../examples/SharedMemory/PhysicsClientSharedMemory.cpp + ../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp + ../../examples/SharedMemory/PhysicsClientC_API.cpp + ../../examples/SharedMemory/Win32SharedMemory.cpp + ../../examples/SharedMemory/PosixSharedMemory.cpp - ../../examples/Utils/b3ResourcePath.cpp - ../../examples/Utils/RobotLoggingUtil.cpp - ../../examples/Utils/b3Clock.cpp - ../../examples/Utils/b3ResourcePath.cpp - ../../examples/Utils/ChromeTraceUtil.cpp + ../../examples/Utils/b3ResourcePath.cpp + ../../examples/Utils/RobotLoggingUtil.cpp + ../../examples/Utils/b3Clock.cpp + ../../examples/Utils/b3ResourcePath.cpp + ../../examples/Utils/ChromeTraceUtil.cpp - ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp - ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp - ../../examples/ThirdPartyLibs/stb_image/stb_image.cpp - ../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp - ../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp - ../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp - ../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp - ../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp - ../../examples/ThirdPartyLibs/BussIK/Misc.cpp - ../../examples/ThirdPartyLibs/BussIK/Node.cpp - ../../examples/ThirdPartyLibs/BussIK/Tree.cpp - ../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp + ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp + ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp + ../../examples/ThirdPartyLibs/stb_image/stb_image.cpp + ../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp + ../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp + ../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp + ../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp + ../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp + ../../examples/ThirdPartyLibs/BussIK/Misc.cpp + ../../examples/ThirdPartyLibs/BussIK/Node.cpp + ../../examples/ThirdPartyLibs/BussIK/Tree.cpp + ../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp - ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp - ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp - ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp - ../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp - ../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp - ../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp - ../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp - ../../examples/Importers/ImportURDFDemo/UrdfParser.cpp - ../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp - ../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp + ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp + ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp + ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp + ../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp + ../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp + ../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp + ../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp + ../../examples/Importers/ImportURDFDemo/UrdfParser.cpp + ../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp + ../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp - ../../examples/MultiThreading/b3PosixThreadSupport.cpp - ../../examples/MultiThreading/b3Win32ThreadSupport.cpp - ../../examples/MultiThreading/b3ThreadSupportInterface.cpp + ../../examples/MultiThreading/b3PosixThreadSupport.cpp + ../../examples/MultiThreading/b3Win32ThreadSupport.cpp + ../../examples/MultiThreading/b3ThreadSupportInterface.cpp ) diff --git a/Extras/BulletRoboticsGUI/CMakeLists.txt b/Extras/BulletRoboticsGUI/CMakeLists.txt index 9926f14b6..8537b57d8 100644 --- a/Extras/BulletRoboticsGUI/CMakeLists.txt +++ b/Extras/BulletRoboticsGUI/CMakeLists.txt @@ -94,21 +94,6 @@ SET(BulletRoboticsGUI_INCLUDES ) SET(BulletRoboticsGUI_SRCS ${BulletRoboticsGUI_INCLUDES} - - ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h - ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.h - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.h - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.h - ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h - ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.h - ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h ../../examples/ExampleBrowser/InProcessExampleBrowser.cpp ../../examples/SharedMemory/GraphicsServerExample.cpp ../../examples/SharedMemory/GraphicsClientExample.cpp