From 3d28f7ecca4b1b06d04301f93799aa7e7d0b90aa Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 11:28:54 +0200 Subject: [PATCH 01/11] CMakeLists: use find_package Eigen3 Instead of hardcoding the Eigen3 path which only works on Mac, use find_package(Eigen3). --- EKF/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index 9a97cf63d1..5a77501f9d 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -37,12 +37,12 @@ project (ECL CXX) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CURRENT_SOURCE_DIR ./) set(CMAKE_CXX_FLAGS "-DPOSIX_SHARED") -set(EIGEN3_INCLUDE_DIR "/usr/local/include/eigen3/") -IF( NOT EIGEN3_INCLUDE_DIR ) - MESSAGE( FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.") -ENDIF() -INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" ) +find_package(Eigen3 REQUIRED) + +if( NOT EIGEN3_INCLUDE_DIR ) + message( FATAL_ERROR "Eigen3 not found.") +endif() if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../matrix/.git" ) message( SEND_ERROR "The git submodules are not available. Please run @@ -54,9 +54,9 @@ include_directories( ./ ../ ../matrix - EIGEN3_INCLUDE_DIR + ${EIGEN3_INCLUDE_DIR} ) -set(SRCS +set(SRCS estimator_interface.cpp ekf.cpp ekf_helper.cpp From 54e62f14959c6ef0f4bacd9bb0080bb754381af5 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 11:37:23 +0200 Subject: [PATCH 02/11] travis: just use libeigen3-dev --- .travis.yml | 4 ++-- build.sh | 12 +----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4832bc6e9d..d4d3d338c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,10 @@ before_install: - sudo apt-get update -qq install: -- sudo apt-get install -qq g++-4.8 +- sudo apt-get install -qq g++-4.8 libeigen3-dev - export CXX="g++-4.8" before_script: - chmod +x build.sh -script: ./build.sh \ No newline at end of file +script: ./build.sh diff --git a/build.sh b/build.sh index 4b45e5592d..2e24303f30 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2015 ECL Development Team. All rights reserved. +# Copyright (c) 2015-2016 ECL Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,16 +31,6 @@ # ############################################################################ -#download, build and install eigen -wget -O eigen.tar.bz2 http://bitbucket.org/eigen/eigen/get/3.2.8.tar.bz2 -mkdir eigen -tar -xvjf eigen.tar.bz2 -C eigen --strip-components=1 -mkdir eigen-build -cd eigen-build -cmake ../eigen -make -sudo make install - #build EKF shared library cd .. mkdir Build From fc476849429a9c574d43f87bdb578288f3054b5e Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 12:35:44 +0200 Subject: [PATCH 03/11] build.sh: get path right for travis build --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 2e24303f30..67b95f6b9c 100755 --- a/build.sh +++ b/build.sh @@ -31,9 +31,9 @@ # ############################################################################ -#build EKF shared library -cd .. +# Build EKF shared library. mkdir Build cd Build cmake ../EKF make +cd .. From 37b73c7d85c9d25034f6422b49770d14e86376fb Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 12:43:50 +0200 Subject: [PATCH 04/11] README: updated build instructions, prerequisites --- README.md | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c3538ab7c0..7f09d55deb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ECL -#### Very lightweight Estimation & Control Library. +**Very lightweight Estimation & Control Library.** [![Build Status](https://travis-ci.org/PX4/ecl.svg?branch=master)](https://travis-ci.org/PX4/ecl) @@ -8,11 +8,35 @@ This library solves the estimation & control problems of a number of robots and The library is currently BSD licensed, but might move to Apache 2.0. ## Building EKF Library -Prerequisite: + +### Prerequisites: + * Eigen3: http://eigen.tuxfamily.org/index.php installed +#### Ubuntu: + +``` +sudo apt-get install libeigen3-dev +``` + +#### Mac + +``` +brew install eigen +``` + + By following the steps mentioned below you can create a shared library which can be included in projects using `-l` flag of gcc: - * mkdir Build/ - * cd Build/ - * cmake ../EKF - * make + +``` +mkdir Build/ +cd Build/ +cmake ../EKF +make +``` + +Alternatively, just run: + +``` +./build.sh +``` From 798cdfe675b3370802544dd3bc1f40d6afa5d8c1 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 12:54:07 +0200 Subject: [PATCH 05/11] build.sh: if cmake fails, don't continue with make --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index 67b95f6b9c..5daff21095 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,4 @@ +#!/bin/sh ############################################################################ # # Copyright (c) 2015-2016 ECL Development Team. All rights reserved. @@ -31,6 +32,9 @@ # ############################################################################ +# Exit on any error. +set -e + # Build EKF shared library. mkdir Build cd Build From dcd191d734a9c26f38848409e14ddfee5a326b96 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 13:07:41 +0200 Subject: [PATCH 06/11] cmake: include FindEIgen3.cmake for older cmake --- EKF/FindEigen3.cmake | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 EKF/FindEigen3.cmake diff --git a/EKF/FindEigen3.cmake b/EKF/FindEigen3.cmake new file mode 100644 index 0000000000..cea1afeabc --- /dev/null +++ b/EKF/FindEigen3.cmake @@ -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, +# Copyright (c) 2008, 2009 Gael Guennebaud, +# Copyright (c) 2009 Benoit Jacob +# 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) + From d242bb78b939595574987619d566bc5daf4fd596 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 13:12:00 +0200 Subject: [PATCH 07/11] cmake: try to provide path to FindEigen3 --- EKF/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index 5a77501f9d..5f947ecf0d 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -38,6 +38,7 @@ set(CMAKE_BUILD_TYPE Release) set(CMAKE_CURRENT_SOURCE_DIR ./) set(CMAKE_CXX_FLAGS "-DPOSIX_SHARED") +set(CMAKE_MODULE_PATH ./) find_package(Eigen3 REQUIRED) if( NOT EIGEN3_INCLUDE_DIR ) From 001433c660fe5d30f9b7d9e6dead46f77e038c7b Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 13:25:36 +0200 Subject: [PATCH 08/11] cmake: debug output for path --- EKF/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index 5f947ecf0d..19a860326e 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -39,6 +39,7 @@ set(CMAKE_CURRENT_SOURCE_DIR ./) set(CMAKE_CXX_FLAGS "-DPOSIX_SHARED") set(CMAKE_MODULE_PATH ./) +message("looking for FindEigen3.cmake in ${CMAKE_MODULE_PATH}") find_package(Eigen3 REQUIRED) if( NOT EIGEN3_INCLUDE_DIR ) From 07ecffc9630ca1bafbc0b0dbeba1f08e94feed72 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 27 Apr 2016 13:48:24 +0200 Subject: [PATCH 09/11] cmake: another try to get the module path right --- EKF/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index 19a860326e..8620ba133c 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -35,10 +35,9 @@ cmake_minimum_required(VERSION 2.8) project (ECL CXX) set(CMAKE_BUILD_TYPE Release) -set(CMAKE_CURRENT_SOURCE_DIR ./) set(CMAKE_CXX_FLAGS "-DPOSIX_SHARED") -set(CMAKE_MODULE_PATH ./) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) message("looking for FindEigen3.cmake in ${CMAKE_MODULE_PATH}") find_package(Eigen3 REQUIRED) From b74114a573f542f8cccd1c11fbfd7da48c7bc4ed Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 12 May 2016 08:27:59 +0200 Subject: [PATCH 10/11] cmake: ignore deprecated warnings of Eigen --- EKF/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index 8620ba133c..72dc91ad2e 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -71,4 +71,8 @@ set(SRCS mathlib.cpp ) add_definitions(-std=c++11 -Wall -Werror) + +# Eigen throws deprecated warnings +add_definitions(-Wno-deprecated-declarations) + add_library(ecl SHARED ${SRCS}) From b8ccc58887261fff617d7e90ce5790c8c779409b Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 12 May 2016 08:38:37 +0200 Subject: [PATCH 11/11] cmake: ignore more eigen warnings --- EKF/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index 72dc91ad2e..e4010f3e1c 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -72,7 +72,7 @@ set(SRCS ) add_definitions(-std=c++11 -Wall -Werror) -# Eigen throws deprecated warnings -add_definitions(-Wno-deprecated-declarations) +# Eigen throws various warnings +add_definitions(-Wno-deprecated-declarations -Wno-enum-compare -Wno-unused-local-typedefs) add_library(ecl SHARED ${SRCS})