Skip to content

Commit

Permalink
Use Eigen for math operations (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Aug 5, 2016
1 parent 0ae7bc9 commit 0168edf
Show file tree
Hide file tree
Showing 125 changed files with 7,574 additions and 9,652 deletions.
12 changes: 11 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,20 @@ before_build:
cmake --build . --target install --config %Configuration% &&
cd ..
) else (echo Using cached libccd)
- cmd: if not exist C:\"Program Files"\Eigen\include\eigen3\Eigen\Core (
curl -L -o eigen-eigen-dc6cfdf9bcec.tar.gz https://bitbucket.org/eigen/eigen/get/3.2.9.tar.gz &&
cmake -E tar zxf eigen-eigen-dc6cfdf9bcec.tar.gz &&
cd eigen-eigen-dc6cfdf9bcec &&
mkdir build &&
cd build &&
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%Configuration% .. &&
cmake --build . --target install --config %Configuration% &&
cd ..\..
) else (echo Using cached Eigen3)
- cmd: set
- cmd: mkdir build
- cmd: cd build
- cmd: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\Program Files\libccd\include" -DCCD_LIBRARY="C:\Program Files\libccd\lib\ccd.lib" ..
- cmd: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\Program Files\libccd\include" -DCCD_LIBRARY="C:\Program Files\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\Program Files\Eigen\include\eigen3" ..

build:
project: C:\projects\fcl\build\fcl.sln
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### FCL 0.6.0 (2016-XX-XX)

* Switched to Eigen for math operations: [#150](https://github.com/flexible-collision-library/fcl/pull/150), [#96](https://github.com/flexible-collision-library/fcl/issues/96)
* Added missing copyright headers: [#149](https://github.com/flexible-collision-library/fcl/pull/149)
* Removed dependency on boost: [#148](https://github.com/flexible-collision-library/fcl/pull/148), [#147](https://github.com/flexible-collision-library/fcl/pull/147), [#146](https://github.com/flexible-collision-library/fcl/pull/146), [#140](https://github.com/flexible-collision-library/fcl/pull/140)

Expand Down
61 changes: 37 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ endif()

project(fcl CXX C)

option(FCL_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)

# set the default build type
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
Expand Down Expand Up @@ -64,9 +66,43 @@ if(FCL_COVERALLS)
coveralls_turn_on_coverage()
endif()

# Find Octomap (optional)
find_package(PkgConfig QUIET)

# Find Eigen3
find_package(Eigen3 3.0.5 QUIET)
if(EIGEN3_FOUND)
set(FCL_HAVE_EIGEN TRUE)
include_directories(${EIGEN3_INCLUDE_DIR})
else()
message(SEND_ERROR "EIGEN3 (>= 3.0.5) is required by FCL")
set(FCL_HAVE_EIGEN FALSE)
endif()

# Find libccd
if(PKG_CONFIG_FOUND)
pkg_check_modules(CCD ccd)
# check to see if the pkg is installed under the libccd name
if(NOT CCD_FOUND)
pkg_check_modules(CCD libccd)
endif()
endif()

if(NOT CCD_FOUND)
# if pkgconfig is not installed, then fall back on more fragile detection
# of ccd
find_path(CCD_INCLUDE_DIRS ccd/ccd.h)
find_library(CCD_LIBRARY
${CMAKE_SHARED_LIBRARY_PREFIX}ccd${CMAKE_SHARED_LIBRARY_SUFFIX})
if(CCD_INCLUDE_DIRS AND CCD_LIBRARY)
set(CCD_LIBRARIES "${CCD_LIBRARY}")
else()
message(FATAL_ERROR "Libccd is required by FCL")
endif()
endif()
include_directories(${CCD_INCLUDE_DIRS})
link_directories(${CCD_LIBRARY_DIRS})

# Find Octomap (optional)
option(FCL_WITH_OCTOMAP "octomap library support" ON)
set(FCL_HAVE_OCTOMAP 0)
if(FCL_WITH_OCTOMAP)
Expand Down Expand Up @@ -116,29 +152,6 @@ endif()
include_directories(BEFORE "include")
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/include")

if(PKG_CONFIG_FOUND)
pkg_check_modules(CCD ccd)
# check to see if the pkg is installed under the libccd name
if(NOT CCD_FOUND)
pkg_check_modules(CCD libccd)
endif()
endif()

if(NOT CCD_FOUND)
# if pkgconfig is not installed, then fall back on more fragile detection
# of ccd
find_path(CCD_INCLUDE_DIRS ccd/ccd.h)
find_library(CCD_LIBRARY
${CMAKE_SHARED_LIBRARY_PREFIX}ccd${CMAKE_SHARED_LIBRARY_SUFFIX})
if(CCD_INCLUDE_DIRS AND CCD_LIBRARY)
set(CCD_LIBRARIES "${CCD_LIBRARY}")
else()
message(FATAL_ERROR "Libccd is required by FCL")
endif()
endif()
include_directories(${CCD_INCLUDE_DIRS})
link_directories(${CCD_LIBRARY_DIRS})

add_subdirectory(include/fcl)
add_subdirectory(src)

Expand Down
25 changes: 22 additions & 3 deletions CMakeModules/CompilerSettings.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# force C++11 mode
add_definitions()

# GCC
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-std=c++11 -W -Wall -g -Wextra -Wno-missing-field-initializers -Wno-unused-parameter)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif(FCL_TREAT_WARNINGS_AS_ERRORS)
endif(CMAKE_COMPILER_IS_GNUCXX)

# Clang
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_definitions(-std=c++11 -W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-unknown-pragmas -Wno-deprecated-register)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif(FCL_TREAT_WARNINGS_AS_ERRORS)
endif()

# Visual Studio
if(MSVC OR MSVC90 OR MSVC10)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /W1")
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(/WX)
endif(FCL_TREAT_WARNINGS_AS_ERRORS)
endif(MSVC OR MSVC90 OR MSVC10)

# Intel
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(IS_ICPC 1)
else()
Expand All @@ -26,8 +37,12 @@ if(IS_ICPC)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING
"Flags used by the C++ compiler during debug builds." FORCE)
set(CMAKE_LINKER "xild" CACHE STRING "Intel linker" FORCE)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif(FCL_TREAT_WARNINGS_AS_ERRORS)
endif(IS_ICPC)

# XL
if(CMAKE_CXX_COMPILER_ID STREQUAL "XL")
set(IS_XLC 1)
else()
Expand All @@ -39,8 +54,12 @@ if(IS_XLC)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -q64")
endif(IS_XLC)

# MinGW
if((CMAKE_COMPILER_IS_GNUCXX OR IS_ICPC) AND NOT MINGW)
add_definitions(-fPIC)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif(FCL_TREAT_WARNINGS_AS_ERRORS)
endif((CMAKE_COMPILER_IS_GNUCXX OR IS_ICPC) AND NOT MINGW)

# Set rpath http://www.paraview.org/Wiki/CMake_RPATH_handling
Expand Down
90 changes: 90 additions & 0 deletions CMakeModules/FindEigen3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
#
# This module reads hints about search locations from
# the following enviroment variables:
#
# EIGEN3_ROOT
# EIGEN3_ROOT_DIR

# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.

if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)

set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)

macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)

string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")

set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})

if(NOT EIGEN3_VERSION_OK)

message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)

if (EIGEN3_INCLUDE_DIR)

# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})

else (EIGEN3_INCLUDE_DIR)

find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
HINTS
ENV EIGEN3_ROOT
ENV EIGEN3_ROOT_DIR
PATHS
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)

if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN3_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)

mark_as_advanced(EIGEN3_INCLUDE_DIR)

endif(EIGEN3_INCLUDE_DIR)

3 changes: 2 additions & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
Dependencies:
============

- Eigen (available at http://eigen.tuxfamily.org/)
- libccd (available at http://libccd.danfis.cz/)
- octomap (optional dependency, available at http://octomap.github.com)

libccd is the only mandatory dependency. If octomap is not found,
Eigen and libccd are mandatory dependencies. If octomap is not found,
collision detection with octrees will not be possible.

For installation, CMake will also be needed (http://cmake.org).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FCL has the following features

## Installation

Before compiling FCL, please make libccd (for collision checking between convex objects and is available here https://github.com/danfis/libccd) is installed. For libccd, make sure to compile from github version instead of the zip file from the webpage, because one bug fixing is not included in the zipped version.
Before compiling FCL, please make sure Eigen and libccd (for collision checking between convex objects and is available here https://github.com/danfis/libccd) are installed. For libccd, make sure to compile from github version instead of the zip file from the webpage, because one bug fixing is not included in the zipped version.

Some optional libraries need to be installed for some optional capability of FCL. For octree collision, please install the octomap library from http://octomap.github.com.

Expand Down
1 change: 1 addition & 0 deletions ci/install_linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo add-apt-repository --yes ppa:libccd-debs/ppa
sudo apt-get -qq update

sudo apt-get -qq --yes --force-yes install libeigen3-dev
sudo apt-get -qq --yes --force-yes install libccd-dev

# Octomap
Expand Down
3 changes: 3 additions & 0 deletions ci/install_osx.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
brew tap homebrew/science

brew update > /dev/null

brew install git
brew install cmake
brew install eigen
brew install libccd
Loading

0 comments on commit 0168edf

Please sign in to comment.