From b095e1d917de73e4dce7bc502656475a67a77074 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 4 Apr 2017 12:47:34 -0700 Subject: [PATCH] expose pybullet.URDF_USE_SELF_COLLISION flag, experimental (likely doesn't work well for many URDF files) --- examples/Importers/ImportURDFDemo/URDF2Bullet.h | 1 + examples/SharedMemory/PhysicsServerCommandProcessor.cpp | 4 ++++ examples/SharedMemory/SharedMemoryPublic.h | 1 + examples/pybullet/pybullet.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/examples/Importers/ImportURDFDemo/URDF2Bullet.h b/examples/Importers/ImportURDFDemo/URDF2Bullet.h index 192a4ad39..de8978faf 100644 --- a/examples/Importers/ImportURDFDemo/URDF2Bullet.h +++ b/examples/Importers/ImportURDFDemo/URDF2Bullet.h @@ -19,6 +19,7 @@ enum ConvertURDFFlags { // Use inertia values in URDF instead of recomputing them from collision shape. CUF_USE_URDF_INERTIA = 2, CUF_USE_MJCF = 4, + CUF_USE_SELF_COLLISION=8 }; void ConvertURDF2Bullet(const URDFImporterInterface& u2b, diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 4ed8ea901..46d5ebabd 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -1810,6 +1810,10 @@ bool PhysicsServerCommandProcessor::loadUrdf(const char* fileName, const btVecto mb->setUserIndex2(bodyUniqueId); bodyHandle->m_multiBody = mb; + if (flags & URDF_USE_SELF_COLLISION) + { + mb->setHasSelfCollision(true); + } createJointMotors(mb); diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h index 7a201aee9..dacc6426e 100644 --- a/examples/SharedMemory/SharedMemoryPublic.h +++ b/examples/SharedMemory/SharedMemoryPublic.h @@ -451,6 +451,7 @@ enum eCONNECT_METHOD { enum eURDF_Flags { URDF_USE_INERTIA_FROM_FILE=2,//sync with URDF2Bullet.h 'ConvertURDFFlags' + URDF_USE_SELF_COLLISION=8,//see CUF_USE_SELF_COLLISION }; #endif//SHARED_MEMORY_PUBLIC_H diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index b041f88d8..0e920f7bd 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -1,4 +1,5 @@ + #include "../SharedMemory/PhysicsClientC_API.h" #include "../SharedMemory/PhysicsDirectC_API.h" #include "../SharedMemory/SharedMemoryInProcessPhysicsC_API.h" @@ -5434,6 +5435,7 @@ initpybullet(void) PyModule_AddIntConstant(m, "ER_BULLET_HARDWARE_OPENGL", ER_BULLET_HARDWARE_OPENGL); PyModule_AddIntConstant(m, "URDF_USE_INERTIA_FROM_FILE", URDF_USE_INERTIA_FROM_FILE); + PyModule_AddIntConstant(m, "URDF_USE_SELF_COLLISION", URDF_USE_SELF_COLLISION); PyModule_AddIntConstant(m, "B3G_F1", B3G_F1); PyModule_AddIntConstant(m, "B3G_F2", B3G_F2);