add forceFixedBase option for URDF import example

This commit is contained in:
Erwin Coumans 2015-07-07 15:39:36 -07:00
parent 272ffeb232
commit 7f4beba7ee
7 changed files with 30 additions and 10 deletions

View File

@ -93,7 +93,7 @@ struct BulletErrorLogger : public ErrorLogger
}
};
bool BulletURDFImporter::loadURDF(const char* fileName)
bool BulletURDFImporter::loadURDF(const char* fileName, bool forceFixedBase)
{
@ -129,7 +129,7 @@ bool BulletURDFImporter::loadURDF(const char* fileName)
}
BulletErrorLogger loggie;
bool result = m_data->m_urdfParser.loadUrdf(xml_string.c_str(),&loggie);
bool result = m_data->m_urdfParser.loadUrdf(xml_string.c_str(), &loggie, forceFixedBase);
return result;
}

View File

@ -16,7 +16,7 @@ public:
virtual ~BulletURDFImporter();
virtual bool loadURDF(const char* fileName);
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false);
const char* getPathPrefix();

View File

@ -95,7 +95,7 @@ ROSURDFImporter::ROSURDFImporter(struct GUIHelperInterface* helper)
}
bool ROSURDFImporter::loadURDF(const char* fileName)
bool ROSURDFImporter::loadURDF(const char* fileName, bool forceFixedBase)
{

View File

@ -16,7 +16,8 @@ public:
virtual ~ROSURDFImporter();
virtual bool loadURDF(const char* fileName);
// Note that forceFixedBase is ignored in this implementation.
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false);
virtual const char* getPathPrefix();

View File

@ -15,7 +15,7 @@ public:
virtual ~URDFImporterInterface() {}
virtual bool loadURDF(const char* fileName)=0;
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false)=0;
virtual const char* getPathPrefix()=0;

View File

@ -715,7 +715,8 @@ bool UrdfParser::initTreeAndRoot(ErrorLogger* logger)
return true;
}
bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger)
bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceFixedBase)
{
TiXmlDocument xml_doc;
@ -840,8 +841,26 @@ bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger)
}
}
bool ok(initTreeAndRoot(logger));
if (!ok)
{
return false;
}
return initTreeAndRoot(logger);
if (forceFixedBase)
{
for (int i=0;i<m_model.m_rootLinks.size();i++)
{
UrdfLink* link(m_model.m_rootLinks.at(i));
link->m_inertia.m_mass = 0.0;
link->m_inertia.m_ixx = 0.0;
link->m_inertia.m_ixy = 0.0;
link->m_inertia.m_ixz = 0.0;
link->m_inertia.m_iyy = 0.0;
link->m_inertia.m_iyz = 0.0;
link->m_inertia.m_izz = 0.0;
}
}
return true;
}

View File

@ -150,7 +150,7 @@ public:
UrdfParser();
virtual ~UrdfParser();
bool loadUrdf(const char* urdfText, ErrorLogger* logger);
bool loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceFixedBase);
const UrdfModel& getModel() const
{