@@ -1604,6 +1604,7 @@ void CopyBlob(tinyxml2::XMLElement *_src, tinyxml2::XMLElement *_blob_parent)
16041604void InsertSDFExtensionCollision (tinyxml2::XMLElement *_elem,
16051605 const std::string &_linkName)
16061606{
1607+ bool link_found = false ;
16071608 // loop through extensions for the whole model
16081609 // and see which ones belong to _linkName
16091610 // This might be complicated since there's:
@@ -1615,6 +1616,7 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem,
16151616 {
16161617 if (sdfIt->first == _linkName)
16171618 {
1619+ link_found = true ;
16181620 // std::cerr << "============================\n";
16191621 // std::cerr << "working on g_extensions for link ["
16201622 // << sdfIt->first << "]\n";
@@ -1908,12 +1910,19 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem,
19081910 }
19091911 }
19101912 }
1913+ // If we didn't find the link, emit a warning
1914+ if (!link_found) {
1915+ sdfwarn << " <collision> tag with reference[" << _linkName << " ] does not exist"
1916+ << " in the URDF model. Please ensure that the reference attribute"
1917+ << " matches the name of a link." ;
1918+ }
19111919}
19121920
19131921// //////////////////////////////////////////////////////////////////////////////
19141922void InsertSDFExtensionVisual (tinyxml2::XMLElement *_elem,
19151923 const std::string &_linkName)
19161924{
1925+ bool link_found = false ;
19171926 // loop through extensions for the whole model
19181927 // and see which ones belong to _linkName
19191928 // This might be complicated since there's:
@@ -1925,6 +1934,7 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem,
19251934 {
19261935 if (sdfIt->first == _linkName)
19271936 {
1937+ link_found=true ;
19281938 // std::cerr << "============================\n";
19291939 // std::cerr << "working on g_extensions for link ["
19301940 // << sdfIt->first << "]\n";
@@ -2102,6 +2112,12 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem,
21022112 }
21032113 }
21042114 }
2115+ // If we didn't find the link, emit a warning
2116+ if (!link_found) {
2117+ sdfwarn << " <visual> tag with reference[" << _linkName << " ] does not exist"
2118+ << " in the URDF model. Please ensure that the reference attribute"
2119+ << " matches the name of a link." ;
2120+ }
21052121}
21062122
21072123// //////////////////////////////////////////////////////////////////////////////
@@ -2168,13 +2184,15 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem,
21682184void InsertSDFExtensionJoint (tinyxml2::XMLElement *_elem,
21692185 const std::string &_jointName)
21702186{
2187+ bool joint_found = false ;
21712188 auto * doc = _elem->GetDocument ();
21722189 for (StringSDFExtensionPtrMap::iterator
21732190 sdfIt = g_extensions.begin ();
21742191 sdfIt != g_extensions.end (); ++sdfIt)
21752192 {
21762193 if (sdfIt->first == _jointName)
21772194 {
2195+ joint_found = true ;
21782196 for (std::vector<SDFExtensionPtr>::iterator
21792197 ge = sdfIt->second .begin ();
21802198 ge != sdfIt->second .end (); ++ge)
@@ -2309,6 +2327,13 @@ void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem,
23092327 }
23102328 }
23112329 }
2330+
2331+ // If we didn't find the link, emit a warning
2332+ if (!joint_found) {
2333+ sdfwarn << " <joint> tag with name[" << _jointName << " ] does not exist"
2334+ << " in the URDF model. Please ensure that the name attribute"
2335+ << " matches the name of a joint." ;
2336+ }
23122337}
23132338
23142339// //////////////////////////////////////////////////////////////////////////////
0 commit comments