Merge pull request #10 from uzh-rpg/feature/plain_cmake_build

Build svo without ROS/Catkin
This commit is contained in:
Christian Forster
2014-06-11 11:48:57 +02:00
5 changed files with 131 additions and 20 deletions
+28 -13
View File
@@ -3,6 +3,8 @@
SET(TRACE TRUE)
SET(HAVE_G2O TRUE)
SET(USE_ROS TRUE) # Set FALSE if you want to build this package without Catkin
SET(DEBUG_OUTPUT FALSE) # Only relevant if build without ROS
################################################################################
@@ -20,7 +22,12 @@ ENDIF()
IF(HAVE_G2O)
ADD_DEFINITIONS(-DUSE_BUNDLE_ADJUSTMENT)
ENDIF()
ADD_DEFINITIONS(-DSVO_USE_ROS)
IF(USE_ROS)
ADD_DEFINITIONS(-DSVO_USE_ROS)
ENDIF()
IF(DEBUG_OUTPUT)
ADD_DEFINITIONS(-DSVO_DEBUG_OUTPUT)
ENDIF()
# Set build flags, set ARM_ARCHITECTURE environment variable on Odroid
SET(CMAKE_CXX_FLAGS "-Wall -Werror -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas")
@@ -35,9 +42,6 @@ ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF()
# Add catkin and required ROS packages
FIND_PACKAGE(catkin REQUIRED COMPONENTS roscpp roslib cmake_modules vikit_common vikit_ros)
# Add plain cmake packages
FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(Eigen REQUIRED)
@@ -45,13 +49,19 @@ FIND_PACKAGE(Sophus REQUIRED)
FIND_PACKAGE(fast REQUIRED)
FIND_PACKAGE(Boost REQUIRED COMPONENTS thread)
# Describe catkin Project
catkin_package(
IF(USE_ROS)
FIND_PACKAGE(catkin REQUIRED COMPONENTS roscpp roslib cmake_modules vikit_common vikit_ros)
catkin_package(
DEPENDS Eigen OpenCV Sophus Boost fast
CATKIN_DEPENDS roscpp roslib vikit_common vikit_ros
INCLUDE_DIRS include
LIBRARIES svo
)
)
ELSE()
FIND_PACKAGE(vikit_common REQUIRED)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
ENDIF()
# Include dirs
INCLUDE_DIRECTORIES(
@@ -60,7 +70,6 @@ INCLUDE_DIRECTORIES(
${OpenCV_INCLUDE_DIRS}
${Sophus_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${fast_INCLUDE_DIRS}
)
@@ -69,10 +78,17 @@ LIST(APPEND LINK_LIBS
${OpenCV_LIBRARIES}
${Sophus_LIBRARIES}
${Boost_LIBRARIES}
${catkin_LIBRARIES}
${fast_LIBRARIES}
)
IF(USE_ROS)
INCLUDE_DIRECTORIES(${catkin_INCLUDE_DIRS})
LIST(APPEND LINK_LIBS ${catkin_LIBRARIES})
ELSE()
INCLUDE_DIRECTORIES(${vikit_common_INCLUDE_DIRS})
LIST(APPEND LINK_LIBS ${vikit_common_LIBRARIES})
ENDIF()
# Set sourcefiles
LIST(APPEND SOURCEFILES
src/frame_handler_mono.cpp
@@ -94,12 +110,12 @@ LIST(APPEND SOURCEFILES
IF(HAVE_G2O)
FIND_PACKAGE(G2O REQUIRED)
INCLUDE_DIRECTORIES(
${G2O_ROOT}/include
${G2O_INCLUDE_DIR}
/usr/include/suitesparse # for cholmod
)
LIST(APPEND LINK_LIBS
g2o_core g2o_stuff g2o_solver_cholmod g2o_solver_csparse g2o_solver_dense
g2o_solver_pcg g2o_types_sba cholmod cxsparse
${G2O_CORE_LIBRARY} ${G2O_STUFF_LIBRARY} ${G2O_SOLVER_CHOLMOD} ${G2O_SOLVER_CSPARSE} ${G2O_SOLVER_DENSE}
${G2O_SOLVER_PCG} ${G2O_TYPES_SBA} cholmod cxsparse
)
LIST(APPEND SOURCEFILES src/bundle_adjustment.cpp)
ENDIF(HAVE_G2O)
@@ -108,7 +124,6 @@ ENDIF(HAVE_G2O)
ADD_LIBRARY(svo SHARED ${SOURCEFILES})
TARGET_LINK_LIBRARIES(svo ${LINK_LIBS})
################################################################################
# TESTS
+81
View File
@@ -0,0 +1,81 @@
###############################################################################
#
# CMake script for finding the Eigen library.
#
# http://eigen.tuxfamily.org/index.php?title=Main_Page
#
# Copyright (c) 2006, 2007 Montel Laurent, <[email protected]>
# Copyright (c) 2008, 2009 Gael Guennebaud, <[email protected]>
# Copyright (c) 2009 Benoit Jacob <[email protected]>
# Redistribution and use is allowed according to the terms of the 2-clause BSD
# license.
#
#
# Input variables:
#
# - Eigen_ROOT_DIR (optional): When specified, header files and libraries
# will be searched for in `${Eigen_ROOT_DIR}/include` and
# `${Eigen_ROOT_DIR}/libs` respectively, and the default CMake search order
# will be ignored. When unspecified, the default CMake search order is used.
# This variable can be specified either as a CMake or environment variable.
# If both are set, preference is given to the CMake variable.
# Use this variable for finding packages installed in a nonstandard location,
# or for enforcing that one of multiple package installations is picked up.
#
# Cache variables (not intended to be used in CMakeLists.txt files)
#
# - Eigen_INCLUDE_DIR: Absolute path to package headers.
#
#
# Output variables:
#
# - Eigen_FOUND: Boolean that indicates if the package was found
# - Eigen_INCLUDE_DIRS: Paths to the necessary header files
# - Eigen_VERSION: Version of Eigen library found
# - Eigen_DEFINITIONS: Definitions to be passed on behalf of eigen
#
#
# Example usage:
#
# # Passing the version means Eigen_FOUND will only be TRUE if a
# # version >= the provided version is found.
# find_package(Eigen 3.1.2)
# if(NOT Eigen_FOUND)
# # Error handling
# endif()
# ...
# add_definitions(${Eigen_DEFINITIONS})
# ...
# include_directories(${Eigen_INCLUDE_DIRS} ...)
#
###############################################################################
find_package(PkgConfig)
pkg_check_modules(PC_EIGEN eigen3)
set(EIGEN_DEFINITIONS ${PC_EIGEN_CFLAGS_OTHER})
find_path(EIGEN_INCLUDE_DIR Eigen/Core
HINTS ${PC_EIGEN_INCLUDEDIR} ${PC_EIGEN_INCLUDE_DIRS}
"${Eigen_ROOT_DIR}" "$ENV{EIGEN_ROOT_DIR}"
"${EIGEN_ROOT}" "$ENV{EIGEN_ROOT}" # Backwards Compatibility
PATHS "$ENV{PROGRAMFILES}/Eigen" "$ENV{PROGRAMW6432}/Eigen"
"$ENV{PROGRAMFILES}/Eigen 3.0.0" "$ENV{PROGRAMW6432}/Eigen 3.0.0"
PATH_SUFFIXES eigen3 include/eigen3 include)
set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR)
mark_as_advanced(EIGEN_INCLUDE_DIR)
if(EIGEN_FOUND)
message(STATUS "Eigen found (include: ${EIGEN_INCLUDE_DIRS})")
endif(EIGEN_FOUND)
set(Eigen_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
set(Eigen_FOUND ${EIGEN_FOUND})
set(Eigen_VERSION ${EIGEN_VERSION})
set(Eigen_DEFINITIONS ${EIGEN_DEFINITIONS})
+4
View File
@@ -39,7 +39,11 @@
#define SVO_ERROR_STREAM(x) ROS_ERROR_STREAM(x)
#else
#define SVO_INFO_STREAM(x) std::cerr<<"\033[0;0m[INFO] "<<x<<"\033[0;0m"<<std::endl;
#ifdef SVO_DEBUG_OUTPUT
#define SVO_DEBUG_STREAM(x) SVO_INFO_STREAM(x)
#else
#define SVO_DEBUG_STREAM(x)
#endif
#define SVO_WARN_STREAM(x) std::cerr<<"\033[0;33m[WARN] "<<x<<"\033[0;0m"<<std::endl;
#define SVO_ERROR_STREAM(x) std::cerr<<"\033[1;31m[ERROR] "<<x<<"\033[0;0m"<<std::endl;
#include <chrono> // Adapted from rosconsole. Copyright (c) 2008, Willow Garage, Inc.
+1
View File
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdexcept>
#include <svo/frame.h>
#include <svo/feature.h>
#include <svo/point.h>
+12 -2
View File
@@ -20,24 +20,34 @@
#include <string.h>
#include <cstdlib> // for getenv
#include <ros/package.h>
#include <vikit/params_helper.h>
#ifdef SVO_USE_ROS
#include <vikit/params_helper.h>
#endif
namespace svo {
namespace test_utils {
std::string getDatasetDir()
{
std::string dataset_dir(ros::package::getPath("svo")+"/test/data");
const char* env_dir = std::getenv("SVO_DATASET_DIR");
#ifdef SVO_USE_ROS
std::string dataset_dir(ros::package::getPath("svo")+"/test/data");
if(env_dir != NULL)
dataset_dir = std::string(env_dir);
return dataset_dir;
#else
return std::string(env_dir);
#endif
}
std::string getTraceDir()
{
#ifdef SVO_USE_ROS
std::string default_dir(ros::package::getPath("svo")+"/test/results");
return vk::getParam<std::string>("svo/trace_dir", default_dir);
#else
return "/tmp";
#endif
}
} // namespace test_utils