Skip to content

Commit

Permalink
Backport #761 to DART 4.3 as a single commit
Browse files Browse the repository at this point in the history
# Conflicts:
#	CMakeLists.txt
#	cmake/FindFLANN.cmake
#	unittests/CMakeLists.txt
  • Loading branch information
jslee02 committed Jan 6, 2018
1 parent 3e0b883 commit 08e3b58
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ if(NOT BUILD_CORE_ONLY)
# FLANN
find_package(FLANN QUIET)
if(FLANN_FOUND)
message(STATUS "Looking for FLANN - found")
message(STATUS "Looking for FLANN - ${FLANN_VERSION} found")
set(HAVE_FLANN TRUE)
else()
message(SEND_ERROR "Looking for FLANN - NOT found, please install libflann-dev")
if(FLANN_VERSION)
message(SEND_ERROR "Looking for FLANN - ${FLANN_VERSION} found, ${PROJECT_NAME} requires 1.8.4 or greater.")
else()
message(SEND_ERROR "Looking for FLANN - NOT found, please install libflann-dev")
endif()
set(HAVE_FLANN FALSE)
endif()

# TinyXML
Expand Down Expand Up @@ -269,9 +275,8 @@ if(HAVE_BULLET_COLLISION)
endif()

if(NOT BUILD_CORE_ONLY)
message(STATUS "FLANN_LIBRARIES: ${FLANN_LIBRARIES}")
set(DART_DEPENDENCIES ${FLANN_LIBRARIES}
${urdfdom_LIBRARIES}
set(DART_DEPENDENCIES ${urdfdom_LIBRARIES}
${FLANN_LIBRARIES}
${TinyXML_LIBRARIES}
${TinyXML2_LIBRARIES}
)
Expand Down
27 changes: 21 additions & 6 deletions cmake/FindFLANN.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
# Copyright (c) 2015, Georgia Tech Graphics Lab and Humanoid Robotics Lab
# This file is provided under the "BSD-style" License

# Find FLANN
#
# This sets the following variables:
# FLANN_FOUND
# FLANN_INCLUDE_DIRS
# FLANN_LIBRARIES
# FLANN_VERSION

find_package(PkgConfig QUIET)

pkg_check_modules(PC_FLANN flann)
find_path(FLANN_INCLUDE_DIR
# Check to see if pkgconfig is installed.
pkg_check_modules(PC_FLANN flann QUIET)

# Include directories
find_path(FLANN_INCLUDE_DIRS
NAMES flann/flann.h
HINTS ${PC_FLANN_INCLUDEDIR}
PATHS "${CMAKE_INSTALL_PREFIX}/include")

set(FLANN_INCLUDE_DIRS ${FLANN_INCLUDE_DIR})
# Libraries
find_library(FLANN_LIBRARIES flann_cpp
HINTS ${PC_FLANN_LIBDIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FLANN DEFAULT_MSG FLANN_INCLUDE_DIR)
# Version
set(FLANN_VERSION ${PC_FLANN_VERSION})

mark_as_advanced(FLANN_INCLUDE_DIR)
# Set (NAME)_FOUND if all the variables and the version are satisfied.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FLANN
FAIL_MESSAGE DEFAULT_MSG
REQUIRED_VARS FLANN_INCLUDE_DIRS FLANN_LIBRARIES
VERSION_VAR FLANN_VERSION)
1 change: 1 addition & 0 deletions dart/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#cmakedefine HAVE_IPOPT 1
#cmakedefine HAVE_SNOPT 1
#cmakedefine HAVE_BULLET_COLLISION 1
#cmakedefine HAVE_FLANN 1

#define DART_ROOT_PATH "@CMAKE_SOURCE_DIR@/"
#define DART_DATA_PATH "@CMAKE_SOURCE_DIR@/data/"
Expand Down
3 changes: 1 addition & 2 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Author(s): Can Erdogan <cerdogan3@gatech.edu>,
# Jeongseok Lee <jslee02@gmail.com>
#
# Geoorgia Tech Graphics Lab and Humanoid Robotics Lab
# Georgia Tech Graphics Lab and Humanoid Robotics Lab
#
# Directed by Prof. C. Karen Liu and Prof. Mike Stilman
# <karenliu@cc.gatech.edu> <mstilman@cc.gatech.edu>
Expand Down Expand Up @@ -82,4 +82,3 @@ foreach(test ${tests})
endif(NOT contains)

endforeach(test)

7 changes: 6 additions & 1 deletion unittests/testNearestNeighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@

#include <iostream>
#include <gtest/gtest.h>
#include <flann/flann.hpp>
#include <Eigen/Core>
#include <dart/dart.h>
#if HAVE_FLANN
#include <flann/flann.hpp>
#endif // HAVE_FLANN
#include "TestHelpers.h"

/* ********************************************************************************************* */
#if HAVE_FLANN
TEST(NEAREST_NEIGHBOR, 2D) {

// Build the index with the first node
Expand Down Expand Up @@ -44,6 +48,7 @@ TEST(NEAREST_NEIGHBOR, 2D) {
bool equality = equals(Vector2d(point[0], point[1]), p3, 1e-3);
EXPECT_TRUE(equality);
}
#endif // HAVE_FLANN

/* ********************************************************************************************* */
int main(int argc, char* argv[]) {
Expand Down

0 comments on commit 08e3b58

Please sign in to comment.