Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use own build script for gtest #485

Merged
merged 13 commits into from Jan 24, 2019
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -77,7 +77,9 @@
* Defined optional dependencies: [#376](https://github.com/personalrobotics/aikido/pull/376)
* Fixed compilation bug with Eigen 3.3.5: [#452](https://github.com/personalrobotics/aikido/pull/452)
* Updated gtest version to 1.8.1: [#478](https://github.com/personalrobotics/aikido/pull/478)
* Added DART 6.7 support: [#480](https://github.com/personalrobotics/aikido/pull/480)
* Fixed use of dart::common::make_unique for C++14 enabled compilers: [#481](https://github.com/personalrobotics/aikido/pull/481)
* Changed to use own build script for GoogleTest: [#485](https://github.com/personalrobotics/aikido/pull/485)

### 0.2.0 (2018-01-09)

Expand Down
17 changes: 1 addition & 16 deletions CMakeLists.txt
Expand Up @@ -101,21 +101,6 @@ macro(aikido_check_package variable component dependency)
endif()
endmacro()

#==============================================================================
# Register an Aikido test.
#
set_property(GLOBAL PROPERTY AIKIDO_TESTS)

function(aikido_add_test target_name)
add_executable("${target_name}" ${ARGN})
add_test("${target_name}" "${target_name}")

target_link_libraries("${target_name}" gtest gtest_main)

set_property(GLOBAL APPEND PROPERTY AIKIDO_TESTS "${target_name}")
format_add_sources(${ARGN})
endfunction()

#==============================================================================
# Required Dependencies
#
Expand All @@ -126,7 +111,7 @@ include(FindPkgConfig)

find_package(Boost REQUIRED COMPONENTS filesystem)

find_package(DART 6.6.0 REQUIRED
find_package(DART 6.6.2 REQUIRED
COMPONENTS optimizer-nlopt utils
OPTIONAL_COMPONENTS utils-urdf # for 'perception' target
CONFIG
Expand Down
4 changes: 4 additions & 0 deletions src/planner/World.cpp
Expand Up @@ -38,7 +38,11 @@ std::unique_ptr<World> World::clone(const std::string& newName) const
worldClone->mSkeletons.reserve(mSkeletons.size());
for (std::size_t i = 0; i < mSkeletons.size(); ++i)
{
#if DART_VERSION_AT_LEAST(6,7,0)
const auto clonedSkeleton = mSkeletons[i]->cloneSkeleton();
#else
const auto clonedSkeleton = mSkeletons[i]->clone();
#endif
clonedSkeleton->setConfiguration(mSkeletons[i]->getConfiguration());
worldClone->addSkeleton(std::move(clonedSkeleton));
}
Expand Down
25 changes: 23 additions & 2 deletions tests/CMakeLists.txt
@@ -1,5 +1,26 @@
# GTest setup.
add_subdirectory(gtest)
# GTest setup
add_library(gtest STATIC "${CMAKE_CURRENT_SOURCE_DIR}/gtest/src/gtest-all.cc")
target_include_directories(gtest SYSTEM BEFORE
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/gtest/include"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/gtest"
)
if(NOT WIN32)
target_link_libraries(gtest PUBLIC pthread)
endif()
add_library(gtest_main STATIC gtest/src/gtest_main.cc)
target_link_libraries(gtest_main PUBLIC gtest)

# Define aikido_add_test for registering Aikido tests.
set_property(GLOBAL PROPERTY AIKIDO_TESTS)
function(aikido_add_test target_name)
add_executable("${target_name}" ${ARGN})
add_test("${target_name}" "${target_name}")

target_link_libraries("${target_name}" gtest gtest_main)

set_property(GLOBAL APPEND PROPERTY AIKIDO_TESTS "${target_name}")
format_add_sources(${ARGN})
endfunction()

# Add helper scripts to the include path.
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion tests/gtest/CMakeLists.txt
Expand Up @@ -108,7 +108,7 @@ endif()
set(gtest_build_include_dirs
"${gtest_SOURCE_DIR}/include"
"${gtest_SOURCE_DIR}")
include_directories(SYSTEM ${gtest_build_include_dirs})
include_directories(${gtest_build_include_dirs})

# Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support
Expand Down
8 changes: 8 additions & 0 deletions tests/statespace/dart/test_MetaSkeletonStateSpace.cpp
Expand Up @@ -98,12 +98,20 @@ TEST(MetaSkeletonStateSpace, RevoluteJoint_CompatibleSkeletons)
withBoundSpace.checkCompatibility(withoutBound.get()),
std::invalid_argument);

#if DART_VERSION_AT_LEAST(6,7,0)
auto withoutBoundClone = withoutBound->cloneSkeleton();
#else
auto withoutBoundClone = withoutBound->clone();
#endif
EXPECT_TRUE(withoutBoundSpace.isCompatible(withoutBoundClone.get()));
EXPECT_NO_THROW(
withoutBoundSpace.checkCompatibility(withoutBoundClone.get()));

#if DART_VERSION_AT_LEAST(6,7,0)
auto withBoundClone = withBound->cloneSkeleton();
#else
auto withBoundClone = withBound->clone();
#endif
EXPECT_TRUE(withBoundSpace.isCompatible(withBoundClone.get()));
EXPECT_NO_THROW(withBoundSpace.checkCompatibility(withBoundClone.get()));

Expand Down
4 changes: 4 additions & 0 deletions tests/statespace/test_CartesianProduct.cpp
Expand Up @@ -20,7 +20,11 @@ TEST(CartesianProduct, Clone)
for (auto i = 0u; i < 5u; ++i)
{
auto s1 = space.createState();
#if DART_VERSION_AT_LEAST(6,7,0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to merge changes from #480 first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

const auto angle = dart::math::Random::uniform(-M_PI, M_PI);
#else
const auto angle = dart::math::random(-M_PI, M_PI);
#endif
s1.getSubStateHandle<SO2>(0).fromAngle(angle);
s1.getSubStateHandle<R2>(1).setValue(Eigen::Vector2d::Random());

Expand Down
4 changes: 4 additions & 0 deletions tests/statespace/test_SE2.cpp
Expand Up @@ -10,7 +10,11 @@ TEST(SE2, Clone)

for (auto i = 0u; i < 5u; ++i)
{
#if DART_VERSION_AT_LEAST(6,7,0)
const auto angle = dart::math::Random::uniform(-M_PI, M_PI);
#else
const auto angle = dart::math::random(-M_PI, M_PI);
#endif
Eigen::Isometry2d pose = Eigen::Isometry2d::Identity();
pose.rotate(Eigen::Rotation2Dd(angle));
pose.translation() = Eigen::Vector2d::Random();
Expand Down
4 changes: 4 additions & 0 deletions tests/statespace/test_SE3.cpp
Expand Up @@ -12,7 +12,11 @@ TEST(SE3, Clone)
for (auto i = 0u; i < 5u; ++i)
{
Eigen::Isometry3d pose = Eigen::Isometry3d::Identity();
#if DART_VERSION_AT_LEAST(6,7,0)
const auto angle = dart::math::Random::uniform(-M_PI, M_PI);
#else
const auto angle = dart::math::random(-M_PI, M_PI);
#endif
const auto axis = Eigen::Vector3d::Random().normalized();
const auto angleAxis = Eigen::AngleAxisd(angle, axis);
pose.linear() = angleAxis.toRotationMatrix();
Expand Down
4 changes: 4 additions & 0 deletions tests/statespace/test_SO2.cpp
Expand Up @@ -33,7 +33,11 @@ TEST(SO2, Clone)

for (auto i = 0u; i < 5u; ++i)
{
#if DART_VERSION_AT_LEAST(6,7,0)
const auto angle = dart::math::Random::uniform(-M_PI, M_PI);
#else
const auto angle = dart::math::random(-M_PI, M_PI);
#endif

auto s1 = so2.createState();
s1.fromAngle(angle);
Expand Down
4 changes: 4 additions & 0 deletions tests/statespace/test_SO3.cpp
Expand Up @@ -10,7 +10,11 @@ TEST(SO3, Clone)

for (auto i = 0u; i < 5u; ++i)
{
#if DART_VERSION_AT_LEAST(6,7,0)
const auto angle = dart::math::Random::uniform(-M_PI, M_PI);
#else
const auto angle = dart::math::random(-M_PI, M_PI);
#endif
const auto axis = Eigen::Vector3d::Random().normalized();
const auto angleAxis = Eigen::AngleAxisd(angle, axis);
const Eigen::Quaterniond quat(angleAxis);
Expand Down