mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
add forceFixedBase option for URDF import example
This commit is contained in:
parent
272ffeb232
commit
7f4beba7ee
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 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();
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user