Skip to content

Commit

Permalink
Don't install deprecated parser_urdf.hh header
Browse files Browse the repository at this point in the history
* Remove unused includes of parser_urdf.hh in tests
* mv include/sdf/parser_urdf.hh src, since the contents
  of this header were deprecated in 9.2
* parser_urdf.hh: remove deprecation macros and warning suppression
* parser_urdf.hh: remove visibility macro
* codecheck: helper functions public, use in test

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed May 15, 2020
1 parent b80e070 commit 7d00a7c
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 50 deletions.
6 changes: 3 additions & 3 deletions cmake/SDFUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ macro (sdf_build_tests)
link_directories(${IGNITION-MATH_LIBRARY_DIRS})

if (USE_EXTERNAL_TINYXML)
target_link_libraries(${BINARY_NAME}
target_link_libraries(${BINARY_NAME} PRIVATE
${tinyxml_LIBRARIES})
endif()

if (UNIX)
target_link_libraries(${BINARY_NAME}
target_link_libraries(${BINARY_NAME} PRIVATE
libgtest.a
libgtest_main.a
${sdf_target}
pthread
${IGNITION-MATH_LIBRARIES}
)
elseif(WIN32)
target_link_libraries(${BINARY_NAME}
target_link_libraries(${BINARY_NAME} PRIVATE
gtest.lib
gtest_main.lib
${sdf_target}
Expand Down
2 changes: 1 addition & 1 deletion include/sdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ endforeach()
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/sdf.hh.in
${CMAKE_CURRENT_BINARY_DIR}/sdf.hh)

sdf_install_includes("" ${headers} parser_urdf.hh
sdf_install_includes("" ${headers}
${CMAKE_CURRENT_BINARY_DIR}/sdf.hh)
13 changes: 12 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ set (gtest_sources
Mesh_TEST.cc
Model_TEST.cc
Noise_TEST.cc
parser_urdf_TEST.cc
Param_TEST.cc
parser_TEST.cc
Pbr_TEST.cc
Expand Down Expand Up @@ -163,6 +162,18 @@ if (NOT WIN32)
sdf_build_tests(Converter_TEST.cc)
endif()

if (NOT WIN32)
set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS SDFExtension.cc parser_urdf.cc)
sdf_build_tests(parser_urdf_TEST.cc)
if (NOT USE_INTERNAL_URDF)
target_compile_options(UNIT_parser_urdf_TEST PRIVATE ${URDF_CFLAGS})
if (${CMAKE_VERSION} VERSION_GREATER 3.13)
target_link_options(UNIT_parser_urdf_TEST PRIVATE ${URDF_LDFLAGS})
endif()
target_link_libraries(UNIT_parser_urdf_TEST PRIVATE ${URDF_LIBRARIES})
endif()
endif()

sdf_add_library(${sdf_target} ${sources})
target_compile_features(${sdf_target} PUBLIC cxx_std_17)
target_link_libraries(${sdf_target} PUBLIC ${IGNITION-MATH_LIBRARIES})
Expand Down
2 changes: 0 additions & 2 deletions src/SDFExtension.hh
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ namespace sdf
// blobs into body or robot
public: std::vector<std::shared_ptr<TiXmlElement> > blobs;

SDF_SUPPRESS_DEPRECATED_BEGIN
friend class URDF2SDF;
SDF_SUPPRESS_DEPRECATED_END
};
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
#include "sdf/SDFImpl.hh"
#include "sdf/World.hh"
#include "sdf/parser.hh"
#include "sdf/parser_urdf.hh"
#include "sdf/sdf_config.h"

#include "Converter.hh"
#include "FrameSemantics.hh"
#include "parser_private.hh"
#include "parser_urdf.hh"

namespace sdf
{
Expand Down Expand Up @@ -406,7 +406,6 @@ bool readFileInternal(const std::string &_filename, SDFPtr _sdf,
}

// Suppress deprecation for sdf::URDF2SDF
SDF_SUPPRESS_DEPRECATED_BEGIN
if (readDoc(&xmlDoc, _sdf, filename, _convert, _errors))
{
return true;
Expand All @@ -426,7 +425,6 @@ bool readFileInternal(const std::string &_filename, SDFPtr _sdf,
return false;
}
}
SDF_SUPPRESS_DEPRECATED_END

return false;
}
Expand Down Expand Up @@ -474,9 +472,7 @@ bool readStringInternal(const std::string &_xmlString, SDFPtr _sdf,
}
else
{
SDF_SUPPRESS_DEPRECATED_BEGIN
URDF2SDF u2g;
SDF_SUPPRESS_DEPRECATED_END
TiXmlDocument doc = u2g.InitModelString(_xmlString);
if (sdf::readDoc(&doc, _sdf, "urdf string", _convert, _errors))
{
Expand Down
2 changes: 1 addition & 1 deletion src/parser_urdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#include <urdf_model/link.h>
#include <urdf_parser/urdf_parser.h>

#include "sdf/parser_urdf.hh"
#include "sdf/sdf.hh"

#include "SDFExtension.hh"
#include "parser_urdf.hh"

using namespace sdf;

Expand Down
14 changes: 7 additions & 7 deletions include/sdf/parser_urdf.hh → src/parser_urdf.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace sdf
/// This is now deprecated for external usage and will be removed in the next
/// major version of libsdformat. Instead, consider using `sdf::readFile` or
/// `sdf::readString`, which automatically convert URDF to SDF.
class SDFORMAT_VISIBLE SDF_DEPRECATED(9.2) URDF2SDF
class URDF2SDF
{
/// \brief constructor
public: URDF2SDF();
Expand Down Expand Up @@ -68,15 +68,15 @@ namespace sdf
/// \return True if _filename is a URDF model.
public: static bool IsURDF(const std::string &_filename);

/// things that do not belong in urdf but should be mapped into sdf
/// @todo: do this using sdf definitions, not hard coded stuff
private: void ParseSDFExtension(TiXmlDocument &_urdfXml);

/// list extensions for debugging
private: void ListSDFExtensions();
public: void ListSDFExtensions();

/// list extensions for debugging
private: void ListSDFExtensions(const std::string &_reference);
public: void ListSDFExtensions(const std::string &_reference);

/// things that do not belong in urdf but should be mapped into sdf
/// @todo: do this using sdf definitions, not hard coded stuff
private: void ParseSDFExtension(TiXmlDocument &_urdfXml);
};
}
}
Expand Down
43 changes: 16 additions & 27 deletions src/parser_urdf_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <list>

#include "sdf/sdf.hh"
#include "sdf/parser_urdf.hh"
#include "parser_urdf.hh"

/////////////////////////////////////////////////
std::string getMinimalUrdfTxt()
Expand All @@ -35,9 +35,7 @@ std::string getMinimalUrdfTxt()
/////////////////////////////////////////////////
std::string convertUrdfStrToSdfStr(const std::string &_urdf)
{
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
TiXmlDocument sdf_result = parser_.InitModelString(_urdf);
TiXmlPrinter printer;
sdf_result.Accept(&printer);
Expand All @@ -55,27 +53,23 @@ void convertUrdfStrToSdf(const std::string &_urdf, sdf::SDF &_sdf)
TEST(URDFParser, InitModelDoc_EmptyDoc_NoThrow)
{
// Suppress deprecation for sdf::URDF2SDF
SDF_SUPPRESS_DEPRECATED_BEGIN
ASSERT_NO_THROW(
TiXmlDocument doc = TiXmlDocument();
sdf::URDF2SDF parser_;
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);
); // NOLINT(whitespace/parens)
SDF_SUPPRESS_DEPRECATED_END
}

/////////////////////////////////////////////////
TEST(URDFParser, InitModelDoc_BasicModel_NoThrow)
{
// Suppress deprecation for sdf::URDF2SDF
SDF_SUPPRESS_DEPRECATED_BEGIN
ASSERT_NO_THROW(
TiXmlDocument doc;
doc.Parse(getMinimalUrdfTxt().c_str());
sdf::URDF2SDF parser_;
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);
); // NOLINT(whitespace/parens)
SDF_SUPPRESS_DEPRECATED_END
}

/////////////////////////////////////////////////
Expand All @@ -84,9 +78,7 @@ TEST(URDFParser, ParseResults_BasicModel_ParseEqualToModel)
// URDF -> SDF
TiXmlDocument doc;
doc.Parse(getMinimalUrdfTxt().c_str());
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);
std::string sdf_result_str;
sdf_result_str << sdf_result;
Expand Down Expand Up @@ -115,9 +107,7 @@ TEST(URDFParser, ParseRobotOriginXYZBlank)
<< "</robot>";
TiXmlDocument doc;
doc.Parse(stream.str().c_str());
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);
TiXmlElement *sdf = sdf_result.FirstChildElement("sdf");
ASSERT_NE(nullptr, sdf);
Expand All @@ -136,9 +126,7 @@ TEST(URDFParser, ParseRobotOriginRPYBlank)
<< " <link name=\"link\" />"
<< "</robot>";
TiXmlDocument doc;
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
doc.Parse(stream.str().c_str());
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);
TiXmlElement *sdf = sdf_result.FirstChildElement("sdf");
Expand Down Expand Up @@ -172,9 +160,7 @@ TEST(URDFParser, ParseRobotMaterialBlank)
<< "</robot>";
TiXmlDocument doc;
doc.Parse(stream.str().c_str());
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser;
SDF_SUPPRESS_DEPRECATED_END
auto sdfXml = parser.InitModelDoc(&doc);
auto sdfElem = sdfXml.FirstChildElement("sdf");
ASSERT_NE(nullptr, sdfElem);
Expand All @@ -187,6 +173,9 @@ TEST(URDFParser, ParseRobotMaterialBlank)

auto materialElem = visualElem->FirstChildElement("material");
ASSERT_EQ(nullptr, materialElem);

parser.ListSDFExtensions();
parser.ListSDFExtensions("link");
}

/////////////////////////////////////////////////
Expand All @@ -212,9 +201,7 @@ TEST(URDFParser, ParseRobotMaterialName)
<< "</robot>";
TiXmlDocument doc;
doc.Parse(stream.str().c_str());
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser;
SDF_SUPPRESS_DEPRECATED_END
auto sdfXml = parser.InitModelDoc(&doc);
auto sdfElem = sdfXml.FirstChildElement("sdf");
ASSERT_NE(nullptr, sdfElem);
Expand All @@ -236,6 +223,9 @@ TEST(URDFParser, ParseRobotMaterialName)
ASSERT_NE(nullptr, uriElem);
EXPECT_EQ("file://media/materials/scripts/gazebo.material",
std::string(uriElem->GetText()));

parser.ListSDFExtensions();
parser.ListSDFExtensions("link");
}

/////////////////////////////////////////////////
Expand All @@ -247,9 +237,7 @@ TEST(URDFParser, ParseRobotOriginInvalidXYZ)
<< " <link name=\"link\" />"
<< "</robot>";
TiXmlDocument doc;
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
doc.Parse(stream.str().c_str());
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);
TiXmlElement *sdf = sdf_result.FirstChildElement("sdf");
Expand Down Expand Up @@ -310,9 +298,7 @@ TEST(URDFParser, ParseGazeboLinkFactors)
<< "</robot>";

TiXmlDocument doc;
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
doc.Parse(stream.str().c_str());
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);

Expand All @@ -329,6 +315,9 @@ TEST(URDFParser, ParseGazeboLinkFactors)

// For the last element, check that it is exactly what we expect
EXPECT_EQ(tmp->FirstChild()->ValueStr(), it->second[i]);

parser_.ListSDFExtensions();
parser_.ListSDFExtensions("wheel_left_link");
}
}

Expand All @@ -348,12 +337,13 @@ TEST(URDFParser, ParseGazeboInvalidDampingFactor)
<< " </gazebo>"
<< "</robot>";
TiXmlDocument doc;
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
doc.Parse(stream.str().c_str());
ASSERT_THROW(TiXmlDocument sdf_result = parser_.InitModelDoc(&doc),
std::invalid_argument);

parser_.ListSDFExtensions();
parser_.ListSDFExtensions("link");
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -419,9 +409,7 @@ TEST(URDFParser, ParseGazeboJointElements)
<< "</robot>";

TiXmlDocument doc;
SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
doc.Parse(stream.str().c_str());
TiXmlDocument sdf_result = parser_.InitModelDoc(&doc);

Expand All @@ -438,6 +426,9 @@ TEST(URDFParser, ParseGazeboJointElements)

// For the last element, check that it is exactly what we expect
EXPECT_EQ(tmp->FirstChild()->ValueStr(), it->second[i]);

parser_.ListSDFExtensions();
parser_.ListSDFExtensions("head_j0");
}
}

Expand Down Expand Up @@ -807,9 +798,7 @@ TEST(URDFParser, OutputPrecision)
</link>
</robot>)";

SDF_SUPPRESS_DEPRECATED_BEGIN
sdf::URDF2SDF parser;
SDF_SUPPRESS_DEPRECATED_END
TiXmlDocument sdfResult = parser.InitModelString(str);

auto root = sdfResult.RootElement();
Expand Down
1 change: 0 additions & 1 deletion test/integration/element_memory_leak.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <gtest/gtest.h>

#include "sdf/sdf.hh"
#include "sdf/parser_urdf.hh"

#include "test_config.h"

Expand Down
1 change: 0 additions & 1 deletion test/integration/locale_fix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <gtest/gtest.h>

#include "sdf/sdf.hh"
#include "sdf/parser_urdf.hh"

#include "test_config.h"

Expand Down
1 change: 0 additions & 1 deletion test/performance/parser_urdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <gtest/gtest.h>

#include "sdf/sdf.hh"
#include "sdf/parser_urdf.hh"

#include "test_config.h"

Expand Down

0 comments on commit 7d00a7c

Please sign in to comment.