diff --git a/gtsam/3rdparty/CMakeLists.txt b/gtsam/3rdparty/CMakeLists.txt index f77454b9b..5822a51f5 100644 --- a/gtsam/3rdparty/CMakeLists.txt +++ b/gtsam/3rdparty/CMakeLists.txt @@ -25,8 +25,11 @@ if(NOT GTSAM_USE_SYSTEM_EIGEN) FILES_MATCHING PATTERN "*.h") endif() +option(GTSAM_BUILD_METIS "Build metis library" ON) option(GTSAM_BUILD_METIS_EXECUTABLES "Build metis library executables" OFF) -add_subdirectory(metis-5.1.0) +if(GTSAM_BUILD_METIS) + add_subdirectory(metis-5.1.0) +endif(GTSAM_BUILD_METIS) ############ NOTE: When updating GeographicLib be sure to disable building their examples ############ and unit tests by commenting out their lines: # add_subdirectory (examples) diff --git a/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt b/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt index ceeb5d2aa..827e50b34 100644 --- a/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt +++ b/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt @@ -2,9 +2,13 @@ cmake_minimum_required(VERSION 2.8) project(METIS) # Add flags for currect directory and below -add_definitions(-Wno-unused-variable) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-sometimes-uninitialized) +endif() + add_definitions(-Wno-unknown-pragmas) -add_definitions(-Wno-sometimes-uninitialized) +add_definitions(-Wunused-but-set-variable) set(GKLIB_PATH ${PROJECT_SOURCE_DIR}/GKlib CACHE PATH "path to GKlib") set(SHARED FALSE CACHE BOOL "build a shared library") diff --git a/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake b/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake index 3fcc29108..7ea5bab94 100644 --- a/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake +++ b/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake @@ -33,7 +33,7 @@ if(CMAKE_COMPILER_IS_GNUCC) set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC") endif(NOT MINGW) # GCC warnings. - set(GKlib_COPTIONS "${GKlib_COPTIONS} -Wall -pedantic -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas") + set(GKlib_COPTIONS "${GKlib_COPTIONS} -Wall -pedantic -Wno-unused-variable -Wno-unknown-pragmas") elseif(${CMAKE_C_COMPILER_ID} MATCHES "Sun") # Sun insists on -xc99. set(GKlib_COPTIONS "${GKlib_COPTIONS} -xc99") diff --git a/gtsam/linear/GaussianFactorGraph.h b/gtsam/linear/GaussianFactorGraph.h index aea90da1a..50442ac6b 100644 --- a/gtsam/linear/GaussianFactorGraph.h +++ b/gtsam/linear/GaussianFactorGraph.h @@ -88,6 +88,9 @@ namespace gtsam { template GaussianFactorGraph(const FactorGraph& graph) : Base(graph) {} + /** Virtual destructor */ + virtual ~GaussianFactorGraph() {} + /// @name Testable /// @{ diff --git a/gtsam/nonlinear/ISAM2.cpp b/gtsam/nonlinear/ISAM2.cpp index 2c2b4b719..6d6785b14 100644 --- a/gtsam/nonlinear/ISAM2.cpp +++ b/gtsam/nonlinear/ISAM2.cpp @@ -151,13 +151,13 @@ void ISAM2Clique::print(const std::string& s, const KeyFormatter& formatter) con } /* ************************************************************************* */ -ISAM2::ISAM2(const ISAM2Params& params): params_(params) { +ISAM2::ISAM2(const ISAM2Params& params): params_(params), update_count_(0) { if(params_.optimizationParams.type() == typeid(ISAM2DoglegParams)) doglegDelta_ = boost::get(params_.optimizationParams).initialDelta; } /* ************************************************************************* */ -ISAM2::ISAM2() { +ISAM2::ISAM2() : update_count_(0) { if(params_.optimizationParams.type() == typeid(ISAM2DoglegParams)) doglegDelta_ = boost::get(params_.optimizationParams).initialDelta; } @@ -521,8 +521,7 @@ ISAM2Result ISAM2::update( gttic(ISAM2_update); - static int count = 0; - count++; + this->update_count_++; lastAffectedVariableCount = 0; lastAffectedFactorCount = 0; @@ -533,7 +532,8 @@ ISAM2Result ISAM2::update( ISAM2Result result; if(params_.enableDetailedResults) result.detail = ISAM2Result::DetailedResults(); - const bool relinearizeThisStep = force_relinearize || (params_.enableRelinearization && count % params_.relinearizeSkip == 0); + const bool relinearizeThisStep = force_relinearize + || (params_.enableRelinearization && update_count_ % params_.relinearizeSkip == 0); if(verbose) { cout << "ISAM2::update\n"; diff --git a/gtsam/nonlinear/ISAM2.h b/gtsam/nonlinear/ISAM2.h index 9eac64b4d..a98ef851f 100644 --- a/gtsam/nonlinear/ISAM2.h +++ b/gtsam/nonlinear/ISAM2.h @@ -468,6 +468,8 @@ protected: * variables and thus cannot have their linearization points changed. */ FastSet fixedVariables_; + int update_count_; ///< Counter incremented every update(), used to determine periodic relinearization + public: typedef ISAM2 This; ///< This class diff --git a/gtsam_unstable/CMakeLists.txt b/gtsam_unstable/CMakeLists.txt index 2e1097130..a33a4548c 100644 --- a/gtsam_unstable/CMakeLists.txt +++ b/gtsam_unstable/CMakeLists.txt @@ -1,15 +1,18 @@ # Build full gtsam_unstable library as a single library -# and also build tests +# and also build tests set (gtsam_unstable_subdirs - base + base geometry discrete dynamics nonlinear - partition slam ) +if(GTSAM_BUILD_METIS) # Only build partition if metis is built + set (gtsam_unstable_subdirs ${gtsam_unstable_subdirs} partition) +endif(GTSAM_BUILD_METIS) + set(GTSAM_UNSTABLE_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES}) add_custom_target(check.unstable COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) @@ -22,7 +25,7 @@ set (excluded_sources # "") ) set (excluded_headers # "") - "${CMAKE_CURRENT_SOURCE_DIR}/slam/serialization.h" + "${CMAKE_CURRENT_SOURCE_DIR}/slam/serialization.h" ) # assemble core libaries @@ -36,32 +39,35 @@ foreach(subdir ${gtsam_unstable_subdirs}) gtsam_assign_source_folders("${${subdir}_srcs}") # Create MSVC structure # Build local library and tests - message(STATUS "Building ${subdir}_unstable") + message(STATUS "Building ${subdir}_unstable") add_subdirectory(${subdir}) endforeach(subdir) - + # assemble gtsam_unstable components set(gtsam_unstable_srcs - ${base_srcs} + ${base_srcs} ${geometry_srcs} ${discrete_srcs} - ${dynamics_srcs} + ${dynamics_srcs} ${nonlinear_srcs} - ${partition_srcs} ${slam_srcs} ) +if(GTSAM_BUILD_METIS) # Only build partition if metis is built + set (gtsam_unstable_srcs ${gtsam_unstable_srcs} ${partition_srcs}) +endif(GTSAM_BUILD_METIS) + # Versions - same as core gtsam library set(gtsam_unstable_version ${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}) set(gtsam_unstable_soversion ${GTSAM_VERSION_MAJOR}) message(STATUS "GTSAM_UNSTABLE Version: ${gtsam_unstable_version}") message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") - + # build shared and static versions of the library if (GTSAM_BUILD_STATIC_LIBRARY) message(STATUS "Building GTSAM_UNSTABLE - static") add_library(gtsam_unstable STATIC ${gtsam_unstable_srcs}) - set_target_properties(gtsam_unstable PROPERTIES + set_target_properties(gtsam_unstable PROPERTIES OUTPUT_NAME gtsam_unstable CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_unstable_version} @@ -78,7 +84,7 @@ if (GTSAM_BUILD_STATIC_LIBRARY) else() message(STATUS "Building GTSAM_UNSTABLE - shared") add_library(gtsam_unstable SHARED ${gtsam_unstable_srcs}) - set_target_properties(gtsam_unstable PROPERTIES + set_target_properties(gtsam_unstable PROPERTIES OUTPUT_NAME gtsam_unstable CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_unstable_version} @@ -99,7 +105,7 @@ endif() if (GTSAM_INSTALL_MATLAB_TOOLBOX) # Set up codegen include(GtsamMatlabWrap) - + # Generate, build and install toolbox set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}") if(GTSAM_BUILD_STATIC_LIBRARY) diff --git a/gtsam_unstable/partition/CMakeLists.txt b/gtsam_unstable/partition/CMakeLists.txt index 9020346bf..d8d254513 100644 --- a/gtsam_unstable/partition/CMakeLists.txt +++ b/gtsam_unstable/partition/CMakeLists.txt @@ -4,4 +4,4 @@ install(FILES ${partition_headers} DESTINATION include/gtsam_unstable/parition) set(ignore_test "tests/testNestedDissection.cpp") # Add all tests -gtsamAddTestsGlob(partition_unstable "tests/*.cpp" "${ignore_test}" "gtsam_unstable;metis") \ No newline at end of file +gtsamAddTestsGlob(partition_unstable "tests/*.cpp" "${ignore_test}" "gtsam_unstable;metis") diff --git a/gtsam_unstable/partition/GenericGraph.cpp b/gtsam_unstable/partition/GenericGraph.cpp index aca916a04..a3db6a9c1 100644 --- a/gtsam_unstable/partition/GenericGraph.cpp +++ b/gtsam_unstable/partition/GenericGraph.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -468,9 +469,9 @@ namespace gtsam { namespace partition { } if (minFoundConstraintsPerCamera < minNrConstraintsPerCamera) - throw runtime_error("checkSingularity:minConstraintsPerCamera < " + minFoundConstraintsPerCamera); + throw runtime_error("checkSingularity:minConstraintsPerCamera < " + boost::lexical_cast(minFoundConstraintsPerCamera)); if (minFoundConstraintsPerLandmark < minNrConstraintsPerLandmark) - throw runtime_error("checkSingularity:minConstraintsPerLandmark < " + minFoundConstraintsPerLandmark); + throw runtime_error("checkSingularity:minConstraintsPerLandmark < " + boost::lexical_cast(minFoundConstraintsPerLandmark)); } }} // namespace