diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.cpp b/examples/Importers/ImportURDFDemo/UrdfParser.cpp index 0eeba3e46..9acc6c4c7 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.cpp +++ b/examples/Importers/ImportURDFDemo/UrdfParser.cpp @@ -1167,20 +1167,17 @@ bool UrdfParser::parseDeformable(UrdfModel& model, tinyxml2::XMLElement* config, XMLElement* spring_xml = config->FirstChildElement("spring"); if (spring_xml) { - XMLElement* elastic_stiffness = spring_xml->FirstChildElement("elastic_stiffness"); - XMLElement* damping_stiffness = spring_xml->FirstChildElement("damping_stiffness"); - XMLElement* bending_stiffness = spring_xml->FirstChildElement("bending_stiffness"); - if (!elastic_stiffness || !damping_stiffness) + if (!spring_xml->Attribute("elastic_stiffness") || !spring_xml->Attribute("damping_stiffness")) { - logger->reportError("srping element expect elastic and damping stiffness"); + logger->reportError("spring element expect elastic and damping stiffness"); return false; } - deformable.m_springCoefficients.elastic_stiffness = urdfLexicalCast(elastic_stiffness->GetText()); - deformable.m_springCoefficients.damping_stiffness = urdfLexicalCast(damping_stiffness->GetText()); + deformable.m_springCoefficients.elastic_stiffness = urdfLexicalCast(spring_xml->Attribute("elastic_stiffness")); + deformable.m_springCoefficients.damping_stiffness = urdfLexicalCast(spring_xml->Attribute("damping_stiffness")); - if (bending_stiffness) - deformable.m_springCoefficients.bending_stiffness = urdfLexicalCast(bending_stiffness->GetText()); + if (spring_xml->Attribute("bending_stiffness")) + deformable.m_springCoefficients.bending_stiffness = urdfLexicalCast(spring_xml->Attribute("bending_stiffness")); } XMLElement* corotated_xml = config->FirstChildElement("corotated"); @@ -1212,7 +1209,19 @@ bool UrdfParser::parseDeformable(UrdfModel& model, tinyxml2::XMLElement* config, logger->reportError("expected a filename for visual geometry"); return false; } - deformable.m_visualFileName = vis_xml->Attribute("filename"); + std::string fn = vis_xml->Attribute("filename"); + deformable.m_visualFileName = fn; + + int out_type(0); + bool success = UrdfFindMeshFile(m_fileIO, + model.m_sourceFile, fn, sourceFileLocation(vis_xml), + &deformable.m_visualFileName, &out_type); + + if (!success) + { + // warning already printed + return false; + } XMLElement* col_xml = config->FirstChildElement("collision"); if (col_xml) @@ -1222,7 +1231,16 @@ bool UrdfParser::parseDeformable(UrdfModel& model, tinyxml2::XMLElement* config, logger->reportError("expected a filename for collision geoemtry"); return false; } - deformable.m_simFileName = col_xml->Attribute("filename"); + fn = vis_xml->Attribute("filename"); + success = UrdfFindMeshFile(m_fileIO, + model.m_sourceFile, fn, sourceFileLocation(vis_xml), + &deformable.m_simFileName, &out_type); + + if (!success) + { + // warning already printed + return false; + } } ParseUserData(config, deformable.m_userData, logger); diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index f967dd64b..b540f50d1 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -8517,6 +8517,10 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo std::string object_name(std::string(relativeFileName).substr(pos + 1, strlen(relativeFileName) - 5 - pos)); bodyHandle->m_bodyName = object_name; } + b3Notification notification; + notification.m_notificationType = BODY_ADDED; + notification.m_bodyArgs.m_bodyUniqueId = *bodyUniqueId; + m_data->m_pluginManager.addNotification(notification); } return true; } @@ -8577,11 +8581,6 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar InternalBodyData* body = m_data->m_bodyHandles.getHandle(bodyUniqueId); strcpy(serverStatusOut.m_dataStreamArguments.m_bodyName, body->m_bodyName.c_str()); serverStatusOut.m_loadSoftBodyResultArguments.m_objectUniqueId = bodyUniqueId; - - b3Notification notification; - notification.m_notificationType = BODY_ADDED; - notification.m_bodyArgs.m_bodyUniqueId = bodyUniqueId; - m_data->m_pluginManager.addNotification(notification); #endif } return hasStatus;