mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-08 12:30:20 +08:00
Fixed g2o build error with melodic/noetic versions
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@NONFREE@#define RTABMAP_NONFREE
|
||||
@TORO@#define RTABMAP_TORO
|
||||
@G2O@#define RTABMAP_G2O
|
||||
@G2O_CPP_CONF@#define RTABMAP_G2O_CPP11
|
||||
@G2O_CPP_CONF@#define RTABMAP_G2O_CPP11 @G2O_CPP11@
|
||||
@GTSAM@#define RTABMAP_GTSAM
|
||||
@CERES@#define RTABMAP_CERES
|
||||
@VERTIGO@#define RTABMAP_VERTIGO
|
||||
|
||||
@@ -22,6 +22,10 @@ FIND_FILE(G2O_CONFIG_FILE g2o/config.h
|
||||
PATHS ${G2O_INCLUDE_DIR}
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
FIND_FILE(G2O_FACTORY_FILE g2o/core/factory.h
|
||||
PATHS ${G2O_INCLUDE_DIR}
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
#ifdef G2O_NUMBER_FORMAT_STR
|
||||
#define G2O_CPP11 // we assume that if G2O_NUMBER_FORMAT_STR is defined, this is the new g2o code with c++11 interface
|
||||
#endif
|
||||
@@ -84,7 +88,7 @@ ENDIF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER
|
||||
|
||||
# G2O itself declared found if we found the core libraries and at least one solver
|
||||
SET(G2O_FOUND "NO")
|
||||
IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_CONFIG_FILE AND G2O_SOLVERS_FOUND)
|
||||
IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_CONFIG_FILE AND G2O_FACTORY_FILE AND G2O_SOLVERS_FOUND)
|
||||
SET(G2O_INCLUDE_DIRS ${G2O_INCLUDE_DIR})
|
||||
SET(G2O_LIBRARIES
|
||||
${G2O_CORE_LIBRARY}
|
||||
@@ -121,8 +125,16 @@ IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_CONFIG_FIL
|
||||
SET(G2O_CPP11 0)
|
||||
ELSE()
|
||||
MESSAGE(WARNING "Latest g2o version detected with c++11 interface (config file: ${G2O_CONFIG_FILE}). Make sure g2o is built with \"-DBUILD_WITH_MARCH_NATIVE=OFF\" to avoid segmentation faults caused by Eigen.")
|
||||
SET(G2O_CPP11 1)
|
||||
FILE(READ ${G2O_FACTORY_FILE} TMPTXT)
|
||||
STRING(FIND "${TMPTXT}" "shared_ptr" matchres)
|
||||
IF(${matchres} EQUAL -1)
|
||||
MESSAGE(STATUS "Old g2o factory version detected without shared ptr (factory file: ${G2O_FACTORY_FILE}).")
|
||||
SET(G2O_CPP11 2)
|
||||
ELSE()
|
||||
MESSAGE(WARNING "Latest g2o factory version detected with shared ptr (factory file: ${G2O_FACTORY_FILE}).")
|
||||
SET(G2O_CPP11 1)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(G2O_FOUND "YES")
|
||||
ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_CONFIG_FILE AND G2O_SOLVERS_FOUND)
|
||||
ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_CONFIG_FILE AND G2O_FACTORY_FILE AND G2O_SOLVERS_FOUND)
|
||||
|
||||
@@ -42,16 +42,7 @@ public:
|
||||
static bool isCholmodAvailable();
|
||||
|
||||
public:
|
||||
OptimizerG2O(const ParametersMap & parameters = ParametersMap()) :
|
||||
Optimizer(parameters),
|
||||
solver_(Parameters::defaultg2oSolver()),
|
||||
optimizer_(Parameters::defaultg2oOptimizer()),
|
||||
pixelVariance_(Parameters::defaultg2oPixelVariance()),
|
||||
robustKernelDelta_(Parameters::defaultg2oRobustKernelDelta()),
|
||||
baseline_(Parameters::defaultg2oBaseline())
|
||||
{
|
||||
parseParameters(parameters);
|
||||
}
|
||||
OptimizerG2O(const ParametersMap & parameters = ParametersMap());
|
||||
virtual ~OptimizerG2O() {}
|
||||
|
||||
virtual Type type() const {return kTypeG2O;}
|
||||
|
||||
@@ -137,6 +137,26 @@ bool OptimizerG2O::isCholmodAvailable()
|
||||
#endif
|
||||
}
|
||||
|
||||
OptimizerG2O::OptimizerG2O(const ParametersMap & parameters) :
|
||||
Optimizer(parameters),
|
||||
solver_(Parameters::defaultg2oSolver()),
|
||||
optimizer_(Parameters::defaultg2oOptimizer()),
|
||||
pixelVariance_(Parameters::defaultg2oPixelVariance()),
|
||||
robustKernelDelta_(Parameters::defaultg2oRobustKernelDelta()),
|
||||
baseline_(Parameters::defaultg2oBaseline())
|
||||
{
|
||||
// Issue on android, have to explicitly register this type when using fixed root prior below
|
||||
if(!g2o::Factory::instance()->knowsTag("CACHE_SE3_OFFSET"))
|
||||
{
|
||||
#if defined(RTABMAP_G2O_CPP11) and RTABMAP_G2O_CPP11 == 1
|
||||
g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", g2o::make_unique<g2o::HyperGraphElementCreator<g2o::CacheSE3Offset> >());
|
||||
#else
|
||||
g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", new g2o::HyperGraphElementCreator<g2o::CacheSE3Offset>);
|
||||
#endif
|
||||
}
|
||||
parseParameters(parameters);
|
||||
}
|
||||
|
||||
void OptimizerG2O::parseParameters(const ParametersMap & parameters)
|
||||
{
|
||||
Optimizer::parseParameters(parameters);
|
||||
@@ -149,16 +169,6 @@ void OptimizerG2O::parseParameters(const ParametersMap & parameters)
|
||||
UASSERT(pixelVariance_ > 0.0);
|
||||
UASSERT(baseline_ >= 0.0);
|
||||
|
||||
// Issue on android, have to explicitly register this type when using fixed root prior below
|
||||
if(!g2o::Factory::instance()->knowsTag("CACHE_SE3_OFFSET"))
|
||||
{
|
||||
#ifdef RTABMAP_G2O_CPP11
|
||||
g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", g2o::make_unique<g2o::HyperGraphElementCreator<g2o::CacheSE3Offset> >());
|
||||
#else
|
||||
g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", new g2o::HyperGraphElementCreator<g2o::CacheSE3Offset>);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef RTABMAP_ORB_SLAM
|
||||
if(solver_ != 3)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user