add forceFixedBase option for URDF import example
This commit is contained in:
@@ -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;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
|
|
||||||
virtual ~BulletURDFImporter();
|
virtual ~BulletURDFImporter();
|
||||||
|
|
||||||
virtual bool loadURDF(const char* fileName);
|
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false);
|
||||||
|
|
||||||
const char* getPathPrefix();
|
const char* getPathPrefix();
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ ROSURDFImporter::ROSURDFImporter(struct GUIHelperInterface* helper)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ROSURDFImporter::loadURDF(const char* fileName)
|
bool ROSURDFImporter::loadURDF(const char* fileName, bool forceFixedBase)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public:
|
|||||||
|
|
||||||
virtual ~ROSURDFImporter();
|
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();
|
virtual const char* getPathPrefix();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
virtual ~URDFImporterInterface() {}
|
virtual ~URDFImporterInterface() {}
|
||||||
|
|
||||||
|
|
||||||
virtual bool loadURDF(const char* fileName)=0;
|
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false)=0;
|
||||||
|
|
||||||
virtual const char* getPathPrefix()=0;
|
virtual const char* getPathPrefix()=0;
|
||||||
|
|
||||||
|
|||||||
@@ -715,7 +715,8 @@ bool UrdfParser::initTreeAndRoot(ErrorLogger* logger)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger)
|
|
||||||
|
bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceFixedBase)
|
||||||
{
|
{
|
||||||
|
|
||||||
TiXmlDocument xml_doc;
|
TiXmlDocument xml_doc;
|
||||||
@@ -840,8 +841,26 @@ bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ok(initTreeAndRoot(logger));
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forceFixedBase)
|
||||||
return initTreeAndRoot(logger);
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public:
|
|||||||
UrdfParser();
|
UrdfParser();
|
||||||
virtual ~UrdfParser();
|
virtual ~UrdfParser();
|
||||||
|
|
||||||
bool loadUrdf(const char* urdfText, ErrorLogger* logger);
|
bool loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceFixedBase);
|
||||||
|
|
||||||
const UrdfModel& getModel() const
|
const UrdfModel& getModel() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user