diff --git a/.appveyor.yml b/.appveyor.yml index 6630d7b278df8..821be49f0acd4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,8 +10,9 @@ platform: x64 # specify custom environment variables environment: + VCPKG_BUILD_TAG: v0.2.0-70f192e MSVC_DEFAULT_OPTIONS: ON - CMAKE_TOOLCHAIN_FILE: -DCMAKE_TOOLCHAIN_FILE="C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake" + CMAKE_TOOLCHAIN_FILE: -DCMAKE_TOOLCHAIN_FILE="C:\dartsim\vcpkg\scripts\buildsystems\vcpkg.cmake" matrix: - CMAKE_GENERATOR: -G"Visual Studio 16 2019" CMAKE_TOOLCHAIN: -T"v142" @@ -37,27 +38,12 @@ install: #------------------ # Windows 10 #------------------ - # update vcpkg - # - cmd: cd C:\tools\vcpkg - # - cmd: git pull - # - cmd: .\bootstrap-vcpkg.bat - - cmd: if "%platform%"=="Win32" set VCPKG_ARCH=x86-windows - cmd: if "%platform%"=="x64" set VCPKG_ARCH=x64-windows - - # remove outdated versions - # - cmd: vcpkg remove --outdated --recurse - - # install required dependencies - - cmd: vcpkg install --recurse --triplet %VCPKG_ARCH% assimp boost-system boost-filesystem ccd eigen3 fcl - - # install optional dependencies - # 'dart-utils' needs tinyxml2 and boost algorithm/lexical-cast - # and also boost-math to resolve a circular dependency with lexical-cast - - cmd: vcpkg install --recurse --triplet %VCPKG_ARCH% boost-algorithm boost-lexical-cast boost-math bullet3 freeglut ode opengl tinyxml2 - #- vcpkg install --recurse --triplet %VCPKG_ARCH% flann ipopt nlopt osg urdfdom - - - cmd: vcpkg integrate install + - cmd: mkdir -p C:\dartsim + - cmd: choco install -y wget + - cmd: wget -q https://github.com/dartsim/vcpkg-build/releases/download/%VCPKG_BUILD_TAG%/vcpkg-dartsim-dependencies.zip + - cmd: unzip -qq vcpkg-dartsim-dependencies.zip -d C:\dartsim - cmd: cd "%APPVEYOR_BUILD_FOLDER%" #------------------------------- @@ -69,17 +55,13 @@ install: - sh: sudo apt-get --yes install libnlopt-dev coinor-libipopt-dev libbullet-dev libflann-dev libtinyxml2-dev liburdfdom-dev libxi-dev libxmu-dev freeglut3-dev libopenscenegraph-dev - sh: sudo apt-get --yes install clang-format-6.0 -# preserve contents of selected directories and files across project builds -cache: - - C:\tools\vcpkg\installed -> .appveyor.yml - build_script: #------------------ # Windows 10 #------------------ - cmd: mkdir build && cd build - cmd: cmake %CMAKE_GENERATOR% -A x64 -DCMAKE_BUILD_TYPE=%configuration% -DDART_VERBOSE=ON -DDART_MSVC_DEFAULT_OPTIONS="%MSVC_DEFAULT_OPTIONS%" %CMAKE_TOOLCHAIN_FILE% %CMAKE_TOOLCHAIN% .. - # - cmd: cmake --build . --target ALL_BUILD --config %configuration% -- /maxcpucount:4 + - cmd: cmake --build . --target ALL_BUILD --config %configuration% --parallel #------------------------------- # Ubuntu 16.04 LTS && 18.04 LTS @@ -90,5 +72,12 @@ build_script: - sh: make check-format test_script: - #- cmd: ctest --build-config %configuration% --parallel 4 --output-on-failure + #------------------ + # Windows 10 + #------------------ + - cmd: ctest --output-on-fauilure + + #------------------------------- + # Ubuntu 16.04 LTS && 18.04 LTS + #------------------------------- - sh: ctest -j4 diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index ac181608bf0df..31bfa19da4e0b 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -5,10 +5,10 @@ name: C/C++ CI on: push: branches: - - '*' + - '**' pull_request: branches: - - '*' + - '**' schedule: # Run every day at 02:00 - cron: '0 2 * * 0-6' @@ -179,28 +179,57 @@ jobs: name: Windows [Release] runs-on: windows-2019 env: - COMPILER: gcc BUILD_TYPE: Release - RUN_TESTS: OFF VCPKG_ROOT: 'C:/dartsim/vcpkg' - VCPKG_BUILD_TAG: v0.1.1 + VCPKG_BUILD_TAG: v0.2.0-70f192e steps: - uses: actions/checkout@v1 - name: Install Dependencies shell: cmd run: | - mkdir -p C:/dartsim + mkdir -p C:\dartsim choco install -y wget - wget https://github.com/dartsim/vcpkg-build/releases/download/%VCPKG_BUILD_TAG%/vcpkg-dartsim-dependencies.zip - unzip vcpkg-dartsim-dependencies.zip -d C:/dartsim + wget -q https://github.com/dartsim/vcpkg-build/releases/download/%VCPKG_BUILD_TAG%/vcpkg-dartsim-dependencies.zip + unzip -qq vcpkg-dartsim-dependencies.zip -d C:\dartsim - name: Build shell: cmd run: | mkdir build cd build cmake .. -G "Visual Studio 16 2019" -A x64 -Wno-dev ^ - -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^ -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" ^ -DDART_MSVC_DEFAULT_OPTIONS=ON ^ -DDART_VERBOSE=ON - cmake --build . --target ALL_BUILD -- /maxcpucount:4 + cmake --build . --target ALL_BUILD --parallel + ctest --output-on-fauilure + + windows_2019_clang_cl: + name: Windows (clang-cl) [Release] + runs-on: windows-2019 + env: + BUILD_TYPE: Release + VCPKG_ROOT: 'C:/dartsim/vcpkg' + VCPKG_BUILD_TAG: v0.2.0-70f192e + steps: + - uses: actions/checkout@v1 + - name: Install Dependencies + shell: cmd + run: | + mkdir -p C:\dartsim + choco install -y wget + wget -q https://github.com/dartsim/vcpkg-build/releases/download/%VCPKG_BUILD_TAG%/vcpkg-dartsim-dependencies.zip + unzip -qq vcpkg-dartsim-dependencies.zip -d C:\dartsim + - name: Build + shell: cmd + run: | + mkdir build + cd build + cmake .. -G "Visual Studio 16 2019" -A x64 -Wno-dev ^ + -T ClangCl ^ + -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^ + -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" ^ + -DDART_MSVC_DEFAULT_OPTIONS=ON ^ + -DDART_VERBOSE=ON + cmake --build . --target ALL_BUILD --parallel + ctest --output-on-fauilure diff --git a/CMakeLists.txt b/CMakeLists.txt index 720d1d5155006..12a429ee5f8c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,6 @@ set(DART_PKG_EXTERNAL_DEPS "eigen, ccd, fcl, assimp, boost") # Build options #=============================================================================== option(DART_VERBOSE "Whether print detailed information in CMake process" OFF) -option(ENABLE_OPENMP "Build with OpenMP parallaization enabled" ON) if(MSVC) set(DART_RUNTIME_LIBRARY "/MD" CACHE STRING "BaseName chosen by the user at CMake configure time") set_property(CACHE DART_RUNTIME_LIBRARY PROPERTY STRINGS /MD /MT) @@ -171,7 +170,7 @@ if(MSVC) # Visual Studio enables C++14 support by default set(msvc_required_version 1920) - if(MSVC_VERSION VERSION_LESS ${msvc_required_version}) + if(MSVC_VERSION VERSION_LESS ${msvc_required_version} AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") message(FATAL_ERROR "Visual Studio ${MSVC_VERSION} is detected, but " "${PROJECT_NAME_UPPERCASE} requires ${msvc_required_version} or greater." ) @@ -186,17 +185,17 @@ if(MSVC) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DART_RUNTIME_LIBRARY}d /Zi /Gy /W1 /EHsc") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DART_RUNTIME_LIBRARY} /Zi /GL /Gy /W1 /EHsc") endif(NOT DART_MSVC_DEFAULT_OPTIONS) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_compile_options(/wd4334) - add_compile_options(/wd4267) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE) + add_compile_options(/wd4005) + add_compile_options(/wd4099) add_compile_options(/wd4244) add_compile_options(/wd4250) - add_compile_options(/wd4996) - add_compile_options(/wd4099) + add_compile_options(/wd4267) add_compile_options(/wd4305) + add_compile_options(/wd4334) add_compile_options(/wd4838) + add_compile_options(/wd4996) add_compile_options(/bigobj) - add_compile_definitions(_ENABLE_EXTENDED_ALIGNED_STORAGE) elseif(CMAKE_COMPILER_IS_GNUCXX) @@ -206,7 +205,6 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC") execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion -dumpversion OUTPUT_VARIABLE GCC_VERSION) - set(CXX_COMPILER_VERSION ${GCC_VERSION}) if(GCC_VERSION VERSION_LESS 5.3.1) message(FATAL_ERROR "The installed g++ version is ${GCC_VERSION}. ${PROJECT_NAME} requires g++ 5.3.1 or greater.") endif() @@ -234,7 +232,6 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION) - set(CXX_COMPILER_VERSION ${CLANG_VERSION}) if(CLANG_VERSION VERSION_LESS 3.8) message(FATAL_ERROR "The installed Clang version is ${CLANG_VERSION}. ${PROJECT_NAME} requires clang 3.8 or greater.") endif() @@ -269,10 +266,9 @@ if(DART_VERBOSE) message(STATUS "[ Build summary ]") message(STATUS "CMAKE_GENERATOR : ${CMAKE_GENERATOR}") message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}") - message(STATUS "Compiler version : ${CXX_COMPILER_VERSION}") + message(STATUS "Compiler version : ${CMAKE_CXX_COMPILER_VERSION}") message(STATUS "Build type : ${CMAKE_BUILD_TYPE}") message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") - message(STATUS "ENABLE_OPENMP : ${ENABLE_OPENMP}") message(STATUS "Build gui::osg : ${DART_BUILD_GUI_OSG}") message(STATUS "Install path : ${CMAKE_INSTALL_PREFIX}") message(STATUS "CXX_FLAGS : ${CMAKE_CXX_FLAGS}") @@ -302,7 +298,7 @@ if(TARGET dart) # Add a "tests" target to build unit tests. enable_testing() if(MSVC) - # add_subdirectory(unittests) + add_subdirectory(unittests) else() add_subdirectory(unittests EXCLUDE_FROM_ALL) endif() diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..0a7fc50dc5163 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,70 @@ +FROM ubuntu:focal + +ENV DEBIAN_FRONTEND=noninteractive + +# Install build dependencies +RUN apt-get clean \ + && apt-get update \ + && apt-get -y install --no-install-recommends \ + build-essential \ + cmake \ + git \ + pkg-config \ + software-properties-common \ + && rm -rf /var/lib/apt/lists/* + +# Install DART dependencies +RUN apt-get update \ + && apt-get -y install --no-install-recommends \ + libeigen3-dev \ + libassimp-dev \ + libccd-dev \ + libfcl-dev \ + libboost-all-dev \ + libnlopt-cxx-dev \ + coinor-libipopt-dev \ + libbullet-dev \ + liblz4-dev \ + libode-dev \ + liboctomap-dev \ + libflann-dev \ + libtinyxml2-dev \ + liburdfdom-dev \ + libxi-dev \ + libxmu-dev \ + freeglut3-dev \ + libopenscenegraph-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install dartpy dependencies +RUN apt-get update \ + && apt-get -y install --no-install-recommends \ + libpython3-dev \ + pybind11-dev \ + python3 \ + python3-pip \ + python3-pytest \ + python3-distutils \ + && rm -rf /var/lib/apt/lists/* + +# Compile and install DART and dartpy +COPY . /opt/dart +WORKDIR /opt/dart +RUN cd /opt/dart \ + && mkdir build \ + && cd build \ + && cmake \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_BUILD_TYPE=Release .. \ + -DBUILD_SHARED_LIBS=ON \ + -DDART_BUILD_DARTPY=ON \ + && make \ + && make install \ + && make dartpy \ + && make install-dartpy + +# Install python dependencies +RUN python3 -m pip install\ + numpy + +WORKDIR "/" diff --git a/cmake/DARTFindODE.cmake b/cmake/DARTFindODE.cmake index 9833f5acce855..6c574f0c1351e 100644 --- a/cmake/DARTFindODE.cmake +++ b/cmake/DARTFindODE.cmake @@ -6,12 +6,18 @@ # # This file is provided under the "BSD-style" License -find_package(ODE 0.13 QUIET MODULE) +find_package(ODE CONFIG NAMES ODE ode) + +if(NOT ODE_FOUND) + + find_package(ODE 0.13 QUIET MODULE) + + if(ODE_FOUND AND NOT TARGET ODE::ODE) + add_library(ODE::ODE INTERFACE IMPORTED) + set_target_properties(ODE::ODE PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ODE_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${ODE_LIBRARIES}" + ) + endif() -if(ODE_FOUND AND NOT TARGET ODE::ODE) - add_library(ODE::ODE INTERFACE IMPORTED) - set_target_properties(ODE::ODE PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ODE_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${ODE_LIBRARIES}" - ) endif() diff --git a/cmake/DARTFindtinyxml2.cmake b/cmake/DARTFindtinyxml2.cmake index 2dcbf2d1f0166..b5c84d4d5be79 100644 --- a/cmake/DARTFindtinyxml2.cmake +++ b/cmake/DARTFindtinyxml2.cmake @@ -6,7 +6,17 @@ # # This file is provided under the "BSD-style" License -find_package(tinyxml2 QUIET MODULE) +find_package(tinyxml2 QUIET CONFIG) +if(tinyxml2_FOUND) + set(TINYXML2_FOUND ${tinyxml2_FOUND}) + set(TINYXML2_INCLUDE_DIRS ${tinyxml2_INCLUDE_DIRS}) + set(TINYXML2_LIBRARIES ${tinyxml2_LIBRARIES}) + set(TINYXML2_VERSION ${tinyxml2_VERSION}) +endif() + +if(NOT tinyxml2_FOUND) + find_package(tinyxml2 QUIET MODULE) +endif() if((TINYXML2_FOUND OR tinyxml2_FOUND) AND NOT TARGET tinyxml2::tinyxml2) add_library(tinyxml2::tinyxml2 INTERFACE IMPORTED) diff --git a/cmake/Findassimp.cmake b/cmake/Findassimp.cmake index 3063d6d20cb4e..07b4a41738587 100644 --- a/cmake/Findassimp.cmake +++ b/cmake/Findassimp.cmake @@ -26,7 +26,10 @@ find_path(ASSIMP_INCLUDE_DIRS assimp/scene.h # Libraries if(MSVC) - set(ASSIMP_LIBRARIES "assimp$<$:d>") + find_package(assimp QUIET CONFIG) + if(TARGET assimp::assimp) + set(ASSIMP_LIBRARIES "assimp::assimp") + endif() else() find_library(ASSIMP_LIBRARIES NAMES assimp @@ -34,7 +37,9 @@ else() endif() # Version -set(ASSIMP_VERSION ${PC_ASSIMP_VERSION}) +if(PC_ASSIMP_VERSION) + set(ASSIMP_VERSION ${PC_ASSIMP_VERSION}) +endif() # Set (NAME)_FOUND if all the variables and the version are satisfied. include(FindPackageHandleStandardArgs) diff --git a/cmake/Findfcl.cmake b/cmake/Findfcl.cmake index e49de2cadb2f9..5f586c675dcff 100644 --- a/cmake/Findfcl.cmake +++ b/cmake/Findfcl.cmake @@ -28,7 +28,10 @@ find_path(FCL_INCLUDE_DIRS # Libraries if(MSVC) - set(FCL_LIBRARIES "fcl$<$:d>") + find_package(fcl QUIET CONFIG) + if(TARGET fcl) + set(FCL_LIBRARIES fcl) + endif() else() # Give explicit precedence to ${PC_FCL_LIBDIR} find_library(FCL_LIBRARIES @@ -44,7 +47,9 @@ else() endif() # Version -set(FCL_VERSION ${PC_FCL_VERSION}) +if(PC_FCL_VERSION) + set(FCL_VERSION ${PC_FCL_VERSION}) +endif() # Set (NAME)_FOUND if all the variables and the version are satisfied. include(FindPackageHandleStandardArgs) diff --git a/dart/CMakeLists.txt b/dart/CMakeLists.txt index a6d8c850c400c..aa4c82b8787a3 100644 --- a/dart/CMakeLists.txt +++ b/dart/CMakeLists.txt @@ -3,7 +3,7 @@ add_subdirectory(external) # Enable multi-threaded compilation. # We do this here and not in the root folder since the examples and the # tutorials do not have enough source files to benefit from this. -if(MSVC) +if(MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() diff --git a/dart/collision/DistanceOption.hpp b/dart/collision/DistanceOption.hpp index b84beccb9fc6b..7dd4633050cb5 100644 --- a/dart/collision/DistanceOption.hpp +++ b/dart/collision/DistanceOption.hpp @@ -39,7 +39,7 @@ namespace dart { namespace collision { -class DistanceFilter; +struct DistanceFilter; struct DistanceOption { diff --git a/dart/gui/glut/GraphWindow.cpp b/dart/gui/glut/GraphWindow.cpp index 16a4e6740567f..c1b7090f9d392 100644 --- a/dart/gui/glut/GraphWindow.cpp +++ b/dart/gui/glut/GraphWindow.cpp @@ -126,11 +126,7 @@ void GraphWindow::draw() void GraphWindow::keyboard(unsigned char _key, int _x, int _y) { - switch (_key) - { - default: - Win2D::keyboard(_key, _x, _y); - } + Win2D::keyboard(_key, _x, _y); glutPostRedisplay(); } diff --git a/examples/wam_ikfast/ikfast/ikfast71.Transform6D.4_6_9_10_11_12_f8.cpp b/examples/wam_ikfast/ikfast/ikfast71.Transform6D.4_6_9_10_11_12_f8.cpp index 971cf9f9c0e38..e10209dd0f82f 100644 --- a/examples/wam_ikfast/ikfast/ikfast71.Transform6D.4_6_9_10_11_12_f8.cpp +++ b/examples/wam_ikfast/ikfast/ikfast71.Transform6D.4_6_9_10_11_12_f8.cpp @@ -63,18 +63,6 @@ IKFAST_COMPILE_ASSERT(IKFAST_VERSION==71); #define IKPI ((IkReal)3.14159265358979) #define IKPI_2 ((IkReal)1.57079632679490) -#ifdef _MSC_VER -#ifndef isnan -#define isnan _isnan -#endif -#ifndef isinf -#define isinf _isinf -#endif -//#ifndef isfinite -//#define isfinite _isfinite -//#endif -#endif // _MSC_VER - // lapack routines extern "C" { void dgetrf_ (const int* m, const int* n, double* a, const int* lda, int* ipiv, int* info); diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 0262385b542be..0ffbe2f802975 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -66,16 +66,7 @@ function(dart_add_test test_type target_name) # ARGN for source files add_executable(${target_name} ${sources}) add_test(${target_name} ${target_name}) - - if(MSVC) - target_link_libraries(${target_name} - dart - optimized gtest debug gtestd - optimized gtest_main debug gtest_maind - ) - else() - target_link_libraries(${target_name} dart gtest gtest_main) - endif() + target_link_libraries(${target_name} dart gtest gtest_main) dart_format_add(${sources}) @@ -102,8 +93,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # fixed even after further changes are made # - "unit": low level tests for one or few classes and functions to verify that # they performs correctly as expected -add_subdirectory(comprehensive) -add_subdirectory(regression) +if(NOT MSVC) + # Disabled due to limitied disk space in CI image + add_subdirectory(comprehensive) + add_subdirectory(regression) +endif() add_subdirectory(unit) # Print tests diff --git a/unittests/GTestUtils.hpp b/unittests/GTestUtils.hpp index 3820521cc48c1..02cb3422cd2cd 100644 --- a/unittests/GTestUtils.hpp +++ b/unittests/GTestUtils.hpp @@ -169,44 +169,109 @@ namespace dart { namespace test { -//============================================================================== -/// Returns true if the two matrices are equal within the given bound -template -bool equals( - const Eigen::DenseBase& expected, - const Eigen::DenseBase& actual, - double tol = 1e-5) +namespace detail { + +template +struct EqualsImpl { - // Get the matrix sizes and sanity check the call - const std::size_t n1 = expected.cols(), m1 = expected.rows(); - const std::size_t n2 = actual.cols(), m2 = actual.rows(); - if (m1 != m2 || n1 != n2) - return false; - - // Check each index - for (std::size_t i = 0; i < m1; i++) + static bool run( + const Eigen::DenseBase& expected, + const Eigen::DenseBase& actual, + typename DerivedA::Scalar tol) { - for (std::size_t j = 0; j < n1; j++) + // Get the matrix sizes and sanity check the call + const std::size_t n1 = expected.cols(), m1 = expected.rows(); + const std::size_t n2 = actual.cols(), m2 = actual.rows(); + if (m1 != m2 || n1 != n2) + return false; + + // Check each index + for (std::size_t i = 0; i < m1; i++) { - if (std::isnan(expected(i, j)) ^ std::isnan(actual(i, j))) + for (std::size_t j = 0; j < n1; j++) { - return false; - } - else if (std::abs(expected(i, j)) > 1) - { - // Test relative error for values that are larger than 1 - if (std::abs((expected(i, j) - actual(i, j)) / expected(i, j)) > tol) + if (std::isnan(expected(i, j)) ^ std::isnan(actual(i, j))) + { + return false; + } + else if (std::abs(expected(i, j)) > 1) + { + // Test relative error for values that are larger than 1 + if (std::abs((expected(i, j) - actual(i, j)) / expected(i, j)) > tol) + return false; + } + else if (std::abs(expected(i, j) - actual(i, j)) > tol) + { return false; + } } - else if (std::abs(expected(i, j) - actual(i, j)) > tol) + } + + // If no problems, the two matrices are equal + return true; + } +}; + +// Workaround to resolve: "fpclassify': ambiguous call to overloaded function +// Reference: https://stackoverflow.com/a/61646279 +#ifdef _WIN32 +template +struct EqualsImpl< + DerivedA, + DerivedB, + std::enable_if_t::value>> +{ + static bool run( + const Eigen::DenseBase& expected, + const Eigen::DenseBase& actual, + typename DerivedA::Scalar tol) + { + // Get the matrix sizes and sanity check the call + const std::size_t n1 = expected.cols(), m1 = expected.rows(); + const std::size_t n2 = actual.cols(), m2 = actual.rows(); + if (m1 != m2 || n1 != n2) + return false; + + // Check each index + for (std::size_t i = 0; i < m1; i++) + { + for (std::size_t j = 0; j < n1; j++) { - return false; + if (std::isnan(static_cast(expected(i, j))) + ^ std::isnan(static_cast(actual(i, j)))) + { + return false; + } + else if (std::abs(expected(i, j)) > 1) + { + // Test relative error for values that are larger than 1 + if (std::abs((expected(i, j) - actual(i, j)) / expected(i, j)) > tol) + return false; + } + else if (std::abs(expected(i, j) - actual(i, j)) > tol) + { + return false; + } } } + + // If no problems, the two matrices are equal + return true; } +}; +#endif + +} // namespace detail - // If no problems, the two matrices are equal - return true; +//============================================================================== +/// Returns true if the two matrices are equal within the given bound +template +bool equals( + const T1& expected, + const T2& actual, + typename T1::Scalar tol = static_cast(1e-5)) +{ + return detail::EqualsImpl::run(expected, actual, tol); } //============================================================================== diff --git a/unittests/TestHelpers.hpp b/unittests/TestHelpers.hpp index 0fee8982dc7a3..434abcf75525d 100644 --- a/unittests/TestHelpers.hpp +++ b/unittests/TestHelpers.hpp @@ -65,11 +65,10 @@ enum TypeOfDOF //============================================================================== // Deprecated. Use dart::test::equals() instead. -template -bool equals(const Eigen::DenseBase& _expected, - const Eigen::DenseBase& _actual, double tol = 1e-5) +template +bool equals(const MatrixA& expected, const MatrixB& actual, double tol = 1e-5) { - return dart::test::equals(_expected, _actual, tol); + return dart::test::equals(expected, actual, tol); } //============================================================================== diff --git a/unittests/comprehensive/test_Joints.cpp b/unittests/comprehensive/test_Joints.cpp index 726817e954c1d..02c6ca79adbab 100644 --- a/unittests/comprehensive/test_Joints.cpp +++ b/unittests/comprehensive/test_Joints.cpp @@ -82,7 +82,7 @@ class JOINTS : public testing::Test void kinematicsTest( #ifdef _WIN32 const typename JointType::Properties& _joint - = BodyNode::createJointProperties()); + = createJointProperties()); #else const typename JointType::Properties& _joint = typename JointType::Properties()); diff --git a/unittests/unit/CMakeLists.txt b/unittests/unit/CMakeLists.txt index fb0593507747e..64005f5eadaca 100644 --- a/unittests/unit/CMakeLists.txt +++ b/unittests/unit/CMakeLists.txt @@ -1,6 +1,15 @@ -dart_add_test("unit" test_Aspect) -dart_add_test("unit" test_CollisionGroups) -dart_add_test("unit" test_ContactConstraint) +if(NOT MSVC) + dart_add_test("unit" test_Aspect) + dart_add_test("unit" test_CollisionGroups) + foreach(collision_engine + dart-collision-bullet + dart-collision-ode) + if(TARGET ${collision_engine}) + target_link_libraries(test_CollisionGroups ${collision_engine}) + endif() + endforeach() + dart_add_test("unit" test_ContactConstraint) +endif() dart_add_test("unit" test_Factory) dart_add_test("unit" test_GenericJoints) dart_add_test("unit" test_Geometry) @@ -10,9 +19,11 @@ dart_add_test("unit" test_LocalResourceRetriever) dart_add_test("unit" test_Math) dart_add_test("unit" test_Optimizer) dart_add_test("unit" test_Random) -dart_add_test("unit" test_ScrewJoint) -dart_add_test("unit" test_Signal) -dart_add_test("unit" test_Subscriptions) +if(NOT MSVC) + dart_add_test("unit" test_ScrewJoint) + dart_add_test("unit" test_Signal) + dart_add_test("unit" test_Subscriptions) +endif() dart_add_test("unit" test_Uri) if(TARGET dart-optimizer-ipopt) @@ -30,30 +41,36 @@ if(TARGET dart-utils) dart_add_test("unit" test_DartResourceRetriever) target_link_libraries(test_DartResourceRetriever dart-utils) - - dart_add_test("unit" test_FileInfoWorld) - target_link_libraries(test_FileInfoWorld dart-utils) + + if(NOT MSVC) + dart_add_test("unit" test_FileInfoWorld) + target_link_libraries(test_FileInfoWorld dart-utils) + endif() dart_add_test("unit" test_PackageResourceRetriever) target_link_libraries(test_PackageResourceRetriever dart-utils) - dart_add_test("unit" test_MjcfParser) - target_link_libraries(test_MjcfParser dart-utils) - - dart_add_test("unit" test_SdfParser) - target_link_libraries(test_SdfParser dart-utils) - - dart_add_test("unit" test_SkelParser) - target_link_libraries(test_SkelParser dart-utils) - - dart_add_test("unit" test_VskParser) - target_link_libraries(test_VskParser dart-utils) + if(NOT MSVC) + dart_add_test("unit" test_MjcfParser) + target_link_libraries(test_MjcfParser dart-utils) + + dart_add_test("unit" test_SdfParser) + target_link_libraries(test_SdfParser dart-utils) + + dart_add_test("unit" test_SkelParser) + target_link_libraries(test_SkelParser dart-utils) + + dart_add_test("unit" test_VskParser) + target_link_libraries(test_VskParser dart-utils) + endif() endif() if(TARGET dart-utils-urdf) - dart_add_test("unit" test_DartLoader) - target_link_libraries(test_DartLoader dart-utils-urdf) + if(NOT MSVC) + dart_add_test("unit" test_DartLoader) + target_link_libraries(test_DartLoader dart-utils-urdf) + endif() dart_add_library(SharedLibraryWamIkFast SharedLibraryWamIkFast.hpp SharedLibraryWamIkFast.cpp) target_link_libraries(SharedLibraryWamIkFast PUBLIC dart) @@ -77,16 +94,6 @@ if(TARGET dart-planning) target_link_libraries(test_NearestNeighbor dart-planning) endif() -foreach(collision_engine - dart-collision-bullet - dart-collision-ode) - - if(TARGET ${collision_engine}) - target_link_libraries(test_CollisionGroups ${collision_engine}) - endif() - -endforeach() - dart_format_add( GeneratedWamIkFast.cpp SharedLibraryWamIkFast.hpp diff --git a/unittests/unit/GeneratedWamIkFast.cpp b/unittests/unit/GeneratedWamIkFast.cpp index ed0a7f52a3813..7b1e05316ab29 100644 --- a/unittests/unit/GeneratedWamIkFast.cpp +++ b/unittests/unit/GeneratedWamIkFast.cpp @@ -74,18 +74,6 @@ IKFAST_COMPILE_ASSERT(IKFAST_VERSION == 71); #define IKPI ((IkReal)3.14159265358979) #define IKPI_2 ((IkReal)1.57079632679490) -#ifdef _MSC_VER -# ifndef isnan -# define isnan _isnan -# endif -# ifndef isinf -# define isinf _isinf -# endif -//#ifndef isfinite -//#define isfinite _isfinite -//#endif -#endif // _MSC_VER - // lapack routines extern "C" { void dgetrf_( diff --git a/unittests/unit/SharedLibraryWamIkFast.cpp b/unittests/unit/SharedLibraryWamIkFast.cpp index e172c1032a1be..2ba9d6db3368f 100644 --- a/unittests/unit/SharedLibraryWamIkFast.cpp +++ b/unittests/unit/SharedLibraryWamIkFast.cpp @@ -86,18 +86,6 @@ IKFAST_COMPILE_ASSERT(IKFAST_VERSION == 71); #define IKPI ((IkReal)3.14159265358979) #define IKPI_2 ((IkReal)1.57079632679490) -#ifdef _MSC_VER -# ifndef isnan -# define isnan _isnan -# endif -# ifndef isinf -# define isinf _isinf -# endif -//#ifndef isfinite -//#define isfinite _isfinite -//#endif -#endif // _MSC_VER - // lapack routines extern "C" { void dgetrf_( diff --git a/unittests/unit/test_Aspect.cpp b/unittests/unit/test_Aspect.cpp index 3bd3e359edefb..8664c069ee19e 100644 --- a/unittests/unit/test_Aspect.cpp +++ b/unittests/unit/test_Aspect.cpp @@ -236,13 +236,6 @@ class StateAspectTest } }; -class StateAndPropertiesAspectTest - : public dart::common::AspectWithVersionedProperties< - StateAndPropertiesAspectTest, - dart::common::Empty> -{ -}; - class GenericAspect : public Aspect, public Subject { public: