support single-scalar scale values in URDF, even though "officially" it should be a vector3. This will load quadcopter.urdf in Drake:

https://github.com/RobotLocomotion/drake/blob/master/drake/examples/Quadrotor/quadrotor.urdf
This commit is contained in:
Erwin Coumans
2016-06-22 09:59:25 -07:00
parent a67df7fd03
commit 2b8bd58e1c

View File

@@ -393,13 +393,22 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
}
geom.m_meshFileName = shape->Attribute("filename");
geom.m_meshScale.setValue(1,1,1);
if (shape->Attribute("scale"))
if (shape->Attribute("scale"))
{
parseVector3(geom.m_meshScale,shape->Attribute("scale"),logger);
if (!parseVector3(geom.m_meshScale,shape->Attribute("scale"),logger))
{
logger->reportWarning("scale should be a vector3, not single scalar. Workaround activated.\n");
std::string scalar_str = shape->Attribute("scale");
double scaleFactor = urdfLexicalCast<double>(scalar_str.c_str());
if (scaleFactor)
{
geom.m_meshScale.setValue(scaleFactor,scaleFactor,scaleFactor);
}
}
} else
{
geom.m_meshScale.setValue(1,1,1);
}
}
}