mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-15 14:10:11 +00:00
Merge pull request #1671 from erwincoumans/master
don't use the URDF inertia element, unless flag CUF_USE_URDF_INERTIA …
This commit is contained in:
commit
ab4b663800
@ -300,6 +300,45 @@ std::string BulletURDFImporter::getJointName(int linkIndex) const
|
||||
return "";
|
||||
}
|
||||
|
||||
void BulletURDFImporter::getMassAndInertia2(int urdfLinkIndex, btScalar& mass, btVector3& localInertiaDiagonal, btTransform& inertialFrame, int flags) const
|
||||
{
|
||||
if (flags & CUF_USE_URDF_INERTIA)
|
||||
{
|
||||
getMassAndInertia(urdfLinkIndex, mass, localInertiaDiagonal, inertialFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
//the link->m_inertia is NOT necessarily aligned with the inertial frame
|
||||
//so an additional transform might need to be computed
|
||||
UrdfLink* const* linkPtr = m_data->m_urdfParser.getModel().m_links.getAtIndex(urdfLinkIndex);
|
||||
|
||||
btAssert(linkPtr);
|
||||
if (linkPtr)
|
||||
{
|
||||
UrdfLink* link = *linkPtr;
|
||||
btScalar linkMass;
|
||||
if (link->m_parentJoint == 0 && m_data->m_urdfParser.getModel().m_overrideFixedBase)
|
||||
{
|
||||
linkMass = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
linkMass = link->m_inertia.m_mass;
|
||||
}
|
||||
mass = linkMass;
|
||||
localInertiaDiagonal.setValue(0,0,0);
|
||||
inertialFrame.setOrigin(link->m_inertia.m_linkLocalFrame.getOrigin());
|
||||
inertialFrame.setBasis(link->m_inertia.m_linkLocalFrame.getBasis());
|
||||
}
|
||||
else
|
||||
{
|
||||
mass = 1.f;
|
||||
localInertiaDiagonal.setValue(1, 1, 1);
|
||||
inertialFrame.setIdentity();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BulletURDFImporter::getMassAndInertia(int linkIndex, btScalar& mass,btVector3& localInertiaDiagonal, btTransform& inertialFrame) const
|
||||
{
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
virtual std::string getJointName(int linkIndex) const;
|
||||
|
||||
virtual void getMassAndInertia(int linkIndex, btScalar& mass,btVector3& localInertiaDiagonal, btTransform& inertialFrame) const;
|
||||
virtual void getMassAndInertia2(int urdfLinkIndex, btScalar& mass, btVector3& localInertiaDiagonal, btTransform& inertialFrame, int flags) const;
|
||||
|
||||
|
||||
virtual bool getJointInfo(int urdfLinkIndex, btTransform& parent2joint, btTransform& linkTransformInWorld, btVector3& jointAxisInJointSpace, int& jointType, btScalar& jointLowerLimit, btScalar& jointUpperLimit, btScalar& jointDamping, btScalar& jointFriction) const;
|
||||
virtual bool getJointInfo2(int urdfLinkIndex, btTransform& parent2joint, btTransform& linkTransformInWorld, btVector3& jointAxisInJointSpace, int& jointType, btScalar& jointLowerLimit, btScalar& jointUpperLimit, btScalar& jointDamping, btScalar& jointFriction, btScalar& jointMaxForce, btScalar& jointMaxVelocity) const;
|
||||
|
@ -215,7 +215,7 @@ void ConvertURDF2BulletInternal(
|
||||
//b3Printf("urdf parent index = %d\n",urdfParentIndex);
|
||||
//b3Printf("mb parent index = %d\n",mbParentIndex);
|
||||
parentRigidBody = cache.getRigidBodyFromLink(urdfParentIndex);
|
||||
u2b.getMassAndInertia(urdfParentIndex, parentMass,parentLocalInertiaDiagonal,parentLocalInertialFrame);
|
||||
u2b.getMassAndInertia2(urdfParentIndex, parentMass,parentLocalInertiaDiagonal,parentLocalInertialFrame, flags);
|
||||
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ void ConvertURDF2BulletInternal(
|
||||
btTransform localInertialFrame;
|
||||
localInertialFrame.setIdentity();
|
||||
btVector3 localInertiaDiagonal(0,0,0);
|
||||
u2b.getMassAndInertia(urdfLinkIndex, mass,localInertiaDiagonal,localInertialFrame);
|
||||
u2b.getMassAndInertia2(urdfLinkIndex, mass,localInertiaDiagonal,localInertialFrame, flags);
|
||||
|
||||
|
||||
|
||||
|
@ -48,8 +48,12 @@ public:
|
||||
virtual std::string getJointName(int linkIndex) const = 0;
|
||||
|
||||
//fill mass and inertial data. If inertial data is missing, please initialize mass, inertia to sensitive values, and inertialFrame to identity.
|
||||
virtual void getMassAndInertia(int urdfLinkIndex, btScalar& mass,btVector3& localInertiaDiagonal, btTransform& inertialFrame) const =0;
|
||||
|
||||
virtual void getMassAndInertia (int urdfLinkIndex, btScalar& mass,btVector3& localInertiaDiagonal, btTransform& inertialFrame) const =0;
|
||||
virtual void getMassAndInertia2(int urdfLinkIndex, btScalar& mass, btVector3& localInertiaDiagonal, btTransform& inertialFrame, int flags) const
|
||||
{
|
||||
getMassAndInertia(urdfLinkIndex, mass, localInertiaDiagonal, inertialFrame);
|
||||
}
|
||||
|
||||
///fill an array of child link indices for this link, btAlignedObjectArray behaves like a std::vector so just use push_back and resize(0) if needed
|
||||
virtual void getLinkChildIndices(int urdfLinkIndex, btAlignedObjectArray<int>& childLinkIndices) const =0;
|
||||
|
||||
|
@ -2602,7 +2602,7 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
|
||||
bodyHandle->m_bodyName = u2b.getBodyName();
|
||||
btVector3 localInertiaDiagonal(0,0,0);
|
||||
int urdfLinkIndex = u2b.getRootLinkIndex();
|
||||
u2b.getMassAndInertia(urdfLinkIndex, mass,localInertiaDiagonal,bodyHandle->m_rootLocalInertialFrame);
|
||||
u2b.getMassAndInertia2(urdfLinkIndex, mass,localInertiaDiagonal,bodyHandle->m_rootLocalInertialFrame,flags);
|
||||
}
|
||||
|
||||
|
||||
@ -2664,7 +2664,7 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
|
||||
btScalar mass;
|
||||
btVector3 localInertiaDiagonal(0,0,0);
|
||||
btTransform localInertialFrame;
|
||||
u2b.getMassAndInertia(urdfLinkIndex, mass,localInertiaDiagonal,localInertialFrame);
|
||||
u2b.getMassAndInertia2(urdfLinkIndex, mass,localInertiaDiagonal,localInertialFrame, flags);
|
||||
bodyHandle->m_linkLocalInertialFrames.push_back(localInertialFrame);
|
||||
|
||||
std::string* linkName = new std::string(u2b.getLinkName(urdfLinkIndex).c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user