From 640766f319f968a20208281916c089d1f8ee78c8 Mon Sep 17 00:00:00 2001 From: Aditya Agrawal Date: Thu, 4 Apr 2024 22:33:01 +0800 Subject: [PATCH 1/8] initial draft of warning message functionality Signed-off-by: Aditya Agrawal --- src/parser_urdf.cc | 9 +++++++ src/parser_urdf_TEST.cc | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index d8d2b2352..40c5ee66a 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -2108,12 +2108,14 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, const std::string &_linkName) { + bool link_found = false; for (StringSDFExtensionPtrMap::iterator sdfIt = g_extensions.begin(); sdfIt != g_extensions.end(); ++sdfIt) { if (sdfIt->first == _linkName) { + link_found = true; sdfdbg << "inserting extension with reference [" << _linkName << "] into link.\n"; for (std::vector::iterator ge = @@ -2153,6 +2155,13 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, } } } + + // If we didn't find the link, emit a warning + if (!link_found) { + sdfwarn << " tag with reference[" << _linkName << "] does not exist in the URDF model. Please " + << "ensure that the referenced attribute matches the name of a link, consider checking unicode " + << "representation for reference attribute in case of invisible characters and homoglyphs"; + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index 96b940d99..5c8d55318 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -2460,6 +2460,64 @@ TEST(URDFParser, ZeroMassLeafLink) } } +///////////////////////////////////////////////// +TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) +{ +// Redirect sdfwarn output + std::stringstream buffer; + sdf::testing::RedirectConsoleStream redir( + sdf::Console::Instance()->GetMsgStream(), &buffer); +#ifdef _WIN32 + sdf::Console::Instance()->SetQuiet(false); + sdf::testing::ScopeExit revertSetQuiet( + [] + { + sdf::Console::Instance()->SetQuiet(true); + }); +#endif + + // test if reference to link exists + { + // clear the contents of the buffer + buffer.str(""); + + std::string str = R"( + + + + + + + + + + 1 + 100 + 0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315 + + + + + )"; + + sdf::URDF2SDF parser; + tinyxml2::XMLDocument sdfResult; + sdf::ParserConfig config; + parser.InitModelString(str, config, &sdfResult); + + EXPECT_PRED2(sdf::testing::contains, buffer.str(), + " tag with reference[link1] does not exist in the URDF model. Please " + "ensure that the referenced attribute matches the name of a link, consider checking unicode " + "representation for reference attribute in case of invisible characters and homoglyphs"); + } + + // TODO: Similar tests for - + // InsertSDFExtensionCollision, + // InsertSDFExtensionRobot, + // InsertSDFExtensionVisual, + // InsertSDFExtensionJoint +} + ///////////////////////////////////////////////// /// Main int main(int argc, char **argv) From ff06de35be5333080a91ffb54f2afdf2ed1f5706 Mon Sep 17 00:00:00 2001 From: Aditya Agrawal Date: Fri, 5 Apr 2024 16:29:15 +0800 Subject: [PATCH 2/8] fixed formatting Signed-off-by: Aditya Agrawal --- src/parser_urdf.cc | 18 ++++++------ src/parser_urdf_TEST.cc | 65 ++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index 40c5ee66a..763ec5397 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -2108,14 +2108,14 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, const std::string &_linkName) { - bool link_found = false; + bool link_found = false; for (StringSDFExtensionPtrMap::iterator sdfIt = g_extensions.begin(); sdfIt != g_extensions.end(); ++sdfIt) { if (sdfIt->first == _linkName) { - link_found = true; + link_found = true; sdfdbg << "inserting extension with reference [" << _linkName << "] into link.\n"; for (std::vector::iterator ge = @@ -2155,13 +2155,13 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, } } } - - // If we didn't find the link, emit a warning - if (!link_found) { - sdfwarn << " tag with reference[" << _linkName << "] does not exist in the URDF model. Please " - << "ensure that the referenced attribute matches the name of a link, consider checking unicode " - << "representation for reference attribute in case of invisible characters and homoglyphs"; - } + + // If we didn't find the link, emit a warning + if (!link_found) { + sdfwarn << " tag with reference[" << _linkName << "] does not exist" + << " in the URDF model. Please ensure that the reference attribute" + << " matches the name of a link."; + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index 5c8d55318..c29acb559 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -2463,7 +2463,7 @@ TEST(URDFParser, ZeroMassLeafLink) ///////////////////////////////////////////////// TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) { -// Redirect sdfwarn output + // Redirect sdfwarn output std::stringstream buffer; sdf::testing::RedirectConsoleStream redir( sdf::Console::Instance()->GetMsgStream(), &buffer); @@ -2476,46 +2476,45 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) }); #endif - // test if reference to link exists - { - // clear the contents of the buffer + // test if reference to link exists + { + // clear the contents of the buffer buffer.str(""); std::string str = R"( - - - - - - - - - - 1 - 100 - 0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315 - - - - - )"; + + + + + + + + + + 1 + 100 + 0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315 + + + + )"; sdf::URDF2SDF parser; tinyxml2::XMLDocument sdfResult; sdf::ParserConfig config; parser.InitModelString(str, config, &sdfResult); - - EXPECT_PRED2(sdf::testing::contains, buffer.str(), - " tag with reference[link1] does not exist in the URDF model. Please " - "ensure that the referenced attribute matches the name of a link, consider checking unicode " - "representation for reference attribute in case of invisible characters and homoglyphs"); - } - - // TODO: Similar tests for - - // InsertSDFExtensionCollision, - // InsertSDFExtensionRobot, - // InsertSDFExtensionVisual, - // InsertSDFExtensionJoint + + EXPECT_PRED2(sdf::testing::contains, buffer.str(), + " tag with reference[" << _linkName << "] does not exist" + " in the URDF model. Please ensure that the reference attribute" + " matches the name of a link."); + } + + /* TODO(aagrawal05): Similar tests for - + InsertSDFExtensionCollision, + InsertSDFExtensionRobot, + InsertSDFExtensionVisual, + InsertSDFExtensionJoint */ } ///////////////////////////////////////////////// From bff4f75f003b2f839cee75f84b30269846759dbc Mon Sep 17 00:00:00 2001 From: Aditya Agrawal <58559719+aagrawal05@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:53:18 +0800 Subject: [PATCH 3/8] Formatting changes parser_urdf_TEST.cc Signed-off-by: Aditya Agrawal <58559719+aagrawal05@users.noreply.github.com> Signed-off-by: Aditya Agrawal --- src/parser_urdf_TEST.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index c29acb559..fbfc1289c 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -2504,16 +2504,16 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) sdf::ParserConfig config; parser.InitModelString(str, config, &sdfResult); - EXPECT_PRED2(sdf::testing::contains, buffer.str(), + EXPECT_PRED2(sdf::testing::contains, buffer.str(), " tag with reference[" << _linkName << "] does not exist" " in the URDF model. Please ensure that the reference attribute" " matches the name of a link."); } - /* TODO(aagrawal05): Similar tests for - + /* TODO(aagrawal05): Similar tests for - InsertSDFExtensionCollision, InsertSDFExtensionRobot, - InsertSDFExtensionVisual, + InsertSDFExtensionVisual, InsertSDFExtensionJoint */ } From d9f56f54a2bbd8bb72832d66ba5171007a078557 Mon Sep 17 00:00:00 2001 From: Aditya Agrawal <58559719+aagrawal05@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:53:26 +0800 Subject: [PATCH 4/8] Formatting changes in parser_urdf.cc Signed-off-by: Aditya Agrawal <58559719+aagrawal05@users.noreply.github.com> Signed-off-by: Aditya Agrawal --- src/parser_urdf.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index 763ec5397..2d5b938b9 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -2156,12 +2156,12 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, } } - // If we didn't find the link, emit a warning - if (!link_found) { - sdfwarn << " tag with reference[" << _linkName << "] does not exist" + // If we didn't find the link, emit a warning + if (!link_found) { + sdfwarn << " tag with reference[" << _linkName << "] does not exist" << " in the URDF model. Please ensure that the reference attribute" << " matches the name of a link."; - } + } } //////////////////////////////////////////////////////////////////////////////// From 2d221fe11de0d9eafd9b7504bd35de7c63ec8869 Mon Sep 17 00:00:00 2001 From: Aditya Agrawal <58559719+aagrawal05@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:01:31 +0800 Subject: [PATCH 5/8] Update parser_urdf_TEST.cc and fixed mistake in test Signed-off-by: Aditya Agrawal <58559719+aagrawal05@users.noreply.github.com> Signed-off-by: Aditya Agrawal --- src/parser_urdf_TEST.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index fbfc1289c..648ac3ec9 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -2505,12 +2505,12 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) parser.InitModelString(str, config, &sdfResult); EXPECT_PRED2(sdf::testing::contains, buffer.str(), - " tag with reference[" << _linkName << "] does not exist" + " tag with reference[link1] does not exist" " in the URDF model. Please ensure that the reference attribute" " matches the name of a link."); - } - - /* TODO(aagrawal05): Similar tests for - + } + + /* TODO(aagrawal05): Similar tests for - InsertSDFExtensionCollision, InsertSDFExtensionRobot, InsertSDFExtensionVisual, From d610aa9d67475c0f2152a1499ebf8dff5d80e7a8 Mon Sep 17 00:00:00 2001 From: Aditya Agrawal Date: Fri, 16 Aug 2024 19:50:36 +0800 Subject: [PATCH 6/8] added other SDFExtensions Signed-off-by: Aditya Agrawal --- src/parser_urdf.cc | 25 +++++++++++++ src/parser_urdf_TEST.cc | 79 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 96 insertions(+), 8 deletions(-) diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index 2d5b938b9..99fb8159e 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -1604,6 +1604,7 @@ void CopyBlob(tinyxml2::XMLElement *_src, tinyxml2::XMLElement *_blob_parent) void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, const std::string &_linkName) { + bool link_found = false; // loop through extensions for the whole model // and see which ones belong to _linkName // This might be complicated since there's: @@ -1615,6 +1616,7 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _linkName) { + link_found = true; // std::cerr << "============================\n"; // std::cerr << "working on g_extensions for link [" // << sdfIt->first << "]\n"; @@ -1908,12 +1910,19 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, } } } + // If we didn't find the link, emit a warning + if (!link_found) { + sdfwarn << " tag with reference[" << _linkName << "] does not exist" + << " in the URDF model. Please ensure that the reference attribute" + << " matches the name of a link."; + } } //////////////////////////////////////////////////////////////////////////////// void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, const std::string &_linkName) { + bool link_found = false; // loop through extensions for the whole model // and see which ones belong to _linkName // This might be complicated since there's: @@ -1925,6 +1934,7 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _linkName) { + link_found=true; // std::cerr << "============================\n"; // std::cerr << "working on g_extensions for link [" // << sdfIt->first << "]\n"; @@ -2102,6 +2112,12 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, } } } + // If we didn't find the link, emit a warning + if (!link_found) { + sdfwarn << " tag with reference[" << _linkName << "] does not exist" + << " in the URDF model. Please ensure that the reference attribute" + << " matches the name of a link."; + } } //////////////////////////////////////////////////////////////////////////////// @@ -2168,6 +2184,7 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem, const std::string &_jointName) { + bool joint_found = false; auto* doc = _elem->GetDocument(); for (StringSDFExtensionPtrMap::iterator sdfIt = g_extensions.begin(); @@ -2175,6 +2192,7 @@ void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _jointName) { + joint_found = true; for (std::vector::iterator ge = sdfIt->second.begin(); ge != sdfIt->second.end(); ++ge) @@ -2309,6 +2327,13 @@ void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem, } } } + + // If we didn't find the link, emit a warning + if (!joint_found) { + sdfwarn << " tag with name[" << _jointName << "] does not exist" + << " in the URDF model. Please ensure that the name attribute" + << " matches the name of a joint."; + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index 648ac3ec9..3360466c7 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -2476,8 +2476,8 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) }); #endif - // test if reference to link exists - { + // test if reference to link exists + { // clear the contents of the buffer buffer.str(""); @@ -2509,12 +2509,75 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) " in the URDF model. Please ensure that the reference attribute" " matches the name of a link."); } - - /* TODO(aagrawal05): Similar tests for - - InsertSDFExtensionCollision, - InsertSDFExtensionRobot, - InsertSDFExtensionVisual, - InsertSDFExtensionJoint */ + + { + // clear the contents of the buffer + buffer.str(""); + + std::string str = R"( + + + + + + + + + + + 1 1 1 + + + + + + + + )"; + + sdf::URDF2SDF parser; + tinyxml2::XMLDocument sdfResult; + sdf::ParserConfig config; + parser.InitModelString(str, config, &sdfResult); + + EXPECT_PRED2(sdf::testing::contains, buffer.str(), + " tag with reference[link1] does not exist" + " in the URDF model. Please ensure that the reference attribute" + " matches the name of a link."); + } + + { + // clear the contents of the buffer + buffer.str(""); + + std::string str = R"( + + + + + + + + + + + 0.5 + + + + + )"; + + sdf::URDF2SDF parser; + tinyxml2::XMLDocument sdfResult; + sdf::ParserConfig config; + parser.InitModelString(str, config, &sdfResult); + + EXPECT_PRED2(sdf::testing::contains, buffer.str(), + " tag with reference[link1] does not exist" + " in the URDF model. Please ensure that the reference attribute" + " matches the name of a link."); + } } ///////////////////////////////////////////////// From 8046a015532e1658aca1dddc447ae443fec53b2e Mon Sep 17 00:00:00 2001 From: Aditya Agrawal Date: Sat, 17 Aug 2024 17:23:54 +0800 Subject: [PATCH 7/8] fixed error messages, tests, and style Signed-off-by: Aditya Agrawal --- src/parser_urdf.cc | 35 ++++++++------- src/parser_urdf_TEST.cc | 97 +++++++++++++++++++++++++++++++---------- 2 files changed, 92 insertions(+), 40 deletions(-) diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index 99fb8159e..7b5315823 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -1604,7 +1604,7 @@ void CopyBlob(tinyxml2::XMLElement *_src, tinyxml2::XMLElement *_blob_parent) void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, const std::string &_linkName) { - bool link_found = false; + bool linkFound = false; // loop through extensions for the whole model // and see which ones belong to _linkName // This might be complicated since there's: @@ -1616,7 +1616,7 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _linkName) { - link_found = true; + linkFound = true; // std::cerr << "============================\n"; // std::cerr << "working on g_extensions for link [" // << sdfIt->first << "]\n"; @@ -1911,8 +1911,8 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, } } // If we didn't find the link, emit a warning - if (!link_found) { - sdfwarn << " tag with reference[" << _linkName << "] does not exist" + if (!linkFound) { + sdfwarn << " tag reference[" << _linkName << "] does not exist" << " in the URDF model. Please ensure that the reference attribute" << " matches the name of a link."; } @@ -1922,7 +1922,7 @@ void InsertSDFExtensionCollision(tinyxml2::XMLElement *_elem, void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, const std::string &_linkName) { - bool link_found = false; + bool linkFound = false; // loop through extensions for the whole model // and see which ones belong to _linkName // This might be complicated since there's: @@ -1934,7 +1934,7 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _linkName) { - link_found=true; + linkFound=true; // std::cerr << "============================\n"; // std::cerr << "working on g_extensions for link [" // << sdfIt->first << "]\n"; @@ -2113,8 +2113,8 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, } } // If we didn't find the link, emit a warning - if (!link_found) { - sdfwarn << " tag with reference[" << _linkName << "] does not exist" + if (!linkFound) { + sdfwarn << " tag reference[" << _linkName << "] does not exist" << " in the URDF model. Please ensure that the reference attribute" << " matches the name of a link."; } @@ -2124,14 +2124,14 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, const std::string &_linkName) { - bool link_found = false; + bool linkFound = false; for (StringSDFExtensionPtrMap::iterator sdfIt = g_extensions.begin(); sdfIt != g_extensions.end(); ++sdfIt) { if (sdfIt->first == _linkName) { - link_found = true; + linkFound = true; sdfdbg << "inserting extension with reference [" << _linkName << "] into link.\n"; for (std::vector::iterator ge = @@ -2171,10 +2171,9 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, } } } - // If we didn't find the link, emit a warning - if (!link_found) { - sdfwarn << " tag with reference[" << _linkName << "] does not exist" + if (!linkFound) { + sdfwarn << " tag reference[" << _linkName << "] does not exist" << " in the URDF model. Please ensure that the reference attribute" << " matches the name of a link."; } @@ -2184,7 +2183,7 @@ void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem, void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem, const std::string &_jointName) { - bool joint_found = false; + bool jointFound = false; auto* doc = _elem->GetDocument(); for (StringSDFExtensionPtrMap::iterator sdfIt = g_extensions.begin(); @@ -2192,7 +2191,7 @@ void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _jointName) { - joint_found = true; + jointFound = true; for (std::vector::iterator ge = sdfIt->second.begin(); ge != sdfIt->second.end(); ++ge) @@ -2329,9 +2328,9 @@ void InsertSDFExtensionJoint(tinyxml2::XMLElement *_elem, } // If we didn't find the link, emit a warning - if (!joint_found) { - sdfwarn << " tag with name[" << _jointName << "] does not exist" - << " in the URDF model. Please ensure that the name attribute" + if (!jointFound) { + sdfwarn << " tag reference[" << _jointName << "] does not exist" + << " in the URDF model. Please ensure that the reference attribute" << " matches the name of a joint."; } } diff --git a/src/parser_urdf_TEST.cc b/src/parser_urdf_TEST.cc index 3360466c7..58a4f9643 100644 --- a/src/parser_urdf_TEST.cc +++ b/src/parser_urdf_TEST.cc @@ -2505,7 +2505,7 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) parser.InitModelString(str, config, &sdfResult); EXPECT_PRED2(sdf::testing::contains, buffer.str(), - " tag with reference[link1] does not exist" + " tag reference[link1] does not exist" " in the URDF model. Please ensure that the reference attribute" " matches the name of a link."); } @@ -2521,18 +2521,20 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) + + + + 1 1 1 + + + + + + + - - - - 1 1 1 - - - - - - - + + )"; sdf::URDF2SDF parser; @@ -2541,7 +2543,7 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) parser.InitModelString(str, config, &sdfResult); EXPECT_PRED2(sdf::testing::contains, buffer.str(), - " tag with reference[link1] does not exist" + " tag reference[link1] does not exist" " in the URDF model. Please ensure that the reference attribute" " matches the name of a link."); } @@ -2557,15 +2559,21 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) + + + + + + - - - - 0.5 - - - - + + + 1 + 100 + 0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315 + + + )"; sdf::URDF2SDF parser; @@ -2574,10 +2582,55 @@ TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) parser.InitModelString(str, config, &sdfResult); EXPECT_PRED2(sdf::testing::contains, buffer.str(), - " tag with reference[link1] does not exist" + " tag reference[link1] does not exist" " in the URDF model. Please ensure that the reference attribute" " matches the name of a link."); } + + { + // clear the contents of the buffer + buffer.str(""); + + std::string str = R"( + + + + + + + + + + + + + + + + + + + + + + 1 + 100 + 0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315 + + + + )"; + + sdf::URDF2SDF parser; + tinyxml2::XMLDocument sdfResult; + sdf::ParserConfig config; + parser.InitModelString(str, config, &sdfResult); + + EXPECT_PRED2(sdf::testing::contains, buffer.str(), + " tag reference[joint1] does not exist" + " in the URDF model. Please ensure that the reference attribute" + " matches the name of a joint."); + } } ///////////////////////////////////////////////// From 7f7b183dab796da46e198db8f5659f3fb08897c3 Mon Sep 17 00:00:00 2001 From: Aditya Agrawal Date: Tue, 20 Aug 2024 10:22:32 +0800 Subject: [PATCH 8/8] style Signed-off-by: Aditya Agrawal --- src/parser_urdf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index 7b5315823..549e8a38d 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -1934,7 +1934,7 @@ void InsertSDFExtensionVisual(tinyxml2::XMLElement *_elem, { if (sdfIt->first == _linkName) { - linkFound=true; + linkFound = true; // std::cerr << "============================\n"; // std::cerr << "working on g_extensions for link [" // << sdfIt->first << "]\n";