Add body name when loading urdf.

This commit is contained in:
yunfeibai committed 2017-03-23 10:16:39 -07:00
1 parent 59fcf7ca24
commit 50f0cfca9e
6 files changed
+20

No files matched your search

@@ -1311,6 +1311,11 @@ int BulletMJCFImporter::getRootLinkIndex() const
return "";
}
std::string BulletMJCFImporter::getBodyName() const
{
return m_data->m_fileModelName;
}
bool BulletMJCFImporter::getLinkColor(int linkIndex, btVector4& colorRGBA) const
{
// UrdfLink* link = m_data->getLink(linkIndex);
@@ -42,6 +42,8 @@ public:
///pure virtual interfaces, precondition is a valid linkIndex (you can assert/terminate if the linkIndex is out of range)
virtual std::string getLinkName(int linkIndex) const;
virtual std::string getBodyName() const;
/// optional method to provide the link color. return true if the color is available and copied into colorRGBA, return false otherwise
virtual bool getLinkColor(int linkIndex, btVector4& colorRGBA) const;
@@ -270,6 +270,11 @@ std::string BulletURDFImporter::getLinkName(int linkIndex) const
return "";
}
std::string BulletURDFImporter::getBodyName() const
{
return m_data->m_urdfParser.getModel().m_name;
}
std::string BulletURDFImporter::getJointName(int linkIndex) const
{
UrdfLink* const* linkPtr = m_data->m_urdfParser.getModel().m_links.getAtIndex(linkIndex);
@@ -35,6 +35,8 @@ public:
virtual void getLinkChildIndices(int linkIndex, btAlignedObjectArray<int>& childLinkIndices) const;
virtual std::string getBodyName() const;
virtual std::string getLinkName(int linkIndex) const;
virtual bool getLinkColor(int linkIndex, btVector4& colorRGBA) const;
@@ -27,6 +27,9 @@ public:
///pure virtual interfaces, precondition is a valid linkIndex (you can assert/terminate if the linkIndex is out of range)
virtual std::string getLinkName(int linkIndex) const =0;
virtual std::string getBodyName() const = 0;
/// optional method to provide the link color. return true if the color is available and copied into colorRGBA, return false otherwise
virtual bool getLinkColor(int linkIndex, btVector4& colorRGBA) const { return false;}
@@ -120,6 +120,7 @@ struct InteralBodyData
btMultiBody* m_multiBody;
btRigidBody* m_rigidBody;
int m_testData;
std::string m_bodyName;
btTransform m_rootLocalInertialFrame;
btAlignedObjectArray<btTransform> m_linkLocalInertialFrames;
@@ -1608,6 +1609,8 @@ bool PhysicsServerCommandProcessor::loadUrdf(const char* fileName, const btVecto
btMultiBody* mb = creation.getBulletMultiBody();
btRigidBody* rb = creation.getRigidBody();
bodyHandle->m_bodyName = u2b.getBodyName();
if (useMultiBody)
{