From 2cf4514e81fc3716b3c26c4c56bc3a644ff5f2da Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Tue, 9 Jul 2019 17:11:01 -0400 Subject: [PATCH 01/15] Changes to get gtsam to compile in Windows --- CMakeLists.txt | 36 ++++++++++++++----------------- cmake/GtsamMatlabWrap.cmake | 19 ++++++++++------ gtsam/geometry/CalibratedCamera.h | 7 ++++-- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe57b599..738a434f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,20 +179,18 @@ option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF) # so we downgraded this to classic filenames-based variables, and manually adding # the target_include_directories(xxx ${Boost_INCLUDE_DIR}) set(GTSAM_BOOST_LIBRARIES - optimized - ${Boost_SERIALIZATION_LIBRARY_RELEASE} - ${Boost_SYSTEM_LIBRARY_RELEASE} - ${Boost_FILESYSTEM_LIBRARY_RELEASE} - ${Boost_THREAD_LIBRARY_RELEASE} - ${Boost_DATE_TIME_LIBRARY_RELEASE} - ${Boost_REGEX_LIBRARY_RELEASE} - debug - ${Boost_SERIALIZATION_LIBRARY_DEBUG} - ${Boost_SYSTEM_LIBRARY_DEBUG} - ${Boost_FILESYSTEM_LIBRARY_DEBUG} - ${Boost_THREAD_LIBRARY_DEBUG} - ${Boost_DATE_TIME_LIBRARY_DEBUG} - ${Boost_REGEX_LIBRARY_DEBUG} + optimized ${Boost_SERIALIZATION_LIBRARY_RELEASE} + optimized ${Boost_SYSTEM_LIBRARY_RELEASE} + optimized ${Boost_FILESYSTEM_LIBRARY_RELEASE} + optimized ${Boost_THREAD_LIBRARY_RELEASE} + optimized ${Boost_DATE_TIME_LIBRARY_RELEASE} + optimized ${Boost_REGEX_LIBRARY_RELEASE} + debug ${Boost_SERIALIZATION_LIBRARY_DEBUG} + debug ${Boost_SYSTEM_LIBRARY_DEBUG} + debug ${Boost_FILESYSTEM_LIBRARY_DEBUG} + debug ${Boost_THREAD_LIBRARY_DEBUG} + debug ${Boost_DATE_TIME_LIBRARY_DEBUG} + debug ${Boost_REGEX_LIBRARY_DEBUG} ) message(STATUS "GTSAM_BOOST_LIBRARIES: ${GTSAM_BOOST_LIBRARIES}") if (GTSAM_DISABLE_NEW_TIMERS) @@ -201,12 +199,10 @@ if (GTSAM_DISABLE_NEW_TIMERS) else() if(Boost_TIMER_LIBRARY) list(APPEND GTSAM_BOOST_LIBRARIES - optimized - ${Boost_TIMER_LIBRARY_RELEASE} - ${Boost_CHRONO_LIBRARY_RELEASE} - debug - ${Boost_TIMER_LIBRARY_DEBUG} - ${Boost_CHRONO_LIBRARY_DEBUG} + optimized ${Boost_TIMER_LIBRARY_RELEASE} + optimized ${Boost_CHRONO_LIBRARY_RELEASE} + debug ${Boost_TIMER_LIBRARY_DEBUG} + debug ${Boost_CHRONO_LIBRARY_DEBUG} ) else() list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt diff --git a/cmake/GtsamMatlabWrap.cmake b/cmake/GtsamMatlabWrap.cmake index bdd868665..fd6d4bed5 100644 --- a/cmake/GtsamMatlabWrap.cmake +++ b/cmake/GtsamMatlabWrap.cmake @@ -35,7 +35,11 @@ mark_as_advanced(FORCE MEX_COMMAND) # Now that we have mex, trace back to find the Matlab installation root get_filename_component(MEX_COMMAND "${MEX_COMMAND}" REALPATH) get_filename_component(mex_path "${MEX_COMMAND}" PATH) -get_filename_component(MATLAB_ROOT "${mex_path}/.." ABSOLUTE) +if(mex_path MATCHES ".*/win64$") + get_filename_component(MATLAB_ROOT "${mex_path}/../.." ABSOLUTE) +else() + get_filename_component(MATLAB_ROOT "${mex_path}/.." ABSOLUTE) +endif() set(MATLAB_ROOT "${MATLAB_ROOT}" CACHE PATH "Path to MATLAB installation root (e.g. /usr/local/MATLAB/R2012a)") @@ -97,9 +101,9 @@ function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs ex set(compiled_mex_modules_root "${PROJECT_BINARY_DIR}/wrap/${moduleName}_mex") message(STATUS "Building wrap module ${moduleName}") - + # Find matlab.h in GTSAM - if("${PROJECT_NAME}" STREQUAL "GTSAM") + if("${PROJECT_NAME}" STREQUAL "gtsam") set(matlab_h_path "${PROJECT_SOURCE_DIR}") else() if(NOT GTSAM_INCLUDE_DIR) @@ -115,14 +119,15 @@ function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs ex set(automaticDependencies "") foreach(lib ${moduleName} ${linkLibraries}) #message("MODULE NAME: ${moduleName}") + #message("lib: ${lib}") if(TARGET "${lib}") get_target_property(dependentLibraries ${lib} INTERFACE_LINK_LIBRARIES) - # message("DEPENDENT LIBRARIES: ${dependentLibraries}") - if(dependentLibraries) - list(APPEND automaticDependencies ${dependentLibraries}) + #message("DEPENDENT LIBRARIES: ${dependentLibraries}") + if(dependentLibraries) + list(APPEND automaticDependencies ${dependentLibraries}) endif() endif() - endforeach() + endforeach() ## CHRIS: Temporary fix. On my system the get_target_property above returned Not-found for gtsam module ## This needs to be fixed!! diff --git a/gtsam/geometry/CalibratedCamera.h b/gtsam/geometry/CalibratedCamera.h index 1f791935d..f2bc2f84a 100644 --- a/gtsam/geometry/CalibratedCamera.h +++ b/gtsam/geometry/CalibratedCamera.h @@ -18,6 +18,10 @@ #pragma once +//Needed if windows.h is included somehow. +//It defines min and max, which conflicts with numeric_limits::max() +#define NOMINMAX + #include #include #include @@ -29,8 +33,7 @@ namespace gtsam { -class GTSAM_EXPORT CheiralityException: public ThreadsafeException< - CheiralityException> { +class GTSAM_EXPORT CheiralityException: public ThreadsafeException { public: CheiralityException() : CheiralityException(std::numeric_limits::max()) {} From f52db1eadc8dfaed097a2436819829d867ac9324 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Thu, 11 Jul 2019 14:23:14 +0200 Subject: [PATCH 02/15] undo whitespace changes --- cmake/GtsamMatlabWrap.cmake | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmake/GtsamMatlabWrap.cmake b/cmake/GtsamMatlabWrap.cmake index fd6d4bed5..28b3dac2c 100644 --- a/cmake/GtsamMatlabWrap.cmake +++ b/cmake/GtsamMatlabWrap.cmake @@ -101,7 +101,7 @@ function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs ex set(compiled_mex_modules_root "${PROJECT_BINARY_DIR}/wrap/${moduleName}_mex") message(STATUS "Building wrap module ${moduleName}") - + # Find matlab.h in GTSAM if("${PROJECT_NAME}" STREQUAL "gtsam") set(matlab_h_path "${PROJECT_SOURCE_DIR}") @@ -119,15 +119,14 @@ function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs ex set(automaticDependencies "") foreach(lib ${moduleName} ${linkLibraries}) #message("MODULE NAME: ${moduleName}") - #message("lib: ${lib}") if(TARGET "${lib}") get_target_property(dependentLibraries ${lib} INTERFACE_LINK_LIBRARIES) - #message("DEPENDENT LIBRARIES: ${dependentLibraries}") - if(dependentLibraries) - list(APPEND automaticDependencies ${dependentLibraries}) + # message("DEPENDENT LIBRARIES: ${dependentLibraries}") + if(dependentLibraries) + list(APPEND automaticDependencies ${dependentLibraries}) endif() endif() - endforeach() + endforeach() ## CHRIS: Temporary fix. On my system the get_target_property above returned Not-found for gtsam module ## This needs to be fixed!! From 5384d209625958acadb723d793c32c4e747ca2c4 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Thu, 11 Jul 2019 14:26:50 +0200 Subject: [PATCH 03/15] Undo changes in CalibratedCamera --- gtsam/geometry/CalibratedCamera.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gtsam/geometry/CalibratedCamera.h b/gtsam/geometry/CalibratedCamera.h index f2bc2f84a..1f791935d 100644 --- a/gtsam/geometry/CalibratedCamera.h +++ b/gtsam/geometry/CalibratedCamera.h @@ -18,10 +18,6 @@ #pragma once -//Needed if windows.h is included somehow. -//It defines min and max, which conflicts with numeric_limits::max() -#define NOMINMAX - #include #include #include @@ -33,7 +29,8 @@ namespace gtsam { -class GTSAM_EXPORT CheiralityException: public ThreadsafeException { +class GTSAM_EXPORT CheiralityException: public ThreadsafeException< + CheiralityException> { public: CheiralityException() : CheiralityException(std::numeric_limits::max()) {} From 69c3eafb300750b6441317c3d9ffcd23aa41b135 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Thu, 11 Jul 2019 14:27:09 +0200 Subject: [PATCH 04/15] Add NOMINMAX macro for MSVC via cmake --- cmake/GtsamBuildTypes.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/GtsamBuildTypes.cmake b/cmake/GtsamBuildTypes.cmake index 56dd7dc08..aa35fea05 100644 --- a/cmake/GtsamBuildTypes.cmake +++ b/cmake/GtsamBuildTypes.cmake @@ -77,7 +77,10 @@ set(GTSAM_COMPILE_DEFINITIONS_PRIVATE_PROFILING "NDEBUG" CACHE STRING "(Us set(GTSAM_COMPILE_DEFINITIONS_PRIVATE_TIMING "NDEBUG;ENABLE_TIMING" CACHE STRING "(User editable) Private preprocessor macros for Timing configuration.") if(MSVC) # Common to all configurations: - list_append_cache(GTSAM_COMPILE_DEFINITIONS_PRIVATE WINDOWS_LEAN_AND_MEAN) + list_append_cache(GTSAM_COMPILE_DEFINITIONS_PRIVATE + WINDOWS_LEAN_AND_MEAN + NOMINMAX + ) endif() # Other (non-preprocessor macros) compiler flags: From 6dec8b12686500ffdb81c374e129e31ce6e40066 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Fri, 12 Jul 2019 01:16:24 +0200 Subject: [PATCH 05/15] fix cmake error with MATLAB --- cmake/GtsamMatlabWrap.cmake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmake/GtsamMatlabWrap.cmake b/cmake/GtsamMatlabWrap.cmake index 28b3dac2c..9f46e898a 100644 --- a/cmake/GtsamMatlabWrap.cmake +++ b/cmake/GtsamMatlabWrap.cmake @@ -82,28 +82,29 @@ function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs ex set(mexModuleExt mexw32) endif() endif() - + # Wrap codegen interface #usage: wrap interfacePath moduleName toolboxPath headerPath # interfacePath : *absolute* path to directory of module interface file # moduleName : the name of the module, interface file must be called moduleName.h # toolboxPath : the directory in which to generate the wrappers - # headerPath : path to matlab.h - + # headerPath : path to matlab.h + # Extract module name from interface header file name get_filename_component(interfaceHeader "${interfaceHeader}" ABSOLUTE) get_filename_component(modulePath "${interfaceHeader}" PATH) get_filename_component(moduleName "${interfaceHeader}" NAME_WE) - + # Paths for generated files set(generated_files_path "${PROJECT_BINARY_DIR}/wrap/${moduleName}") set(generated_cpp_file "${generated_files_path}/${moduleName}_wrapper.cpp") set(compiled_mex_modules_root "${PROJECT_BINARY_DIR}/wrap/${moduleName}_mex") - + message(STATUS "Building wrap module ${moduleName}") - + # Find matlab.h in GTSAM - if("${PROJECT_NAME}" STREQUAL "gtsam") + if(("${PROJECT_NAME}" STREQUAL "gtsam") OR + ("${PROJECT_NAME}" STREQUAL "gtsam_unstable")) set(matlab_h_path "${PROJECT_SOURCE_DIR}") else() if(NOT GTSAM_INCLUDE_DIR) From 1ca0e3395ca4359687caff1a369f27a6cc753abf Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Fri, 12 Jul 2019 07:58:18 +0200 Subject: [PATCH 06/15] Partial fix to MSVC Matlab builds --- cmake/GtsamMatlabWrap.cmake | 1 + gtsam/navigation/ScenarioRunner.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/GtsamMatlabWrap.cmake b/cmake/GtsamMatlabWrap.cmake index 9f46e898a..5fc829bf2 100644 --- a/cmake/GtsamMatlabWrap.cmake +++ b/cmake/GtsamMatlabWrap.cmake @@ -226,6 +226,7 @@ function(wrap_library_internal interfaceHeader linkLibraries extraIncludeDirs ex string(REPLACE ";" " " mexFlagsSpaced "${GTSAM_BUILD_MEX_BINARY_FLAGS}") add_library(${moduleName}_matlab_wrapper MODULE ${generated_cpp_file} ${interfaceHeader} ${otherSourcesAndObjects}) target_link_libraries(${moduleName}_matlab_wrapper ${correctedOtherLibraries}) + target_link_libraries(${moduleName}_matlab_wrapper ${moduleName}) set_target_properties(${moduleName}_matlab_wrapper PROPERTIES OUTPUT_NAME "${moduleName}_wrapper" PREFIX "" diff --git a/gtsam/navigation/ScenarioRunner.h b/gtsam/navigation/ScenarioRunner.h index de451b7e3..5fb9f78d7 100644 --- a/gtsam/navigation/ScenarioRunner.h +++ b/gtsam/navigation/ScenarioRunner.h @@ -36,7 +36,7 @@ static noiseModel::Diagonal::shared_ptr Diagonal(const Matrix& covariance) { * Simple class to test navigation scenarios. * Takes a trajectory scenario as input, and can generate IMU measurements */ -class ScenarioRunner { +class GTSAM_EXPORT ScenarioRunner { public: typedef imuBias::ConstantBias Bias; typedef boost::shared_ptr SharedParams; From 33bda1ef71186bed91067d458d381fb5ff6b328d Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Fri, 12 Jul 2019 20:42:45 -0400 Subject: [PATCH 07/15] Resolved several MSVC compiling errors * The check.base unit tests all pass now. * The gstam_matlab_wrapper class compiles with now errors now. * Note that I had to remove all LieMatrix, LieVector, and LieScalar stuff to get this to work... --- gtsam.h | 93 --------------------- gtsam/CMakeLists.txt | 7 ++ gtsam/base/Matrix.h | 2 +- gtsam/base/tests/testLieMatrix.cpp | 70 ---------------- gtsam/base/tests/testLieScalar.cpp | 64 -------------- gtsam/base/tests/testLieVector.cpp | 66 --------------- gtsam/base/tests/testTestableAssertions.cpp | 10 --- 7 files changed, 8 insertions(+), 304 deletions(-) delete mode 100644 gtsam/base/tests/testLieMatrix.cpp delete mode 100644 gtsam/base/tests/testLieScalar.cpp delete mode 100644 gtsam/base/tests/testLieVector.cpp diff --git a/gtsam.h b/gtsam.h index 826f8472e..d86887e8b 100644 --- a/gtsam.h +++ b/gtsam.h @@ -286,99 +286,6 @@ virtual class GenericValue : gtsam::Value { void serializable() const; }; -#include -class LieScalar { - // Standard constructors - LieScalar(); - LieScalar(double d); - - // Standard interface - double value() const; - - // Testable - void print(string s) const; - bool equals(const gtsam::LieScalar& expected, double tol) const; - - // Group - static gtsam::LieScalar identity(); - gtsam::LieScalar inverse() const; - gtsam::LieScalar compose(const gtsam::LieScalar& p) const; - gtsam::LieScalar between(const gtsam::LieScalar& l2) const; - - // Manifold - size_t dim() const; - gtsam::LieScalar retract(Vector v) const; - Vector localCoordinates(const gtsam::LieScalar& t2) const; - - // Lie group - static gtsam::LieScalar Expmap(Vector v); - static Vector Logmap(const gtsam::LieScalar& p); -}; - -#include -class LieVector { - // Standard constructors - LieVector(); - LieVector(Vector v); - - // Standard interface - Vector vector() const; - - // Testable - void print(string s) const; - bool equals(const gtsam::LieVector& expected, double tol) const; - - // Group - static gtsam::LieVector identity(); - gtsam::LieVector inverse() const; - gtsam::LieVector compose(const gtsam::LieVector& p) const; - gtsam::LieVector between(const gtsam::LieVector& l2) const; - - // Manifold - size_t dim() const; - gtsam::LieVector retract(Vector v) const; - Vector localCoordinates(const gtsam::LieVector& t2) const; - - // Lie group - static gtsam::LieVector Expmap(Vector v); - static Vector Logmap(const gtsam::LieVector& p); - - // enabling serialization functionality - void serialize() const; -}; - -#include -class LieMatrix { - // Standard constructors - LieMatrix(); - LieMatrix(Matrix v); - - // Standard interface - Matrix matrix() const; - - // Testable - void print(string s) const; - bool equals(const gtsam::LieMatrix& expected, double tol) const; - - // Group - static gtsam::LieMatrix identity(); - gtsam::LieMatrix inverse() const; - gtsam::LieMatrix compose(const gtsam::LieMatrix& p) const; - gtsam::LieMatrix between(const gtsam::LieMatrix& l2) const; - - // Manifold - size_t dim() const; - gtsam::LieMatrix retract(Vector v) const; - Vector localCoordinates(const gtsam::LieMatrix & t2) const; - - // Lie group - static gtsam::LieMatrix Expmap(Vector v); - static Vector Logmap(const gtsam::LieMatrix& p); - - // enabling serialization functionality - void serialize() const; -}; - //************************************************************************* // geometry //************************************************************************* diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index b4a33943e..b80f1626c 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -39,6 +39,12 @@ set (excluded_sources #"") set (excluded_headers #"") "${CMAKE_CURRENT_SOURCE_DIR}/slam/serialization.h" + "${CMAKE_CURRENT_SOURCE_DIR}/base/LieMatrix.h" + "${CMAKE_CURRENT_SOURCE_DIR}/base/LieVector.h" + "${CMAKE_CURRENT_SOURCE_DIR}/base/LieScalar.h" + "${CMAKE_CURRENT_SOURCE_DIR}/base/deprecated/LieMatrix.h" + "${CMAKE_CURRENT_SOURCE_DIR}/base/deprecated/LieVector.h" + "${CMAKE_CURRENT_SOURCE_DIR}/base/deprecated/LieScalar.h" ) if(GTSAM_USE_QUATERNIONS) @@ -56,6 +62,7 @@ foreach(subdir ${gtsam_subdirs}) # Build convenience libraries file(GLOB_RECURSE subdir_srcs "${subdir}/*.cpp" "${subdir}/*.h") # Include header files so they show up in Visual Studio list(REMOVE_ITEM subdir_srcs ${excluded_sources}) + list(REMOVE_ITEM subdir_srcs ${excluded_headers}) file(GLOB subdir_test_files "${subdir}/tests/*") list(REMOVE_ITEM subdir_srcs ${subdir_test_files}) # Remove test files from sources compiled into library gtsam_assign_source_folders("${subdir_srcs}") # Create MSVC structure diff --git a/gtsam/base/Matrix.h b/gtsam/base/Matrix.h index 235cd30f3..8060ae7f4 100644 --- a/gtsam/base/Matrix.h +++ b/gtsam/base/Matrix.h @@ -299,7 +299,7 @@ GTSAM_EXPORT std::pair qr(const Matrix& A); * @param A is the input matrix, and is the output * @param clear_below_diagonal enables zeroing out below diagonal */ -void inplace_QR(Matrix& A); +GTSAM_EXPORT void inplace_QR(Matrix& A); /** * Imperative algorithm for in-place full elimination with diff --git a/gtsam/base/tests/testLieMatrix.cpp b/gtsam/base/tests/testLieMatrix.cpp deleted file mode 100644 index 8c68bf8a0..000000000 --- a/gtsam/base/tests/testLieMatrix.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file testLieMatrix.cpp - * @author Richard Roberts - */ - -#include -#include -#include -#include - -using namespace gtsam; - -GTSAM_CONCEPT_TESTABLE_INST(LieMatrix) -GTSAM_CONCEPT_LIE_INST(LieMatrix) - -/* ************************************************************************* */ -TEST( LieMatrix, construction ) { - Matrix m = (Matrix(2,2) << 1.0,2.0, 3.0,4.0).finished(); - LieMatrix lie1(m), lie2(m); - - EXPECT(traits::GetDimension(m) == 4); - EXPECT(assert_equal(m, lie1.matrix())); - EXPECT(assert_equal(lie1, lie2)); -} - -/* ************************************************************************* */ -TEST( LieMatrix, other_constructors ) { - Matrix init = (Matrix(2,2) << 10.0,20.0, 30.0,40.0).finished(); - LieMatrix exp(init); - double data[] = {10,30,20,40}; - LieMatrix b(2,2,data); - EXPECT(assert_equal(exp, b)); -} - -/* ************************************************************************* */ -TEST(LieMatrix, retract) { - LieMatrix init((Matrix(2,2) << 1.0,2.0,3.0,4.0).finished()); - Vector update = (Vector(4) << 3.0, 4.0, 6.0, 7.0).finished(); - - LieMatrix expected((Matrix(2,2) << 4.0, 6.0, 9.0, 11.0).finished()); - LieMatrix actual = traits::Retract(init,update); - - EXPECT(assert_equal(expected, actual)); - - Vector expectedUpdate = update; - Vector actualUpdate = traits::Local(init,actual); - - EXPECT(assert_equal(expectedUpdate, actualUpdate)); - - Vector expectedLogmap = (Vector(4) << 1, 2, 3, 4).finished(); - Vector actualLogmap = traits::Logmap(LieMatrix((Matrix(2,2) << 1.0, 2.0, 3.0, 4.0).finished())); - EXPECT(assert_equal(expectedLogmap, actualLogmap)); -} - -/* ************************************************************************* */ -int main() { TestResult tr; return TestRegistry::runAllTests(tr); } -/* ************************************************************************* */ - - diff --git a/gtsam/base/tests/testLieScalar.cpp b/gtsam/base/tests/testLieScalar.cpp deleted file mode 100644 index 74f5e0d41..000000000 --- a/gtsam/base/tests/testLieScalar.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file testLieScalar.cpp - * @author Kai Ni - */ - -#include -#include -#include -#include - -using namespace gtsam; - -GTSAM_CONCEPT_TESTABLE_INST(LieScalar) -GTSAM_CONCEPT_LIE_INST(LieScalar) - -const double tol=1e-9; - -//****************************************************************************** -TEST(LieScalar , Concept) { - BOOST_CONCEPT_ASSERT((IsGroup)); - BOOST_CONCEPT_ASSERT((IsManifold)); - BOOST_CONCEPT_ASSERT((IsLieGroup)); -} - -//****************************************************************************** -TEST(LieScalar , Invariants) { - LieScalar lie1(2), lie2(3); - CHECK(check_group_invariants(lie1, lie2)); - CHECK(check_manifold_invariants(lie1, lie2)); -} - -/* ************************************************************************* */ -TEST( testLieScalar, construction ) { - double d = 2.; - LieScalar lie1(d), lie2(d); - - EXPECT_DOUBLES_EQUAL(2., lie1.value(),tol); - EXPECT_DOUBLES_EQUAL(2., lie2.value(),tol); - EXPECT(traits::dimension == 1); - EXPECT(assert_equal(lie1, lie2)); -} - -/* ************************************************************************* */ -TEST( testLieScalar, localCoordinates ) { - LieScalar lie1(1.), lie2(3.); - - Vector1 actual = traits::Local(lie1, lie2); - EXPECT( assert_equal((Vector)(Vector(1) << 2).finished(), actual)); -} - -/* ************************************************************************* */ -int main() { TestResult tr; return TestRegistry::runAllTests(tr); } -/* ************************************************************************* */ diff --git a/gtsam/base/tests/testLieVector.cpp b/gtsam/base/tests/testLieVector.cpp deleted file mode 100644 index 76c4fc490..000000000 --- a/gtsam/base/tests/testLieVector.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file testLieVector.cpp - * @author Alex Cunningham - */ - -#include -#include -#include -#include - -using namespace gtsam; - -GTSAM_CONCEPT_TESTABLE_INST(LieVector) -GTSAM_CONCEPT_LIE_INST(LieVector) - -//****************************************************************************** -TEST(LieVector , Concept) { - BOOST_CONCEPT_ASSERT((IsGroup)); - BOOST_CONCEPT_ASSERT((IsManifold)); - BOOST_CONCEPT_ASSERT((IsLieGroup)); -} - -//****************************************************************************** -TEST(LieVector , Invariants) { - Vector v = Vector3(1.0, 2.0, 3.0); - LieVector lie1(v), lie2(v); - check_manifold_invariants(lie1, lie2); -} - -//****************************************************************************** -TEST( testLieVector, construction ) { - Vector v = Vector3(1.0, 2.0, 3.0); - LieVector lie1(v), lie2(v); - - EXPECT(lie1.dim() == 3); - EXPECT(assert_equal(v, lie1.vector())); - EXPECT(assert_equal(lie1, lie2)); -} - -//****************************************************************************** -TEST( testLieVector, other_constructors ) { - Vector init = Vector2(10.0, 20.0); - LieVector exp(init); - double data[] = { 10, 20 }; - LieVector b(2, data); - EXPECT(assert_equal(exp, b)); -} - -/* ************************************************************************* */ -int main() { - TestResult tr; - return TestRegistry::runAllTests(tr); -} -/* ************************************************************************* */ - diff --git a/gtsam/base/tests/testTestableAssertions.cpp b/gtsam/base/tests/testTestableAssertions.cpp index 305aa7ca9..3fd2e9003 100644 --- a/gtsam/base/tests/testTestableAssertions.cpp +++ b/gtsam/base/tests/testTestableAssertions.cpp @@ -15,20 +15,10 @@ */ #include -#include #include using namespace gtsam; -/* ************************************************************************* */ -TEST( testTestableAssertions, optional ) { - typedef boost::optional OptionalScalar; - LieScalar x(1.0); - OptionalScalar ox(x), dummy = boost::none; - EXPECT(assert_equal(ox, ox)); - EXPECT(assert_equal(x, ox)); - EXPECT(assert_equal(dummy, dummy)); -} /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); } From 063cf72c00482a7c1b36be003efac38742aa1e50 Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Sat, 13 Jul 2019 22:08:29 -0400 Subject: [PATCH 08/15] Revert "Resolved several MSVC compiling errors" -- bring back Lie* This reverts commit 33bda1ef71186bed91067d458d381fb5ff6b328d. --- gtsam.h | 93 +++++++++++++++++++++ gtsam/CMakeLists.txt | 7 -- gtsam/base/Matrix.h | 2 +- gtsam/base/tests/testLieMatrix.cpp | 70 ++++++++++++++++ gtsam/base/tests/testLieScalar.cpp | 64 ++++++++++++++ gtsam/base/tests/testLieVector.cpp | 66 +++++++++++++++ gtsam/base/tests/testTestableAssertions.cpp | 10 +++ 7 files changed, 304 insertions(+), 8 deletions(-) create mode 100644 gtsam/base/tests/testLieMatrix.cpp create mode 100644 gtsam/base/tests/testLieScalar.cpp create mode 100644 gtsam/base/tests/testLieVector.cpp diff --git a/gtsam.h b/gtsam.h index d86887e8b..826f8472e 100644 --- a/gtsam.h +++ b/gtsam.h @@ -286,6 +286,99 @@ virtual class GenericValue : gtsam::Value { void serializable() const; }; +#include +class LieScalar { + // Standard constructors + LieScalar(); + LieScalar(double d); + + // Standard interface + double value() const; + + // Testable + void print(string s) const; + bool equals(const gtsam::LieScalar& expected, double tol) const; + + // Group + static gtsam::LieScalar identity(); + gtsam::LieScalar inverse() const; + gtsam::LieScalar compose(const gtsam::LieScalar& p) const; + gtsam::LieScalar between(const gtsam::LieScalar& l2) const; + + // Manifold + size_t dim() const; + gtsam::LieScalar retract(Vector v) const; + Vector localCoordinates(const gtsam::LieScalar& t2) const; + + // Lie group + static gtsam::LieScalar Expmap(Vector v); + static Vector Logmap(const gtsam::LieScalar& p); +}; + +#include +class LieVector { + // Standard constructors + LieVector(); + LieVector(Vector v); + + // Standard interface + Vector vector() const; + + // Testable + void print(string s) const; + bool equals(const gtsam::LieVector& expected, double tol) const; + + // Group + static gtsam::LieVector identity(); + gtsam::LieVector inverse() const; + gtsam::LieVector compose(const gtsam::LieVector& p) const; + gtsam::LieVector between(const gtsam::LieVector& l2) const; + + // Manifold + size_t dim() const; + gtsam::LieVector retract(Vector v) const; + Vector localCoordinates(const gtsam::LieVector& t2) const; + + // Lie group + static gtsam::LieVector Expmap(Vector v); + static Vector Logmap(const gtsam::LieVector& p); + + // enabling serialization functionality + void serialize() const; +}; + +#include +class LieMatrix { + // Standard constructors + LieMatrix(); + LieMatrix(Matrix v); + + // Standard interface + Matrix matrix() const; + + // Testable + void print(string s) const; + bool equals(const gtsam::LieMatrix& expected, double tol) const; + + // Group + static gtsam::LieMatrix identity(); + gtsam::LieMatrix inverse() const; + gtsam::LieMatrix compose(const gtsam::LieMatrix& p) const; + gtsam::LieMatrix between(const gtsam::LieMatrix& l2) const; + + // Manifold + size_t dim() const; + gtsam::LieMatrix retract(Vector v) const; + Vector localCoordinates(const gtsam::LieMatrix & t2) const; + + // Lie group + static gtsam::LieMatrix Expmap(Vector v); + static Vector Logmap(const gtsam::LieMatrix& p); + + // enabling serialization functionality + void serialize() const; +}; + //************************************************************************* // geometry //************************************************************************* diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index b80f1626c..b4a33943e 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -39,12 +39,6 @@ set (excluded_sources #"") set (excluded_headers #"") "${CMAKE_CURRENT_SOURCE_DIR}/slam/serialization.h" - "${CMAKE_CURRENT_SOURCE_DIR}/base/LieMatrix.h" - "${CMAKE_CURRENT_SOURCE_DIR}/base/LieVector.h" - "${CMAKE_CURRENT_SOURCE_DIR}/base/LieScalar.h" - "${CMAKE_CURRENT_SOURCE_DIR}/base/deprecated/LieMatrix.h" - "${CMAKE_CURRENT_SOURCE_DIR}/base/deprecated/LieVector.h" - "${CMAKE_CURRENT_SOURCE_DIR}/base/deprecated/LieScalar.h" ) if(GTSAM_USE_QUATERNIONS) @@ -62,7 +56,6 @@ foreach(subdir ${gtsam_subdirs}) # Build convenience libraries file(GLOB_RECURSE subdir_srcs "${subdir}/*.cpp" "${subdir}/*.h") # Include header files so they show up in Visual Studio list(REMOVE_ITEM subdir_srcs ${excluded_sources}) - list(REMOVE_ITEM subdir_srcs ${excluded_headers}) file(GLOB subdir_test_files "${subdir}/tests/*") list(REMOVE_ITEM subdir_srcs ${subdir_test_files}) # Remove test files from sources compiled into library gtsam_assign_source_folders("${subdir_srcs}") # Create MSVC structure diff --git a/gtsam/base/Matrix.h b/gtsam/base/Matrix.h index 8060ae7f4..235cd30f3 100644 --- a/gtsam/base/Matrix.h +++ b/gtsam/base/Matrix.h @@ -299,7 +299,7 @@ GTSAM_EXPORT std::pair qr(const Matrix& A); * @param A is the input matrix, and is the output * @param clear_below_diagonal enables zeroing out below diagonal */ -GTSAM_EXPORT void inplace_QR(Matrix& A); +void inplace_QR(Matrix& A); /** * Imperative algorithm for in-place full elimination with diff --git a/gtsam/base/tests/testLieMatrix.cpp b/gtsam/base/tests/testLieMatrix.cpp new file mode 100644 index 000000000..8c68bf8a0 --- /dev/null +++ b/gtsam/base/tests/testLieMatrix.cpp @@ -0,0 +1,70 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file testLieMatrix.cpp + * @author Richard Roberts + */ + +#include +#include +#include +#include + +using namespace gtsam; + +GTSAM_CONCEPT_TESTABLE_INST(LieMatrix) +GTSAM_CONCEPT_LIE_INST(LieMatrix) + +/* ************************************************************************* */ +TEST( LieMatrix, construction ) { + Matrix m = (Matrix(2,2) << 1.0,2.0, 3.0,4.0).finished(); + LieMatrix lie1(m), lie2(m); + + EXPECT(traits::GetDimension(m) == 4); + EXPECT(assert_equal(m, lie1.matrix())); + EXPECT(assert_equal(lie1, lie2)); +} + +/* ************************************************************************* */ +TEST( LieMatrix, other_constructors ) { + Matrix init = (Matrix(2,2) << 10.0,20.0, 30.0,40.0).finished(); + LieMatrix exp(init); + double data[] = {10,30,20,40}; + LieMatrix b(2,2,data); + EXPECT(assert_equal(exp, b)); +} + +/* ************************************************************************* */ +TEST(LieMatrix, retract) { + LieMatrix init((Matrix(2,2) << 1.0,2.0,3.0,4.0).finished()); + Vector update = (Vector(4) << 3.0, 4.0, 6.0, 7.0).finished(); + + LieMatrix expected((Matrix(2,2) << 4.0, 6.0, 9.0, 11.0).finished()); + LieMatrix actual = traits::Retract(init,update); + + EXPECT(assert_equal(expected, actual)); + + Vector expectedUpdate = update; + Vector actualUpdate = traits::Local(init,actual); + + EXPECT(assert_equal(expectedUpdate, actualUpdate)); + + Vector expectedLogmap = (Vector(4) << 1, 2, 3, 4).finished(); + Vector actualLogmap = traits::Logmap(LieMatrix((Matrix(2,2) << 1.0, 2.0, 3.0, 4.0).finished())); + EXPECT(assert_equal(expectedLogmap, actualLogmap)); +} + +/* ************************************************************************* */ +int main() { TestResult tr; return TestRegistry::runAllTests(tr); } +/* ************************************************************************* */ + + diff --git a/gtsam/base/tests/testLieScalar.cpp b/gtsam/base/tests/testLieScalar.cpp new file mode 100644 index 000000000..74f5e0d41 --- /dev/null +++ b/gtsam/base/tests/testLieScalar.cpp @@ -0,0 +1,64 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file testLieScalar.cpp + * @author Kai Ni + */ + +#include +#include +#include +#include + +using namespace gtsam; + +GTSAM_CONCEPT_TESTABLE_INST(LieScalar) +GTSAM_CONCEPT_LIE_INST(LieScalar) + +const double tol=1e-9; + +//****************************************************************************** +TEST(LieScalar , Concept) { + BOOST_CONCEPT_ASSERT((IsGroup)); + BOOST_CONCEPT_ASSERT((IsManifold)); + BOOST_CONCEPT_ASSERT((IsLieGroup)); +} + +//****************************************************************************** +TEST(LieScalar , Invariants) { + LieScalar lie1(2), lie2(3); + CHECK(check_group_invariants(lie1, lie2)); + CHECK(check_manifold_invariants(lie1, lie2)); +} + +/* ************************************************************************* */ +TEST( testLieScalar, construction ) { + double d = 2.; + LieScalar lie1(d), lie2(d); + + EXPECT_DOUBLES_EQUAL(2., lie1.value(),tol); + EXPECT_DOUBLES_EQUAL(2., lie2.value(),tol); + EXPECT(traits::dimension == 1); + EXPECT(assert_equal(lie1, lie2)); +} + +/* ************************************************************************* */ +TEST( testLieScalar, localCoordinates ) { + LieScalar lie1(1.), lie2(3.); + + Vector1 actual = traits::Local(lie1, lie2); + EXPECT( assert_equal((Vector)(Vector(1) << 2).finished(), actual)); +} + +/* ************************************************************************* */ +int main() { TestResult tr; return TestRegistry::runAllTests(tr); } +/* ************************************************************************* */ diff --git a/gtsam/base/tests/testLieVector.cpp b/gtsam/base/tests/testLieVector.cpp new file mode 100644 index 000000000..76c4fc490 --- /dev/null +++ b/gtsam/base/tests/testLieVector.cpp @@ -0,0 +1,66 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file testLieVector.cpp + * @author Alex Cunningham + */ + +#include +#include +#include +#include + +using namespace gtsam; + +GTSAM_CONCEPT_TESTABLE_INST(LieVector) +GTSAM_CONCEPT_LIE_INST(LieVector) + +//****************************************************************************** +TEST(LieVector , Concept) { + BOOST_CONCEPT_ASSERT((IsGroup)); + BOOST_CONCEPT_ASSERT((IsManifold)); + BOOST_CONCEPT_ASSERT((IsLieGroup)); +} + +//****************************************************************************** +TEST(LieVector , Invariants) { + Vector v = Vector3(1.0, 2.0, 3.0); + LieVector lie1(v), lie2(v); + check_manifold_invariants(lie1, lie2); +} + +//****************************************************************************** +TEST( testLieVector, construction ) { + Vector v = Vector3(1.0, 2.0, 3.0); + LieVector lie1(v), lie2(v); + + EXPECT(lie1.dim() == 3); + EXPECT(assert_equal(v, lie1.vector())); + EXPECT(assert_equal(lie1, lie2)); +} + +//****************************************************************************** +TEST( testLieVector, other_constructors ) { + Vector init = Vector2(10.0, 20.0); + LieVector exp(init); + double data[] = { 10, 20 }; + LieVector b(2, data); + EXPECT(assert_equal(exp, b)); +} + +/* ************************************************************************* */ +int main() { + TestResult tr; + return TestRegistry::runAllTests(tr); +} +/* ************************************************************************* */ + diff --git a/gtsam/base/tests/testTestableAssertions.cpp b/gtsam/base/tests/testTestableAssertions.cpp index 3fd2e9003..305aa7ca9 100644 --- a/gtsam/base/tests/testTestableAssertions.cpp +++ b/gtsam/base/tests/testTestableAssertions.cpp @@ -15,10 +15,20 @@ */ #include +#include #include using namespace gtsam; +/* ************************************************************************* */ +TEST( testTestableAssertions, optional ) { + typedef boost::optional OptionalScalar; + LieScalar x(1.0); + OptionalScalar ox(x), dummy = boost::none; + EXPECT(assert_equal(ox, ox)); + EXPECT(assert_equal(x, ox)); + EXPECT(assert_equal(dummy, dummy)); +} /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); } From 44faca1b1c74c64f40082c97d23bf41d8059cc87 Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Sat, 13 Jul 2019 22:35:08 -0400 Subject: [PATCH 09/15] Fixed compilation issues for MSVC -- for real this time. --- gtsam/base/Matrix.h | 2 +- gtsam/base/deprecated/LieMatrix.h | 2 +- gtsam/base/deprecated/LieScalar.h | 2 +- gtsam/base/deprecated/LieVector.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gtsam/base/Matrix.h b/gtsam/base/Matrix.h index 235cd30f3..8060ae7f4 100644 --- a/gtsam/base/Matrix.h +++ b/gtsam/base/Matrix.h @@ -299,7 +299,7 @@ GTSAM_EXPORT std::pair qr(const Matrix& A); * @param A is the input matrix, and is the output * @param clear_below_diagonal enables zeroing out below diagonal */ -void inplace_QR(Matrix& A); +GTSAM_EXPORT void inplace_QR(Matrix& A); /** * Imperative algorithm for in-place full elimination with diff --git a/gtsam/base/deprecated/LieMatrix.h b/gtsam/base/deprecated/LieMatrix.h index 953537bf7..a3d0a4328 100644 --- a/gtsam/base/deprecated/LieMatrix.h +++ b/gtsam/base/deprecated/LieMatrix.h @@ -29,7 +29,7 @@ namespace gtsam { * we can directly add double, Vector, and Matrix into values now, because of * gtsam::traits. */ -struct GTSAM_EXPORT LieMatrix : public Matrix { +struct LieMatrix : public Matrix { /// @name Constructors /// @{ diff --git a/gtsam/base/deprecated/LieScalar.h b/gtsam/base/deprecated/LieScalar.h index 50ea9d695..4e9bfb7db 100644 --- a/gtsam/base/deprecated/LieScalar.h +++ b/gtsam/base/deprecated/LieScalar.h @@ -28,7 +28,7 @@ namespace gtsam { * we can directly add double, Vector, and Matrix into values now, because of * gtsam::traits. */ - struct GTSAM_EXPORT LieScalar { + struct LieScalar { enum { dimension = 1 }; diff --git a/gtsam/base/deprecated/LieVector.h b/gtsam/base/deprecated/LieVector.h index 60c8103e2..745189c3d 100644 --- a/gtsam/base/deprecated/LieVector.h +++ b/gtsam/base/deprecated/LieVector.h @@ -27,7 +27,7 @@ namespace gtsam { * we can directly add double, Vector, and Matrix into values now, because of * gtsam::traits. */ -struct GTSAM_EXPORT LieVector : public Vector { +struct LieVector : public Vector { enum { dimension = Eigen::Dynamic }; From ffb3043284cfcfd48a84f0a5713236570e0a6d60 Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Sun, 14 Jul 2019 00:14:16 -0400 Subject: [PATCH 10/15] More GTSAM_EXPORT fixes. This allows gtsam_unstable to compile --- gtsam/geometry/Point2.h | 16 ++++++++-------- gtsam/geometry/Point3.h | 20 ++++++++++---------- gtsam/geometry/Pose2.h | 38 +++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/gtsam/geometry/Point2.h b/gtsam/geometry/Point2.h index 30e902c2b..718fb2992 100644 --- a/gtsam/geometry/Point2.h +++ b/gtsam/geometry/Point2.h @@ -37,7 +37,7 @@ namespace gtsam { * @addtogroup geometry * \nosubgrouping */ -class GTSAM_EXPORT Point2 : public Vector2 { +class Point2 : public Vector2 { private: public: @@ -66,10 +66,10 @@ public: /// @{ /// print with optional string - void print(const std::string& s = "") const; + GTSAM_EXPORT void print(const std::string& s = "") const; /// equals with an tolerance, prints out message if unequal - bool equals(const Point2& q, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const Point2& q, double tol = 1e-9) const; /// @} /// @name Group @@ -86,10 +86,10 @@ public: Point2 unit() const { return *this/norm(); } /** norm of point, with derivative */ - double norm(OptionalJacobian<1,2> H = boost::none) const; + GTSAM_EXPORT double norm(OptionalJacobian<1,2> H = boost::none) const; /** distance between two points */ - double distance(const Point2& p2, OptionalJacobian<1,2> H1 = boost::none, + GTSAM_EXPORT double distance(const Point2& p2, OptionalJacobian<1,2> H1 = boost::none, OptionalJacobian<1,2> H2 = boost::none) const; /// @} @@ -124,9 +124,9 @@ public: static Vector2 Logmap(const Point2& p) { return p;} static Point2 Expmap(const Vector2& v) { return Point2(v);} inline double dist(const Point2& p2) const {return distance(p2);} - static boost::optional CircleCircleIntersection(double R_d, double r_d, double tol = 1e-9); - static std::list CircleCircleIntersection(Point2 c1, Point2 c2, boost::optional fh); - static std::list CircleCircleIntersection(Point2 c1, double r1, Point2 c2, double r2, double tol = 1e-9); + GTSAM_EXPORT static boost::optional CircleCircleIntersection(double R_d, double r_d, double tol = 1e-9); + GTSAM_EXPORT static std::list CircleCircleIntersection(Point2 c1, Point2 c2, boost::optional fh); + GTSAM_EXPORT static std::list CircleCircleIntersection(Point2 c1, double r1, Point2 c2, double r2, double tol = 1e-9); /// @} #endif diff --git a/gtsam/geometry/Point3.h b/gtsam/geometry/Point3.h index 215161b3a..3b2330403 100644 --- a/gtsam/geometry/Point3.h +++ b/gtsam/geometry/Point3.h @@ -42,7 +42,7 @@ namespace gtsam { * @addtogroup geometry * \nosubgrouping */ -class GTSAM_EXPORT Point3 : public Vector3 { +class Point3 : public Vector3 { public: @@ -63,10 +63,10 @@ class GTSAM_EXPORT Point3 : public Vector3 { /// @{ /** print with optional string */ - void print(const std::string& s = "") const; + GTSAM_EXPORT void print(const std::string& s = "") const; /** equals with an tolerance */ - bool equals(const Point3& p, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const Point3& p, double tol = 1e-9) const; /// @} /// @name Group @@ -80,21 +80,21 @@ class GTSAM_EXPORT Point3 : public Vector3 { /// @{ /** distance between two points */ - double distance(const Point3& p2, OptionalJacobian<1, 3> H1 = boost::none, + GTSAM_EXPORT double distance(const Point3& p2, OptionalJacobian<1, 3> H1 = boost::none, OptionalJacobian<1, 3> H2 = boost::none) const; /** Distance of the point from the origin, with Jacobian */ - double norm(OptionalJacobian<1,3> H = boost::none) const; + GTSAM_EXPORT double norm(OptionalJacobian<1,3> H = boost::none) const; /** normalize, with optional Jacobian */ - Point3 normalized(OptionalJacobian<3, 3> H = boost::none) const; + GTSAM_EXPORT Point3 normalized(OptionalJacobian<3, 3> H = boost::none) const; /** cross product @return this x q */ - Point3 cross(const Point3 &q, OptionalJacobian<3, 3> H_p = boost::none, // + GTSAM_EXPORT Point3 cross(const Point3 &q, OptionalJacobian<3, 3> H_p = boost::none, // OptionalJacobian<3, 3> H_q = boost::none) const; /** dot product @return this * q*/ - double dot(const Point3 &q, OptionalJacobian<1, 3> H_p = boost::none, // + GTSAM_EXPORT double dot(const Point3 &q, OptionalJacobian<1, 3> H_p = boost::none, // OptionalJacobian<1, 3> H_q = boost::none) const; /// @} @@ -130,9 +130,9 @@ class GTSAM_EXPORT Point3 : public Vector3 { static Point3 Expmap(const Vector3& v) { return Point3(v);} inline double dist(const Point3& q) const { return (q - *this).norm(); } Point3 normalize(OptionalJacobian<3, 3> H = boost::none) const { return normalized(H);} - Point3 add(const Point3& q, OptionalJacobian<3, 3> H1 = boost::none, + GTSAM_EXPORT Point3 add(const Point3& q, OptionalJacobian<3, 3> H1 = boost::none, OptionalJacobian<3, 3> H2 = boost::none) const; - Point3 sub(const Point3& q, OptionalJacobian<3, 3> H1 = boost::none, + GTSAM_EXPORT Point3 sub(const Point3& q, OptionalJacobian<3, 3> H1 = boost::none, OptionalJacobian<3, 3> H2 = boost::none) const; /// @} #endif diff --git a/gtsam/geometry/Pose2.h b/gtsam/geometry/Pose2.h index efd6a7f88..388318827 100644 --- a/gtsam/geometry/Pose2.h +++ b/gtsam/geometry/Pose2.h @@ -33,7 +33,7 @@ namespace gtsam { * @addtogroup geometry * \nosubgrouping */ -class GTSAM_EXPORT Pose2: public LieGroup { +class Pose2: public LieGroup { public: @@ -97,10 +97,10 @@ public: /// @{ /** print with optional string */ - void print(const std::string& s = "") const; + GTSAM_EXPORT void print(const std::string& s = "") const; /** assert equality up to a tolerance */ - bool equals(const Pose2& pose, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const Pose2& pose, double tol = 1e-9) const; /// @} /// @name Group @@ -110,7 +110,7 @@ public: inline static Pose2 identity() { return Pose2(); } /// inverse - Pose2 inverse() const; + GTSAM_EXPORT Pose2 inverse() const; /// compose syntactic sugar inline Pose2 operator*(const Pose2& p2) const { @@ -122,16 +122,16 @@ public: /// @{ ///Exponential map at identity - create a rotation from canonical coordinates \f$ [T_x,T_y,\theta] \f$ - static Pose2 Expmap(const Vector3& xi, ChartJacobian H = boost::none); + GTSAM_EXPORT static Pose2 Expmap(const Vector3& xi, ChartJacobian H = boost::none); ///Log map at identity - return the canonical coordinates \f$ [T_x,T_y,\theta] \f$ of this rotation - static Vector3 Logmap(const Pose2& p, ChartJacobian H = boost::none); + GTSAM_EXPORT static Vector3 Logmap(const Pose2& p, ChartJacobian H = boost::none); /** * Calculate Adjoint map * Ad_pose is 3*3 matrix that when applied to twist xi \f$ [T_x,T_y,\theta] \f$, returns Ad_pose(xi) */ - Matrix3 AdjointMap() const; + GTSAM_EXPORT Matrix3 AdjointMap() const; /// Apply AdjointMap to twist xi inline Vector3 Adjoint(const Vector3& xi) const { @@ -141,7 +141,7 @@ public: /** * Compute the [ad(w,v)] operator for SE2 as in [Kobilarov09siggraph], pg 19 */ - static Matrix3 adjointMap(const Vector3& v); + GTSAM_EXPORT static Matrix3 adjointMap(const Vector3& v); /** * Action of the adjointMap on a Lie-algebra vector y, with optional derivatives @@ -177,15 +177,15 @@ public: } /// Derivative of Expmap - static Matrix3 ExpmapDerivative(const Vector3& v); + GTSAM_EXPORT static Matrix3 ExpmapDerivative(const Vector3& v); /// Derivative of Logmap - static Matrix3 LogmapDerivative(const Pose2& v); + GTSAM_EXPORT static Matrix3 LogmapDerivative(const Pose2& v); // Chart at origin, depends on compile-time flag SLOW_BUT_CORRECT_EXPMAP struct ChartAtOrigin { - static Pose2 Retract(const Vector3& v, ChartJacobian H = boost::none); - static Vector3 Local(const Pose2& r, ChartJacobian H = boost::none); + GTSAM_EXPORT static Pose2 Retract(const Vector3& v, ChartJacobian H = boost::none); + GTSAM_EXPORT static Vector3 Local(const Pose2& r, ChartJacobian H = boost::none); }; using LieGroup::inverse; // version with derivative @@ -195,12 +195,12 @@ public: /// @{ /** Return point coordinates in pose coordinate frame */ - Point2 transformTo(const Point2& point, + GTSAM_EXPORT Point2 transformTo(const Point2& point, OptionalJacobian<2, 3> Dpose = boost::none, OptionalJacobian<2, 2> Dpoint = boost::none) const; /** Return point coordinates in global frame */ - Point2 transformFrom(const Point2& point, + GTSAM_EXPORT Point2 transformFrom(const Point2& point, OptionalJacobian<2, 3> Dpose = boost::none, OptionalJacobian<2, 2> Dpoint = boost::none) const; @@ -233,14 +233,14 @@ public: inline const Rot2& rotation() const { return r_; } //// return transformation matrix - Matrix3 matrix() const; + GTSAM_EXPORT Matrix3 matrix() const; /** * Calculate bearing to a landmark * @param point 2D location of landmark * @return 2D rotation \f$ \in SO(2) \f$ */ - Rot2 bearing(const Point2& point, + GTSAM_EXPORT Rot2 bearing(const Point2& point, OptionalJacobian<1, 3> H1=boost::none, OptionalJacobian<1, 2> H2=boost::none) const; /** @@ -248,7 +248,7 @@ public: * @param point SO(2) location of other pose * @return 2D rotation \f$ \in SO(2) \f$ */ - Rot2 bearing(const Pose2& pose, + GTSAM_EXPORT Rot2 bearing(const Pose2& pose, OptionalJacobian<1, 3> H1=boost::none, OptionalJacobian<1, 3> H2=boost::none) const; /** @@ -256,7 +256,7 @@ public: * @param point 2D location of landmark * @return range (double) */ - double range(const Point2& point, + GTSAM_EXPORT double range(const Point2& point, OptionalJacobian<1, 3> H1=boost::none, OptionalJacobian<1, 2> H2=boost::none) const; @@ -265,7 +265,7 @@ public: * @param point 2D location of other pose * @return range (double) */ - double range(const Pose2& point, + GTSAM_EXPORT double range(const Pose2& point, OptionalJacobian<1, 3> H1=boost::none, OptionalJacobian<1, 3> H2=boost::none) const; From e28fb84fef494109a1a928417da369f408b5b4eb Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Mon, 15 Jul 2019 11:43:54 -0400 Subject: [PATCH 11/15] Added document explaining GTSAM_EXPORT usage rules --- Using-GTSAM-EXPORT.md | 41 +++++++++++++++++++ gtsam/geometry/SO3.h | 12 +++--- gtsam/geometry/tests/testCalibratedCamera.cpp | 2 +- gtsam/geometry/tests/testPinholePose.cpp | 4 +- gtsam/geometry/tests/testQuaternion.cpp | 8 ++-- gtsam_unstable/geometry/Event.h | 6 +-- gtsam_unstable/geometry/Similarity3.h | 38 ++++++++--------- 7 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 Using-GTSAM-EXPORT.md diff --git a/Using-GTSAM-EXPORT.md b/Using-GTSAM-EXPORT.md new file mode 100644 index 000000000..6c8480d5d --- /dev/null +++ b/Using-GTSAM-EXPORT.md @@ -0,0 +1,41 @@ +# Using GTSAM_EXPORT + +To create a DLL in windows, the `GTSAM_EXPORT` keyword has been created and needs to be applied to different methods and classes in the code to expose this code outside of the DLL. However, there are several intricacies that make this more difficult than it sounds. In general, if you follow the following three rules, GTSAM_EXPORT should work properly. The rest of the document also describes (1) the common error message encountered when you are not following these rules and (2) the reasoning behind these usage rules. + +## Usage Rules +1. Put `GTSAM_EXPORT` in front of any function that you want exported in the DLL _if and only if_ that function is defined in a .cpp file, not just a .h file. +2. Use `GTSAM_EXPORT` in a class definition (i.e. `class GSTAM_EXPORT MyClass {...}`) only if: + * At least one of the functions inside that class is defined in a .cpp file and not just the .h file. + * You can `GTSAM_EXPORT` any class it inherits from as well. (Note that this implictly requires the class does not derive from a "header-only" class. Note that Eigen is a "header-only" library, so if your class derives from Eigen, _do not_ use `GTSAM_EXPORT` in the class definition!) +3. If you have defined a class using `GTSAM_EXPORT`, do not use `GTSAM_EXPORT` in any of its individual function declarations. (Note that you _can_ put `GTSAM_EXPORT` in the definition of individual functions within a class as long as you don't put `GTSAM_EXPORT` in the class definition.) + +## When is GTSAM_EXPORT being used incorrectly +Unfortunately, using `GTSAM_EXPORT` incorrectly often does not cause a compiler or linker error in the library that is being compiled, but only when you try to use that DLL in a different library. For example, an error in gtsam/base will often show up when compiling the check_base_program or the MATLAB wrapper, but not when compiling/linking gtsam itself. The most common errors will say something like: + +``` +Error LNK2019 unresolved external symbol "public: void __cdecl gtsam::SO3::print(class std::basic_string,class std::allocator > const &)const " (?print@SO3@gtsam@@QEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: static void __cdecl gtsam::Testable::Print(class gtsam::SO3 const &,class std::basic_string,class std::allocator > const &)" (?Print@?$Testable@VSO3@gtsam@@@gtsam@@SAXAEBVSO3@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) check_geometry_program C:\AFIT\lib\gtsam\build\gtsam\geometry\tests\testSO3.obj +``` + +Sorry for the long error message there, but I want to quickly decode it to help understand what is going on. First, there is an unresolved symbol `gtsam::SO3::print`. This can occur because _either_ `GTSAM_EXPORT` was not added to the print function definition when it should have been, _OR_ because `GTSAM_EXPORT` was added to the print function definition when it is fully declared in the header. This error was detected while compiling `check_geometry_program` and pulling in `...\testSO3.obj`. Specifically, within the function call `gtsam::Testabl::Print (...)`. Note that this error did _not_ occur when compiling the library that actually has SO3 inside of it. + +## But Why? +To me, the behavior of GTSAM_EXPORT was very baffling. However, I believe it can be explained by understanding the rules that MSVC operates under. + +First, we need to understand exactly what `GTSAM_EXPORT` does. When you use `GTSAM_EXPORT` on a function (or class) definition, it actually does two things. First, when you are building the library, it turns into a "dllexport" command, telling the compiler that this function should go into the DLL and be visible externally. When you pull in that same header for a different library, it switches to a "dllimport" command, telling the compiler it should find this function in a DLL somewhere. This leads to the first rule the compiler uses. (Note that I say "compiler rules" when the rules may actually be in the linker, but I am conflating the two terms here when I speak of the "compiler rules".) + +***Compiler Rule #1*** If a `dllimport` command is used in defining a function or class, that function or class _must_ be found in a DLL. + +Rule #1 doesn't seem very bad, until you combine it with rule #2 + +***Compiler Rule #2*** Anything defined in a header file is not included in a DLL. + +When these two rules are combined, you get some very confusing results. For example, a class which is completely defined in a header (e.g. LieMatrix) cannot use `GTSAM_EXPORT` in its definition. If LieMatrix is defined with `GTSAM_EXPORT`, then the compiler _must_ find LieMatrix in a DLL. Because LieMatrix is a header-only class, however, it can't find it, leading to a very confusing "I can't find this symbol" type of error. Note that the linker says it can't find the symbol even though the compiler found the header file that completely defines the class. + +This leads to another compiler rule that finishes explaining the usage rules proposed above. + +***Compiler Rule #3*** If a class is defined with `GTSAM_EXPORT`, then any classes it inherits from must be definable with a dllexport command as well. + +One of the most immediate results of this compiler rule is that any class that inherits from an Eigen class _cannot_ be defined with `GTSAM_EXPORT`. Because Eigen is a header-only class, compiler rule #2 prohibits any Eigen class from being defined with a "dllexport" command. Therefore, no Eigen inherited classes can use `GTSAM_EXPORT` either. (Note that individual functions with an inherited class can be "exported." Just not the entire class.) + +## Conclusion +Hopefully, this little document clarifies when `GTSAM_EXPORT` should and should not be used whenever future GTSAM code is being written. Following the usage rules above, I have been able to get all of the libraries, together with their test and wrapping libraries, to compile/link successfully. \ No newline at end of file diff --git a/gtsam/geometry/SO3.h b/gtsam/geometry/SO3.h index 3b27d45c5..a4f6861cc 100644 --- a/gtsam/geometry/SO3.h +++ b/gtsam/geometry/SO3.h @@ -62,13 +62,13 @@ public: } /// Static, named constructor TODO think about relation with above - static SO3 AxisAngle(const Vector3& axis, double theta); + GTSAM_EXPORT static SO3 AxisAngle(const Vector3& axis, double theta); /// @} /// @name Testable /// @{ - void print(const std::string& s) const; + GTSAM_EXPORT void print(const std::string& s) const; bool equals(const SO3 & R, double tol) const { return equal_with_abs_tol(*this, R, tol); @@ -96,19 +96,19 @@ public: * Exponential map at identity - create a rotation from canonical coordinates * \f$ [R_x,R_y,R_z] \f$ using Rodrigues' formula */ - static SO3 Expmap(const Vector3& omega, ChartJacobian H = boost::none); + GTSAM_EXPORT static SO3 Expmap(const Vector3& omega, ChartJacobian H = boost::none); /// Derivative of Expmap - static Matrix3 ExpmapDerivative(const Vector3& omega); + GTSAM_EXPORT static Matrix3 ExpmapDerivative(const Vector3& omega); /** * Log map at identity - returns the canonical coordinates * \f$ [R_x,R_y,R_z] \f$ of this rotation */ - static Vector3 Logmap(const SO3& R, ChartJacobian H = boost::none); + GTSAM_EXPORT static Vector3 Logmap(const SO3& R, ChartJacobian H = boost::none); /// Derivative of Logmap - static Matrix3 LogmapDerivative(const Vector3& omega); + GTSAM_EXPORT static Matrix3 LogmapDerivative(const Vector3& omega); Matrix3 AdjointMap() const { return *this; diff --git a/gtsam/geometry/tests/testCalibratedCamera.cpp b/gtsam/geometry/tests/testCalibratedCamera.cpp index f5f824d05..1982b8f50 100644 --- a/gtsam/geometry/tests/testCalibratedCamera.cpp +++ b/gtsam/geometry/tests/testCalibratedCamera.cpp @@ -206,7 +206,7 @@ TEST( CalibratedCamera, DBackprojectFromCamera) static Point3 backproject(const Pose3& pose, const Point2& point, const double& depth) { return CalibratedCamera(pose).backproject(point, depth); } -TEST( PinholePose, Dbackproject) +TEST( PinholePose, DbackprojectCalibCamera) { Matrix36 Dpose; Matrix31 Ddepth; diff --git a/gtsam/geometry/tests/testPinholePose.cpp b/gtsam/geometry/tests/testPinholePose.cpp index 05d48f4cc..1cf2f4a3f 100644 --- a/gtsam/geometry/tests/testPinholePose.cpp +++ b/gtsam/geometry/tests/testPinholePose.cpp @@ -58,6 +58,7 @@ TEST( PinholePose, constructor) } //****************************************************************************** +/* Already in testPinholeCamera??? TEST(PinholeCamera, Pose) { Matrix actualH; @@ -69,6 +70,7 @@ TEST(PinholeCamera, Pose) { Matrix numericalH = numericalDerivative11(f,camera); EXPECT(assert_equal(numericalH, actualH, 1e-9)); } +*/ /* ************************************************************************* */ TEST( PinholePose, lookat) @@ -207,7 +209,7 @@ static Point3 backproject(const Pose3& pose, const Cal3_S2& cal, return Camera(pose, cal.vector()).backproject(p, depth); } -TEST( PinholePose, Dbackproject) +TEST( PinholePose, DbackprojectRegCamera) { Matrix36 Dpose; Matrix31 Ddepth; diff --git a/gtsam/geometry/tests/testQuaternion.cpp b/gtsam/geometry/tests/testQuaternion.cpp index 843dc6cc1..e862b94ad 100644 --- a/gtsam/geometry/tests/testQuaternion.cpp +++ b/gtsam/geometry/tests/testQuaternion.cpp @@ -81,13 +81,14 @@ TEST(Quaternion , Compose) { } //****************************************************************************** -Vector3 z_axis(0, 0, 1); -Q id(Eigen::AngleAxisd(0, z_axis)); -Q R1(Eigen::AngleAxisd(1, z_axis)); +Vector3 Q_z_axis(0, 0, 1); +Q id(Eigen::AngleAxisd(0, Q_z_axis)); +Q R1(Eigen::AngleAxisd(1, Q_z_axis)); Q R2(Eigen::AngleAxisd(2, Vector3(0, 1, 0))); //****************************************************************************** TEST(Quaternion , Between) { + Vector3 z_axis(0, 0, 1); Q q1(Eigen::AngleAxisd(0.2, z_axis)); Q q2(Eigen::AngleAxisd(0.1, z_axis)); @@ -98,6 +99,7 @@ TEST(Quaternion , Between) { //****************************************************************************** TEST(Quaternion , Inverse) { + Vector3 z_axis(0, 0, 1); Q q1(Eigen::AngleAxisd(0.1, z_axis)); Q expected(Eigen::AngleAxisd(-0.1, z_axis)); diff --git a/gtsam_unstable/geometry/Event.h b/gtsam_unstable/geometry/Event.h index d9bacd106..b22164117 100644 --- a/gtsam_unstable/geometry/Event.h +++ b/gtsam_unstable/geometry/Event.h @@ -60,10 +60,10 @@ public: } /** print with optional string */ - void print(const std::string& s = "") const; + GTSAM_EXPORT void print(const std::string& s = "") const; /** equals with an tolerance */ - bool equals(const Event& other, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const Event& other, double tol = 1e-9) const; /// Updates a with tangent space delta inline Event retract(const Vector4& v) const { @@ -94,6 +94,6 @@ public: // Define GTSAM traits template<> -struct GTSAM_EXPORT traits : internal::Manifold {}; +struct traits : internal::Manifold {}; } //\ namespace gtsam diff --git a/gtsam_unstable/geometry/Similarity3.h b/gtsam_unstable/geometry/Similarity3.h index f7ba53d87..a3d80c1d0 100644 --- a/gtsam_unstable/geometry/Similarity3.h +++ b/gtsam_unstable/geometry/Similarity3.h @@ -49,32 +49,32 @@ public: /// @{ /// Default constructor - Similarity3(); + GTSAM_EXPORT Similarity3(); /// Construct pure scaling - Similarity3(double s); + GTSAM_EXPORT Similarity3(double s); /// Construct from GTSAM types - Similarity3(const Rot3& R, const Point3& t, double s); + GTSAM_EXPORT Similarity3(const Rot3& R, const Point3& t, double s); /// Construct from Eigen types - Similarity3(const Matrix3& R, const Vector3& t, double s); + GTSAM_EXPORT Similarity3(const Matrix3& R, const Vector3& t, double s); /// Construct from matrix [R t; 0 s^-1] - Similarity3(const Matrix4& T); + GTSAM_EXPORT Similarity3(const Matrix4& T); /// @} /// @name Testable /// @{ /// Compare with tolerance - bool equals(const Similarity3& sim, double tol) const; + GTSAM_EXPORT bool equals(const Similarity3& sim, double tol) const; /// Exact equality - bool operator==(const Similarity3& other) const; + GTSAM_EXPORT bool operator==(const Similarity3& other) const; /// Print with optional string - void print(const std::string& s) const; + GTSAM_EXPORT void print(const std::string& s) const; GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &os, const Similarity3& p); @@ -83,25 +83,25 @@ public: /// @{ /// Return an identity transform - static Similarity3 identity(); + GTSAM_EXPORT static Similarity3 identity(); /// Composition - Similarity3 operator*(const Similarity3& T) const; + GTSAM_EXPORT Similarity3 operator*(const Similarity3& T) const; /// Return the inverse - Similarity3 inverse() const; + GTSAM_EXPORT Similarity3 inverse() const; /// @} /// @name Group action on Point3 /// @{ /// Action on a point p is s*(R*p+t) - Point3 transformFrom(const Point3& p, // + GTSAM_EXPORT Point3 transformFrom(const Point3& p, // OptionalJacobian<3, 7> H1 = boost::none, // OptionalJacobian<3, 3> H2 = boost::none) const; /** syntactic sugar for transformFrom */ - Point3 operator*(const Point3& p) const; + GTSAM_EXPORT Point3 operator*(const Point3& p) const; /// @} /// @name Lie Group @@ -110,12 +110,12 @@ public: /** Log map at the identity * \f$ [R_x,R_y,R_z, t_x, t_y, t_z, \lambda] \f$ */ - static Vector7 Logmap(const Similarity3& s, // + GTSAM_EXPORT static Vector7 Logmap(const Similarity3& s, // OptionalJacobian<7, 7> Hm = boost::none); /** Exponential map at the identity */ - static Similarity3 Expmap(const Vector7& v, // + GTSAM_EXPORT static Similarity3 Expmap(const Vector7& v, // OptionalJacobian<7, 7> Hm = boost::none); /// Chart at the origin @@ -136,17 +136,17 @@ public: * @return 4*4 element of Lie algebra that can be exponentiated * TODO(frank): rename to Hat, make part of traits */ - static Matrix4 wedge(const Vector7& xi); + GTSAM_EXPORT static Matrix4 wedge(const Vector7& xi); /// Project from one tangent space to another - Matrix7 AdjointMap() const; + GTSAM_EXPORT Matrix7 AdjointMap() const; /// @} /// @name Standard interface /// @{ /// Calculate 4*4 matrix group equivalent - const Matrix4 matrix() const; + GTSAM_EXPORT const Matrix4 matrix() const; /// Return a GTSAM rotation const Rot3& rotation() const { @@ -165,7 +165,7 @@ public: /// Convert to a rigid body pose (R, s*t) /// TODO(frank): why is this here? Red flag! Definitely don't have it as a cast. - operator Pose3() const; + GTSAM_EXPORT operator Pose3() const; /// Dimensionality of tangent space = 7 DOF - used to autodetect sizes inline static size_t Dim() { From a49ed61a58ed0d0dce076a11565de076d98bd09d Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Mon, 15 Jul 2019 20:19:00 -0400 Subject: [PATCH 12/15] Reducing errors in check* libraries when compiling --- gtsam/inference/tests/testKey.cpp | 4 ++-- gtsam/inference/tests/testLabeledSymbol.cpp | 4 ++-- gtsam/inference/tests/testSymbol.cpp | 4 ++-- timing/timeGaussianFactorGraph.cpp | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gtsam/inference/tests/testKey.cpp b/gtsam/inference/tests/testKey.cpp index fcdb5709b..a60258581 100644 --- a/gtsam/inference/tests/testKey.cpp +++ b/gtsam/inference/tests/testKey.cpp @@ -76,7 +76,7 @@ TEST(Key, ChrTest) { /* ************************************************************************* */ // A custom (nonsensical) formatter. -string myFormatter(Key key) { +string keyMyFormatter(Key key) { return "special"; } @@ -91,7 +91,7 @@ TEST(Key, Formatting) { // use key_formatter with a function pointer stringstream ss2; - ss2 << key_formatter(myFormatter) << StreamedKey(key); + ss2 << key_formatter(keyMyFormatter) << StreamedKey(key); EXPECT("special" == ss2.str()); // use key_formatter with a function object. diff --git a/gtsam/inference/tests/testLabeledSymbol.cpp b/gtsam/inference/tests/testLabeledSymbol.cpp index 2a56b39c2..4ac171c73 100644 --- a/gtsam/inference/tests/testLabeledSymbol.cpp +++ b/gtsam/inference/tests/testLabeledSymbol.cpp @@ -81,7 +81,7 @@ TEST(LabeledSymbol, ChrTest) { /* ************************************************************************* */ // A custom (nonsensical) formatter. -string myFormatter(Key key) { +string labeledSymbolMyFormatter(Key key) { return "special"; } @@ -90,7 +90,7 @@ TEST(LabeledSymbol, Formatting) { // use key_formatter with a function pointer stringstream ss2; - ss2 << key_formatter(myFormatter) << symbol; + ss2 << key_formatter(labeledSymbolMyFormatter) << symbol; EXPECT("special" == ss2.str()); // use key_formatter with a function object. diff --git a/gtsam/inference/tests/testSymbol.cpp b/gtsam/inference/tests/testSymbol.cpp index 43a0e219a..bedd69044 100644 --- a/gtsam/inference/tests/testSymbol.cpp +++ b/gtsam/inference/tests/testSymbol.cpp @@ -23,7 +23,7 @@ using namespace gtsam; /* ************************************************************************* */ // A custom (nonsensical) formatter. -string myFormatter(Key key) { +string symbolMyFormatter(Key key) { return "special"; } @@ -32,7 +32,7 @@ TEST(Symbol, Formatting) { // use key_formatter with a function pointer stringstream ss2; - ss2 << key_formatter(myFormatter) << symbol; + ss2 << key_formatter(symbolMyFormatter) << symbol; EXPECT("special" == ss2.str()); // use key_formatter with a function object. diff --git a/timing/timeGaussianFactorGraph.cpp b/timing/timeGaussianFactorGraph.cpp index 1efdb9542..3258edb49 100644 --- a/timing/timeGaussianFactorGraph.cpp +++ b/timing/timeGaussianFactorGraph.cpp @@ -153,13 +153,13 @@ TEST(timeGaussianFactorGraph, linearTime) // Switch to 100*100 grid = 10K poses // 1879: 15.6498 15.3851 15.5279 -int size = 100; +int grid_size = 100; /* ************************************************************************* */ TEST(timeGaussianFactorGraph, planar_old) { cout << "Timing planar - original version" << endl; - double time = timePlanarSmoother(size); + double time = timePlanarSmoother(grid_size); cout << "timeGaussianFactorGraph : " << time << endl; //DOUBLES_EQUAL(5.97,time,0.1); } @@ -168,7 +168,7 @@ TEST(timeGaussianFactorGraph, planar_old) TEST(timeGaussianFactorGraph, planar_new) { cout << "Timing planar - new version" << endl; - double time = timePlanarSmoother(size, false); + double time = timePlanarSmoother(grid_size, false); cout << "timeGaussianFactorGraph : " << time << endl; //DOUBLES_EQUAL(5.97,time,0.1); } @@ -177,7 +177,7 @@ TEST(timeGaussianFactorGraph, planar_new) TEST(timeGaussianFactorGraph, planar_eliminate_old) { cout << "Timing planar Eliminate - original version" << endl; - double time = timePlanarSmootherEliminate(size); + double time = timePlanarSmootherEliminate(grid_size); cout << "timeGaussianFactorGraph : " << time << endl; //DOUBLES_EQUAL(5.97,time,0.1); } @@ -186,7 +186,7 @@ TEST(timeGaussianFactorGraph, planar_eliminate_old) TEST(timeGaussianFactorGraph, planar_eliminate_new) { cout << "Timing planar Eliminate - new version" << endl; - double time = timePlanarSmootherEliminate(size, false); + double time = timePlanarSmootherEliminate(grid_size, false); cout << "timeGaussianFactorGraph : " << time << endl; //DOUBLES_EQUAL(5.97,time,0.1); } From 393e9edf18c7f72512efee8f38021ab73c703001 Mon Sep 17 00:00:00 2001 From: Clark Taylor Date: Mon, 15 Jul 2019 22:22:47 -0400 Subject: [PATCH 13/15] Updated Using GTSAM_EXPORT document --- Using-GTSAM-EXPORT.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Using-GTSAM-EXPORT.md b/Using-GTSAM-EXPORT.md index 6c8480d5d..41eccc178 100644 --- a/Using-GTSAM-EXPORT.md +++ b/Using-GTSAM-EXPORT.md @@ -3,9 +3,9 @@ To create a DLL in windows, the `GTSAM_EXPORT` keyword has been created and needs to be applied to different methods and classes in the code to expose this code outside of the DLL. However, there are several intricacies that make this more difficult than it sounds. In general, if you follow the following three rules, GTSAM_EXPORT should work properly. The rest of the document also describes (1) the common error message encountered when you are not following these rules and (2) the reasoning behind these usage rules. ## Usage Rules -1. Put `GTSAM_EXPORT` in front of any function that you want exported in the DLL _if and only if_ that function is defined in a .cpp file, not just a .h file. +1. Put `GTSAM_EXPORT` in front of any function that you want exported in the DLL _if and only if_ that function is declared in a .cpp file, not just a .h file. 2. Use `GTSAM_EXPORT` in a class definition (i.e. `class GSTAM_EXPORT MyClass {...}`) only if: - * At least one of the functions inside that class is defined in a .cpp file and not just the .h file. + * At least one of the functions inside that class is declared in a .cpp file and not just the .h file. * You can `GTSAM_EXPORT` any class it inherits from as well. (Note that this implictly requires the class does not derive from a "header-only" class. Note that Eigen is a "header-only" library, so if your class derives from Eigen, _do not_ use `GTSAM_EXPORT` in the class definition!) 3. If you have defined a class using `GTSAM_EXPORT`, do not use `GTSAM_EXPORT` in any of its individual function declarations. (Note that you _can_ put `GTSAM_EXPORT` in the definition of individual functions within a class as long as you don't put `GTSAM_EXPORT` in the class definition.) @@ -16,26 +16,22 @@ Unfortunately, using `GTSAM_EXPORT` incorrectly often does not cause a compiler Error LNK2019 unresolved external symbol "public: void __cdecl gtsam::SO3::print(class std::basic_string,class std::allocator > const &)const " (?print@SO3@gtsam@@QEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: static void __cdecl gtsam::Testable::Print(class gtsam::SO3 const &,class std::basic_string,class std::allocator > const &)" (?Print@?$Testable@VSO3@gtsam@@@gtsam@@SAXAEBVSO3@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) check_geometry_program C:\AFIT\lib\gtsam\build\gtsam\geometry\tests\testSO3.obj ``` -Sorry for the long error message there, but I want to quickly decode it to help understand what is going on. First, there is an unresolved symbol `gtsam::SO3::print`. This can occur because _either_ `GTSAM_EXPORT` was not added to the print function definition when it should have been, _OR_ because `GTSAM_EXPORT` was added to the print function definition when it is fully declared in the header. This error was detected while compiling `check_geometry_program` and pulling in `...\testSO3.obj`. Specifically, within the function call `gtsam::Testabl::Print (...)`. Note that this error did _not_ occur when compiling the library that actually has SO3 inside of it. +Let's analyze this error statement. First, there is an unresolved symbol `gtsam::SO3::print`. This can occur because _either_ `GTSAM_EXPORT` was not added to the print function definition when it should have been, _OR_ because `GTSAM_EXPORT` was added to the print function definition when it is fully declared in the header. This error was detected while compiling `check_geometry_program` and pulling in `...\testSO3.obj`. Specifically, within the function call `gtsam::Testable::Print (...)`. Note that this error did _not_ occur when compiling the library that actually has SO3 inside of it. ## But Why? -To me, the behavior of GTSAM_EXPORT was very baffling. However, I believe it can be explained by understanding the rules that MSVC operates under. +I believe that how the compiler/linker interacts with GTSAM_EXPORT can be explained by understanding the rules that MSVC operates under. -First, we need to understand exactly what `GTSAM_EXPORT` does. When you use `GTSAM_EXPORT` on a function (or class) definition, it actually does two things. First, when you are building the library, it turns into a "dllexport" command, telling the compiler that this function should go into the DLL and be visible externally. When you pull in that same header for a different library, it switches to a "dllimport" command, telling the compiler it should find this function in a DLL somewhere. This leads to the first rule the compiler uses. (Note that I say "compiler rules" when the rules may actually be in the linker, but I am conflating the two terms here when I speak of the "compiler rules".) +But first, we need to understand exactly what `GTSAM_EXPORT` is. `GTSAM_EXPORT` is a `#define` macro that is created by CMAKE when GTSAM is being compiled on a Windows machine. Inside the GTSAM project, GTSAM export will be set to a "dllexport" command. A "dllexport" command tells the compiler that this function should go into the DLL and be visible externally. In any other library, `GTSAM_EXPORT` will be set to a "dllimport" command, telling the linker it should find this function in a DLL somewhere. This leads to the first rule the compiler uses. (Note that I say "compiler rules" when the rules may actually be in the linker, but I am conflating the two terms here when I speak of the "compiler rules".) ***Compiler Rule #1*** If a `dllimport` command is used in defining a function or class, that function or class _must_ be found in a DLL. Rule #1 doesn't seem very bad, until you combine it with rule #2 -***Compiler Rule #2*** Anything defined in a header file is not included in a DLL. +***Compiler Rule #2*** Anything declared in a header file is not included in a DLL. When these two rules are combined, you get some very confusing results. For example, a class which is completely defined in a header (e.g. LieMatrix) cannot use `GTSAM_EXPORT` in its definition. If LieMatrix is defined with `GTSAM_EXPORT`, then the compiler _must_ find LieMatrix in a DLL. Because LieMatrix is a header-only class, however, it can't find it, leading to a very confusing "I can't find this symbol" type of error. Note that the linker says it can't find the symbol even though the compiler found the header file that completely defines the class. -This leads to another compiler rule that finishes explaining the usage rules proposed above. - -***Compiler Rule #3*** If a class is defined with `GTSAM_EXPORT`, then any classes it inherits from must be definable with a dllexport command as well. - -One of the most immediate results of this compiler rule is that any class that inherits from an Eigen class _cannot_ be defined with `GTSAM_EXPORT`. Because Eigen is a header-only class, compiler rule #2 prohibits any Eigen class from being defined with a "dllexport" command. Therefore, no Eigen inherited classes can use `GTSAM_EXPORT` either. (Note that individual functions with an inherited class can be "exported." Just not the entire class.) +Also note that when a class that you want to export inherits from another class that is not exportable, this can cause significant issues. According to this [MSVC Warning page](https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=vs-2019), it may not strictly be a rule, but we have seen several linker errors when a class that is defined with `GTSAM_EXPORT` extended an Eigen class. In general, it appears that any inheritance of non-exportable class by an exportable class is a bad idea. ## Conclusion -Hopefully, this little document clarifies when `GTSAM_EXPORT` should and should not be used whenever future GTSAM code is being written. Following the usage rules above, I have been able to get all of the libraries, together with their test and wrapping libraries, to compile/link successfully. \ No newline at end of file +Hopefully, this little document clarifies when `GTSAM_EXPORT` should and should not be used whenever future GTSAM code is being written. Following the usage rules above, we have been able to get all of the libraries, together with their test and wrapping libraries, to compile/link successfully. \ No newline at end of file From 52b0579a9b0a6ed82f2e0d20a5696126e29c716b Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Thu, 18 Jul 2019 08:22:41 +0200 Subject: [PATCH 14/15] Consistent dllexport.h across gtsam & gtsam_unstable --- gtsam_unstable/CMakeLists.txt | 6 ++++ gtsam_unstable/base/Dummy.h | 2 +- gtsam_unstable/base/dllexport.h | 36 ------------------- gtsam_unstable/discrete/Constraint.h | 2 +- gtsam_unstable/dynamics/PoseRTV.h | 2 +- gtsam_unstable/geometry/BearingS2.h | 2 +- gtsam_unstable/geometry/Pose3Upright.h | 2 +- gtsam_unstable/geometry/SimWall2D.h | 2 +- .../ConcurrentFilteringAndSmoothing.h | 2 +- gtsam_unstable/nonlinear/FixedLagSmoother.h | 2 +- gtsam_unstable/nonlinear/LinearizedFactor.h | 2 +- gtsam_unstable/slam/AHRS.h | 2 +- gtsam_unstable/slam/DummyFactor.h | 2 +- gtsam_unstable/slam/Mechanization_bRn2.h | 2 +- gtsam_unstable/slam/RelativeElevationFactor.h | 2 +- gtsam_unstable/slam/SmartRangeFactor.h | 2 +- 16 files changed, 20 insertions(+), 50 deletions(-) delete mode 100644 gtsam_unstable/base/dllexport.h diff --git a/gtsam_unstable/CMakeLists.txt b/gtsam_unstable/CMakeLists.txt index 65ba4848d..53ba83fad 100644 --- a/gtsam_unstable/CMakeLists.txt +++ b/gtsam_unstable/CMakeLists.txt @@ -44,6 +44,12 @@ foreach(subdir ${gtsam_unstable_subdirs}) add_subdirectory(${subdir}) endforeach(subdir) +# dllexport.h +set(library_name GTSAM_UNSTABLE) # For substitution in dllexport.h.in +configure_file("${GTSAM_SOURCE_DIR}/cmake/dllexport.h.in" "dllexport.h") +list(APPEND gtsam_unstable_srcs "${PROJECT_BINARY_DIR}/dllexport.h") +install(FILES "${PROJECT_BINARY_DIR}/dllexport.h" DESTINATION include/gtsam_unstable) + # assemble gtsam_unstable components set(gtsam_unstable_srcs ${base_srcs} diff --git a/gtsam_unstable/base/Dummy.h b/gtsam_unstable/base/Dummy.h index 14b4b4854..a2f544de5 100644 --- a/gtsam_unstable/base/Dummy.h +++ b/gtsam_unstable/base/Dummy.h @@ -18,7 +18,7 @@ */ #include -#include +#include #include namespace gtsam { diff --git a/gtsam_unstable/base/dllexport.h b/gtsam_unstable/base/dllexport.h deleted file mode 100644 index 903996db4..000000000 --- a/gtsam_unstable/base/dllexport.h +++ /dev/null @@ -1,36 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file dllexport.h - * @brief Symbols for exporting classes and methods from DLLs - * @author Richard Roberts - * @date Mar 9, 2013 - */ - -#ifdef _WIN32 -# ifdef GTSAM_UNSTABLE_EXPORTS -# define GTSAM_UNSTABLE_EXPORT __declspec(dllexport) -# define GTSAM_UNSTABLE_EXTERN_EXPORT __declspec(dllexport) extern -# else -# ifndef GTSAM_UNSTABLE_IMPORT_STATIC -# define GTSAM_UNSTABLE_EXPORT __declspec(dllimport) -# define GTSAM_UNSTABLE_EXTERN_EXPORT __declspec(dllimport) -# else /* GTSAM_UNSTABLE_IMPORT_STATIC */ -# define GTSAM_UNSTABLE_EXPORT -# define GTSAM_UNSTABLE_EXTERN_EXPORT extern -# endif /* GTSAM_UNSTABLE_IMPORT_STATIC */ -# endif /* GTSAM_UNSTABLE_EXPORTS */ -#else /* _WIN32 */ -# define GTSAM_UNSTABLE_EXPORT -# define GTSAM_UNSTABLE_EXTERN_EXPORT extern -#endif - diff --git a/gtsam_unstable/discrete/Constraint.h b/gtsam_unstable/discrete/Constraint.h index 32fb6f1ce..136704c2d 100644 --- a/gtsam_unstable/discrete/Constraint.h +++ b/gtsam_unstable/discrete/Constraint.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include diff --git a/gtsam_unstable/dynamics/PoseRTV.h b/gtsam_unstable/dynamics/PoseRTV.h index 0c00e5d95..b1cfb6f30 100644 --- a/gtsam_unstable/dynamics/PoseRTV.h +++ b/gtsam_unstable/dynamics/PoseRTV.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include diff --git a/gtsam_unstable/geometry/BearingS2.h b/gtsam_unstable/geometry/BearingS2.h index 70a22b9a5..197d4910d 100644 --- a/gtsam_unstable/geometry/BearingS2.h +++ b/gtsam_unstable/geometry/BearingS2.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include diff --git a/gtsam_unstable/geometry/Pose3Upright.h b/gtsam_unstable/geometry/Pose3Upright.h index 9d01e20a5..d833c9cf4 100644 --- a/gtsam_unstable/geometry/Pose3Upright.h +++ b/gtsam_unstable/geometry/Pose3Upright.h @@ -11,7 +11,7 @@ #pragma once -#include +#include #include #include diff --git a/gtsam_unstable/geometry/SimWall2D.h b/gtsam_unstable/geometry/SimWall2D.h index c143bc36d..fd5afbc54 100644 --- a/gtsam_unstable/geometry/SimWall2D.h +++ b/gtsam_unstable/geometry/SimWall2D.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include diff --git a/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h b/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h index 42f82f52f..316db921a 100644 --- a/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h +++ b/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h @@ -20,7 +20,7 @@ // \callgraph #pragma once -#include +#include #include #include #include diff --git a/gtsam_unstable/nonlinear/FixedLagSmoother.h b/gtsam_unstable/nonlinear/FixedLagSmoother.h index bef35ffce..362cfae96 100644 --- a/gtsam_unstable/nonlinear/FixedLagSmoother.h +++ b/gtsam_unstable/nonlinear/FixedLagSmoother.h @@ -20,7 +20,7 @@ // \callgraph #pragma once -#include +#include #include #include #include diff --git a/gtsam_unstable/nonlinear/LinearizedFactor.h b/gtsam_unstable/nonlinear/LinearizedFactor.h index ece8cd2f6..128889b82 100644 --- a/gtsam_unstable/nonlinear/LinearizedFactor.h +++ b/gtsam_unstable/nonlinear/LinearizedFactor.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/gtsam_unstable/slam/AHRS.h b/gtsam_unstable/slam/AHRS.h index e15e6e0f7..f22de48cf 100644 --- a/gtsam_unstable/slam/AHRS.h +++ b/gtsam_unstable/slam/AHRS.h @@ -9,7 +9,7 @@ #define AHRS_H_ #include "Mechanization_bRn2.h" -#include +#include #include namespace gtsam { diff --git a/gtsam_unstable/slam/DummyFactor.h b/gtsam_unstable/slam/DummyFactor.h index 9f749e9e5..574efabea 100644 --- a/gtsam_unstable/slam/DummyFactor.h +++ b/gtsam_unstable/slam/DummyFactor.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #include namespace gtsam { diff --git a/gtsam_unstable/slam/Mechanization_bRn2.h b/gtsam_unstable/slam/Mechanization_bRn2.h index a228b2347..5a6f1df6d 100644 --- a/gtsam_unstable/slam/Mechanization_bRn2.h +++ b/gtsam_unstable/slam/Mechanization_bRn2.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace gtsam { diff --git a/gtsam_unstable/slam/RelativeElevationFactor.h b/gtsam_unstable/slam/RelativeElevationFactor.h index 3d81fbab3..3507a4492 100644 --- a/gtsam_unstable/slam/RelativeElevationFactor.h +++ b/gtsam_unstable/slam/RelativeElevationFactor.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include diff --git a/gtsam_unstable/slam/SmartRangeFactor.h b/gtsam_unstable/slam/SmartRangeFactor.h index c05633345..5511a0209 100644 --- a/gtsam_unstable/slam/SmartRangeFactor.h +++ b/gtsam_unstable/slam/SmartRangeFactor.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include #include From 438b4ff014447c59ae1fa2b9d4115e348a7df36b Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Thu, 18 Jul 2019 11:09:08 +0200 Subject: [PATCH 15/15] more DLL warnings & errors fixed --- gtsam/base/timing.h | 18 +++++----- gtsam/geometry/CalibratedCamera.h | 3 +- gtsam/geometry/EssentialMatrix.h | 14 ++++---- gtsam/geometry/SO3.h | 8 ++--- gtsam/geometry/Unit3.h | 28 +++++++-------- gtsam/geometry/triangulation.h | 2 +- gtsam/inference/Key.h | 6 ++-- gtsam/linear/IterativeSolver.h | 20 +++++------ gtsam/nonlinear/ISAM2Result.h | 2 +- gtsam/nonlinear/ISAM2UpdateParams.h | 2 +- gtsam/nonlinear/LinearContainerFactor.h | 38 ++++++++++---------- gtsam/nonlinear/NonlinearOptimizerParams.h | 16 ++++----- gtsam/nonlinear/Values.h | 18 +++++----- gtsam/symbolic/SymbolicBayesNet.h | 6 ++-- gtsam/symbolic/SymbolicBayesTree.h | 6 ++-- gtsam_unstable/geometry/Event.h | 5 +-- gtsam_unstable/geometry/Similarity3.h | 41 +++++++++++----------- 17 files changed, 117 insertions(+), 116 deletions(-) diff --git a/gtsam/base/timing.h b/gtsam/base/timing.h index ec80baad3..557500e73 100644 --- a/gtsam/base/timing.h +++ b/gtsam/base/timing.h @@ -142,7 +142,7 @@ namespace gtsam { /** * Timing Entry, arranged in a tree */ - class GTSAM_EXPORT TimingOutline { + class TimingOutline { protected: size_t id_; size_t t_; @@ -174,21 +174,21 @@ namespace gtsam { public: /// Constructor - TimingOutline(const std::string& label, size_t myId); - size_t time() const; ///< time taken, including children + GTSAM_EXPORT TimingOutline(const std::string& label, size_t myId); + GTSAM_EXPORT size_t time() const; ///< time taken, including children double secs() const { return double(time()) / 1000000.0;} ///< time taken, in seconds, including children double self() const { return double(t_) / 1000000.0;} ///< self time only, in seconds double wall() const { return double(tWall_) / 1000000.0;} ///< wall time, in seconds double min() const { return double(tMin_) / 1000000.0;} ///< min time, in seconds double max() const { return double(tMax_) / 1000000.0;} ///< max time, in seconds double mean() const { return self() / double(n_); } ///< mean self time, in seconds - void print(const std::string& outline = "") const; - void print2(const std::string& outline = "", const double parentTotal = -1.0) const; - const boost::shared_ptr& + GTSAM_EXPORT void print(const std::string& outline = "") const; + GTSAM_EXPORT void print2(const std::string& outline = "", const double parentTotal = -1.0) const; + GTSAM_EXPORT const boost::shared_ptr& child(size_t child, const std::string& label, const boost::weak_ptr& thisPtr); - void tic(); - void toc(); - void finishedIteration(); + GTSAM_EXPORT void tic(); + GTSAM_EXPORT void toc(); + GTSAM_EXPORT void finishedIteration(); GTSAM_EXPORT friend void toc(size_t id, const char *label); }; // \TimingOutline diff --git a/gtsam/geometry/CalibratedCamera.h b/gtsam/geometry/CalibratedCamera.h index 1f791935d..9d9b37d7a 100644 --- a/gtsam/geometry/CalibratedCamera.h +++ b/gtsam/geometry/CalibratedCamera.h @@ -29,8 +29,7 @@ namespace gtsam { -class GTSAM_EXPORT CheiralityException: public ThreadsafeException< - CheiralityException> { +class GTSAM_EXPORT CheiralityException: public ThreadsafeException { public: CheiralityException() : CheiralityException(std::numeric_limits::max()) {} diff --git a/gtsam/geometry/EssentialMatrix.h b/gtsam/geometry/EssentialMatrix.h index 891902da7..3235fdedd 100644 --- a/gtsam/geometry/EssentialMatrix.h +++ b/gtsam/geometry/EssentialMatrix.h @@ -23,7 +23,7 @@ namespace gtsam { * but here we choose instead to parameterize it as a (Rot3,Unit3) pair. * We can then non-linearly optimize immediately on this 5-dimensional manifold. */ -class GTSAM_EXPORT EssentialMatrix { +class EssentialMatrix { private: Rot3 R_; ///< Rotation Unit3 t_; ///< Translation @@ -48,12 +48,12 @@ class GTSAM_EXPORT EssentialMatrix { } /// Named constructor with derivatives - static EssentialMatrix FromRotationAndDirection(const Rot3& aRb, const Unit3& aTb, + GTSAM_EXPORT static EssentialMatrix FromRotationAndDirection(const Rot3& aRb, const Unit3& aTb, OptionalJacobian<5, 3> H1 = boost::none, OptionalJacobian<5, 2> H2 = boost::none); /// Named constructor converting a Pose3 with scale to EssentialMatrix (no scale) - static EssentialMatrix FromPose3(const Pose3& _1P2_, + GTSAM_EXPORT static EssentialMatrix FromPose3(const Pose3& _1P2_, OptionalJacobian<5, 6> H = boost::none); /// Random, using Rot3::Random and Unit3::Random @@ -70,7 +70,7 @@ class GTSAM_EXPORT EssentialMatrix { /// @{ /// print with optional string - void print(const std::string& s = "") const; + GTSAM_EXPORT void print(const std::string& s = "") const; /// assert equality up to a tolerance bool equals(const EssentialMatrix& other, double tol = 1e-8) const { @@ -138,7 +138,7 @@ class GTSAM_EXPORT EssentialMatrix { * @param Dpoint optional 3*3 Jacobian wrpt point * @return point in pose coordinates */ - Point3 transformTo(const Point3& p, + GTSAM_EXPORT Point3 transformTo(const Point3& p, OptionalJacobian<3, 5> DE = boost::none, OptionalJacobian<3, 3> Dpoint = boost::none) const; @@ -147,7 +147,7 @@ class GTSAM_EXPORT EssentialMatrix { * @param cRb rotation from body frame to camera frame * @param E essential matrix E in camera frame C */ - EssentialMatrix rotate(const Rot3& cRb, OptionalJacobian<5, 5> HE = + GTSAM_EXPORT EssentialMatrix rotate(const Rot3& cRb, OptionalJacobian<5, 5> HE = boost::none, OptionalJacobian<5, 3> HR = boost::none) const; /** @@ -160,7 +160,7 @@ class GTSAM_EXPORT EssentialMatrix { } /// epipolar error, algebraic - double error(const Vector3& vA, const Vector3& vB, + GTSAM_EXPORT double error(const Vector3& vA, const Vector3& vB, OptionalJacobian<1, 5> H = boost::none) const; /// @} diff --git a/gtsam/geometry/SO3.h b/gtsam/geometry/SO3.h index a4f6861cc..5f1c7d1bf 100644 --- a/gtsam/geometry/SO3.h +++ b/gtsam/geometry/SO3.h @@ -156,14 +156,14 @@ class GTSAM_EXPORT ExpmapFunctor { }; /// Functor that implements Exponential map *and* its derivatives -class GTSAM_EXPORT DexpFunctor : public ExpmapFunctor { +class DexpFunctor : public ExpmapFunctor { const Vector3 omega; double a, b; Matrix3 dexp_; public: /// Constructor with element of Lie algebra so(3) - DexpFunctor(const Vector3& omega, bool nearZeroApprox = false); + GTSAM_EXPORT DexpFunctor(const Vector3& omega, bool nearZeroApprox = false); // NOTE(luca): Right Jacobian for Exponential map in SO(3) - equation // (10.86) and following equations in G.S. Chirikjian, "Stochastic Models, @@ -174,11 +174,11 @@ class GTSAM_EXPORT DexpFunctor : public ExpmapFunctor { const Matrix3& dexp() const { return dexp_; } /// Multiplies with dexp(), with optional derivatives - Vector3 applyDexp(const Vector3& v, OptionalJacobian<3, 3> H1 = boost::none, + GTSAM_EXPORT Vector3 applyDexp(const Vector3& v, OptionalJacobian<3, 3> H1 = boost::none, OptionalJacobian<3, 3> H2 = boost::none) const; /// Multiplies with dexp().inverse(), with optional derivatives - Vector3 applyInvDexp(const Vector3& v, + GTSAM_EXPORT Vector3 applyInvDexp(const Vector3& v, OptionalJacobian<3, 3> H1 = boost::none, OptionalJacobian<3, 3> H2 = boost::none) const; }; diff --git a/gtsam/geometry/Unit3.h b/gtsam/geometry/Unit3.h index f182df285..211698806 100644 --- a/gtsam/geometry/Unit3.h +++ b/gtsam/geometry/Unit3.h @@ -39,7 +39,7 @@ namespace gtsam { /// Represents a 3D point on a unit sphere. -class GTSAM_EXPORT Unit3 { +class Unit3 { private: @@ -94,11 +94,11 @@ public: } /// Named constructor from Point3 with optional Jacobian - static Unit3 FromPoint3(const Point3& point, // + GTSAM_EXPORT static Unit3 FromPoint3(const Point3& point, // OptionalJacobian<2, 3> H = boost::none); /// Random direction, using boost::uniform_on_sphere - static Unit3 Random(boost::mt19937 & rng); + GTSAM_EXPORT static Unit3 Random(boost::mt19937 & rng); /// @} @@ -108,7 +108,7 @@ public: friend std::ostream& operator<<(std::ostream& os, const Unit3& pair); /// The print fuction - void print(const std::string& s = std::string()) const; + GTSAM_EXPORT void print(const std::string& s = std::string()) const; /// The equals function with tolerance bool equals(const Unit3& s, double tol = 1e-9) const { @@ -125,16 +125,16 @@ public: * tangent to the sphere at the current direction. * Provides derivatives of the basis with the two basis vectors stacked up as a 6x1. */ - const Matrix32& basis(OptionalJacobian<6, 2> H = boost::none) const; + GTSAM_EXPORT const Matrix32& basis(OptionalJacobian<6, 2> H = boost::none) const; /// Return skew-symmetric associated with 3D point on unit sphere - Matrix3 skew() const; + GTSAM_EXPORT Matrix3 skew() const; /// Return unit-norm Point3 - Point3 point3(OptionalJacobian<3, 2> H = boost::none) const; + GTSAM_EXPORT Point3 point3(OptionalJacobian<3, 2> H = boost::none) const; /// Return unit-norm Vector - Vector3 unitVector(OptionalJacobian<3, 2> H = boost::none) const; + GTSAM_EXPORT Vector3 unitVector(OptionalJacobian<3, 2> H = boost::none) const; /// Return scaled direction as Point3 friend Point3 operator*(double s, const Unit3& d) { @@ -142,20 +142,20 @@ public: } /// Return dot product with q - double dot(const Unit3& q, OptionalJacobian<1,2> H1 = boost::none, // + GTSAM_EXPORT double dot(const Unit3& q, OptionalJacobian<1,2> H1 = boost::none, // OptionalJacobian<1,2> H2 = boost::none) const; /// Signed, vector-valued error between two directions /// @deprecated, errorVector has the proper derivatives, this confusingly has only the second. - Vector2 error(const Unit3& q, OptionalJacobian<2, 2> H_q = boost::none) const; + GTSAM_EXPORT Vector2 error(const Unit3& q, OptionalJacobian<2, 2> H_q = boost::none) const; /// Signed, vector-valued error between two directions /// NOTE(hayk): This method has zero derivatives if this (p) and q are orthogonal. - Vector2 errorVector(const Unit3& q, OptionalJacobian<2, 2> H_p = boost::none, // + GTSAM_EXPORT Vector2 errorVector(const Unit3& q, OptionalJacobian<2, 2> H_p = boost::none, // OptionalJacobian<2, 2> H_q = boost::none) const; /// Distance between two directions - double distance(const Unit3& q, OptionalJacobian<1, 2> H = boost::none) const; + GTSAM_EXPORT double distance(const Unit3& q, OptionalJacobian<1, 2> H = boost::none) const; /// Cross-product between two Unit3s Unit3 cross(const Unit3& q) const { @@ -188,10 +188,10 @@ public: }; /// The retract function - Unit3 retract(const Vector2& v, OptionalJacobian<2,2> H = boost::none) const; + GTSAM_EXPORT Unit3 retract(const Vector2& v, OptionalJacobian<2,2> H = boost::none) const; /// The local coordinates function - Vector2 localCoordinates(const Unit3& s) const; + GTSAM_EXPORT Vector2 localCoordinates(const Unit3& s) const; /// @} diff --git a/gtsam/geometry/triangulation.h b/gtsam/geometry/triangulation.h index 851c5e4d3..ed61c75b5 100644 --- a/gtsam/geometry/triangulation.h +++ b/gtsam/geometry/triangulation.h @@ -386,7 +386,7 @@ private: /** * TriangulationResult is an optional point, along with the reasons why it is invalid. */ -class GTSAM_EXPORT TriangulationResult: public boost::optional { +class TriangulationResult: public boost::optional { enum Status { VALID, DEGENERATE, BEHIND_CAMERA, OUTLIER, FAR_POINT }; diff --git a/gtsam/inference/Key.h b/gtsam/inference/Key.h index ae3f3844b..8b13f0b4c 100644 --- a/gtsam/inference/Key.h +++ b/gtsam/inference/Key.h @@ -58,7 +58,7 @@ static const gtsam::KeyFormatter MultiRobotKeyFormatter = struct StreamedKey { const Key &key_; explicit StreamedKey(const Key &key) : key_(key) {} - friend std::ostream &operator<<(std::ostream &, const StreamedKey &); + GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &, const StreamedKey &); }; /** @@ -72,8 +72,8 @@ struct StreamedKey { class key_formatter { public: explicit key_formatter(KeyFormatter v) : formatter_(v) {} - friend std::ostream &operator<<(std::ostream &, const key_formatter &); - friend std::ostream &operator<<(std::ostream &, const StreamedKey &); + GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &, const key_formatter &); + GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &, const StreamedKey &); private: KeyFormatter formatter_; diff --git a/gtsam/linear/IterativeSolver.h b/gtsam/linear/IterativeSolver.h index f0fbfbfd2..758d2aec9 100644 --- a/gtsam/linear/IterativeSolver.h +++ b/gtsam/linear/IterativeSolver.h @@ -41,7 +41,7 @@ class VectorValues; /** * parameters for iterative linear solvers */ -class GTSAM_EXPORT IterativeOptimizationParameters { +class IterativeOptimizationParameters { public: @@ -63,27 +63,27 @@ public: inline Verbosity verbosity() const { return verbosity_; } - std::string getVerbosity() const; - void setVerbosity(const std::string &s); + GTSAM_EXPORT std::string getVerbosity() const; + GTSAM_EXPORT void setVerbosity(const std::string &s); /* matlab interface */ - void print() const; + GTSAM_EXPORT void print() const; /* virtual print function */ - virtual void print(std::ostream &os) const; + GTSAM_EXPORT virtual void print(std::ostream &os) const; /* for serialization */ friend std::ostream& operator<<(std::ostream &os, const IterativeOptimizationParameters &p); - static Verbosity verbosityTranslator(const std::string &s); - static std::string verbosityTranslator(Verbosity v); + GTSAM_EXPORT static Verbosity verbosityTranslator(const std::string &s); + GTSAM_EXPORT static std::string verbosityTranslator(Verbosity v); }; /** * Base class for Iterative Solvers like SubgraphSolver */ -class GTSAM_EXPORT IterativeSolver { +class IterativeSolver { public: typedef boost::shared_ptr shared_ptr; IterativeSolver() { @@ -92,12 +92,12 @@ public: } /* interface to the nonlinear optimizer, without metadata, damping and initial estimate */ - VectorValues optimize(const GaussianFactorGraph &gfg, + GTSAM_EXPORT VectorValues optimize(const GaussianFactorGraph &gfg, boost::optional = boost::none, boost::optional&> lambda = boost::none); /* interface to the nonlinear optimizer, without initial estimate */ - VectorValues optimize(const GaussianFactorGraph &gfg, const KeyInfo &keyInfo, + GTSAM_EXPORT VectorValues optimize(const GaussianFactorGraph &gfg, const KeyInfo &keyInfo, const std::map &lambda); /* interface to the nonlinear optimizer that the subclasses have to implement */ diff --git a/gtsam/nonlinear/ISAM2Result.h b/gtsam/nonlinear/ISAM2Result.h index 3953c760b..e45b17e4a 100644 --- a/gtsam/nonlinear/ISAM2Result.h +++ b/gtsam/nonlinear/ISAM2Result.h @@ -38,7 +38,7 @@ namespace gtsam { * converging, and about how much work was required for the update. See member * variables for details and information about each entry. */ -struct GTSAM_EXPORT ISAM2Result { +struct ISAM2Result { /** The nonlinear error of all of the factors, \a including new factors and * variables added during the current call to ISAM2::update(). This error is * calculated using the following variable values: diff --git a/gtsam/nonlinear/ISAM2UpdateParams.h b/gtsam/nonlinear/ISAM2UpdateParams.h index 884ac7922..44519e3aa 100644 --- a/gtsam/nonlinear/ISAM2UpdateParams.h +++ b/gtsam/nonlinear/ISAM2UpdateParams.h @@ -29,7 +29,7 @@ namespace gtsam { * This struct is used by ISAM2::update() to pass additional parameters to * give the user a fine-grained control on how factors and relinearized, etc. */ -struct GTSAM_EXPORT ISAM2UpdateParams { +struct ISAM2UpdateParams { ISAM2UpdateParams() = default; /** Indices of factors to remove from system (default: empty) */ diff --git a/gtsam/nonlinear/LinearContainerFactor.h b/gtsam/nonlinear/LinearContainerFactor.h index 928b59e77..8a1f600ff 100644 --- a/gtsam/nonlinear/LinearContainerFactor.h +++ b/gtsam/nonlinear/LinearContainerFactor.h @@ -23,7 +23,7 @@ namespace gtsam { * This factor does have the ability to perform relinearization under small-angle and * linearity assumptions if a linearization point is added. */ -class GTSAM_EXPORT LinearContainerFactor : public NonlinearFactor { +class LinearContainerFactor : public NonlinearFactor { protected: GaussianFactor::shared_ptr factor_; @@ -33,7 +33,7 @@ protected: LinearContainerFactor() {} /** direct copy constructor */ - LinearContainerFactor(const GaussianFactor::shared_ptr& factor, const boost::optional& linearizationPoint); + GTSAM_EXPORT LinearContainerFactor(const GaussianFactor::shared_ptr& factor, const boost::optional& linearizationPoint); // Some handy typedefs typedef NonlinearFactor Base; @@ -44,13 +44,13 @@ public: typedef boost::shared_ptr shared_ptr; /** Primary constructor: store a linear factor with optional linearization point */ - LinearContainerFactor(const JacobianFactor& factor, const Values& linearizationPoint = Values()); + GTSAM_EXPORT LinearContainerFactor(const JacobianFactor& factor, const Values& linearizationPoint = Values()); /** Primary constructor: store a linear factor with optional linearization point */ - LinearContainerFactor(const HessianFactor& factor, const Values& linearizationPoint = Values()); + GTSAM_EXPORT LinearContainerFactor(const HessianFactor& factor, const Values& linearizationPoint = Values()); /** Constructor from shared_ptr */ - LinearContainerFactor(const GaussianFactor::shared_ptr& factor, const Values& linearizationPoint = Values()); + GTSAM_EXPORT LinearContainerFactor(const GaussianFactor::shared_ptr& factor, const Values& linearizationPoint = Values()); // Access @@ -59,10 +59,10 @@ public: // Testable /** print */ - void print(const std::string& s = "", const KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const; + GTSAM_EXPORT void print(const std::string& s = "", const KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const; /** Check if two factors are equal */ - bool equals(const NonlinearFactor& f, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const NonlinearFactor& f, double tol = 1e-9) const; // NonlinearFactor @@ -74,10 +74,10 @@ public: * * @return nonlinear error if linearizationPoint present, zero otherwise */ - double error(const Values& c) const; + GTSAM_EXPORT double error(const Values& c) const; /** get the dimension of the factor: rows of linear factor */ - size_t dim() const; + GTSAM_EXPORT size_t dim() const; /** Extract the linearization point used in recalculating error */ const boost::optional& linearizationPoint() const { return linearizationPoint_; } @@ -98,17 +98,17 @@ public: * TODO: better approximation of relinearization * TODO: switchable modes for approximation technique */ - GaussianFactor::shared_ptr linearize(const Values& c) const; + GTSAM_EXPORT GaussianFactor::shared_ptr linearize(const Values& c) const; /** * Creates an anti-factor directly */ - GaussianFactor::shared_ptr negateToGaussian() const; + GTSAM_EXPORT GaussianFactor::shared_ptr negateToGaussian() const; /** * Creates the equivalent anti-factor as another LinearContainerFactor. */ - NonlinearFactor::shared_ptr negateToNonlinear() const; + GTSAM_EXPORT NonlinearFactor::shared_ptr negateToNonlinear() const; /** * Creates a shared_ptr clone of the factor - needs to be specialized to allow @@ -127,31 +127,31 @@ public: /** * Simple checks whether this is a Jacobian or Hessian factor */ - bool isJacobian() const; - bool isHessian() const; + GTSAM_EXPORT bool isJacobian() const; + GTSAM_EXPORT bool isHessian() const; /** Casts to JacobianFactor */ - boost::shared_ptr toJacobian() const; + GTSAM_EXPORT boost::shared_ptr toJacobian() const; /** Casts to HessianFactor */ - boost::shared_ptr toHessian() const; + GTSAM_EXPORT boost::shared_ptr toHessian() const; /** * Utility function for converting linear graphs to nonlinear graphs * consisting of LinearContainerFactors. */ - static NonlinearFactorGraph ConvertLinearGraph(const GaussianFactorGraph& linear_graph, + GTSAM_EXPORT static NonlinearFactorGraph ConvertLinearGraph(const GaussianFactorGraph& linear_graph, const Values& linearizationPoint = Values()); #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4 - static NonlinearFactorGraph convertLinearGraph(const GaussianFactorGraph& linear_graph, + GTSAM_EXPORT static NonlinearFactorGraph convertLinearGraph(const GaussianFactorGraph& linear_graph, const Values& linearizationPoint = Values()) { return ConvertLinearGraph(linear_graph, linearizationPoint); } #endif protected: - void initializeLinearizationPoint(const Values& linearizationPoint); + GTSAM_EXPORT void initializeLinearizationPoint(const Values& linearizationPoint); private: diff --git a/gtsam/nonlinear/NonlinearOptimizerParams.h b/gtsam/nonlinear/NonlinearOptimizerParams.h index 3018a14b9..180f4fb84 100644 --- a/gtsam/nonlinear/NonlinearOptimizerParams.h +++ b/gtsam/nonlinear/NonlinearOptimizerParams.h @@ -31,7 +31,7 @@ namespace gtsam { /** The common parameters for Nonlinear optimizers. Most optimizers * deriving from NonlinearOptimizer also subclass the parameters. */ -class GTSAM_EXPORT NonlinearOptimizerParams { +class NonlinearOptimizerParams { public: /** See NonlinearOptimizerParams::verbosity */ enum Verbosity { @@ -52,7 +52,7 @@ public: virtual ~NonlinearOptimizerParams() { } - virtual void print(const std::string& str = "") const; + GTSAM_EXPORT virtual void print(const std::string& str = "") const; size_t getMaxIterations() const { return maxIterations; } double getRelativeErrorTol() const { return relativeErrorTol; } @@ -68,8 +68,8 @@ public: verbosity = verbosityTranslator(src); } - static Verbosity verbosityTranslator(const std::string &s) ; - static std::string verbosityTranslator(Verbosity value) ; + GTSAM_EXPORT static Verbosity verbosityTranslator(const std::string &s) ; + GTSAM_EXPORT static std::string verbosityTranslator(Verbosity value) ; /** See NonlinearOptimizerParams::linearSolverType */ enum LinearSolverType { @@ -144,10 +144,10 @@ public: } private: - std::string linearSolverTranslator(LinearSolverType linearSolverType) const; - LinearSolverType linearSolverTranslator(const std::string& linearSolverType) const; - std::string orderingTypeTranslator(Ordering::OrderingType type) const; - Ordering::OrderingType orderingTypeTranslator(const std::string& type) const; + GTSAM_EXPORT std::string linearSolverTranslator(LinearSolverType linearSolverType) const; + GTSAM_EXPORT LinearSolverType linearSolverTranslator(const std::string& linearSolverType) const; + GTSAM_EXPORT std::string orderingTypeTranslator(Ordering::OrderingType type) const; + GTSAM_EXPORT Ordering::OrderingType orderingTypeTranslator(const std::string& type) const; }; // For backward compatibility: diff --git a/gtsam/nonlinear/Values.h b/gtsam/nonlinear/Values.h index 1048cd73a..4b0fceaf9 100644 --- a/gtsam/nonlinear/Values.h +++ b/gtsam/nonlinear/Values.h @@ -422,7 +422,7 @@ namespace gtsam { }; /* ************************************************************************* */ - class GTSAM_EXPORT ValuesKeyAlreadyExists : public std::exception { + class ValuesKeyAlreadyExists : public std::exception { protected: const Key key_; ///< The key that already existed @@ -440,11 +440,11 @@ namespace gtsam { Key key() const throw() { return key_; } /// The message to be displayed to the user - virtual const char* what() const throw(); + GTSAM_EXPORT virtual const char* what() const throw(); }; /* ************************************************************************* */ - class GTSAM_EXPORT ValuesKeyDoesNotExist : public std::exception { + class ValuesKeyDoesNotExist : public std::exception { protected: const char* operation_; ///< The operation that attempted to access the key const Key key_; ///< The key that does not exist @@ -463,11 +463,11 @@ namespace gtsam { Key key() const throw() { return key_; } /// The message to be displayed to the user - virtual const char* what() const throw(); + GTSAM_EXPORT virtual const char* what() const throw(); }; /* ************************************************************************* */ - class GTSAM_EXPORT ValuesIncorrectType : public std::exception { + class ValuesIncorrectType : public std::exception { protected: const Key key_; ///< The key requested const std::type_info& storedTypeId_; @@ -494,11 +494,11 @@ namespace gtsam { const std::type_info& requestedTypeId() const { return requestedTypeId_; } /// The message to be displayed to the user - virtual const char* what() const throw(); + GTSAM_EXPORT virtual const char* what() const throw(); }; /* ************************************************************************* */ - class GTSAM_EXPORT DynamicValuesMismatched : public std::exception { + class DynamicValuesMismatched : public std::exception { public: DynamicValuesMismatched() throw() {} @@ -511,7 +511,7 @@ namespace gtsam { }; /* ************************************************************************* */ - class GTSAM_EXPORT NoMatchFoundForFixed: public std::exception { + class NoMatchFoundForFixed: public std::exception { protected: const size_t M1_, N1_; @@ -528,7 +528,7 @@ namespace gtsam { virtual ~NoMatchFoundForFixed() throw () { } - virtual const char* what() const throw (); + GTSAM_EXPORT virtual const char* what() const throw (); }; /* ************************************************************************* */ diff --git a/gtsam/symbolic/SymbolicBayesNet.h b/gtsam/symbolic/SymbolicBayesNet.h index ab89a4dba..ca87b2bbc 100644 --- a/gtsam/symbolic/SymbolicBayesNet.h +++ b/gtsam/symbolic/SymbolicBayesNet.h @@ -27,7 +27,7 @@ namespace gtsam { /** Symbolic Bayes Net * \nosubgrouping */ - class GTSAM_EXPORT SymbolicBayesNet : public FactorGraph { + class SymbolicBayesNet : public FactorGraph { public: @@ -61,14 +61,14 @@ namespace gtsam { /// @{ /** Check equality */ - bool equals(const This& bn, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const This& bn, double tol = 1e-9) const; /// @} /// @name Standard Interface /// @{ - void saveGraph(const std::string &s, const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; + GTSAM_EXPORT void saveGraph(const std::string &s, const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; /// @} diff --git a/gtsam/symbolic/SymbolicBayesTree.h b/gtsam/symbolic/SymbolicBayesTree.h index e28f28764..5f7bdde7e 100644 --- a/gtsam/symbolic/SymbolicBayesTree.h +++ b/gtsam/symbolic/SymbolicBayesTree.h @@ -30,7 +30,7 @@ namespace gtsam { /* ************************************************************************* */ /// A clique in a SymbolicBayesTree - class GTSAM_EXPORT SymbolicBayesTreeClique : + class SymbolicBayesTreeClique : public BayesTreeCliqueBase { public: @@ -45,7 +45,7 @@ namespace gtsam { /* ************************************************************************* */ /// A Bayes tree that represents the connectivity between variables but is not associated with any /// probability functions. - class GTSAM_EXPORT SymbolicBayesTree : + class SymbolicBayesTree : public BayesTree { private: @@ -59,7 +59,7 @@ namespace gtsam { SymbolicBayesTree() {} /** check equality */ - bool equals(const This& other, double tol = 1e-9) const; + GTSAM_EXPORT bool equals(const This& other, double tol = 1e-9) const; private: /** Serialization function */ diff --git a/gtsam_unstable/geometry/Event.h b/gtsam_unstable/geometry/Event.h index b22164117..fc186857f 100644 --- a/gtsam_unstable/geometry/Event.h +++ b/gtsam_unstable/geometry/Event.h @@ -22,6 +22,7 @@ #include #include #include +#include namespace gtsam { @@ -60,10 +61,10 @@ public: } /** print with optional string */ - GTSAM_EXPORT void print(const std::string& s = "") const; + GTSAM_UNSTABLE_EXPORT void print(const std::string& s = "") const; /** equals with an tolerance */ - GTSAM_EXPORT bool equals(const Event& other, double tol = 1e-9) const; + GTSAM_UNSTABLE_EXPORT bool equals(const Event& other, double tol = 1e-9) const; /// Updates a with tangent space delta inline Event retract(const Vector4& v) const { diff --git a/gtsam_unstable/geometry/Similarity3.h b/gtsam_unstable/geometry/Similarity3.h index a3d80c1d0..bf4937ed4 100644 --- a/gtsam_unstable/geometry/Similarity3.h +++ b/gtsam_unstable/geometry/Similarity3.h @@ -21,6 +21,7 @@ #include #include #include +#include namespace gtsam { @@ -49,59 +50,59 @@ public: /// @{ /// Default constructor - GTSAM_EXPORT Similarity3(); + GTSAM_UNSTABLE_EXPORT Similarity3(); /// Construct pure scaling - GTSAM_EXPORT Similarity3(double s); + GTSAM_UNSTABLE_EXPORT Similarity3(double s); /// Construct from GTSAM types - GTSAM_EXPORT Similarity3(const Rot3& R, const Point3& t, double s); + GTSAM_UNSTABLE_EXPORT Similarity3(const Rot3& R, const Point3& t, double s); /// Construct from Eigen types - GTSAM_EXPORT Similarity3(const Matrix3& R, const Vector3& t, double s); + GTSAM_UNSTABLE_EXPORT Similarity3(const Matrix3& R, const Vector3& t, double s); /// Construct from matrix [R t; 0 s^-1] - GTSAM_EXPORT Similarity3(const Matrix4& T); + GTSAM_UNSTABLE_EXPORT Similarity3(const Matrix4& T); /// @} /// @name Testable /// @{ /// Compare with tolerance - GTSAM_EXPORT bool equals(const Similarity3& sim, double tol) const; + GTSAM_UNSTABLE_EXPORT bool equals(const Similarity3& sim, double tol) const; /// Exact equality - GTSAM_EXPORT bool operator==(const Similarity3& other) const; + GTSAM_UNSTABLE_EXPORT bool operator==(const Similarity3& other) const; /// Print with optional string - GTSAM_EXPORT void print(const std::string& s) const; + GTSAM_UNSTABLE_EXPORT void print(const std::string& s) const; - GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &os, const Similarity3& p); + GTSAM_UNSTABLE_EXPORT friend std::ostream &operator<<(std::ostream &os, const Similarity3& p); /// @} /// @name Group /// @{ /// Return an identity transform - GTSAM_EXPORT static Similarity3 identity(); + GTSAM_UNSTABLE_EXPORT static Similarity3 identity(); /// Composition - GTSAM_EXPORT Similarity3 operator*(const Similarity3& T) const; + GTSAM_UNSTABLE_EXPORT Similarity3 operator*(const Similarity3& T) const; /// Return the inverse - GTSAM_EXPORT Similarity3 inverse() const; + GTSAM_UNSTABLE_EXPORT Similarity3 inverse() const; /// @} /// @name Group action on Point3 /// @{ /// Action on a point p is s*(R*p+t) - GTSAM_EXPORT Point3 transformFrom(const Point3& p, // + GTSAM_UNSTABLE_EXPORT Point3 transformFrom(const Point3& p, // OptionalJacobian<3, 7> H1 = boost::none, // OptionalJacobian<3, 3> H2 = boost::none) const; /** syntactic sugar for transformFrom */ - GTSAM_EXPORT Point3 operator*(const Point3& p) const; + GTSAM_UNSTABLE_EXPORT Point3 operator*(const Point3& p) const; /// @} /// @name Lie Group @@ -110,12 +111,12 @@ public: /** Log map at the identity * \f$ [R_x,R_y,R_z, t_x, t_y, t_z, \lambda] \f$ */ - GTSAM_EXPORT static Vector7 Logmap(const Similarity3& s, // + GTSAM_UNSTABLE_EXPORT static Vector7 Logmap(const Similarity3& s, // OptionalJacobian<7, 7> Hm = boost::none); /** Exponential map at the identity */ - GTSAM_EXPORT static Similarity3 Expmap(const Vector7& v, // + GTSAM_UNSTABLE_EXPORT static Similarity3 Expmap(const Vector7& v, // OptionalJacobian<7, 7> Hm = boost::none); /// Chart at the origin @@ -136,17 +137,17 @@ public: * @return 4*4 element of Lie algebra that can be exponentiated * TODO(frank): rename to Hat, make part of traits */ - GTSAM_EXPORT static Matrix4 wedge(const Vector7& xi); + GTSAM_UNSTABLE_EXPORT static Matrix4 wedge(const Vector7& xi); /// Project from one tangent space to another - GTSAM_EXPORT Matrix7 AdjointMap() const; + GTSAM_UNSTABLE_EXPORT Matrix7 AdjointMap() const; /// @} /// @name Standard interface /// @{ /// Calculate 4*4 matrix group equivalent - GTSAM_EXPORT const Matrix4 matrix() const; + GTSAM_UNSTABLE_EXPORT const Matrix4 matrix() const; /// Return a GTSAM rotation const Rot3& rotation() const { @@ -165,7 +166,7 @@ public: /// Convert to a rigid body pose (R, s*t) /// TODO(frank): why is this here? Red flag! Definitely don't have it as a cast. - GTSAM_EXPORT operator Pose3() const; + GTSAM_UNSTABLE_EXPORT operator Pose3() const; /// Dimensionality of tangent space = 7 DOF - used to autodetect sizes inline static size_t Dim() {