Merge pull request #2359 from erwincoumans/master

premake add enable_stable_pd option, so Bullet can be compiled withou…
This commit is contained in:
erwincoumans
2019-08-08 09:58:32 -07:00
committed by GitHub
4 changed files with 219 additions and 176 deletions

View File

@@ -54,6 +54,13 @@
description = "Try to link and use system X11 headers instead of dynamically loading X11 (dlopen is default)"
}
newoption
{
trigger = "enable_stable_pd",
description = "Enable Stable PD control in PyBullet"
}
newoption
{
trigger = "enable_static_vr_plugin",

View File

@@ -660,6 +660,27 @@ btTransform ConvertURDF2BulletInternal(
if (mbLinkIndex >= 0) //???? double-check +/- 1
{
//if the base is static and all joints in the chain between this link and the base are fixed,
//then this link is static too (doesn't merge islands)
if (cache.m_bulletMultiBody->getBaseMass() == 0)
{
bool allJointsFixed = true;
int testLinkIndex = mbLinkIndex;
do
{
if (cache.m_bulletMultiBody->getLink(testLinkIndex).m_jointType != btMultibodyLink::eFixed)
{
allJointsFixed = false;
break;
}
testLinkIndex = cache.m_bulletMultiBody->getLink(testLinkIndex).m_parent;
} while (testLinkIndex> 0);
if (allJointsFixed)
{
col->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
}
}
cache.m_bulletMultiBody->getLink(mbLinkIndex).m_collider = col;
if (flags & CUF_USE_SELF_COLLISION_INCLUDE_PARENT)
{

View File

@@ -17,7 +17,8 @@ project ("pybullet")
includedirs {"../../src", "../../examples",
"../../examples/ThirdPartyLibs"}
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER", "STATIC_LINK_SPD_PLUGIN"}
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
hasCL = findOpenCL("clew")
@@ -181,6 +182,12 @@ if not _OPTIONS["no-enet"] then
"../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp",
"../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp",
"../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h",
if _OPTIONS["enable_stable_pd"] then
defines {"STATIC_LINK_SPD_PLUGIN"}
files {
"../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp",
"../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h",
"../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp",
@@ -196,6 +203,8 @@ if not _OPTIONS["no-enet"] then
"../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp",
"../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h",
}
end
if _OPTIONS["enable_physx"] then
defines {"BT_ENABLE_PHYSX","PX_PHYSX_STATIC_LIB", "PX_FOUNDATION_DLL=0"}

View File

@@ -4319,6 +4319,12 @@ static PyObject* pybullet_resetJointStatesMultiDof(PyObject* self, PyObject* arg
targetVelocitiesSeq = PySequence_Fast(targetVelocitiesObj, "expected a sequence of target positions");
for (i = 0; i < numIndices; i++)
{
double targetPositionArray[4] = { 0, 0, 0, 1 };
double targetVelocityArray[3] = { 0, 0, 0 };
int targetPositionSize = 0;
int targetVelocitySize = 0;
PyObject* targetPositionObj = 0;
PyObject* targetVelocityObj = 0;
int jointIndex = pybullet_internalGetIntFromSequence(jointIndicesSeq, i);
if ((jointIndex >= numJoints) || (jointIndex < 0))
@@ -4333,12 +4339,7 @@ static PyObject* pybullet_resetJointStatesMultiDof(PyObject* self, PyObject* arg
}
double targetPositionArray[4] = { 0, 0, 0, 1 };
double targetVelocityArray[3] = { 0, 0, 0 };
int targetPositionSize = 0;
int targetVelocitySize = 0;
PyObject* targetPositionObj = 0;
PyObject* targetVelocityObj = 0;
if (numTargetPositionObjs > 0)
@@ -6069,6 +6070,7 @@ static PyObject* pybullet_submitProfileTiming(PyObject* self, PyObject* args, Py
b3PhysicsClientHandle sm = 0;
static char* kwlist[] = {"eventName ", "physicsClientId", NULL};
int physicsClientId = 0;
b3SharedMemoryCommandHandle commandHandle;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|si", kwlist,
&eventName, &physicsClientId))
@@ -6080,7 +6082,7 @@ static PyObject* pybullet_submitProfileTiming(PyObject* self, PyObject* args, Py
PyErr_SetString(SpamError, "Not connected to physics server.");
return NULL;
}
b3SharedMemoryCommandHandle commandHandle;
commandHandle = b3ProfileTimingCommandInit(sm, eventName);
if (eventName)
@@ -10979,10 +10981,12 @@ static PyObject* pybullet_calculateInverseKinematics2(PyObject* self,
}
{
int numEndEffectorPositions = extractVertices(targetPosObj, 0, B3_MAX_NUM_END_EFFECTORS);
int numIndices = extractIndices(endEffectorLinkIndicesObj, 0, B3_MAX_NUM_END_EFFECTORS);
double* positions = numEndEffectorPositions ? malloc(numEndEffectorPositions * 3 * sizeof(double)) : 0;
int* indices = numIndices ? malloc(numIndices * sizeof(int)) : 0;
numEndEffectorPositions = extractVertices(targetPosObj, positions, B3_MAX_NUM_VERTICES);
if (endEffectorLinkIndicesObj)
@@ -10990,6 +10994,7 @@ static PyObject* pybullet_calculateInverseKinematics2(PyObject* self,
numIndices = extractIndices(endEffectorLinkIndicesObj, indices, B3_MAX_NUM_INDICES);
}
{
double pos[3] = { 0, 0, 0 };
double ori[4] = { 0, 0, 0, 1 };
int hasPos = numEndEffectorPositions > 0;
@@ -11182,6 +11187,7 @@ static PyObject* pybullet_calculateInverseKinematics2(PyObject* self,
return NULL;
}
}
}
Py_INCREF(Py_None);
return Py_None;