diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ad4da8c44be753f7d52b50c75f60d695fcc3fbd..0bff808030dd5e25a2e691c09f843c51f4cda714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,3 @@ - # Pre-requisites about cmake itself CMAKE_MINIMUM_REQUIRED(VERSION 2.6) @@ -10,12 +9,27 @@ endif(COMMAND cmake_policy) SET(CMAKE_MACOSX_RPATH 1) -# The project name and the type of project +# The project name PROJECT(wolf) -SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) -SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib) -SET(CMAKE_INSTALL_PREFIX /usr/local) + +string(COMPARE EQUAL "${CMAKE_BINARY_DIR}" "" result) +IF(result) + SET(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +ENDIF() +message(STATUS "Binary path : " ${CMAKE_BINARY_DIR}) + +SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) +SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) + +# We'll set the install prefix only is it's empty +# which shouldn't be the case ... +string(COMPARE EQUAL "${CMAKE_INSTALL_PREFIX}" "" result) +IF(result) + # This path is actually default on linux + SET(CMAKE_INSTALL_PREFIX /usr/local) +ENDIF() +message(STATUS "Installation path : " ${CMAKE_INSTALL_PREFIX}) IF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "DEBUG") @@ -26,6 +40,12 @@ message(STATUS "Configured to compile in ${CMAKE_BUILD_TYPE} mode.") SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -D_REENTRANT") SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT") +if(UNIX) + # GCC is not strict enough by default, so enable most of the warnings. + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Werror=all -Werror=extra -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers") +endif(UNIX) + #Set compiler according C++11 support include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) diff --git a/README.md b/README.md index 24239b5deda7e66adf8bb7d13c5f7cb41aaa6da3..1fa8d26adf51ad88f8150d4b9f4cef35d9571d18 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ Wolf can be used within ROS for an easy integration. We provide examples of ROS Dependencies ------------ +! Please notice that we are detailing two installation procedures below. If you are familiar with `ROS` and more especially the [`catkin_tools`](https://catkin-tools.readthedocs.io/en/latest/index.html) package then you may jump directly to the 'Using the `catkin_tools` package' section. + ### Eigen [Eigen](http://eigen.tuxfamily.org). Linear algebra, header library. Eigen 3.2 is also a depencency of ROS-Hydro. In case you don't have ROS in your machine, you can install Eigen by typing: @@ -101,7 +103,7 @@ libglog.so will be installed at **/usr/local/lib** $ cmake -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fPIC" .. $ make $ sudo make install - + libceres.a will be installed at **/usr/local/lib** and headers at **/usr/local/include/ceres** ### Yaml-cpp. Wolf uses YAML files for configuration and for saving and loading workspaces. @@ -109,17 +111,17 @@ libceres.a will be installed at **/usr/local/lib** and headers at **/usr/local/i **(1)** Obtain: - Ubuntu: - + ``` $ sudo apt-get install libyaml-cpp-dev ``` - Mac: - + ``` $ brew install yaml-cpp ``` We are shipping the CMAKE file `FindYamlCpp.cmake` together with Wolf. Find it at `[wolf]/cmake_modules/FindYamlCpp.cmake` - + ### Laser Scan Utils (Optional. Install only if you want to use IRI's laser scan utils) **(1)** Download: @@ -136,7 +138,7 @@ Or, in case you don't have permissions: $ cmake .. $ make $ sudo make install - + ### Raw GPS Utils (Optional. Install only if you want to use IRI's raw gps utils) **(1)** Download: @@ -149,7 +151,7 @@ Or, in case you don't have permissions: $ cmake .. $ make $ sudo make install - + Download and build ------------------ @@ -169,7 +171,7 @@ Download and build **Set the WOLF_ROOT environment variable** -We need a platform-independent way to specify where is the WOLF project, so that code can locate relevant files at run-time. +We need a platform-independent way to specify where is the WOLF project, so that code can locate relevant files at run-time. For example, if we want to use YAML files for configuring sensors, `YAML::LoadFile(filename)` needs an absolute path to a `filename`. This name is platform-specific, and many times user-specific. Usually, these files are out of the WOLF project. But for testing purposes, some of these files exist within the WOLF directories. @@ -181,12 +183,12 @@ Proceed as follows: ``` export WOLF_ROOT="/abs/path/to/wolf" ``` - * Then you need to source the file to get effect, + * Then you need to source the file to get effect, ``` source ~/.bash_profile // or ~/.bashrc, of course ``` 2. If you are using Eclipse or other __GUIs__ and you want this environment variable to be accessed by them, edit the file `/etc/environment` (you need to use `sudo`) and add this line: - + ``` WOLF_ROOT="/abs/path/to/wolf" ``` @@ -211,6 +213,79 @@ Alternatively, you can set up the environment variables in your GUIs only. Follo `$ git clone `[`https://github.com/IRI-MobileRobotics/Wolf_ros.git`](https://github.com/IRI-MobileRobotics/Wolf_ros.git) + + +Using the `catkin_tools` package +-------------------------------- + +1. Install `catkin_tools` : + + [`installation webpage.`](https://catkin-tools.readthedocs.io/en/latest/installing.html) + + . Installing on Ubuntu with `apt-get` + + ```terminal + $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list' + $ wget http://packages.ros.org/ros.key -O - | sudo apt-key add - + $ sudo apt-get update + $ sudo apt-get install python-catkin-tools + ``` + + . Installing with [`pip`](https://pip.pypa.io/en/stable/installing/) + + ```terminal + $ sudo pip install -U catkin_tools + ``` + +2. Create a `catkin workspace` : + + ```terminal + $ cd ~/my_workspace_directory/ + $ create mkdir -p wolf_ws/src + $ cd wolf_ws/src + ``` + +3. Download `Ceres` : + + In the previously created directory `~/my_workspace_directory/wolf_ws/src/` clone `Ceres` & `wolf`. + + ```terminal + $ git clone https://github.com/artivis/ceres_solver.git + ``` + +4. Download `wolf` : + + ```terminal + $ git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf.git + ``` + + At this point you might need to switch to the `catkin_build` branch of the wolf project. + + ```terminal + $ cd wolf + $ git checkout catkin_build + ``` + + (optional) Download `wolf_ros` : + + ```terminal + $ git clone https://github.com/IRI-MobileRobotics/Wolf_ros.git + ``` + +5. Let's Compile ! + + The command below can be launch from any sub-directory in `~/my_workspace_directory/wolf_ws/`. + + ```terminal + $ catkin build + ``` + +6. Run tests: + + ```terminal + $ catkin run_tests + ``` + Inspiring Links --------------- diff --git a/cmake_modules/FindEigen.cmake b/cmake_modules/FindEigen.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5d8ecdac63aa87c1b43e37f64d10702884e876b6 --- /dev/null +++ b/cmake_modules/FindEigen.cmake @@ -0,0 +1,167 @@ +# Ceres Solver - A fast non-linear least squares minimizer +# Copyright 2015 Google Inc. All rights reserved. +# http://ceres-solver.org/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of Google Inc. nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# Author: alexs.mac@gmail.com (Alex Stewart) +# + +# FindEigen.cmake - Find Eigen library, version >= 3. +# +# This module defines the following variables: +# +# EIGEN_FOUND: TRUE iff Eigen is found. +# EIGEN_INCLUDE_DIRS: Include directories for Eigen. +# +# EIGEN_VERSION: Extracted from Eigen/src/Core/util/Macros.h +# EIGEN_WORLD_VERSION: Equal to 3 if EIGEN_VERSION = 3.2.0 +# EIGEN_MAJOR_VERSION: Equal to 2 if EIGEN_VERSION = 3.2.0 +# EIGEN_MINOR_VERSION: Equal to 0 if EIGEN_VERSION = 3.2.0 +# +# The following variables control the behaviour of this module: +# +# EIGEN_INCLUDE_DIR_HINTS: List of additional directories in which to +# search for eigen includes, e.g: /timbuktu/eigen3. +# +# The following variables are also defined by this module, but in line with +# CMake recommended FindPackage() module style should NOT be referenced directly +# by callers (use the plural variables detailed above instead). These variables +# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which +# are NOT re-called (i.e. search for library is not repeated) if these variables +# are set with valid values _in the CMake cache_. This means that if these +# variables are set directly in the cache, either by the user in the CMake GUI, +# or by the user passing -DVAR=VALUE directives to CMake when called (which +# explicitly defines a cache variable), then they will be used verbatim, +# bypassing the HINTS variables and other hard-coded search locations. +# +# EIGEN_INCLUDE_DIR: Include directory for CXSparse, not including the +# include directory of any dependencies. + +# Called if we failed to find Eigen or any of it's required dependencies, +# unsets all public (designed to be used externally) variables and reports +# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. +macro(EIGEN_REPORT_NOT_FOUND REASON_MSG) + unset(EIGEN_FOUND) + unset(EIGEN_INCLUDE_DIRS) + # Make results of search visible in the CMake GUI if Eigen has not + # been found so that user does not have to toggle to advanced view. + mark_as_advanced(CLEAR EIGEN_INCLUDE_DIR) + # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() + # use the camelcase library name, not uppercase. + if (Eigen_FIND_QUIETLY) + message(STATUS "Failed to find Eigen - " ${REASON_MSG} ${ARGN}) + elseif (Eigen_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN}) + else() + # Neither QUIETLY nor REQUIRED, use no priority which emits a message + # but continues configuration and allows generation. + message("-- Failed to find Eigen - " ${REASON_MSG} ${ARGN}) + endif () + return() +endmacro(EIGEN_REPORT_NOT_FOUND) + +# Search user-installed locations first, so that we prefer user installs +# to system installs where both exist. +# +# TODO: Add standard Windows search locations for Eigen. +list(APPEND EIGEN_CHECK_INCLUDE_DIRS + /usr/local/include + /usr/local/homebrew/include # Mac OS X + /opt/local/var/macports/software # Mac OS X. + /opt/local/include + /usr/include) +# Additional suffixes to try appending to each search path. +list(APPEND EIGEN_CHECK_PATH_SUFFIXES + eigen3 # Default root directory for Eigen. + Eigen/include/eigen3 ) # Windows (for C:/Program Files prefix). + +# Search supplied hint directories first if supplied. +find_path(EIGEN_INCLUDE_DIR + NAMES Eigen/Core + PATHS ${EIGEN_INCLUDE_DIR_HINTS} + ${EIGEN_CHECK_INCLUDE_DIRS} + PATH_SUFFIXES ${EIGEN_CHECK_PATH_SUFFIXES}) + +if (NOT EIGEN_INCLUDE_DIR OR + NOT EXISTS ${EIGEN_INCLUDE_DIR}) + eigen_report_not_found( + "Could not find eigen3 include directory, set EIGEN_INCLUDE_DIR to " + "path to eigen3 include directory, e.g. /usr/local/include/eigen3.") +endif (NOT EIGEN_INCLUDE_DIR OR + NOT EXISTS ${EIGEN_INCLUDE_DIR}) + +# Mark internally as found, then verify. EIGEN_REPORT_NOT_FOUND() unsets +# if called. +set(EIGEN_FOUND TRUE) + +# Extract Eigen version from Eigen/src/Core/util/Macros.h +if (EIGEN_INCLUDE_DIR) + set(EIGEN_VERSION_FILE ${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h) + if (NOT EXISTS ${EIGEN_VERSION_FILE}) + eigen_report_not_found( + "Could not find file: ${EIGEN_VERSION_FILE} " + "containing version information in Eigen install located at: " + "${EIGEN_INCLUDE_DIR}.") + else (NOT EXISTS ${EIGEN_VERSION_FILE}) + file(READ ${EIGEN_VERSION_FILE} EIGEN_VERSION_FILE_CONTENTS) + + string(REGEX MATCH "#define EIGEN_WORLD_VERSION [0-9]+" + EIGEN_WORLD_VERSION "${EIGEN_VERSION_FILE_CONTENTS}") + string(REGEX REPLACE "#define EIGEN_WORLD_VERSION ([0-9]+)" "\\1" + EIGEN_WORLD_VERSION "${EIGEN_WORLD_VERSION}") + + string(REGEX MATCH "#define EIGEN_MAJOR_VERSION [0-9]+" + EIGEN_MAJOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}") + string(REGEX REPLACE "#define EIGEN_MAJOR_VERSION ([0-9]+)" "\\1" + EIGEN_MAJOR_VERSION "${EIGEN_MAJOR_VERSION}") + + string(REGEX MATCH "#define EIGEN_MINOR_VERSION [0-9]+" + EIGEN_MINOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}") + string(REGEX REPLACE "#define EIGEN_MINOR_VERSION ([0-9]+)" "\\1" + EIGEN_MINOR_VERSION "${EIGEN_MINOR_VERSION}") + + # This is on a single line s/t CMake does not interpret it as a list of + # elements and insert ';' separators which would result in 3.;2.;0 nonsense. + set(EIGEN_VERSION "${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}") + endif (NOT EXISTS ${EIGEN_VERSION_FILE}) +endif (EIGEN_INCLUDE_DIR) + +# Set standard CMake FindPackage variables if found. +if (EIGEN_FOUND) + set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR}) +endif (EIGEN_FOUND) + +# Handle REQUIRED / QUIET optional arguments and version. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Eigen + REQUIRED_VARS EIGEN_INCLUDE_DIRS + VERSION_VAR EIGEN_VERSION) + +# Only mark internal variables as advanced if we found Eigen, otherwise +# leave it visible in the standard GUI for the user to set manually. +if (EIGEN_FOUND) + mark_as_advanced(FORCE EIGEN_INCLUDE_DIR) +endif (EIGEN_FOUND) diff --git a/Findwolf.cmake b/cmake_modules/Findwolf.cmake similarity index 100% rename from Findwolf.cmake rename to cmake_modules/Findwolf.cmake diff --git a/cmake_modules/wolfConfig.cmake b/cmake_modules/wolfConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..877b55b41d3b648c87d563945c8fad81668ba1d1 --- /dev/null +++ b/cmake_modules/wolfConfig.cmake @@ -0,0 +1,214 @@ +# This file was copied and adapted from the ceres_solver project +# http://ceres-solver.org/ + +# wolf - Windowed Localization Frames +# Copyright 2016 +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of Google Inc. nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# Authors: +# + +# Config file for wolf - Find wolf & dependencies. +# +# This file is used by CMake when find_package(wolf) is invoked and either +# the directory containing this file either is present in CMAKE_MODULE_PATH +# (if wolf was installed), or exists in the local CMake package registry if +# the wolf build directory was exported. +# +# This module defines the following variables: +# +# wolf_FOUND / wolf_FOUND: True if wolf has been successfully +# found. Both variables are set as although +# FindPackage() only references wolf_FOUND +# in Config mode, given the conventions for +# <package>_FOUND when FindPackage() is +# called in Module mode, users could +# reasonably expect to use wolf_FOUND +# instead. +# +# wolf_VERSION: Version of wolf found. +# +# wolf_INCLUDE_DIRS: Include directories for wolf and the +# dependencies which appear in the wolf public +# API and are thus required to use wolf. +# +# wolf_LIBRARIES: Libraries for wolf and all +# dependencies against which wolf was +# compiled. This will not include any optional +# dependencies that were disabled when wolf was +# compiled. +# +# The following variables are also defined for legacy compatibility +# only. Any new code should not use them as they do not conform to +# the standard CMake FindPackage naming conventions. +# +# wolf_INCLUDES = ${wolf_INCLUDE_DIRS}. + +# Called if we failed to find Ceres or any of its required dependencies, +# unsets all public (designed to be used externally) variables and reports +# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. +macro(wolf_report_not_found REASON_MSG) + # FindPackage() only references Ceres_FOUND, and requires it to be + # explicitly set FALSE to denote not found (not merely undefined). + set(wolf_FOUND FALSE) + set(wolf_FOUND FALSE) + unset(wolf_INCLUDE_DIRS) + unset(wolf_LIBRARIES) + + # Reset the CMake module path to its state when this script was called. + set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) + + # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by + # FindPackage() use the camelcase library name, not uppercase. + if (wolf_FIND_QUIETLY) + message(STATUS "Failed to find wolf - " ${REASON_MSG} ${ARGN}) + else (wolf_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find wolf - " ${REASON_MSG} ${ARGN}) + else() + # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error + # that prevents generation, but continues configuration. + message(SEND_ERROR "Failed to find wolf - " ${REASON_MSG} ${ARGN}) + endif () + return() +endmacro(wolf_report_not_found) + +# Record the state of the CMake module path when this script was +# called so that we can ensure that we leave it in the same state on +# exit as it was on entry, but modify it locally. +set(CALLERS_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) + +# Get the (current, i.e. installed) directory containing this file. +get_filename_component(wolf_CURRENT_CONFIG_DIR + "${CMAKE_CURRENT_LIST_FILE}" PATH) + +# Reset CMake module path to the installation directory of this +# script, thus we will use the FindPackage() scripts shipped with +# wolf to find wolf' dependencies, even if the user has equivalently +# named FindPackage() scripts in their project. +set(CMAKE_MODULE_PATH ${wolf_CURRENT_CONFIG_DIR}) + +# Build the absolute root install directory as a relative path +# (determined when wolf was configured & built) from the current +# install directory for this this file. This allows for the install +# tree to be relocated, after wolf was built, outside of CMake. +get_filename_component(CURRENT_ROOT_INSTALL_DIR + ${wolf_CURRENT_CONFIG_DIR}/../../../ + ABSOLUTE) +if (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR}) + wolf_report_not_found( + "wolf install root: ${CURRENT_ROOT_INSTALL_DIR}, " + "determined from relative path from wolfConfig.cmake install location: " + "${wolf_CURRENT_CONFIG_DIR}, does not exist. Either the install " + "directory was deleted, or the install tree was only partially relocated " + "outside of CMake after wolf was built.") +endif (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR}) + +# Set the include directories for wolf (itself). +set(wolf_INCLUDE_DIR "${CURRENT_ROOT_INSTALL_DIR}/include/iri-algorithms") + +if (NOT EXISTS ${wolf_INCLUDE_DIR}/wolf/wolf.h) + wolf_report_not_found( + "wolf install root: ${CURRENT_ROOT_INSTALL_DIR}, " + "determined from relative path from wolfConfig.cmake install location: " + "${wolf_CURRENT_CONFIG_DIR}, does not contain wolf headers. " + "Either the install directory was deleted, or the install tree was only " + "partially relocated outside of CMake after wolf was built.") +endif (NOT EXISTS ${wolf_INCLUDE_DIR}/wolf/wolf.h) +list(APPEND wolf_INCLUDE_DIRS ${wolf_INCLUDE_DIR}) + +# Set the version. +set(wolf_VERSION 0.0.1) + +# Eigen. +# Flag set during configuration and build of wolf. +set(wolf_EIGEN_VERSION @EIGEN_VERSION@) +# Append the locations of Eigen when wolf was built to the search path hints. +list(APPEND EIGEN_INCLUDE_DIR_HINTS /usr/include/eigen3) +# Search quietly to control the timing of the error message if not found. The +# search should be for an exact match, but for usability reasons do a soft +# match and reject with an explanation below. +find_package(Eigen ${wolf_EIGEN_VERSION} QUIET) +if (EIGEN_FOUND) + if (NOT EIGEN_VERSION VERSION_EQUAL wolf_EIGEN_VERSION) + # CMake's VERSION check in FIND_PACKAGE() will accept any version >= the + # specified version. However, only version = is supported. Improve + # usability by explaining why we don't accept non-exact version matching. + wolf_report_not_found("Found Eigen dependency, but the version of Eigen " + "found (${EIGEN_VERSION}) does not exactly match the version of Eigen " + "wolf was compiled with (${wolf_EIGEN_VERSION}). This can cause subtle " + "bugs by triggering violations of the One Definition Rule. See the " + "Wikipedia article http://en.wikipedia.org/wiki/One_Definition_Rule " + "for more details") + endif () + message(STATUS "Found required wolf dependency: " + "Eigen version ${wolf_EIGEN_VERSION} in ${EIGEN_INCLUDE_DIRS}") +else (EIGEN_FOUND) + wolf_report_not_found("Missing required wolf " + "dependency: Eigen version ${wolf_EIGEN_VERSION}, please set " + "EIGEN_INCLUDE_DIR.") +endif (EIGEN_FOUND) +list(APPEND wolf_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}) + +# Import exported wolf targets, if they have not already been imported. +if (NOT TARGET wolf AND NOT wolf_BINARY_DIR) + include(${wolf_CURRENT_CONFIG_DIR}/wolfTargets.cmake) +endif (NOT TARGET wolf AND NOT wolf_BINARY_DIR) +# Set the expected XX_LIBRARIES variable for FindPackage(). +set(wolf_LIBRARIES wolf) + +# Set legacy library variable for backwards compatibility. +set(wolf_LIBRARY ${wolf_LIBRARIES}) + +# Make user aware of any compile flags that will be added to their targets +# which use wolf (i.e. flags exported in the wolf target). Only CMake +# versions >= 2.8.12 support target_compile_options(). +if (TARGET ${wolf_LIBRARIES} AND + NOT CMAKE_VERSION VERSION_LESS "2.8.12") + get_target_property(wolf_INTERFACE_COMPILE_OPTIONS + ${wolf_LIBRARIES} INTERFACE_COMPILE_OPTIONS) + + set(wolf_LOCATION "${CURRENT_ROOT_INSTALL_DIR}") + + # Check for -std=c++11 flags. + if (wolf_INTERFACE_COMPILE_OPTIONS MATCHES ".*std=c\\+\\+11.*") + message(STATUS "wolf version ${wolf_VERSION} detected here: " + "${wolf_LOCATION} was built with C++11. wolf target will add " + "C++11 flags to compile options for targets using it.") + endif() +endif() + +# Reset CMake module path to its state when this script was called. +set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) + +# As we use wolf_REPORT_NOT_FOUND() to abort, if we reach this point we have +# found wolf and all required dependencies. +message(STATUS "Found wolf version: ${wolf_VERSION} installed in: ${CURRENT_ROOT_INSTALL_DIR}") + +# Set wolf_FOUND to be equivalent to wolf_FOUND, which is set to +# TRUE by FindPackage() if this file is found and run, and after which +# wolf_FOUND is not (explicitly, i.e. undefined does not count) set +# to FALSE. +set(wolf_FOUND TRUE) diff --git a/package.xml b/package.xml new file mode 100644 index 0000000000000000000000000000000000000000..e94a5f327b94328c07c868e760a402a5f3cf14cc --- /dev/null +++ b/package.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<package format="2"> + <name>wolf</name> + <version>0.0.1</version> + <description>Windowed Localization Frames</description> + + <maintainer email="jsola@iri.upc.edu">Joan Sola</maintainer> + <maintainer email="jvallve@iri.upc.edu">Joan Vallvé Navarro</maintainer> + <maintainer email="todo@todo.com">todo</maintainer> + + <author>Joan Sola</author> + <author>Joan Vallvé Navarro</author> + <author>todo</author> + + <license>todo</license> + + <buildtool_depend>cmake</buildtool_depend> + + <build_depend>eigen</build_depend> + + <!-- wolf does not REQUIRE the following, they are added here for the dependency tree --> + <build_depend>Ceres</build_depend> + <build_depend>laser_scan_utils</build_depend> + <build_depend>raw_gps_utils</build_depend> + <build_depend>OpenCV</build_depend> + <build_depend>YAMLCPP</build_depend> + + <export> + <build_type>cmake</build_type> + </export> + +</package> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 566a38f541e16b3860f7eff87200805a4b285e40..0161f2a1ea40c426e0c809f948321b38a93c4139 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,11 +4,14 @@ MESSAGE("Starting WOLF CMakeLists ...") CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #CMAKE modules -SET(CMAKE_MODULE_PATH ${CMAKE_ROOT}/Modules/; ../cmake_modules) -MESSAGE(STATUS ${CMAKE_MODULE_PATH}) +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules") +MESSAGE(STATUS ${CMAKE_MODULE_PATH}) #find dependencies. + +FIND_PACKAGE(Eigen 3 REQUIRED) + FIND_PACKAGE(Ceres QUIET) #Ceres is not required IF(Ceres_FOUND) MESSAGE("Ceres Library FOUND: Ceres related sources will be built.") @@ -373,11 +376,13 @@ ENDIF (YAMLCPP_FOUND) #install library #============================================================= -INSTALL(TARGETS ${PROJECT_NAME} +INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib/iri-algorithms ARCHIVE DESTINATION lib/iri-algorithms) +install(EXPORT ${PROJECT_NAME}Targets DESTINATION lib/cmake/${PROJECT_NAME}) + #install headers INSTALL(FILES ${HDRS_BASE} DESTINATION include/iri-algorithms/wolf) @@ -390,7 +395,16 @@ INSTALL(FILES ${HDRS_WRAPPER} INSTALL(FILES ${HDRS_SOLVER} DESTINATION include/iri-algorithms/wolf/solver) -INSTALL(FILES ../Findwolf.cmake DESTINATION ${CMAKE_ROOT}/Modules/) +INSTALL(FILES "${CMAKE_SOURCE_DIR}/cmake_modules/Findwolf.cmake" + DESTINATION "lib/cmake/${PROJECT_NAME}") + +#install Find*.cmake +configure_file("${CMAKE_SOURCE_DIR}/cmake_modules/wolfConfig.cmake" + "${CMAKE_BINARY_DIR}/wolfConfig.cmake" @ONLY) + +INSTALL(FILES "${CMAKE_BINARY_DIR}/wolfConfig.cmake" DESTINATION "lib/cmake/${PROJECT_NAME}") + +export(PACKAGE ${PROJECT_NAME}) #Build examples & tests MESSAGE("Building examples and tests.") diff --git a/src/constraint_container.h b/src/constraint_container.h index 9da4469e7f1e4fbf38ac4a1b00b4f5e6f316c355..d414e58dbb901873f1d2a898d32171e285dd2879 100644 --- a/src/constraint_container.h +++ b/src/constraint_container.h @@ -22,7 +22,7 @@ class ConstraintContainer: public ConstraintSparse<3,2,1,2,1> lmk_ptr_(_lmk_ptr), corner_(_corner) { - assert(_corner >= 0 && _corner <= 3 && "Wrong corner id in constraint container constructor"); + assert(/*_corner >= 0 &&*/ _corner <= 3 && "Wrong corner id in constraint container constructor"); setType("CONTAINER"); std::cout << "new constraint container: corner idx = " << corner_ << std::endl; diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index ba190c92c2217ca850ef83d92ed08fd823b12ff8..7de8d464b45e2d9e1d6ec7209d48cfda81fa9af6 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -8,10 +8,6 @@ ADD_EXECUTABLE(test_sh_ptr test_sh_ptr.cpp) -# Map load and save test -ADD_EXECUTABLE(test_map_yaml test_map_yaml.cpp) -TARGET_LINK_LIBRARIES(test_map_yaml ${PROJECT_NAME}) - # test_processor_odom_3D ADD_EXECUTABLE(test_processor_odom_3D test_processor_odom_3D.cpp) TARGET_LINK_LIBRARIES(test_processor_odom_3D ${PROJECT_NAME}) @@ -50,6 +46,10 @@ IF(YAMLCPP_FOUND) # SensorFactory classes test ADD_EXECUTABLE(test_wolf_factories test_wolf_factories.cpp) TARGET_LINK_LIBRARIES(test_wolf_factories ${PROJECT_NAME}) + + # Map load and save test + ADD_EXECUTABLE(test_map_yaml test_map_yaml.cpp) + TARGET_LINK_LIBRARIES(test_map_yaml ${PROJECT_NAME}) ENDIF(YAMLCPP_FOUND) IF(Suitesparse_FOUND) diff --git a/src/landmark_base.h b/src/landmark_base.h index f861fef29fd169767f3d04dfa1cdcf829dc6481b..328ca267bb955ad24be8313a8bf75fd5c56922cf 100644 --- a/src/landmark_base.h +++ b/src/landmark_base.h @@ -61,7 +61,7 @@ class LandmarkBase : public NodeBase, public std::enable_shared_from_this<Landma // Properties unsigned int id(); void setId(unsigned int _id); - const LandmarkType getTypeId() const; + LandmarkType getTypeId() const; // Fix / unfix void setStatus(LandmarkStatus _st); @@ -240,7 +240,7 @@ inline const Eigen::VectorXs& LandmarkBase::getDescriptor() const return descriptor_; } -inline const LandmarkType LandmarkBase::getTypeId() const +inline LandmarkType LandmarkBase::getTypeId() const { return type_id_; } diff --git a/src/landmark_container.cpp b/src/landmark_container.cpp index b41a0fc2d3eb2387481c4cc1539f7ea4035299f3..bd28dcea66703aabd50d681672133daa7ab51da5 100644 --- a/src/landmark_container.cpp +++ b/src/landmark_container.cpp @@ -181,7 +181,7 @@ Eigen::MatrixXs LandmarkContainer::getCorners() const Eigen::VectorXs LandmarkContainer::getCorner(const unsigned int _id) const { - assert(_id >= 0 && _id <= 4 && "wrong corner id parameter in getCorner(id)"); + assert(/*_id >= 0 &&*/ _id <= 4 && "wrong corner id parameter in getCorner(id)"); return corners_.col(_id); } diff --git a/src/processor_motion.h b/src/processor_motion.h index 21854c8485e83cfa076e02266e95af6a2af45576..7f06324fdae05bb162057b005a8c89c48063ec61 100644 --- a/src/processor_motion.h +++ b/src/processor_motion.h @@ -100,13 +100,13 @@ class ProcessorMotion : public ProcessorBase /** \brief Fills a reference to the state integrated so far * \param _x the returned state vector */ - const void getCurrentState(Eigen::VectorXs& _x); + void getCurrentState(Eigen::VectorXs& _x); /** \brief Fills a reference to the state integrated so far and its stamp * \param _x the returned state vector * \param _ts the returned stamp */ - const void getCurrentState(Eigen::VectorXs& _x, TimeStamp& _ts); + void getCurrentState(Eigen::VectorXs& _x, TimeStamp& _ts); /** \brief Gets a constant reference to the state integrated so far * \return the state vector @@ -700,13 +700,13 @@ inline const Eigen::VectorXs& ProcessorMotion::getCurrentState(TimeStamp& _ts) return x_; } -inline const void ProcessorMotion::getCurrentState(Eigen::VectorXs& _x) +inline void ProcessorMotion::getCurrentState(Eigen::VectorXs& _x) { Scalar Dt = getBuffer().get().back().ts_ - origin_ptr_->getTimeStamp(); xPlusDelta(origin_ptr_->getFramePtr()->getState(), getBuffer().get().back().delta_integr_, Dt, _x); } -inline const void ProcessorMotion::getCurrentState(Eigen::VectorXs& _x, TimeStamp& _ts) +inline void ProcessorMotion::getCurrentState(Eigen::VectorXs& _x, TimeStamp& _ts) { getCurrentState(_x); _ts = getBuffer().get().back().ts_; diff --git a/src/processor_tracker.h b/src/processor_tracker.h index 8f27821c09719cfa5cd872d9b4ab6ee2237cc60a..5a47b3588b1c33891a129578acc09ca903626666 100644 --- a/src/processor_tracker.h +++ b/src/processor_tracker.h @@ -85,7 +85,7 @@ class ProcessorTracker : public ProcessorBase virtual void process(CaptureBasePtr const _incoming_ptr); void setMaxNewFeatures(const unsigned int& _max_new_features); - const unsigned int getMaxNewFeatures(); + unsigned int getMaxNewFeatures(); virtual bool keyFrameCallback(FrameBasePtr _keyframe_ptr, const Scalar& _time_tol_other); @@ -195,7 +195,7 @@ inline void ProcessorTracker::setMaxNewFeatures(const unsigned int& _max_new_fea max_new_features_ = _max_new_features; } -inline const unsigned int ProcessorTracker::getMaxNewFeatures() +inline unsigned int ProcessorTracker::getMaxNewFeatures() { return max_new_features_; }