Enable 'global absolute velocities' by default for btMultiBody. See 8.3.2B Proposed resolution Jakub Stepien PhD Thesis
https://drive.google.com/file/d/0Bz3vEa19XOYGNWdZWGpMdUdqVmZ5ZVBOaEh4ZnpNaUxxZFNV/view?usp=sharing Fixes crashes due to rendering of softbody wireframe in the wrong thread (needs to be in 'debug' rendering section) Use btCapsuleShapeZ instead of btMultiSphereShape when converting MJCF MuJoCo capsules using fromto
This commit is contained in:
@@ -1897,6 +1897,7 @@ class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes( int linkI
|
||||
{
|
||||
if (col->m_geometry.m_hasFromTo)
|
||||
{
|
||||
#if 0
|
||||
btVector3 f = col->m_geometry.m_capsuleFrom;
|
||||
btVector3 t = col->m_geometry.m_capsuleTo;
|
||||
btVector3 fromto[2] = {f,t};
|
||||
@@ -1905,6 +1906,34 @@ class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes( int linkI
|
||||
|
||||
btMultiSphereShape* ms = new btMultiSphereShape(fromto,radii,2);
|
||||
childShape = ms;
|
||||
#else
|
||||
btVector3 f = col->m_geometry.m_capsuleFrom;
|
||||
btVector3 t = col->m_geometry.m_capsuleTo;
|
||||
|
||||
//compute the local 'fromto' transform
|
||||
btVector3 localPosition = btScalar(0.5)*(t+f);
|
||||
btQuaternion localOrn;
|
||||
localOrn = btQuaternion::getIdentity();
|
||||
|
||||
btVector3 diff = t-f;
|
||||
btScalar lenSqr = diff.length2();
|
||||
btScalar height = 0.f;
|
||||
|
||||
if (lenSqr > SIMD_EPSILON)
|
||||
{
|
||||
height = btSqrt(lenSqr);
|
||||
btVector3 ax = diff / height;
|
||||
|
||||
btVector3 zAxis(0,0,1);
|
||||
localOrn = shortestArcQuat(zAxis,ax);
|
||||
}
|
||||
btCapsuleShapeZ* capsule= new btCapsuleShapeZ(col->m_geometry.m_capsuleRadius,height);
|
||||
|
||||
btCompoundShape* compound = new btCompoundShape();
|
||||
btTransform localTransform(localOrn,localPosition);
|
||||
compound->addChildShape(localTransform,capsule);
|
||||
childShape = compound;
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
btCapsuleShapeZ* cap = new btCapsuleShapeZ(col->m_geometry.m_capsuleRadius,
|
||||
|
||||
@@ -344,6 +344,10 @@ void ConvertURDF2BulletInternal(
|
||||
bool isFixedBase = (mass==0);//todo: figure out when base is fixed
|
||||
int totalNumJoints = cache.m_totalNumJoints1;
|
||||
cache.m_bulletMultiBody = creation.allocateMultiBody(urdfLinkIndex, totalNumJoints,mass, localInertiaDiagonal, isFixedBase, canSleep);
|
||||
if (flags & CUF_NO_GLOBAL_VELOCITIES_MB)
|
||||
{
|
||||
cache.m_bulletMultiBody->useGlobalVelocities(false);
|
||||
}
|
||||
if (flags & CUF_USE_MJCF)
|
||||
{
|
||||
cache.m_bulletMultiBody->setBaseWorldTransform(linkTransformInWorldSpace);
|
||||
|
||||
@@ -24,6 +24,7 @@ enum ConvertURDFFlags {
|
||||
CUF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS=32,
|
||||
CUF_RESERVED=64,
|
||||
CUF_USE_IMPLICIT_CYLINDER=128,
|
||||
CUF_NO_GLOBAL_VELOCITIES_MB=256,
|
||||
};
|
||||
|
||||
void ConvertURDF2Bullet(const URDFImporterInterface& u2b,
|
||||
|
||||
@@ -1758,6 +1758,11 @@ B3_SHARED_API int b3GetStatusBodyIndex(b3SharedMemoryStatusHandle statusHandle)
|
||||
bodyId = status->m_dataStreamArguments.m_bodyUniqueId;
|
||||
break;
|
||||
}
|
||||
case CMD_LOAD_SOFT_BODY_COMPLETED:
|
||||
{
|
||||
bodyId = status->m_loadSoftBodyResultArguments.m_objectUniqueId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
b3Assert(0);
|
||||
|
||||
@@ -1276,6 +1276,15 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_LOAD_SOFT_BODY_FAILED:
|
||||
{
|
||||
b3Warning("loadSoftBody failed");
|
||||
break;
|
||||
}
|
||||
case CMD_LOAD_SOFT_BODY_COMPLETED:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
b3Error("Unknown server status %d\n", serverCmd.m_type);
|
||||
btAssert(0);
|
||||
|
||||
@@ -1047,6 +1047,15 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CMD_LOAD_SOFT_BODY_FAILED:
|
||||
{
|
||||
b3Warning("loadSoftBody failed");
|
||||
break;
|
||||
}
|
||||
case CMD_LOAD_SOFT_BODY_COMPLETED:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//b3Warning("Unknown server status type");
|
||||
|
||||
@@ -5757,7 +5757,7 @@ bool PhysicsServerCommandProcessor::processLoadURDFCommand(const struct SharedMe
|
||||
|
||||
bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct SharedMemoryCommand& clientCmd, struct SharedMemoryStatus& serverStatusOut, char* bufferServerToClient, int bufferSizeInBytes)
|
||||
{
|
||||
serverStatusOut.m_type = CMD_UNKNOWN_COMMAND_FLUSHED;
|
||||
serverStatusOut.m_type = CMD_LOAD_SOFT_BODY_FAILED;
|
||||
bool hasStatus = true;
|
||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||
double scale = 0.1;
|
||||
@@ -5840,11 +5840,12 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar
|
||||
InternalBodyHandle* bodyHandle = m_data->m_bodyHandles.getHandle(bodyUniqueId);
|
||||
bodyHandle->m_softBody = psb;
|
||||
serverStatusOut.m_loadSoftBodyResultArguments.m_objectUniqueId = bodyUniqueId;
|
||||
serverStatusOut.m_type = CMD_LOAD_SOFT_BODY_COMPLETED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serverStatusOut.m_type = CMD_CLIENT_COMMAND_COMPLETED;
|
||||
|
||||
#endif
|
||||
return hasStatus;
|
||||
}
|
||||
@@ -9142,17 +9143,7 @@ void PhysicsServerCommandProcessor::renderScene(int renderFlags)
|
||||
|
||||
m_data->m_guiHelper->render(m_data->m_dynamicsWorld);
|
||||
}
|
||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||
for ( int i=0;i<m_data->m_dynamicsWorld->getSoftBodyArray().size();i++)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)m_data->m_dynamicsWorld->getSoftBodyArray()[i];
|
||||
if (m_data->m_dynamicsWorld->getDebugDrawer() && !(m_data->m_dynamicsWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||
{
|
||||
//btSoftBodyHelpers::DrawFrame(psb,m_data->m_dynamicsWorld->getDebugDrawer());
|
||||
btSoftBodyHelpers::Draw(psb,m_data->m_dynamicsWorld->getDebugDrawer(),m_data->m_dynamicsWorld->getDrawFlags());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void PhysicsServerCommandProcessor::physicsDebugDraw(int debugDrawFlags)
|
||||
@@ -9163,6 +9154,18 @@ void PhysicsServerCommandProcessor::physicsDebugDraw(int debugDrawFlags)
|
||||
{
|
||||
m_data->m_dynamicsWorld->getDebugDrawer()->setDebugMode(debugDrawFlags);
|
||||
m_data->m_dynamicsWorld->debugDrawWorld();
|
||||
|
||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||
for ( int i=0;i<m_data->m_dynamicsWorld->getSoftBodyArray().size();i++)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)m_data->m_dynamicsWorld->getSoftBodyArray()[i];
|
||||
if (m_data->m_dynamicsWorld->getDebugDrawer() && !(m_data->m_dynamicsWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||
{
|
||||
//btSoftBodyHelpers::DrawFrame(psb,m_data->m_dynamicsWorld->getDebugDrawer());
|
||||
btSoftBodyHelpers::Draw(psb,m_data->m_dynamicsWorld->getDebugDrawer(),m_data->m_dynamicsWorld->getDrawFlags());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,8 @@ enum EnumSharedMemoryServerStatus
|
||||
CMD_RESTORE_STATE_COMPLETED,
|
||||
CMD_COLLISION_SHAPE_INFO_COMPLETED,
|
||||
CMD_COLLISION_SHAPE_INFO_FAILED,
|
||||
CMD_LOAD_SOFT_BODY_FAILED,
|
||||
CMD_LOAD_SOFT_BODY_COMPLETED,
|
||||
//don't go beyond 'CMD_MAX_SERVER_COMMANDS!
|
||||
CMD_MAX_SERVER_COMMANDS
|
||||
};
|
||||
@@ -671,6 +673,7 @@ enum eURDF_Flags
|
||||
URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS=32,
|
||||
URDF_RESERVED=64,
|
||||
URDF_USE_IMPLICIT_CYLINDER =128,
|
||||
URDF_NO_GLOBAL_VELOCITIES_MB =256,
|
||||
};
|
||||
|
||||
enum eUrdfGeomTypes //sync with UrdfParser UrdfGeomTypes
|
||||
|
||||
@@ -1422,7 +1422,7 @@ static PyObject* pybullet_loadSoftBody(PyObject* self, PyObject* args, PyObject*
|
||||
}
|
||||
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
|
||||
statusType = b3GetStatusType(statusHandle);
|
||||
if (statusType != CMD_CLIENT_COMMAND_COMPLETED)
|
||||
if (statusType != CMD_LOAD_SOFT_BODY_COMPLETED)
|
||||
{
|
||||
PyErr_SetString(SpamError, "Cannot load soft body.");
|
||||
return NULL;
|
||||
@@ -8817,7 +8817,8 @@ initpybullet(void)
|
||||
|
||||
PyModule_AddIntConstant(m, "URDF_USE_INERTIA_FROM_FILE", URDF_USE_INERTIA_FROM_FILE);
|
||||
PyModule_AddIntConstant(m, "URDF_USE_IMPLICIT_CYLINDER", URDF_USE_IMPLICIT_CYLINDER);
|
||||
|
||||
PyModule_AddIntConstant(m, "URDF_NO_GLOBAL_VELOCITIES_MB", URDF_NO_GLOBAL_VELOCITIES_MB);
|
||||
|
||||
PyModule_AddIntConstant(m, "URDF_USE_SELF_COLLISION", URDF_USE_SELF_COLLISION);
|
||||
PyModule_AddIntConstant(m, "URDF_USE_SELF_COLLISION_EXCLUDE_PARENT", URDF_USE_SELF_COLLISION_EXCLUDE_PARENT);
|
||||
PyModule_AddIntConstant(m, "URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS", URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS);
|
||||
|
||||
Reference in New Issue
Block a user