Skip to content

Commit

Permalink
{rolling} rtabmap: Allow rtabmap to be build without graphic support.
Browse files Browse the repository at this point in the history
Signed-off-by: Windel Bouwman <[email protected]>
Signed-off-by: Rob Woolley <[email protected]>
  • Loading branch information
windelbouwman authored and robwoolley committed Nov 26, 2024
1 parent f36f626 commit 2394795
Show file tree
Hide file tree
Showing 4 changed files with 498 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Upstream-Status: Pending

Signed-off-by: Windel Bouwman <[email protected]>

From 3c219390cf625a8c838c42151f86098559030dfb Mon Sep 17 00:00:00 2001
From: Windel Bouwman <[email protected]>
Date: Fri, 13 May 2022 13:44:09 +0200
Subject: [PATCH] Use cmake Thread package to find proper threading library.

---
utilite/CMakeLists.txt | 2 +-
utilite/src/CMakeLists.txt | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)

Index: git/utilite/CMakeLists.txt
===================================================================
--- git.orig/utilite/CMakeLists.txt
+++ git/utilite/CMakeLists.txt
@@ -2,7 +2,7 @@ SET(UTILITE_VERSION "0.3.0")
ADD_DEFINITIONS(-DUTILITE_VERSION="${UTILITE_VERSION}")

if(UNIX AND NOT ANDROID)
- FIND_PACKAGE(Pthreads REQUIRED)
+ FIND_PACKAGE(Threads REQUIRED)
ENDIF(UNIX AND NOT ANDROID)

ADD_SUBDIRECTORY( src )
Index: git/utilite/src/CMakeLists.txt
===================================================================
--- git.orig/utilite/src/CMakeLists.txt
+++ git/utilite/src/CMakeLists.txt
@@ -20,16 +20,16 @@ generate_export_header(rtabmap_utilite
BASE_NAME utilite)

target_include_directories(rtabmap_utilite PUBLIC
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include;${CMAKE_CURRENT_BINARY_DIR}/include;${PTHREADS_INCLUDE_DIR}>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include;${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR};${PTHREADS_INCLUDE_DIR}>")

IF(MINGW)
- TARGET_LINK_LIBRARIES(rtabmap_utilite PRIVATE ${PTHREADS_LIBRARY} "-lpsapi")
+ TARGET_LINK_LIBRARIES(rtabmap_utilite Threads::Threads "-lpsapi")
ELSEIF(WIN32 OR MSVC)
FIND_LIBRARY(PSAPI_LIBRARIES NAMES psapi libpsapi.dll.a libpsapi.a libpsapi.lib )
TARGET_LINK_LIBRARIES(rtabmap_utilite PRIVATE ${PSAPI_LIBRARIES})
ELSE()
- TARGET_LINK_LIBRARIES(rtabmap_utilite PRIVATE ${PTHREADS_LIBRARY})
+ TARGET_LINK_LIBRARIES(rtabmap_utilite Threads::Threads)
ENDIF()

SET_TARGET_PROPERTIES(
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
From 85cc6fe3c742855ad16c8442895e12dbb10b6e8b Mon Sep 17 00:00:00 2001
From: matlabbe <[email protected]>
Date: Wed, 22 Mar 2023 20:42:33 -0700
Subject: [PATCH] fixed build with latest g2o c++17 (#999)

---
CMakeLists.txt | 130 ++++++++++++-------------
corelib/src/optimizer/OptimizerG2O.cpp | 31 +++---
2 files changed, 80 insertions(+), 81 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 047c2f38e7..4d78f05904 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -314,8 +314,8 @@ IF(WITH_QT)
IF("${VTK_MAJOR_VERSION}" GREATER 5)
IF(RTABMAP_QT_VERSION STREQUAL "AUTO" OR RTABMAP_QT_VERSION STREQUAL "5")
FIND_PACKAGE(Qt5 COMPONENTS Widgets Core Gui OpenGL PrintSupport QUIET OPTIONAL_COMPONENTS Svg)
- ENDIF(RTABMAP_QT_VERSION STREQUAL "AUTO" OR RTABMAP_QT_VERSION STREQUAL "5")
- ENDIF("${VTK_MAJOR_VERSION}" GREATER 5)
+ ENDIF(RTABMAP_QT_VERSION STREQUAL "AUTO" OR RTABMAP_QT_VERSION STREQUAL "5")
+ ENDIF("${VTK_MAJOR_VERSION}" GREATER 5)

IF(NOT Qt5_FOUND)
IF(RTABMAP_QT_VERSION STREQUAL "AUTO" OR RTABMAP_QT_VERSION STREQUAL "4")
@@ -328,8 +328,8 @@ IF(WITH_QT)
IF("${VTK_MAJOR_VERSION}" EQUAL 5)
FIND_PACKAGE(QVTK REQUIRED) # only for VTK 5
ELSE()
- list(FIND PCL_LIBRARIES VTK::GUISupportQt value)
- IF(value EQUAL -1)
+ list(FIND PCL_LIBRARIES VTK::GUISupportQt value)
+ IF(value EQUAL -1)
list(FIND PCL_LIBRARIES vtkGUISupportQt value)
IF(value EQUAL -1)
IF(NOT(${VTK_MAJOR_VERSION} LESS 9))
@@ -339,8 +339,8 @@ IF(WITH_QT)
ENDIF()
SET(ADD_VTK_GUI_SUPPORT_QT_TO_CONF TRUE)
ENDIF(value EQUAL -1)
- ENDIF(value EQUAL -1)
-
+ ENDIF(value EQUAL -1)
+
MESSAGE(STATUS "VTK_RENDERING_BACKEND=${VTK_RENDERING_BACKEND}")

IF(VTK_RENDERING_BACKEND STREQUAL "OpenGL2")
@@ -358,12 +358,12 @@ IF(WITH_QT)
ENDIF(value EQUAL -1)
ELSEIF("${VTK_MAJOR_VERSION}" EQUAL 9)
list(FIND PCL_LIBRARIES VTK::RenderingOpenGL2 value)
- IF(NOT value EQUAL -1)
- list(FIND PCL_LIBRARIES VTK::RenderingVolumeOpenGL2 value)
+ IF(NOT value EQUAL -1)
+ list(FIND PCL_LIBRARIES VTK::RenderingVolumeOpenGL2 value)
IF(value EQUAL -1)
SET(PCL_LIBRARIES "${PCL_LIBRARIES};VTK::RenderingVolumeOpenGL2")
ENDIF(value EQUAL -1)
- ENDIF(NOT value EQUAL -1)
+ ENDIF(NOT value EQUAL -1)
ENDIF()

ENDIF()
@@ -426,7 +426,7 @@ ENDIF(WITH_FREENECT2)

IF(WITH_K4W2 AND WIN32)
FIND_PACKAGE(KinectSDK2 QUIET)
- IF(KinectSDK2_FOUND)
+ IF(KinectSDK2_FOUND)
MESSAGE(STATUS "Found Kinect for Windows 2: ${KinectSDK2_INCLUDE_DIRS}")
ENDIF(KinectSDK2_FOUND)
ENDIF(WITH_K4W2 AND WIN32)
@@ -441,7 +441,7 @@ IF(WITH_K4A)
SET(k4a_FOUND FALSE)
ENDIF(NOT (k4a_FOUND AND k4arecord_FOUND))
ENDIF()
- IF(k4a_FOUND)
+ IF(k4a_FOUND)
MESSAGE(STATUS "Found Kinect for Azure: ${k4a_INCLUDE_DIRS}")
ENDIF(k4a_FOUND)
ENDIF(WITH_K4A)
@@ -465,10 +465,10 @@ IF(WITH_G2O)
FIND_PACKAGE(g2o NO_MODULE)
IF(g2o_FOUND)
MESSAGE(STATUS "Found g2o (targets)")
- SET(G2O_FOUND ${g2o_FOUND})
- get_target_property(G2O_INCLUDES g2o::core INTERFACE_INCLUDE_DIRECTORIES)
- MESSAGE(STATUS "g2o include dir: ${G2O_INCLUDES}")
- FIND_FILE(G2O_FACTORY_FILE g2o/core/factory.h
+ SET(G2O_FOUND ${g2o_FOUND})
+ get_target_property(G2O_INCLUDES g2o::core INTERFACE_INCLUDE_DIRECTORIES)
+ MESSAGE(STATUS "g2o include dir: ${G2O_INCLUDES}")
+ FIND_FILE(G2O_FACTORY_FILE g2o/core/factory.h
PATHS ${G2O_INCLUDES}
NO_DEFAULT_PATH)
FILE(READ ${G2O_FACTORY_FILE} TMPTXT)
@@ -528,8 +528,8 @@ IF(libpointmatcher_FOUND OR GTSAM_FOUND)
find_package(Boost COMPONENTS thread filesystem system program_options date_time chrono timer serialization REQUIRED)
ENDIF(Boost_MINOR_VERSION GREATER 47)
IF(WIN32)
- MESSAGE(STATUS "Boost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}")
- link_directories(${Boost_LIBRARY_DIRS})
+ MESSAGE(STATUS "Boost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}")
+ link_directories(${Boost_LIBRARY_DIRS})
ENDIF(WIN32)
ENDIF(libpointmatcher_FOUND OR GTSAM_FOUND)

@@ -766,57 +766,57 @@ IF(WITH_ORB_SLAM AND NOT G2O_FOUND)
ENDIF(WITH_ORB_SLAM AND NOT G2O_FOUND)

IF(NOT MSVC)
- IF(Qt6_FOUND)
+ IF(Qt6_FOUND OR (G2O_FOUND AND ${G2O_CPP11} EQUAL 1))
# Qt6 requires c++17
include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
- IF(COMPILER_SUPPORTS_CXX17)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
- set(CMAKE_CXX_STANDARD 17)
- ELSE()
- message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler if you want to use Qt6.")
- ENDIF()
+ CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
+ IF(COMPILER_SUPPORTS_CXX17)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
+ set(CMAKE_CXX_STANDARD 17)
+ ELSE()
+ message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler if you want to use Qt6.")
+ ENDIF()
+ ENDIF()
+ IF((NOT (${CMAKE_CXX_STANDARD} STREQUAL "17")) AND ((NOT WITH_MSCKF_VIO OR NOT msckf_vio_FOUND) AND (loam_velodyne_FOUND OR floam_FOUND OR PCL_VERSION VERSION_GREATER "1.9.1" OR TORCH_FOUND OR G2O_FOUND OR CCCoreLib_FOUND OR Open3D_FOUND)))
+ #LOAM, PCL>=1.10, latest g2o and CCCoreLib require c++14, but MSCKF_VIO requires c++11
+ include(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
+ IF(COMPILER_SUPPORTS_CXX14)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+ set(CMAKE_CXX_STANDARD 14)
+ ELSE()
+ message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler if you want to use LOAM, latest PCL or g2o.")
+ ENDIF()
+ ENDIF()
+
+ IF( (NOT (${CMAKE_CXX_STANDARD} STREQUAL "17") AND NOT (${CMAKE_CXX_STANDARD} STREQUAL "14")) AND (
+ G2O_FOUND OR
+ GTSAM_FOUND OR
+ CERES_FOUND OR
+ ZED_FOUND OR
+ ZEDOC_FOUND OR
+ ANDROID OR
+ RealSense_FOUND OR
+ realsense2_FOUND OR
+ ORB_SLAM_FOUND OR
+ okvis_FOUND OR
+ open_chisel_FOUND OR
+ msckf_vio_FOUND OR
+ vins_FOUND OR
+ ov_msckf_FOUND OR
+ libpointmatcher_FOUND))
+ #Newest versions require std11
+ include(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+ CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+ IF(COMPILER_SUPPORTS_CXX11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ ELSEIF(COMPILER_SUPPORTS_CXX0X)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ ELSE()
+ message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+ ENDIF()
ENDIF()
- IF((NOT (${CMAKE_CXX_STANDARD} STREQUAL "17")) AND ((NOT WITH_MSCKF_VIO OR NOT msckf_vio_FOUND) AND (loam_velodyne_FOUND OR floam_FOUND OR PCL_VERSION VERSION_GREATER "1.9.1" OR TORCH_FOUND OR G2O_FOUND OR CCCoreLib_FOUND OR Open3D_FOUND)))
- #LOAM, PCL>=1.10, latest g2o and CCCoreLib require c++14, but MSCKF_VIO requires c++11
- include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
- IF(COMPILER_SUPPORTS_CXX14)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
- set(CMAKE_CXX_STANDARD 14)
- ELSE()
- message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler if you want to use LOAM, latest PCL or g2o.")
- ENDIF()
- ENDIF()
-
- IF( (NOT (${CMAKE_CXX_STANDARD} STREQUAL "17") AND NOT (${CMAKE_CXX_STANDARD} STREQUAL "14")) AND (
- G2O_FOUND OR
- GTSAM_FOUND OR
- CERES_FOUND OR
- ZED_FOUND OR
- ZEDOC_FOUND OR
- ANDROID OR
- RealSense_FOUND OR
- realsense2_FOUND OR
- ORB_SLAM_FOUND OR
- okvis_FOUND OR
- open_chisel_FOUND OR
- msckf_vio_FOUND OR
- vins_FOUND OR
- ov_msckf_FOUND OR
- libpointmatcher_FOUND))
- #Newest versions require std11
- include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
- CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
- IF(COMPILER_SUPPORTS_CXX11)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- ELSEIF(COMPILER_SUPPORTS_CXX0X)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
- ELSE()
- message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
- ENDIF()
- ENDIF()
ENDIF()

####### OSX BUNDLE CMAKE_INSTALL_PREFIX #######
diff --git a/corelib/src/optimizer/OptimizerG2O.cpp b/corelib/src/optimizer/OptimizerG2O.cpp
index 405882e4b1..dfcfdb1f05 100644
--- a/corelib/src/optimizer/OptimizerG2O.cpp
+++ b/corelib/src/optimizer/OptimizerG2O.cpp
@@ -1,4 +1,3 @@
-/*
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
All rights reserved.

@@ -154,7 +153,7 @@ OptimizerG2O::OptimizerG2O(const ParametersMap & parameters) :
if(!g2o::Factory::instance()->knowsTag("CACHE_SE3_OFFSET"))
{
#if defined(RTABMAP_G2O_CPP11) && RTABMAP_G2O_CPP11 == 1
- g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", g2o::make_unique<g2o::HyperGraphElementCreator<g2o::CacheSE3Offset> >());
+ g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", std::make_unique<g2o::HyperGraphElementCreator<g2o::CacheSE3Offset> >());
#else
g2o::Factory::instance()->registerType("CACHE_SE3_OFFSET", new g2o::HyperGraphElementCreator<g2o::CacheSE3Offset>);
#endif
@@ -250,17 +249,17 @@ std::map<int, Transform> OptimizerG2O::optimize(
if(solver_ == 3)
{
//eigen
- auto linearSolver = g2o::make_unique<SlamLinearEigenSolver>();
+ auto linearSolver = std::make_unique<SlamLinearEigenSolver>();
linearSolver->setBlockOrdering(false);
- blockSolver = g2o::make_unique<SlamBlockSolver>(std::move(linearSolver));
+ blockSolver = std::make_unique<SlamBlockSolver>(std::move(linearSolver));
}
#ifdef G2O_HAVE_CHOLMOD
else if(solver_ == 2)
{
//chmold
- auto linearSolver = g2o::make_unique<SlamLinearCholmodSolver>();
+ auto linearSolver = std::make_unique<SlamLinearCholmodSolver>();
linearSolver->setBlockOrdering(false);
- blockSolver = g2o::make_unique<SlamBlockSolver>(std::move(linearSolver));
+ blockSolver = std::make_unique<SlamBlockSolver>(std::move(linearSolver));
}
#endif
#ifdef G2O_HAVE_CSPARSE
@@ -268,16 +267,16 @@ std::map<int, Transform> OptimizerG2O::optimize(
{

//csparse
- auto linearSolver = g2o::make_unique<SlamLinearCSparseSolver>();
+ auto linearSolver = std::make_unique<SlamLinearCSparseSolver>();
linearSolver->setBlockOrdering(false);
- blockSolver = g2o::make_unique<SlamBlockSolver>(std::move(linearSolver));
+ blockSolver = std::make_unique<SlamBlockSolver>(std::move(linearSolver));
}
#endif
else
{
//pcg
- auto linearSolver = g2o::make_unique<SlamLinearPCGSolver>();
- blockSolver = g2o::make_unique<SlamBlockSolver>(std::move(linearSolver));
+ auto linearSolver = std::make_unique<SlamLinearPCGSolver>();
+ blockSolver = std::make_unique<SlamBlockSolver>(std::move(linearSolver));
}

if(optimizer_ == 1)
@@ -1427,7 +1426,7 @@ std::map<int, Transform> OptimizerG2O::optimizeBA(
{
//eigen
#ifdef RTABMAP_G2O_CPP11
- linearSolver = g2o::make_unique<g2o::LinearSolverEigen<g2o::BlockSolver_6_3::PoseMatrixType> >();
+ linearSolver = std::make_unique<g2o::LinearSolverEigen<g2o::BlockSolver_6_3::PoseMatrixType> >();
#else
linearSolver = new g2o::LinearSolverEigen<g2o::BlockSolver_6_3::PoseMatrixType>();
#endif
@@ -1437,7 +1436,7 @@ std::map<int, Transform> OptimizerG2O::optimizeBA(
{
//chmold
#ifdef RTABMAP_G2O_CPP11
- linearSolver = g2o::make_unique<g2o::LinearSolverCholmod<g2o::BlockSolver_6_3::PoseMatrixType> >();
+ linearSolver = std::make_unique<g2o::LinearSolverCholmod<g2o::BlockSolver_6_3::PoseMatrixType> >();
#else
linearSolver = new g2o::LinearSolverCholmod<g2o::BlockSolver_6_3::PoseMatrixType>();
#endif
@@ -1448,7 +1447,7 @@ std::map<int, Transform> OptimizerG2O::optimizeBA(
{
//csparse
#ifdef RTABMAP_G2O_CPP11
- linearSolver = g2o::make_unique<g2o::LinearSolverCSparse<g2o::BlockSolver_6_3::PoseMatrixType> >();
+ linearSolver = std::make_unique<g2o::LinearSolverCSparse<g2o::BlockSolver_6_3::PoseMatrixType> >();
#else
linearSolver = new g2o::LinearSolverCSparse<g2o::BlockSolver_6_3::PoseMatrixType>();
#endif
@@ -1458,7 +1457,7 @@ std::map<int, Transform> OptimizerG2O::optimizeBA(
{
//pcg
#ifdef RTABMAP_G2O_CPP11
- linearSolver = g2o::make_unique<g2o::LinearSolverPCG<g2o::BlockSolver_6_3::PoseMatrixType> >();
+ linearSolver = std::make_unique<g2o::LinearSolverPCG<g2o::BlockSolver_6_3::PoseMatrixType> >();
#else
linearSolver = new g2o::LinearSolverPCG<g2o::BlockSolver_6_3::PoseMatrixType>();
#endif
@@ -1470,7 +1469,7 @@ std::map<int, Transform> OptimizerG2O::optimizeBA(
{
#ifdef RTABMAP_G2O_CPP11
optimizer.setAlgorithm(new g2o::OptimizationAlgorithmGaussNewton(
- g2o::make_unique<g2o::BlockSolver_6_3>(std::move(linearSolver))));
+ std::make_unique<g2o::BlockSolver_6_3>(std::move(linearSolver))));
#else
optimizer.setAlgorithm(new g2o::OptimizationAlgorithmGaussNewton(new g2o::BlockSolver_6_3(linearSolver)));
#endif
@@ -1480,7 +1479,7 @@ std::map<int, Transform> OptimizerG2O::optimizeBA(
{
#if defined(RTABMAP_G2O_CPP11) && !defined(RTABMAP_ORB_SLAM)
optimizer.setAlgorithm(new g2o::OptimizationAlgorithmLevenberg(
- g2o::make_unique<g2o::BlockSolver_6_3>(std::move(linearSolver))));
+ std::make_unique<g2o::BlockSolver_6_3>(std::move(linearSolver))));
#else
optimizer.setAlgorithm(new g2o::OptimizationAlgorithmLevenberg(new g2o::BlockSolver_6_3(linearSolver)));
#endif
Loading

0 comments on commit 2394795

Please sign in to comment.