From 707bac9c3d19eb5b00d04f58e6a97e872ef6c22e Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Mon, 22 Oct 2018 16:01:58 -0700 Subject: [PATCH] fix sphere sdf parsing --- .../Importers/ImportURDFDemo/UrdfParser.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.cpp b/examples/Importers/ImportURDFDemo/UrdfParser.cpp index 3dd782bf7..162d37f4c 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.cpp +++ b/examples/Importers/ImportURDFDemo/UrdfParser.cpp @@ -346,14 +346,27 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, XMLElement* g, ErrorLogger* l if (type_name == "sphere") { geom.m_type = URDF_GEOM_SPHERE; - if (!shape->Attribute("radius")) + if (m_parseSDF) { - logger->reportError("Sphere shape must have a radius attribute"); - return false; + XMLElement* size = shape->FirstChildElement("radius"); + if (0 == size) + { + logger->reportError("sphere requires a radius child element"); + return false; + } + geom.m_sphereRadius = urdfLexicalCast(size->GetText()); } else { - geom.m_sphereRadius = m_urdfScaling * urdfLexicalCast(shape->Attribute("radius")); + if (!shape->Attribute("radius")) + { + logger->reportError("Sphere shape must have a radius attribute"); + return false; + } + else + { + geom.m_sphereRadius = m_urdfScaling * urdfLexicalCast(shape->Attribute("radius")); + } } } else if (type_name == "box")