URDF parser: allow inertial element in just ixx, iyy, izz format (non-standard URDF)
tiny_obj_loader: don't crash when/if normals are not specified
This commit is contained in:
@@ -295,8 +295,19 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
|
|||||||
inertia.m_izz = urdfLexicalCast<double>(izz->GetText());
|
inertia.m_izz = urdfLexicalCast<double>(izz->GetText());
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
logger->reportError("Inertial: inertia element must have ixx,ixy,ixz,iyy,iyz,izz child elements");
|
if (ixx && iyy && izz)
|
||||||
return false;
|
{
|
||||||
|
inertia.m_ixx = urdfLexicalCast<double>(ixx->GetText());
|
||||||
|
inertia.m_ixy = 0;
|
||||||
|
inertia.m_ixz = 0;
|
||||||
|
inertia.m_iyy = urdfLexicalCast<double>(iyy->GetText());
|
||||||
|
inertia.m_iyz = 0;
|
||||||
|
inertia.m_izz = urdfLexicalCast<double>(izz->GetText());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
logger->reportError("Inertial: inertia element must have ixx,ixy,ixz,iyy,iyz,izz child elements");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -304,15 +315,29 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
|
|||||||
inertia_xml->Attribute("iyy") && inertia_xml->Attribute("iyz") &&
|
inertia_xml->Attribute("iyy") && inertia_xml->Attribute("iyz") &&
|
||||||
inertia_xml->Attribute("izz")))
|
inertia_xml->Attribute("izz")))
|
||||||
{
|
{
|
||||||
logger->reportError("Inertial: inertia element must have ixx,ixy,ixz,iyy,iyz,izz attributes");
|
if ((inertia_xml->Attribute("ixx") && inertia_xml->Attribute("iyy") &&
|
||||||
return false;
|
inertia_xml->Attribute("izz")))
|
||||||
}
|
{
|
||||||
inertia.m_ixx = urdfLexicalCast<double>(inertia_xml->Attribute("ixx"));
|
inertia.m_ixx = urdfLexicalCast<double>(inertia_xml->Attribute("ixx"));
|
||||||
inertia.m_ixy = urdfLexicalCast<double>(inertia_xml->Attribute("ixy"));
|
inertia.m_ixy = 0;
|
||||||
inertia.m_ixz = urdfLexicalCast<double>(inertia_xml->Attribute("ixz"));
|
inertia.m_ixz = 0;
|
||||||
inertia.m_iyy = urdfLexicalCast<double>(inertia_xml->Attribute("iyy"));
|
inertia.m_iyy = urdfLexicalCast<double>(inertia_xml->Attribute("iyy"));
|
||||||
inertia.m_iyz = urdfLexicalCast<double>(inertia_xml->Attribute("iyz"));
|
inertia.m_iyz = 0;
|
||||||
inertia.m_izz = urdfLexicalCast<double>(inertia_xml->Attribute("izz"));
|
inertia.m_izz = urdfLexicalCast<double>(inertia_xml->Attribute("izz"));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
logger->reportError("Inertial: inertia element must have ixx,ixy,ixz,iyy,iyz,izz attributes");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
inertia.m_ixx = urdfLexicalCast<double>(inertia_xml->Attribute("ixx"));
|
||||||
|
inertia.m_ixy = urdfLexicalCast<double>(inertia_xml->Attribute("ixy"));
|
||||||
|
inertia.m_ixz = urdfLexicalCast<double>(inertia_xml->Attribute("ixz"));
|
||||||
|
inertia.m_iyy = urdfLexicalCast<double>(inertia_xml->Attribute("iyy"));
|
||||||
|
inertia.m_iyz = urdfLexicalCast<double>(inertia_xml->Attribute("iyz"));
|
||||||
|
inertia.m_izz = urdfLexicalCast<double>(inertia_xml->Attribute("izz"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ updateVertex(
|
|||||||
positions.push_back(in_positions[3*i.v_idx+1]);
|
positions.push_back(in_positions[3*i.v_idx+1]);
|
||||||
positions.push_back(in_positions[3*i.v_idx+2]);
|
positions.push_back(in_positions[3*i.v_idx+2]);
|
||||||
|
|
||||||
if (i.vn_idx >= 0) {
|
if (i.vn_idx >= 0 && ((3*i.vn_idx+2)<in_normals.size())) {
|
||||||
normals.push_back(in_normals[3*i.vn_idx+0]);
|
normals.push_back(in_normals[3*i.vn_idx+0]);
|
||||||
normals.push_back(in_normals[3*i.vn_idx+1]);
|
normals.push_back(in_normals[3*i.vn_idx+1]);
|
||||||
normals.push_back(in_normals[3*i.vn_idx+2]);
|
normals.push_back(in_normals[3*i.vn_idx+2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user