[sdformat] 01/03: Imported Upstream version 4.3.2
Jose Luis Rivero
jrivero-guest at moszumanska.debian.org
Tue Sep 5 18:59:41 UTC 2017
This is an automated email from the git hooks/post-receive script.
jrivero-guest pushed a commit to branch master
in repository sdformat.
commit 336ccc99aa0cc6d55f3de2af6cd3be5c89ae9f97
Author: Jose Luis Rivero <jrivero at osrfoundation.org>
Date: Tue Sep 5 20:58:52 2017 +0200
Imported Upstream version 4.3.2
---
.hg_archival.txt | 8 +-
.hgtags | 3 +
CMakeLists.txt | 36 ++---
Changelog.md | 56 ++++++-
Migration.md | 12 ++
cmake/CodeCoverage.cmake | 132 +++++++++++++++
cmake/DefaultCFlags.cmake | 32 ++--
cmake/sdf_config.cmake.in | 4 +
include/sdf/Element.hh | 24 +++
include/sdf/Exception.hh | 4 +
include/sdf/Param.hh | 2 +
include/sdf/parser.hh | 17 ++
include/sdf/parser_urdf.hh | 2 +-
sdf/1.6/heightmap_shape.sdf | 4 +
sdf/1.6/physics.sdf | 14 ++
sdf/1.6/state.sdf | 7 +-
sdf/1.6/surface.sdf | 4 +
Migration.md => sdf/Migration.md | 82 +++++-----
src/Exception.cc | 11 +-
src/Param_TEST.cc | 8 +
src/SDF_TEST.cc | 2 +-
src/parser.cc | 179 ++++++++++++++-------
test/integration/CMakeLists.txt | 3 +
test/integration/category_bitmask.cc | 110 +++++++++++++
test/integration/disable_fixed_joint_reduction.cc | 2 +-
test/integration/joint_axis_frame.cc | 2 +-
test/integration/model/cococan/model-100.sdf | 25 +++
test/integration/model/cococan/model-1_2.sdf | 25 +++
test/integration/model/cococan/model-1_4.sdf | 25 +++
test/integration/model/cococan/model.config | 17 ++
.../model/cococan_malformed/model.config | 14 ++
.../model/cococan_noversiontag/model-1_2.sdf | 25 +++
.../model/cococan_noversiontag/model-1_4.sdf | 25 +++
.../model/cococan_noversiontag/model.config | 16 ++
test/integration/model_versions.cc | 75 +++++++++
test/integration/plugin_bool.cc | 8 +
test/integration/plugin_include.cc | 98 +++++++++++
tools/get_mem_info.py | 2 +-
38 files changed, 970 insertions(+), 145 deletions(-)
diff --git a/.hg_archival.txt b/.hg_archival.txt
index cd36ced..ef511f7 100644
--- a/.hg_archival.txt
+++ b/.hg_archival.txt
@@ -1,6 +1,6 @@
repo: 17049bd77df5bd6cd56a76edba4a54afb5647740
-node: e5ac5aaa49f240725a0dd18bca2f5a7d16aaeeab
+node: d795964aabb1ade78eb1028b89e7e584abf5d61f
branch: sdf4
-latesttag: sdformat4_4.1.1
-latesttagdistance: 28
-changessincelatesttag: 28
+latesttag: sdformat4_4.3.1
+latesttagdistance: 14
+changessincelatesttag: 23
diff --git a/.hgtags b/.hgtags
index 6d96a9f..c5ca1c1 100644
--- a/.hgtags
+++ b/.hgtags
@@ -115,3 +115,6 @@ bb3fff1c17397bada85e3aad11f508c23cead6fd sdformat4_4.0.0~pre2
878cecf3869767f396e50ffb7cf6e6a780163894 sdformat4_4.1.0
01885813c0b9d60ff568ceca9eb09ec836795757 sdformat4_4.1.0
10551a6e8a2c03e3a6e3e81883d3191d5be4a62c sdformat4_4.1.1
+e5ac5aaa49f240725a0dd18bca2f5a7d16aaeeab sdformat4_4.2.0
+61d29926371ddcf497892f4ad29527c377c7eab6 sdformat4_4.3.0
+61c3ffeabd15382f61cfab9254e14f987244350e sdformat4_4.3.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 33c48f7..fd9a60f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,8 +28,8 @@ string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
set (SDF_PROTOCOL_VERSION 1.6)
set (SDF_MAJOR_VERSION 4)
-set (SDF_MINOR_VERSION 2)
-set (SDF_PATCH_VERSION 0)
+set (SDF_MINOR_VERSION 3)
+set (SDF_PATCH_VERSION 2)
set (SDF_VERSION ${SDF_MAJOR_VERSION}.${SDF_MINOR_VERSION})
set (SDF_VERSION_FULL ${SDF_MAJOR_VERSION}.${SDF_MINOR_VERSION}.${SDF_PATCH_VERSION})
@@ -55,9 +55,9 @@ if(LD_LIBRARY_PATH)
set (ENV{LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH})
endif()
-set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/sdformat-${SDF_VERSION}/sdf")
-set (LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Installation directory for libraries (relative to CMAKE_INSTALL_PREFIX)")
-set (BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Installation directory for binaries (relative to CMAKE_INSTALL_PREFIX)")
+set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/sdformat-${SDF_VERSION}/sdf")
+set (LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Installation directory for libraries (relative to CMAKE_INSTALL_PREFIX)")
+set (BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Installation directory for binaries (relative to CMAKE_INSTALL_PREFIX)")
set (USE_FULL_RPATH OFF CACHE BOOL "Set to true to enable full rpath")
@@ -65,17 +65,17 @@ set (USE_FULL_RPATH OFF CACHE BOOL "Set to true to enable full rpath")
if (USE_FULL_RPATH)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
-
+
# when building, don't use the install RPATH already
# (but later on when installing)
- set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
-
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
-
+
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-
+
# the RPATH to be used when installing, but only if its not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
@@ -110,7 +110,7 @@ message (STATUS "----------------------------------------\n")
#####################################
# Set the default build type
if (NOT CMAKE_BUILD_TYPE)
- set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
+ set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo Profile Check" FORCE)
endif (NOT CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
@@ -229,13 +229,13 @@ else (buid_errors)
message (STATUS "C Flags:${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
message (STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
message (STATUS "Install path: ${CMAKE_INSTALL_PREFIX}")
-
+
if (BUILD_SDF)
include_directories(include
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/include
)
-
+
link_directories(${PROJECT_BINARY_DIR}/src)
add_subdirectory(test)
@@ -267,21 +267,21 @@ else (buid_errors)
# Use write_basic_package_version_file to generate a ConfigVersion file that
# allow users of gazebo to specify the API or version to depend on
# TODO: keep this instruction until deprecate Ubuntu/Precise and update with
- # https://github.com/Kitware/CMake/blob/v2.8.8/Modules/CMakePackageConfigHelpers.cmake
+ # https://github.com/Kitware/CMake/blob/v2.8.8/Modules/CMakePackageConfigHelpers.cmake
include(WriteBasicConfigVersionFile)
write_basic_config_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_version_file}
VERSION "${SDF_VERSION_FULL}"
COMPATIBILITY SameMajorVersion)
- install(FILES
+ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/SDFormatConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_version_file}
- DESTINATION
- ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}/
+ DESTINATION
+ ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}/
COMPONENT cmake)
########################################
- # Package Creation:
+ # Package Creation:
include (${sdf_cmake_dir}/sdf_cpack.cmake)
set (CPACK_PACKAGE_VERSION "${SDF_VERSION_FULL}")
set (CPACK_PACKAGE_VERSION_MAJOR "${SDF_MAJOR_VERSION}")
diff --git a/Changelog.md b/Changelog.md
index 3df908a..37688ba 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,7 +1,57 @@
## SDFormat 4.0
+### SDFormat 4.x.x (2017-xx-xx)
+
+### SDFormat 4.3.2 (2017-07-19)
+
+1. Add documentation for `Element::GetFirstElement()` and `Element::GetNextElement()`
+ * [Pull request 341](https://bitbucket.org/osrf/sdformat/pull-request/341)
+
+1. Fix parser to read plugin child elements within an `<include>`
+ * [Pull request 350](https://bitbucket.org/osrf/sdformat/pull-request/350)
+
+### SDFormat 4.3.1 (2017-03-24)
+
+1. Fix segmentation Fault in `sdf::getBestSupportedModelVersion`
+ * [Pull request 327](https://bitbucket.org/osrf/sdformat/pull-requests/327)
+ * [Issue 152](https://bitbucket.org/osrf/sdformat/issues/152)
+
+### SDFormat 4.3.0 (2017-03-20)
+
+1. Choosing models with more recent sdf version with `<include>` tag
+ * [Pull request 291](https://bitbucket.org/osrf/sdformat/pull-request/291)
+ * [Issue 123](https://bitbucket.org/osrf/sdformat/issues/123)
+
+1. Added `<category_bitmask>` to 1.6 surface contact parameters
+ * [Pull request 318](https://bitbucket.org/osrf/sdformat/pull-request/318)
+
+1. Support light insertion in state
+ * [Pull request 325](https://bitbucket.org/osrf/sdformat/pull-request/325)
+
+1. Case insensitive boolean strings
+ * [Pull request 322](https://bitbucket.org/osrf/sdformat/pull-request/322)
+
+1. Enable coverage testing
+ * [Pull request 317](https://bitbucket.org/osrf/sdformat/pull-request/317)
+
+1. Add `friction_model` parameter to ode solver
+ * [Pull request 294](https://bitbucket.org/osrf/sdformat/pull-request/294)
+ * [Gazebo pull request 1522](https://bitbucket.org/osrf/gazebo/pull-request/1522)
+
+1. Added `sampling` parameter to `<heightmap>` SDF element.
+ * [Pull request 293](https://bitbucket.org/osrf/sdformat/pull-request/293)
+
+1. Added Migration guide
+ * [Pull request 290](https://bitbucket.org/osrf/sdformat/pull-request/290)
+
+1. Add cmake `@PKG_NAME at _LIBRARY_DIRS` variable to cmake config file
+ * [Pull request 292](https://bitbucket.org/osrf/sdformat/pull-request/292)
+
### SDFormat 4.2.0 (2016-10-10)
+1. Added tag to specify ODE friction model.
+ * [Pull request 294](https://bitbucket.org/osrf/sdformat/pull-request/294)
+
1. Fix URDF to SDF `self_collide` bug.
* [Pull request 287](https://bitbucket.org/osrf/sdformat/pull-request/287)
@@ -23,11 +73,11 @@
1. Added an upload script
* [Pull request 256](https://bitbucket.org/osrf/sdformat/pull-request/256)
-
+
### SDFormat 4.0.0 (2015-01-12)
1. Boost pointers and boost::function in the public API have been replaced
- by their std::equivalents (C++11 standard)
+ by their std::equivalents (C++11 standard)
1. Move gravity and magnetic_field tags from physics to world
* [Pull request 247](https://bitbucket.org/osrf/sdformat/pull-request/247)
1. Switch lump link prefix from lump:: to lump_
@@ -43,7 +93,7 @@
1. Fix memory leaks.
A contribution from Silvio Traversaro
* [Pull request 249](https://bitbucket.org/osrf/sdformat/pull-request/249)
-1. Update SDF to version 1.6: new style for representing the noise properties
+1. Update SDF to version 1.6: new style for representing the noise properties
of an `imu`
* [Pull request 243](https://bitbucket.org/osrf/sdformat/pull-request/243)
* [Pull request 199](https://bitbucket.org/osrf/sdformat/pull-requests/199)
diff --git a/Migration.md b/Migration.md
index 62f19cd..02ebd57 100644
--- a/Migration.md
+++ b/Migration.md
@@ -72,6 +72,18 @@ but with improved human-readability..
+ required: 0
+ [pull request 246](https://bitbucket.org/osrf/sdformat/pull-requests/246)
+1. **state.sdf** allow `light` tags within `insertions` element
+ * [pull request 325](https://bitbucket.org/osrf/sdformat/pull-request/325)
+
+1. **surface.sdf** `category_bitmask` element
+ + description: Bitmask for category of collision filtering.
+ Collision happens if `((category1 & collision2) | (category2 & collision1))` is not zero.
+ If not specified, the category_bitmask should be interpreted as being the same as collide_bitmask.
+ + type: unsigned int
+ + default: 65535
+ + required: 0
+ + [pull request 318](https://bitbucket.org/osrf/sdformat/pull-requests/318)
+
1. **world.sdf** `wind` element
+ description: The wind tag specifies the type and properties of the wind.
+ required: 0
diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake
new file mode 100644
index 0000000..c032290
--- /dev/null
+++ b/cmake/CodeCoverage.cmake
@@ -0,0 +1,132 @@
+#
+# 2012-01-31, Lars Bilke
+# - Enable Code Coverage
+#
+# 2013-09-17, Joakim Söderberg
+# - Added support for Clang.
+# - Some additional usage instructions.
+#
+# USAGE:
+# 1. Copy this file into your cmake modules path.
+#
+# 2. Add the following line to your CMakeLists.txt:
+# INCLUDE(CodeCoverage)
+#
+# 3. Set compiler flags to turn off optimization and enable coverage:
+# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+#
+# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
+# which runs your test executable and produces a lcov code coverage report:
+# Example:
+# SETUP_TARGET_FOR_COVERAGE(
+# my_coverage_target # Name for custom target.
+# test_driver # Name of the test driver executable that runs the tests.
+# # NOTE! This should always have a ZERO as exit code
+# # otherwise the coverage generation will not complete.
+# coverage # Name of output directory.
+# )
+#
+# 4. Build a Debug build:
+# cmake -DCMAKE_BUILD_TYPE=Debug ..
+# make
+# make my_coverage_target
+#
+#
+
+# Check prereqs
+FIND_PROGRAM( GCOV_PATH gcov )
+FIND_PROGRAM( LCOV_PATH lcov )
+FIND_PROGRAM( GREP_PATH grep )
+FIND_PROGRAM( GENHTML_PATH genhtml )
+FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
+
+IF(NOT GCOV_PATH)
+ MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
+ENDIF() # NOT GCOV_PATH
+
+IF(NOT CMAKE_COMPILER_IS_GNUCXX)
+ # Clang version 3.0.0 and greater now supports gcov as well.
+ MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.")
+
+ IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
+ ENDIF()
+ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX
+
+SET(CMAKE_CXX_FLAGS_COVERAGE
+ "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+ CACHE STRING "Flags used by the C++ compiler during coverage builds."
+ FORCE )
+SET(CMAKE_C_FLAGS_COVERAGE
+ "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+ CACHE STRING "Flags used by the C compiler during coverage builds."
+ FORCE )
+SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
+ ""
+ CACHE STRING "Flags used for linking binaries during coverage builds."
+ FORCE )
+SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
+ ""
+ CACHE STRING "Flags used by the shared libraries linker during coverage builds."
+ FORCE )
+MARK_AS_ADVANCED(
+ CMAKE_CXX_FLAGS_COVERAGE
+ CMAKE_C_FLAGS_COVERAGE
+ CMAKE_EXE_LINKER_FLAGS_COVERAGE
+ CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
+
+IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage"))
+ MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
+ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
+
+
+# Param _targetname The name of new the custom make target
+# Param _testrunner The name of the target which runs the tests.
+# MUST return ZERO always, even on errors.
+# If not, no coverage report will be created!
+# Param _outputname lcov output is generated as _outputname.info
+# HTML report is generated in _outputname/index.html
+# Optional fourth parameter is passed as arguments to _testrunner
+# Pass them in list form, e.g.: "-j;2" for -j 2
+FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
+
+ IF(NOT LCOV_PATH)
+ MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
+ ENDIF() # NOT LCOV_PATH
+
+ IF(NOT GREP_PATH)
+ MESSAGE(FATAL_ERROR "grep not found! Run code coverage on linux or mac.")
+ ENDIF()
+
+ IF(NOT GENHTML_PATH)
+ MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
+ ENDIF() # NOT GENHTML_PATH
+
+ # Setup target
+ ADD_CUSTOM_TARGET(${_targetname}
+
+ # Capturing lcov counters and generating report
+ COMMAND ${LCOV_PATH} -q --no-checksum --directory ${PROJECT_BINARY_DIR}
+ --capture --output-file ${_outputname}.info 2>/dev/null
+ COMMAND ${LCOV_PATH} -q --remove ${_outputname}.info
+ 'test/*' '/usr/*' '*_TEST*' --output-file ${_outputname}.info.cleaned
+ COMMAND ${GENHTML_PATH} -q --legend -o ${_outputname}
+ ${_outputname}.info.cleaned
+ COMMAND ${LCOV_PATH} --summary ${_outputname}.info.cleaned 2>&1 | grep "lines" | cut -d ' ' -f 4 | cut -d '%' -f 1 > coverage/lines.txt
+ COMMAND ${LCOV_PATH} --summary ${_outputname}.info.cleaned 2>&1 | grep "functions" | cut -d ' ' -f 4 | cut -d '%' -f 1 > coverage/functions.txt
+ COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info
+ ${_outputname}.info.cleaned
+
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT "Resetting code coverage counters to zero.\n"
+ "Processing code coverage counters and generating report."
+ )
+
+ # Show info where to find the report
+ ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
+ COMMAND COMMAND ${LCOV_PATH} -q --zerocounters --directory ${PROJECT_BINARY_DIR};
+ COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
+ )
+
+ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
diff --git a/cmake/DefaultCFlags.cmake b/cmake/DefaultCFlags.cmake
index 0eea595..8c784e9 100644
--- a/cmake/DefaultCFlags.cmake
+++ b/cmake/DefaultCFlags.cmake
@@ -3,30 +3,36 @@ set (CMAKE_LINK_FLAGS_RELEASE " " CACHE INTERNAL "Link flags for release" FORCE)
set (CMAKE_LINK_FLAGS_RELWITHDEBINFO " " CACHE INTERNAL "Link flags for release with debug support" FORCE)
set (CMAKE_LINK_FLAGS_DEBUG " " CACHE INTERNAL "Link flags for debug" FORCE)
set (CMAKE_LINK_FLAGS_PROFILE " -pg" CACHE INTERNAL "Link flags for profile" FORCE)
-set (CMAKE_LINK_FLAGS_COVERAGE " --coverage" CACHE INTERNAL "Link flags for static code checking" FORCE)
+set (CMAKE_LINK_FLAGS_COVERAGE " --coverage" CACHE INTERNAL "Link flags for static code coverage" FORCE)
set (CMAKE_C_FLAGS_RELEASE "")
-if (NOT APPLE)
- # -s doesn't work with default osx compiler clang, alternative:
+if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT MSVC)
+ # -s doesn't work with clang or Visual Studio, see alternative in link below:
# http://stackoverflow.com/questions/6085491/gcc-vs-clang-symbol-strippingu
set (CMAKE_C_FLAGS_RELEASE "-s")
endif()
if (NOT MSVC)
- set (CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release" FORCE)
- set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
+ set (CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release" FORCE)
+ set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
- set (CMAKE_C_FLAGS_RELWITHDEBINFO " -g -O2 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release with debug support" FORCE)
- set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO " -g -O2 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release with debug support" FORCE)
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
- set (CMAKE_C_FLAGS_DEBUG " -ggdb3 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for debug" FORCE)
- set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+ set (CMAKE_C_FLAGS_DEBUG " -ggdb3 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for debug" FORCE)
+ set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
- set (CMAKE_C_FLAGS_PROFILE " -fno-omit-frame-pointer -g -pg ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for profile" FORCE)
- set (CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
+ set (CMAKE_C_FLAGS_PROFILE " -fno-omit-frame-pointer -g -pg ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for profile" FORCE)
+ set (CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
- set (CMAKE_C_FLAGS_COVERAGE " -g -O0 -Wformat=2 --coverage -fno-inline ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for static code checking" FORCE)
- set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -fno-elide-constructors -fno-default-inline -fno-implicit-inline-templates")
+ set (CMAKE_C_FLAGS_COVERAGE " -g -O0 -Wformat=2 --coverage -fno-inline ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for static code coverage" FORCE)
+ set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}")
+ if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # -fno-default-inline -fno-implicit-inline-templates are unimplemented, cause errors in clang
+ # -fno-elide-constructors can cause seg-faults in clang 3.4 and earlier
+ # http://llvm.org/bugs/show_bug.cgi?id=12208
+ set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -fno-default-inline -fno-implicit-inline-templates -fno-elide-constructors")
+ endif()
endif()
#####################################
diff --git a/cmake/sdf_config.cmake.in b/cmake/sdf_config.cmake.in
index bd9c8d5..48291fe 100644
--- a/cmake/sdf_config.cmake.in
+++ b/cmake/sdf_config.cmake.in
@@ -10,6 +10,8 @@ if (NOT WIN32)
list(APPEND @PKG_NAME at _CXX_FLAGS "${@PKG_NAME at _CFLAGS} -std=c++11")
endif()
+list(APPEND @PKG_NAME at _LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@")
+
foreach(lib @PKG_LIBRARIES@)
set(onelib "${lib}-NOTFOUND")
find_library(onelib ${lib}
@@ -25,9 +27,11 @@ endforeach()
find_package(ignition-math at IGNITION-MATH_REQUIRED_MAJOR_VERSION@)
list(APPEND @PKG_NAME at _INCLUDE_DIRS ${IGNITION-MATH_INCLUDE_DIRS})
list(APPEND @PKG_NAME at _LIBRARIES ${IGNITION-MATH_LIBRARIES})
+list(APPEND @PKG_NAME at _LIBRARY_DIRS ${IGNITION-MATH_LIBRARY_DIRS})
find_package(Boost)
list(APPEND @PKG_NAME at _INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
list(APPEND @PKG_NAME at _LIBRARIES ${Boost_LIBRARIES})
+list(APPEND @PKG_NAME at _LIBRARY_DIRS ${Boost_LIBRARY_DIRS})
list(APPEND @PKG_NAME at _LDFLAGS "-L at CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@")
diff --git a/include/sdf/Element.hh b/include/sdf/Element.hh
index f2c0d09..ea0286d 100644
--- a/include/sdf/Element.hh
+++ b/include/sdf/Element.hh
@@ -229,11 +229,35 @@ namespace sdf
public: bool HasElement(const std::string &_name) const;
public: ElementPtr GetElement(const std::string &_name) const;
+
+ /// \brief Get the first child element
+ /// \returns A smart pointer to the first child of this element, or
+ /// sdf::ElementPtr(nullptr) if there are no children
public: ElementPtr GetFirstElement() const;
+ /// \brief Get the next sibling of this element
+ /// \param[in] _name if given then filter siblings by their xml tag
+ /// \remarks This function does not alter or store any state
+ /// Repeated calls to "GetNextElement()" with the same string will
+ /// always return a pointer to the same element.
+ /// \returns the next sibling element or sdf::ElementPtr(nullptr)
+ ///
+ /// This can be used in combination with GetFirstElement() to walk the SDF
+ /// tree. First call parent->GetFirstElement() to get the first child. Call
+ /// child = child->GetNextElement() to iterate through the children.
public: ElementPtr GetNextElement(const std::string &_name = "") const;
+ /// \brief Return a pointer to the child element with the provided name.
+ ///
+ /// A new child element, with the provided name, is added to this element
+ /// if there is no existing child element.
+ /// \remarks If there are multiple elements with the given tag, it returns
+ /// the first one.
+ /// \param[in] _name Name of the child element to retreive.
+ /// \return Pointer to the existing child element, or a new child
+ /// element if an existing child element did not exist.
public: ElementPtr GetElement(const std::string &_name);
+
public: ElementPtr AddElement(const std::string &_name);
public: void InsertElement(ElementPtr _elem);
diff --git a/include/sdf/Exception.hh b/include/sdf/Exception.hh
index a2cb55e..1ddfb94 100644
--- a/include/sdf/Exception.hh
+++ b/include/sdf/Exception.hh
@@ -53,6 +53,10 @@ namespace sdf
int64_t _line,
std::string _msg);
+ /// \brief Copy constructor
+ /// \param[in] _e Exception to copy.
+ public: Exception(const Exception &_e);
+
/// \brief Destructor
public: virtual ~Exception();
diff --git a/include/sdf/Param.hh b/include/sdf/Param.hh
index 215d43b..e451e0a 100644
--- a/include/sdf/Param.hh
+++ b/include/sdf/Param.hh
@@ -284,6 +284,8 @@ namespace sdf
{
std::string strValue =
boost::lexical_cast<std::string>(this->dataPtr->value);
+ std::transform(strValue.begin(), strValue.end(),
+ strValue.begin(), ::tolower);
if (strValue == "true" || strValue == "1")
_value = boost::lexical_cast<T>("1");
else
diff --git a/include/sdf/parser.hh b/include/sdf/parser.hh
index 579413c..2d1c889 100644
--- a/include/sdf/parser.hh
+++ b/include/sdf/parser.hh
@@ -78,6 +78,23 @@ namespace sdf
SDFORMAT_VISIBLE
bool readXml(TiXmlElement *_xml, ElementPtr _sdf);
+ /// \brief Get the best SDF version from models supported by this sdformat
+ /// \param[in] _modelXML XML element from config file pointing to the
+ /// model XML tag
+ /// \param[out] _modelFileName file name of the best model file
+ /// \return string with the best SDF version supported
+ SDFORMAT_VISIBLE
+ std::string getBestSupportedModelVersion(TiXmlElement *_modelXML,
+ std::string &_modelFileName);
+
+ /// \brief Get the file path to the model file
+ /// \param[in] _modelDirPath directory system path of the model
+ /// \return string with the full filesystem path to the best version (greater
+ /// SDF protocol supported by this sdformat version) of the .sdf
+ /// model files hosted by _modelDirPath.
+ SDFORMAT_VISIBLE
+ std::string getModelFilePath(const std::string &_modelDirPath);
+
SDFORMAT_VISIBLE
void copyChildren(ElementPtr _sdf, TiXmlElement *_xml);
diff --git a/include/sdf/parser_urdf.hh b/include/sdf/parser_urdf.hh
index f92111b..3e6f519 100644
--- a/include/sdf/parser_urdf.hh
+++ b/include/sdf/parser_urdf.hh
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 Open Source Robotics Foundation
+ * Copyright 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdf/1.6/heightmap_shape.sdf b/sdf/1.6/heightmap_shape.sdf
index 087f4ca..8db8c67 100644
--- a/sdf/1.6/heightmap_shape.sdf
+++ b/sdf/1.6/heightmap_shape.sdf
@@ -37,4 +37,8 @@
<element name="use_terrain_paging" type="bool" default="false" required="0">
<description>Set if the rendering engine will use terrain paging</description>
</element>
+ <element name="sampling" type="unsigned int" default="2" required="0">
+ <description>Samples per heightmap datum. For rasterized heightmaps, this indicates the number of samples to take per pixel. Using a lower value, e.g. 1, will generally improve the performance of the heightmap but lower the heightmap quality.
+ </description>
+ </element>
</element>
diff --git a/sdf/1.6/physics.sdf b/sdf/1.6/physics.sdf
index 6f1c84f..8e80d02 100644
--- a/sdf/1.6/physics.sdf
+++ b/sdf/1.6/physics.sdf
@@ -184,6 +184,20 @@
https://bitbucket.org/osrf/gazebo/pull-request/1114
</description>
</element>
+ <element name="friction_model" type="string" default="pyramid_model" required="0">
+ <description>
+ Name of ODE friction model to use. Valid values include:
+
+ pyramid_model: (default) friction forces limited in two directions
+ in proportion to normal force.
+ box_model: friction forces limited to constant in two directions.
+ cone_model: friction force magnitude limited in proportion to normal force.
+
+ See gazebo pull request 1522 for the implementation of this feature.
+ https://bitbucket.org/osrf/gazebo/pull-request/1522
+ https://bitbucket.org/osrf/gazebo/commits/8c05ad64967c
+ </description>
+ </element>
</element> <!-- End Solver -->
<element name="constraints" required="1">
diff --git a/sdf/1.6/state.sdf b/sdf/1.6/state.sdf
index 9e23d81..6a13e28 100644
--- a/sdf/1.6/state.sdf
+++ b/sdf/1.6/state.sdf
@@ -22,14 +22,15 @@
</element>
<element name="insertions" required="0">
- <description>A list of new model names</description>
+ <description>A list containing the entire description of entities inserted.</description>
<include filename="model.sdf" required="+"/>
+ <include filename="light.sdf" required="+"/>
</element>
<element name="deletions" required="0">
- <description>A list of deleted model names</description>
+ <description>A list of names of deleted entities/</description>
<element name="name" type="string" default="__default__" required="+">
- <description>The name of a deleted model</description>
+ <description>The name of a deleted entity.</description>
</element>
</element>
diff --git a/sdf/1.6/surface.sdf b/sdf/1.6/surface.sdf
index 7545103..85d287c 100644
--- a/sdf/1.6/surface.sdf
+++ b/sdf/1.6/surface.sdf
@@ -88,6 +88,10 @@
<description>Bitmask for collision filtering. This will override collide_without_contact</description>
</element>
+ <element name="category_bitmask" type="unsigned int" default="65535" required="0">
+ <description><![CDATA[Bitmask for category of collision filtering. Collision happens if ((category1 & collision2) | (category2 & collision1)) is not zero. If not specified, the category_bitmask should be interpreted as being the same as collide_bitmask.]]></description>
+ </element>
+
<element name="poissons_ratio" type="double" default="0.3" required="0">
<description>
Poisson's ratio is the ratio between transverse and axial strain.
diff --git a/Migration.md b/sdf/Migration.md
similarity index 53%
copy from Migration.md
copy to sdf/Migration.md
index 62f19cd..cdc63b3 100644
--- a/Migration.md
+++ b/sdf/Migration.md
@@ -10,46 +10,22 @@ and is distinct from sdformat library version
There are `*.convert` files that allow old sdf files to be migrated
forward programmatically.
This document aims to contain similar information to those files
-but with improved human-readability..
-
-## SDFormat 3.x to 4.x
-
-### Additions
-
-1. **New SDF protocol version 1.6**
- + Details about the 1.5 to 1.6 transition are explained below in this same
- document
-
-### Modifications
-
-1. **Boost pointers and boost::function**
- + All boost pointers, boost::function in the public API have been replaced
- by their std:: equivalents (C++11 standard)
-
-1. **`gravity` and `magnetic_field` elements are moved from `physics` to `world`**
- + In physics element: gravity and magnetic_field tags have been moved
- from Physics to World element.
- + [pull request 247](https://bitbucket.org/osrf/sdformat/pull-requests/247)
- + [gazebo pull request 2090](https://bitbucket.org/osrf/gazebo/pull-requests/2090)
-
-1. **New noise for IMU**
- + A new style for representing the noise properties of an `imu` was implemented
- in [pull request 199](https://bitbucket.org/osrf/sdformat/pull-requests/199)
- for sdf 1.5 and the old style was declared as deprecated.
- The old style has been removed from sdf 1.6 with the conversion script
- updating to the new style.
- + [pull request 199](https://bitbucket.org/osrf/sdformat/pull-requests/199)
- + [pull request 243](https://bitbucket.org/osrf/sdformat/pull-requests/243)
- + [pull request 244](https://bitbucket.org/osrf/sdformat/pull-requests/244)
-
-1. **Lump:: prefix in link names**
- + Changed to \_fixed_joint_lump__ to avoid confusion with scoped names
- + [Pull request 245](https://bitbucket.org/osrf/sdformat/pull-request/245)
+but with improved human-readability.
## SDF protocol 1.5 to 1.6
### Additions
+1. **heightmap_shape.sdf** `sampling` element
+ + description: Samples per heightmap datum.
+ For rasterized heightmaps, this indicates the number of samples to take per pixel.
+ Using a lower value, e.g. 1, will generally improve the performance
+ of the heightmap but lower the heightmap quality.
+ + type: unsigned int
+ + default: 2
+ + required: 0
+ + [pull request 293](https://bitbucket.org/osrf/sdformat/pull-requests/293)
+
1. **link.sdf** `enable_wind` element
+ description: If true, the link is affected by the wind
+ type: bool
@@ -58,8 +34,9 @@ but with improved human-readability..
+ [pull request 240](https://bitbucket.org/osrf/sdformat/pull-requests/240)
1. **model.sdf** `enable_wind` element
- + description: If set to true, all links in the model will be affected by
- the wind. Can be overriden by the link wind property.
+ + description: If set to true, all links in the model
+ will be affected by the wind.
+ Can be overriden by the link wind property.
+ type: bool
+ default: false
+ required: 0
@@ -72,6 +49,20 @@ but with improved human-readability..
+ required: 0
+ [pull request 246](https://bitbucket.org/osrf/sdformat/pull-requests/246)
+1. **physics.sdf** `friction_model` element
+ + description: Name of ODE friction model to use. Valid values include:
+ + pyramid_model: (default) friction forces limited in two directions
+ in proportion to normal force.
+ + box_model: friction forces limited to constant in two directions.
+ + cone_model: friction force magnitude limited in proportion to normal force.
+ See [gazebo pull request 1522](https://bitbucket.org/osrf/gazebo/pull-request/1522)
+ (merged in [gazebo 8c05ad64967c](https://bitbucket.org/osrf/gazebo/commits/8c05ad64967c))
+ for the implementation of this feature.
+ + type: string
+ + default: "pyramid_model"
+ + required: 0
+ + [pull request 294](https://bitbucket.org/osrf/sdformat/pull-requests/294)
+
1. **world.sdf** `wind` element
+ description: The wind tag specifies the type and properties of the wind.
+ required: 0
@@ -83,3 +74,20 @@ but with improved human-readability..
+ default: "0 0 0"
+ required: 0
+ [pull request 240](https://bitbucket.org/osrf/sdformat/pull-requests/240)
+
+### Modifications
+
+1. `gravity` and `magnetic_field` elements are moved
+ from `physics` to `world`
+ + [pull request 247](https://bitbucket.org/osrf/sdformat/pull-requests/247)
+ + [gazebo pull request 2090](https://bitbucket.org/osrf/gazebo/pull-requests/2090)
+
+1. A new style for representing the noise properties of an `imu` was implemented
+ in [pull request 199](https://bitbucket.org/osrf/sdformat/pull-requests/199)
+ for sdf 1.5 and the old style was declared as deprecated.
+ The old style has been removed from sdf 1.6 with the conversion script
+ updating to the new style.
+ + [pull request 199](https://bitbucket.org/osrf/sdformat/pull-requests/199)
+ + [pull request 243](https://bitbucket.org/osrf/sdformat/pull-requests/243)
+ + [pull request 244](https://bitbucket.org/osrf/sdformat/pull-requests/244)
+
diff --git a/src/Exception.cc b/src/Exception.cc
index ce78fdf..f4ed0e3 100644
--- a/src/Exception.cc
+++ b/src/Exception.cc
@@ -38,10 +38,19 @@ Exception::Exception(const char *_file, int64_t _line, std::string _msg)
}
//////////////////////////////////////////////////
+Exception::Exception(const Exception &_e)
+ : dataPtr(new ExceptionPrivate)
+{
+ this->dataPtr->file = _e.dataPtr->file;
+ this->dataPtr->line = _e.dataPtr->line;
+ this->dataPtr->str = _e.dataPtr->str;
+}
+
+//////////////////////////////////////////////////
Exception::~Exception()
{
delete this->dataPtr;
- this->dataPtr = NULL;
+ this->dataPtr = nullptr;
}
//////////////////////////////////////////////////
diff --git a/src/Param_TEST.cc b/src/Param_TEST.cc
index 5f86e26..f6354ed 100644
--- a/src/Param_TEST.cc
+++ b/src/Param_TEST.cc
@@ -61,6 +61,14 @@ TEST(Param, Bool)
strParam.Get<bool>(value);
EXPECT_FALSE(value);
+ strParam.Set("True");
+ strParam.Get<bool>(value);
+ EXPECT_TRUE(value);
+
+ strParam.Set("TRUE");
+ strParam.Get<bool>(value);
+ EXPECT_TRUE(value);
+
// Anything other than 1 or true is treated as a false value
strParam.Set("%");
strParam.Get<bool>(value);
diff --git a/src/SDF_TEST.cc b/src/SDF_TEST.cc
index 6b298ec..229578d 100644
--- a/src/SDF_TEST.cc
+++ b/src/SDF_TEST.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 Open Source Robotics Foundation
+ * Copyright 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/src/parser.cc b/src/parser.cc
index 75ad098..f184afc 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -19,6 +19,7 @@
#include <map>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
+#include <ignition/math/SemanticVersion.hh>
#include "sdf/Console.hh"
#include "sdf/Converter.hh"
@@ -472,6 +473,113 @@ bool readDoc(TiXmlDocument *_xmlDoc, ElementPtr _sdf,
}
//////////////////////////////////////////////////
+std::string getBestSupportedModelVersion(TiXmlElement *_modelXML,
+ std::string &_modelFileName)
+{
+ TiXmlElement *sdfXML = _modelXML->FirstChildElement("sdf");
+ TiXmlElement *nameSearch = _modelXML->FirstChildElement("name");
+
+ // If a match is not found, use the latest version of the element
+ // that is not older than the SDF parser.
+ ignition::math::SemanticVersion sdfParserVersion(SDF_VERSION);
+ std::string bestVersionStr = "0.0";
+
+ TiXmlElement *sdfSearch = sdfXML;
+ while (sdfSearch)
+ {
+ if (sdfSearch->Attribute("version"))
+ {
+ auto version = std::string(sdfSearch->Attribute("version"));
+ ignition::math::SemanticVersion modelVersion(version);
+ ignition::math::SemanticVersion bestVersion(bestVersionStr);
+ if (modelVersion > bestVersion)
+ {
+ // this model is better than the previous one
+ if (modelVersion <= sdfParserVersion)
+ {
+ // the parser can read it
+ sdfXML = sdfSearch;
+ bestVersionStr = version;
+ }
+ else
+ {
+ sdfwarn << "Ignoring version " << version
+ << " for model " << nameSearch->GetText()
+ << " because is newer than this sdf parser"
+ << " (version " << SDF_VERSION << ")\n";
+ }
+ }
+ }
+ sdfSearch = sdfSearch->NextSiblingElement("sdf");
+ }
+
+ if (!sdfXML || !sdfXML->GetText())
+ {
+ sdferr << "Failure to detect an sdf tag in the model config file"
+ << " for model: " << nameSearch->GetText() << "\n";
+
+ _modelFileName = "";
+ return "";
+ }
+
+ if (!sdfXML->Attribute("version"))
+ {
+ sdfwarn << "Can not find the XML attribute 'version'"
+ << " in sdf XML tag for model: " << nameSearch->GetText() << "."
+ << " Please specify the SDF protocol supported in the model"
+ << " configuration file. The first sdf tag in the config file"
+ << " will be used \n";
+ }
+
+ _modelFileName = sdfXML->GetText();
+ return bestVersionStr;
+}
+
+//////////////////////////////////////////////////
+std::string getModelFilePath(const std::string &_modelDirPath)
+{
+ boost::filesystem::path configFilePath = _modelDirPath;
+
+ /// \todo This hardcoded bit is very Gazebo centric. It should
+ /// be abstracted away, possible through a plugin to SDF.
+ if (boost::filesystem::exists(configFilePath / "model.config"))
+ {
+ configFilePath /= "model.config";
+ }
+ else if (boost::filesystem::exists(configFilePath / "manifest.xml"))
+ {
+ sdfwarn << "The manifest.xml for a model is deprecated. "
+ << "Please rename configFile.xml to "
+ << "model.config" << ".\n";
+
+ configFilePath /= "manifest.xml";
+ }
+
+ TiXmlDocument configFileDoc;
+ if (!configFileDoc.LoadFile(configFilePath.string()))
+ {
+ sdferr << "Error parsing XML in file ["
+ << configFilePath.string() << "]: "
+ << configFileDoc.ErrorDesc() << '\n';
+ return std::string();
+ }
+
+ TiXmlElement *modelXML = configFileDoc.FirstChildElement("model");
+
+ if (!modelXML)
+ {
+ sdferr << "No <model> element in configFile[" << configFilePath << "]\n";
+ return std::string();
+ }
+
+ std::string modelFileName;
+ if (getBestSupportedModelVersion(modelXML, modelFileName).empty())
+ return std::string();
+
+ return _modelDirPath + "/" + modelFileName;
+}
+
+//////////////////////////////////////////////////
bool readXml(TiXmlElement *_xml, ElementPtr _sdf)
{
if (_sdf->GetRequired() == "-1")
@@ -572,16 +680,14 @@ bool readXml(TiXmlElement *_xml, ElementPtr _sdf)
if (elemXml->FirstChildElement("uri"))
{
- modelPath = sdf::findFile(
- elemXml->FirstChildElement("uri")->GetText(), true, true);
+ std::string uri = elemXml->FirstChildElement("uri")->GetText();
+ modelPath = sdf::findFile(uri, true, true);
// Test the model path
if (modelPath.empty())
{
- sdferr << "Unable to find uri["
- << elemXml->FirstChildElement("uri")->GetText() << "]\n";
+ sdferr << "Unable to find uri[" << uri << "]\n";
- std::string uri = elemXml->FirstChildElement("uri")->GetText();
size_t modelFound = uri.find("model://");
if ( modelFound != 0u)
{
@@ -601,58 +707,8 @@ bool readXml(TiXmlElement *_xml, ElementPtr _sdf)
}
}
- boost::filesystem::path manifestPath = modelPath;
-
- /// \todo This hardcoded bit is very Gazebo centric. It should
- /// be abstracted away, possible through a plugin to SDF.
- if (boost::filesystem::exists(manifestPath / "model.config"))
- {
- manifestPath /= "model.config";
- }
- else
- {
- sdfwarn << "The manifest.xml for a model is deprecated. "
- << "Please rename manifest.xml to "
- << "model.config" << ".\n";
-
- manifestPath /= "manifest.xml";
- }
-
- TiXmlDocument manifestDoc;
- if (manifestDoc.LoadFile(manifestPath.string()))
- {
- TiXmlElement *modelXML = manifestDoc.FirstChildElement("model");
- if (!modelXML)
- sdferr << "No <model> element in manifest["
- << manifestPath << "]\n";
- else
- {
- TiXmlElement *sdfXML = modelXML->FirstChildElement("sdf");
-
- TiXmlElement *sdfSearch = sdfXML;
-
- // Find the SDF element that matches our current SDF version.
- while (sdfSearch)
- {
- if (sdfSearch->Attribute("version") &&
- std::string(sdfSearch->Attribute("version")) == SDF_VERSION)
- {
- sdfXML = sdfSearch;
- break;
- }
-
- sdfSearch = sdfSearch->NextSiblingElement("sdf");
- }
-
- filename = modelPath + "/" + sdfXML->GetText();
- }
- }
- else
- {
- sdferr << "Error parsing XML in file ["
- << manifestPath.string() << "]: "
- << manifestDoc.ErrorDesc() << '\n';
- }
+ // Get the config.xml filename
+ filename = getModelFilePath(modelPath);
}
else
{
@@ -726,10 +782,11 @@ bool readXml(TiXmlElement *_xml, ElementPtr _sdf)
pluginElem = includeSDF->Root()->GetElement(
"model")->AddElement("plugin");
- pluginElem->GetAttribute("filename")->SetFromString(
- childElemXml->Attribute("filename"));
- pluginElem->GetAttribute("name")->SetFromString(
- childElemXml->Attribute("name"));
+ if (!readXml(childElemXml, pluginElem))
+ {
+ sdferr << "Error reading plugin element\n";
+ return false;
+ }
}
}
diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt
index 5537bfb..9859fa2 100644
--- a/test/integration/CMakeLists.txt
+++ b/test/integration/CMakeLists.txt
@@ -2,6 +2,7 @@ set(TEST_TYPE "INTEGRATION")
set(tests
audio.cc
+ category_bitmask.cc
cfm_damping_implicit_spring_damper.cc
converter.cc
disable_fixed_joint_reduction.cc
@@ -11,10 +12,12 @@ set(tests
include.cc
joint_axis_frame.cc
locale_fix.cc
+ model_versions.cc
nested_model.cc
parser_error_detection.cc
plugin_attribute.cc
plugin_bool.cc
+ plugin_include.cc
provide_feedback.cc
urdf_gazebo_extensions.cc
urdf_joint_parameters.cc
diff --git a/test/integration/category_bitmask.cc b/test/integration/category_bitmask.cc
new file mode 100644
index 0000000..e1b6d3b
--- /dev/null
+++ b/test/integration/category_bitmask.cc
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2017 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include <gtest/gtest.h>
+#include "sdf/sdf.hh"
+
+#include "test_config.h"
+
+/////////////////////////////////////////////////
+TEST(CategoryBitmask, WasSpecified)
+{
+ std::string xmlString = R"(
+<?xml version="1.0" ?>
+<sdf version="1.6">
+ <world name="default">
+ <model name="asdf_model">
+ <link name="asdf_link">
+ <collision name="asdf_collision">
+ <geometry/>
+ <surface>
+ <contact>
+ <category_bitmask>1234</category_bitmask>
+ </contact>
+ </surface>
+ </collision>
+ </link>
+ </model>
+ </world>
+</sdf>)";
+
+ sdf::SDFPtr sdf(new sdf::SDF());
+ sdf::init(sdf);
+
+ ASSERT_TRUE(sdf::convertString(xmlString, "1.6", sdf));
+ ASSERT_NE(nullptr, sdf->Root());
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model")
+ ->GetElement("link"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model")
+ ->GetElement("link")->GetElement("collision")->GetElement("surface"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model")
+ ->GetElement("link")->GetElement("collision")->GetElement("surface")
+ ->GetElement("contact"));
+
+ sdf::ElementPtr contact = sdf->Root()->GetElement("world")
+ ->GetElement("model") ->GetElement("link")->GetElement("collision")
+ ->GetElement("surface")->GetElement("contact");
+ ASSERT_NE(nullptr, contact);
+
+ EXPECT_TRUE(contact->HasElement("category_bitmask"));
+ EXPECT_EQ(1234, contact->Get<int>("category_bitmask"));
+}
+
+/////////////////////////////////////////////////
+TEST(CategoryBitmask, WasNotSpecified)
+{
+ std::string xmlString = R"(
+<?xml version="1.0" ?>
+<sdf version="1.6">
+ <world name="default">
+ <model name="asdf_model">
+ <link name="asdf_link">
+ <collision name="asdf_collision">
+ <geometry/>
+ <surface>
+ <contact/>
+ </surface>
+ </collision>
+ </link>
+ </model>
+ </world>
+</sdf>)";
+
+ sdf::SDFPtr sdf(new sdf::SDF());
+ sdf::init(sdf);
+
+ ASSERT_TRUE(sdf::convertString(xmlString, "1.6", sdf));
+ ASSERT_NE(nullptr, sdf->Root());
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model")
+ ->GetElement("link"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model")
+ ->GetElement("link")->GetElement("collision")->GetElement("surface"));
+ ASSERT_NE(nullptr, sdf->Root()->GetElement("world")->GetElement("model")
+ ->GetElement("link")->GetElement("collision")->GetElement("surface")
+ ->GetElement("contact"));
+
+ sdf::ElementPtr contact = sdf->Root()->GetElement("world")
+ ->GetElement("model") ->GetElement("link")->GetElement("collision")
+ ->GetElement("surface")->GetElement("contact");
+ ASSERT_NE(nullptr, contact);
+
+ EXPECT_FALSE(contact->HasElement("category_bitmask"));
+}
diff --git a/test/integration/disable_fixed_joint_reduction.cc b/test/integration/disable_fixed_joint_reduction.cc
index 98e2f82..8f13bdb 100644
--- a/test/integration/disable_fixed_joint_reduction.cc
+++ b/test/integration/disable_fixed_joint_reduction.cc
@@ -28,7 +28,7 @@ const std::string SDF_FIXED_JNT_NO_LUMPING = std::string(PROJECT_SOURCE_PATH)
+ "/test/integration/fixed_joint_reduction_disabled.urdf";
/////////////////////////////////////////////////
-bool findJointInModel(std::string desired_joint_name, sdf::SDFPtr robot)
+bool findJointInModel(const std::string &desired_joint_name, sdf::SDFPtr robot)
{
bool found = false;
sdf::ElementPtr model = robot->Root()->GetElement("model");
diff --git a/test/integration/joint_axis_frame.cc b/test/integration/joint_axis_frame.cc
index 27a4dbc..6f85a80 100644
--- a/test/integration/joint_axis_frame.cc
+++ b/test/integration/joint_axis_frame.cc
@@ -21,7 +21,7 @@
#include "test_config.h"
-std::string get_sdf_string(std::string _version)
+std::string get_sdf_string(const std::string &_version)
{
std::ostringstream stream;
stream
diff --git a/test/integration/model/cococan/model-100.sdf b/test/integration/model/cococan/model-100.sdf
new file mode 100644
index 0000000..f2ae057
--- /dev/null
+++ b/test/integration/model/cococan/model-100.sdf
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<sdf version="100">
+ <model name="cococan">
+ <pose>0 0 0.5 0 0 0</pose>
+ <link name="link">
+ <collision name="collision">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ </collision>
+ <visual name="visual">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ <material>
+ <script>Gazebo/WoodPallet</script>
+ </material>
+ </visual>
+ </link>
+ </model>
+</sdf>
diff --git a/test/integration/model/cococan/model-1_2.sdf b/test/integration/model/cococan/model-1_2.sdf
new file mode 100644
index 0000000..525d59c
--- /dev/null
+++ b/test/integration/model/cococan/model-1_2.sdf
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<sdf version="1.2">
+ <model name="cococan">
+ <pose>0 0 0.5 0 0 0</pose>
+ <link name="link">
+ <collision name="collision">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ </collision>
+ <visual name="visual">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ <material>
+ <script>Gazebo/WoodPallet</script>
+ </material>
+ </visual>
+ </link>
+ </model>
+</sdf>
diff --git a/test/integration/model/cococan/model-1_4.sdf b/test/integration/model/cococan/model-1_4.sdf
new file mode 100644
index 0000000..2eda8a6
--- /dev/null
+++ b/test/integration/model/cococan/model-1_4.sdf
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<sdf version="1.4">
+ <model name="cococan">
+ <pose>0 0 0.5 0 0 0</pose>
+ <link name="link">
+ <collision name="collision">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ </collision>
+ <visual name="visual">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ <material>
+ <script>Gazebo/WoodPallet</script>
+ </material>
+ </visual>
+ </link>
+ </model>
+</sdf>
diff --git a/test/integration/model/cococan/model.config b/test/integration/model/cococan/model.config
new file mode 100644
index 0000000..59fa966
--- /dev/null
+++ b/test/integration/model/cococan/model.config
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+
+<model>
+ <name>cococan</name>
+ <version>1.0</version>
+ <sdf version="1.2">model-1_2.sdf</sdf>
+ <sdf version="1.4">model-1_4.sdf</sdf>
+ <sdf version="100.0">model-100.sdf</sdf>
+ <author>
+ <name>Testo</name>
+ <email>testo at osrfoundation.org</email>
+ </author>
+
+ <description>
+ A simple box with multiple versions
+ </description>
+</model>
diff --git a/test/integration/model/cococan_malformed/model.config b/test/integration/model/cococan_malformed/model.config
new file mode 100644
index 0000000..bfe8525
--- /dev/null
+++ b/test/integration/model/cococan_malformed/model.config
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<model>
+ <name>cococan</name>
+ <version>1.0</version>
+ <author>
+ <name>Testo</name>
+ <email>testo at osrfoundation.org</email>
+ </author>
+
+ <description>
+ A simple box with multiple versions
+ </description>
+</model>
diff --git a/test/integration/model/cococan_noversiontag/model-1_2.sdf b/test/integration/model/cococan_noversiontag/model-1_2.sdf
new file mode 100644
index 0000000..525d59c
--- /dev/null
+++ b/test/integration/model/cococan_noversiontag/model-1_2.sdf
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<sdf version="1.2">
+ <model name="cococan">
+ <pose>0 0 0.5 0 0 0</pose>
+ <link name="link">
+ <collision name="collision">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ </collision>
+ <visual name="visual">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ <material>
+ <script>Gazebo/WoodPallet</script>
+ </material>
+ </visual>
+ </link>
+ </model>
+</sdf>
diff --git a/test/integration/model/cococan_noversiontag/model-1_4.sdf b/test/integration/model/cococan_noversiontag/model-1_4.sdf
new file mode 100644
index 0000000..2eda8a6
--- /dev/null
+++ b/test/integration/model/cococan_noversiontag/model-1_4.sdf
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<sdf version="1.4">
+ <model name="cococan">
+ <pose>0 0 0.5 0 0 0</pose>
+ <link name="link">
+ <collision name="collision">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ </collision>
+ <visual name="visual">
+ <geometry>
+ <box>
+ <size>1 1 1</size>
+ </box>
+ </geometry>
+ <material>
+ <script>Gazebo/WoodPallet</script>
+ </material>
+ </visual>
+ </link>
+ </model>
+</sdf>
diff --git a/test/integration/model/cococan_noversiontag/model.config b/test/integration/model/cococan_noversiontag/model.config
new file mode 100644
index 0000000..70c91e9
--- /dev/null
+++ b/test/integration/model/cococan_noversiontag/model.config
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<model>
+ <name>cococan</name>
+ <version>1.0</version>
+ <sdf>model-1_2.sdf</sdf>
+ <sdf>model-1_4.sdf</sdf>
+ <author>
+ <name>Testo</name>
+ <email>testo at osrfoundation.org</email>
+ </author>
+
+ <description>
+ A simple box with multiple versions
+ </description>
+</model>
diff --git a/test/integration/model_versions.cc b/test/integration/model_versions.cc
new file mode 100644
index 0000000..b95b1f9
--- /dev/null
+++ b/test/integration/model_versions.cc
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2017 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include <gtest/gtest.h>
+#include "sdf/sdf.hh"
+
+#include "test_config.h"
+
+TEST(ModelVersionsTest, Empty_ModelFilePath)
+{
+ std::string modelPath = sdf::getModelFilePath("");
+
+ EXPECT_EQ(modelPath, "");
+}
+
+TEST(ModelVersionsTest, NonExistent_ModelFilePath)
+{
+ const std::string MODEL_PATH = std::string(PROJECT_SOURCE_PATH)
+ + "/test/integration/model/non-existent/";
+
+ std::string modelPath = sdf::getModelFilePath(MODEL_PATH);
+
+ EXPECT_EQ(modelPath, "");
+}
+
+TEST(ModelVersionsTest, MalFormed_ModelFilePath)
+{
+ const std::string MODEL_PATH = std::string(PROJECT_SOURCE_PATH)
+ + "/test/integration/model/cococan_malformed/";
+
+ std::string modelPath = sdf::getModelFilePath(MODEL_PATH);
+
+ EXPECT_EQ(modelPath, "");
+}
+
+TEST(ModelVersionsTest, NoVersionTag_ModelFilePath)
+{
+ const std::string MODEL_PATH = std::string(PROJECT_SOURCE_PATH)
+ + "/test/integration/model/cococan_noversiontag/";
+
+ std::string modelPath = sdf::getModelFilePath(MODEL_PATH);
+
+ EXPECT_EQ(modelPath, MODEL_PATH + "/model-1_2.sdf");
+}
+
+TEST(ModelVersionsTest, Correct_ModelFilePath)
+{
+ const std::string MODEL_PATH = std::string(PROJECT_SOURCE_PATH)
+ + "/test/integration/model/cococan/";
+
+ std::string modelPath = sdf::getModelFilePath(MODEL_PATH);
+
+ EXPECT_EQ(modelPath, MODEL_PATH + "/model-1_4.sdf");
+}
+
+/////////////////////////////////////////////////
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/integration/plugin_bool.cc b/test/integration/plugin_bool.cc
index 8b98933..b10fd6a 100644
--- a/test/integration/plugin_bool.cc
+++ b/test/integration/plugin_bool.cc
@@ -32,6 +32,8 @@ std::string get_sdf_string()
<< " <value2>1</value2>"
<< " <value3>false</value3>"
<< " <value4>0</value4>"
+ << " <value5>True</value5>"
+ << " <value6>TRUE</value6>"
<< " </plugin>"
<< "</model>"
<< "</sdf>";
@@ -60,4 +62,10 @@ TEST(PluginBool, ParseBoolValue)
ASSERT_TRUE(plugin->HasElement("value4"));
EXPECT_FALSE(plugin->Get<bool>("value4"));
+
+ ASSERT_TRUE(plugin->HasElement("value5"));
+ EXPECT_TRUE(plugin->Get<bool>("value5"));
+
+ ASSERT_TRUE(plugin->HasElement("value6"));
+ EXPECT_TRUE(plugin->Get<bool>("value6"));
}
diff --git a/test/integration/plugin_include.cc b/test/integration/plugin_include.cc
new file mode 100644
index 0000000..d39d64d
--- /dev/null
+++ b/test/integration/plugin_include.cc
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2017 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include <gtest/gtest.h>
+#include <string>
+#include "sdf/sdf.hh"
+
+#include "test_config.h"
+
+////////////////////////////////////////
+// Test that plugin child elements are available even when nested in an include
+TEST(PluginInclude, PluginChildElements)
+{
+ const std::string MODEL_PATH = std::string(PROJECT_SOURCE_PATH)
+ + "/test/integration/model/box";
+
+ std::ostringstream stream;
+ stream
+ << "<sdf version='" << SDF_VERSION << "'>"
+ << "<include>"
+ << " <uri>" + MODEL_PATH + "</uri>"
+ << " <plugin name='example' filename='libexample.so'>"
+ << " <user attribute='attribute' />"
+ << " <value attribute='boolean'>true</value>"
+ << " <uri>some_uri</uri>"
+ << " </plugin>"
+ << "</include>"
+ << "</sdf>";
+
+ sdf::SDFPtr sdfParsed(new sdf::SDF());
+ sdf::init(sdfParsed);
+ ASSERT_TRUE(sdf::readString(stream.str(), sdfParsed));
+
+ // Plugin attributes
+ sdf::ElementPtr plugin =
+ sdfParsed->Root()->GetElement("model")->GetElement("plugin");
+ EXPECT_TRUE(plugin->HasAttribute("name"));
+ EXPECT_EQ(plugin->GetAttribute("name")->GetAsString(), "example");
+ EXPECT_TRUE(plugin->HasAttribute("filename"));
+ EXPECT_EQ(plugin->GetAttribute("filename")->GetAsString(), "libexample.so");
+
+ // 1st child element
+ ASSERT_TRUE(plugin->HasElement("user"));
+ {
+ sdf::ElementPtr user = plugin->GetElement("user");
+ EXPECT_TRUE(user->HasAttribute("attribute"));
+ EXPECT_EQ(user->GetAttribute("attribute")->GetAsString(), "attribute");
+ }
+
+ // 2nd child element
+ ASSERT_TRUE(plugin->HasElement("value"));
+ {
+ sdf::ElementPtr value = plugin->GetElement("value");
+ EXPECT_TRUE(value->HasAttribute("attribute"));
+ EXPECT_EQ(value->GetAttribute("attribute")->GetAsString(), "boolean");
+ EXPECT_TRUE(value->Get<bool>(""));
+ }
+ EXPECT_TRUE(plugin->Get<bool>("value"));
+
+ // 3rd child element
+ ASSERT_TRUE(plugin->HasElement("uri"));
+ EXPECT_EQ(plugin->Get<std::string>("uri"), "some_uri");
+}
+
+////////////////////////////////////////
+// Test that missing required plugin attributes are detected
+TEST(PluginInclude, PluginMissingFilename)
+{
+ const std::string MODEL_PATH = std::string(PROJECT_SOURCE_PATH)
+ + "/test/integration/model/box";
+
+ std::ostringstream stream;
+ stream
+ << "<sdf version='" << SDF_VERSION << "'>"
+ << "<include>"
+ << " <uri>" + MODEL_PATH + "</uri>"
+ << " <plugin name='example' />"
+ << "</include>"
+ << "</sdf>";
+
+ sdf::SDFPtr sdfParsed(new sdf::SDF());
+ sdf::init(sdfParsed);
+ ASSERT_FALSE(sdf::readString(stream.str(), sdfParsed));
+}
diff --git a/tools/get_mem_info.py b/tools/get_mem_info.py
index da9a34b..32a1b06 100644
--- a/tools/get_mem_info.py
+++ b/tools/get_mem_info.py
@@ -9,4 +9,4 @@ p = psutil.Process(pid);
# note that different versions of psutil have different API
# some versions have memory_info(), others have get_memory_info()
memory_info = (p.memory_info() if hasattr(p, 'memory_info') else p.get_memory_info());
-print memory_info[0]
+print (memory_info[0])
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sdformat.git
More information about the debian-science-commits
mailing list