feat(slam): add rtabmap_ros
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
|
||||
SET(SRC_FILES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# For Apple set the icns file containing icons
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
# set how it shows up in the Info.plist file
|
||||
SET(MACOSX_BUNDLE_ICON_FILE ${PROJECT_NAME}.icns)
|
||||
# set where in the bundle to put the icns file
|
||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
# include the icns file in the target
|
||||
SET(SRC_FILES ${SRC_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.icns)
|
||||
ENDIF(APPLE AND BUILD_AS_BUNDLE)
|
||||
|
||||
# Add exe icon resource
|
||||
IF(WIN32)
|
||||
IF( MINGW )
|
||||
# resource compilation for MinGW
|
||||
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/AppIco.o
|
||||
COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.rc
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/AppIco.o )
|
||||
SET(SRC_FILES ${SRC_FILES} ${CMAKE_CURRENT_BINARY_DIR}/AppIco.o)
|
||||
ELSE( MINGW )
|
||||
SET(SRC_FILES ${SRC_FILES} ${PROJECT_NAME}.rc)
|
||||
ENDIF( MINGW )
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(BUILD_AS_BUNDLE)
|
||||
ADD_DEFINITIONS("-DBUILD_AS_BUNDLE")
|
||||
ENDIF()
|
||||
|
||||
# Add binary
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
ADD_EXECUTABLE(rtabmap_app MACOSX_BUNDLE ${SRC_FILES})
|
||||
ELSEIF(WIN32 AND BUILD_AS_BUNDLE)
|
||||
ADD_EXECUTABLE(rtabmap_app WIN32 ${SRC_FILES})
|
||||
ELSE()
|
||||
ADD_EXECUTABLE(rtabmap_app ${SRC_FILES})
|
||||
ENDIF()
|
||||
TARGET_LINK_LIBRARIES(rtabmap_app rtabmap_gui)
|
||||
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
SET_TARGET_PROPERTIES(rtabmap_app PROPERTIES
|
||||
OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
|
||||
ELSEIF(WIN32)
|
||||
SET_TARGET_PROPERTIES(rtabmap_app PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_NAME})
|
||||
ELSE()
|
||||
SET_TARGET_PROPERTIES(rtabmap_app PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_PREFIX})
|
||||
ENDIF()
|
||||
|
||||
#---------------------------
|
||||
# Installation stuff
|
||||
#---------------------------
|
||||
INSTALL(TARGETS rtabmap_app
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT runtime
|
||||
BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" COMPONENT runtime)
|
||||
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
INSTALL(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" ${PROJECT_NAME}
|
||||
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
|
||||
ENDIF(APPLE AND BUILD_AS_BUNDLE)
|
||||
|
||||
IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
SET(plugin_dest_dir bin/plugins)
|
||||
SET(qtconf_dest_dir bin)
|
||||
SET(thirdparty_dest_dir bin)
|
||||
|
||||
IF(APPLE)
|
||||
SET(plugin_dest_dir MacOS/plugins)
|
||||
IF(Qt6_FOUND)
|
||||
SET(plugin_dest_dir PlugIns)
|
||||
ENDIF()
|
||||
SET(qtconf_dest_dir Resources)
|
||||
SET(thirdparty_dest_dir MacOS)
|
||||
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
|
||||
ENDIF(APPLE)
|
||||
|
||||
IF(OpenNI2_FOUND)
|
||||
# Install needed OpenNI sensor dll by copying directories from the OpenNI2 installation
|
||||
IF(WIN32)
|
||||
find_path(OpenNI2_BIN_DIR NAMES OpenNI2.dll)
|
||||
IF(NOT OpenNI2_BIN_DIR)
|
||||
MESSAGE(FATAL_ERROR "OpenNI2.dll not found! Verify your PATH.")
|
||||
ENDIF(NOT OpenNI2_BIN_DIR)
|
||||
ELSE()
|
||||
# Mac OS X
|
||||
get_filename_component(OpenNI2_BIN_DIR "${OpenNI2_LIBRARY}" PATH)
|
||||
ENDIF()
|
||||
|
||||
INSTALL(DIRECTORY "${OpenNI2_BIN_DIR}/OpenNI2"
|
||||
DESTINATION ${thirdparty_dest_dir}
|
||||
COMPONENT runtime
|
||||
REGEX ".*pdb" EXCLUDE)
|
||||
INSTALL(FILES "${OpenNI2_BIN_DIR}/OpenNI.ini"
|
||||
DESTINATION ${thirdparty_dest_dir}
|
||||
COMPONENT runtime)
|
||||
ENDIF(OpenNI2_FOUND)
|
||||
|
||||
IF(k4a_FOUND)
|
||||
# Install needed depthengine_2_0.dll
|
||||
IF(WIN32)
|
||||
file(TO_CMAKE_PATH "$ENV{K4A_ROOT_DIR}" ENV_K4A_ROOT_DIR)
|
||||
INSTALL(FILES "${ENV_K4A_ROOT_DIR}/tools/depthengine_2_0.dll"
|
||||
DESTINATION ${thirdparty_dest_dir}
|
||||
COMPONENT runtime)
|
||||
ENDIF(WIN32)
|
||||
ENDIF(k4a_FOUND)
|
||||
|
||||
IF(Torch_FOUND)
|
||||
# Install needed cudnn_ops_infer64_8.dll and cudnn_cnn_infer64_8.dll
|
||||
# TODO: should be a more general way to include them if version is different
|
||||
IF(WIN32 AND CUDA_FOUND)
|
||||
find_file(CUDNN_OPS_DLL NAMES cudnn_ops_infer64_8.dll)
|
||||
find_file(CUDNN_CNN_DLL NAMES cudnn_cnn_infer64_8.dll)
|
||||
IF(CUDNN_OPS_DLL AND CUDNN_CNN_DLL)
|
||||
MESSAGE(STATUS "Found ${CUDNN_OPS_DLL}")
|
||||
MESSAGE(STATUS "Found ${CUDNN_CNN_DLL}")
|
||||
INSTALL(FILES ${CUDNN_OPS_DLL} ${CUDNN_CNN_DLL}
|
||||
DESTINATION ${thirdparty_dest_dir}
|
||||
COMPONENT runtime)
|
||||
ELSE()
|
||||
MESSAGE(AUTHOR_WARNING "Using Torch with CUDA, but cudnn_ops_infer64_8.dll and cudnn_cnn_infer64_8.dll are not found on the PATH, so it won't be added to package.")
|
||||
ENDIF()
|
||||
ENDIF(WIN32 AND CUDA_FOUND)
|
||||
ENDIF(Torch_FOUND)
|
||||
|
||||
IF(Qt6_FOUND)
|
||||
# Reference: https://doc-snapshots.qt.io/qt6-6.4/qt-deploy-runtime-dependencies.html
|
||||
# The following script must only be executed at install time
|
||||
set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_app$<CONFIG>.cmake")
|
||||
file(GENERATE OUTPUT ${deploy_script} CONTENT "
|
||||
# Including the file pointed to by QT_DEPLOY_SUPPORT ensures the generated
|
||||
# deployment script has access to qt_deploy_runtime_dependencies()
|
||||
include(\"${QT_DEPLOY_SUPPORT}\")
|
||||
qt_deploy_runtime_dependencies(
|
||||
EXECUTABLE \"${APPS}\"
|
||||
PLUGINS_DIR ${plugin_dest_dir}
|
||||
GENERATE_QT_CONF
|
||||
NO_TRANSLATIONS
|
||||
VERBOSE
|
||||
)")
|
||||
IF("${CMAKE_BUILD_TYPE}" STREQUAL "" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/deploy_appDebug.cmake"
|
||||
CONFIGURATIONS Debug
|
||||
COMPONENT runtime)
|
||||
ENDIF()
|
||||
IF("${CMAKE_BUILD_TYPE}" STREQUAL "" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/deploy_appRelease.cmake"
|
||||
CONFIGURATIONS Release
|
||||
COMPONENT runtime)
|
||||
ENDIF()
|
||||
IF("${CMAKE_BUILD_TYPE}" STREQUAL "" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
||||
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/deploy_appRelWithDebInfo.cmake"
|
||||
CONFIGURATIONS RelWithDebInfo
|
||||
COMPONENT runtime)
|
||||
ENDIF()
|
||||
IF("${CMAKE_BUILD_TYPE}" STREQUAL "" OR "${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
|
||||
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/deploy_appMinSizeRel.cmake"
|
||||
CONFIGURATIONS MinSizeRel
|
||||
COMPONENT runtime)
|
||||
ENDIF()
|
||||
ELSEIF(Qt5_FOUND)
|
||||
#Qt5
|
||||
foreach(plugin ${Qt5Gui_PLUGINS})
|
||||
get_target_property(plugin_loc ${plugin} LOCATION)
|
||||
get_filename_component(plugin_dir ${plugin_loc} DIRECTORY)
|
||||
string(REPLACE "plugins" ";" loc_list ${plugin_dir})
|
||||
list(GET loc_list 1 plugin_type)
|
||||
IF(NOT plugin_root)
|
||||
get_filename_component(plugin_root ${plugin_dir} DIRECTORY)
|
||||
ENDIF(NOT plugin_root)
|
||||
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}${plugin_type}\"")
|
||||
INSTALL(FILES ${plugin_loc}
|
||||
DESTINATION ${plugin_dest_dir}${plugin_type}
|
||||
COMPONENT runtime)
|
||||
endforeach()
|
||||
IF(NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0)
|
||||
IF(WIN32)
|
||||
SET(plugin_loc "${plugin_root}/styles/qwindowsvistastyle.dll")
|
||||
ELSEIF(APPLE)
|
||||
SET(plugin_loc "${plugin_root}/styles/libqmacstyle.dylib")
|
||||
ENDIF()
|
||||
IF(EXISTS ${plugin_loc})
|
||||
get_filename_component(plugin_dir ${plugin_loc} DIRECTORY)
|
||||
string(REPLACE "plugins" ";" loc_list ${plugin_dir})
|
||||
list(GET loc_list 1 plugin_type)
|
||||
INSTALL(FILES ${plugin_loc}
|
||||
DESTINATION ${plugin_dest_dir}/plugins${plugin_type}
|
||||
COMPONENT runtime)
|
||||
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}${plugin_type}\"")
|
||||
ENDIF(EXISTS ${plugin_loc})
|
||||
ENDIF(NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0)
|
||||
ELSEIF(QT_PLUGINS_DIR) # Qt4
|
||||
# Install needed Qt plugins by copying directories from the qt installation
|
||||
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
|
||||
# Exclude debug libraries
|
||||
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
|
||||
DESTINATION ${plugin_dest_dir}
|
||||
COMPONENT runtime
|
||||
REGEX ".*d4.dll" EXCLUDE
|
||||
REGEX ".*d4.a" EXCLUDE)
|
||||
ENDIF()
|
||||
|
||||
IF(Qt5_FOUND OR QT4_FOUND)
|
||||
# install a qt.conf file
|
||||
# this inserts some cmake code into the install script to write the file
|
||||
SET(QT_CONF_FILE [Paths]\nPlugins=plugins)
|
||||
IF(APPLE)
|
||||
SET(QT_CONF_FILE [Paths]\nPlugins=MacOS/plugins)
|
||||
ENDIF(APPLE)
|
||||
INSTALL(CODE "
|
||||
file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\")
|
||||
" COMPONENT runtime)
|
||||
ENDIF()
|
||||
|
||||
# directories to look for dependencies
|
||||
SET(DIRS "${QT_LIBRARY_DIRS}" "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib")
|
||||
IF(APPLE)
|
||||
SET(DIRS ${DIRS} /usr/local /usr/local/lib /opt/homebrew /opt/homebrew/lib /opt/homebrew/lib/gcc/current)
|
||||
ENDIF(APPLE)
|
||||
|
||||
# Now the work of copying dependencies into the bundle/package
|
||||
# The quotes are escaped and variables to use at install time have their $ escaped
|
||||
# An alternative is the do a configure_file() on a script and use install(SCRIPT ...).
|
||||
# Note that the image plugins depend on QtSvg and QtXml, and it got those copied
|
||||
# over.
|
||||
# To find dependencies, cmake use "otool" on Apple and "dumpbin" on Windows (make sure you have one of them).
|
||||
install(CODE "
|
||||
file(GLOB_RECURSE QTPLUGINS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
||||
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
include(\"BundleUtilities\")
|
||||
fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
|
||||
" COMPONENT runtime)
|
||||
|
||||
ENDIF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "RTABMap.ico"
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Universite de Sherbrooke nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include "rtabmap/utilite/UEventsManager.h"
|
||||
#include "rtabmap/core/RtabmapThread.h"
|
||||
#include "rtabmap/core/Rtabmap.h"
|
||||
#include "rtabmap/gui/MainWindow.h"
|
||||
#include <QMessageBox>
|
||||
#include "rtabmap/utilite/UObjDeletionThread.h"
|
||||
#include "rtabmap/utilite/UFile.h"
|
||||
#include "rtabmap/utilite/UConversion.h"
|
||||
|
||||
#include <vtkVersionMacros.h>
|
||||
#include <vtkObject.h>
|
||||
|
||||
#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION==9 && VTK_MINOR_VERSION >= 1)
|
||||
#include <QVTKRenderWidget.h>
|
||||
#endif
|
||||
|
||||
using namespace rtabmap;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
/* Set logger type */
|
||||
ULogger::setType(ULogger::kTypeConsole);
|
||||
ULogger::setLevel(ULogger::kWarning);
|
||||
|
||||
#ifdef WIN32
|
||||
CoInitialize(nullptr);
|
||||
#endif
|
||||
|
||||
#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION==9 && VTK_MINOR_VERSION >= 1)
|
||||
// needed to ensure appropriate OpenGL context is created for VTK rendering.
|
||||
QSurfaceFormat::setDefaultFormat(QVTKRenderWidget::defaultFormat());
|
||||
#endif
|
||||
|
||||
/* Create tasks */
|
||||
QApplication * app = new QApplication(argc, argv);
|
||||
app->setStyleSheet("QMessageBox { messagebox-text-interaction-flags: 5; }"); // selectable message box
|
||||
|
||||
ParametersMap parameters = Parameters::parseArguments(argc, argv, false);
|
||||
MainWindow * mainWindow = new MainWindow();
|
||||
app->installEventFilter(mainWindow); // to catch FileOpen events.
|
||||
|
||||
std::string database;
|
||||
for(int i=1; i<argc; ++i)
|
||||
{
|
||||
std::string value = uReplaceChar(argv[i], '~', UDirectory::homeDir());
|
||||
if(UFile::exists(value) &&
|
||||
UFile::getExtension(value).compare("db") == 0)
|
||||
{
|
||||
database = value;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Program started...\n");
|
||||
|
||||
UEventsManager::addHandler(mainWindow);
|
||||
|
||||
/* Start thread's task */
|
||||
if(mainWindow->isSavedMaximized())
|
||||
{
|
||||
mainWindow->showMaximized();
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWindow->show();
|
||||
}
|
||||
|
||||
RtabmapThread * rtabmap = new RtabmapThread(new Rtabmap());
|
||||
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
|
||||
UEventsManager::addHandler(rtabmap);
|
||||
|
||||
if(!database.empty())
|
||||
{
|
||||
mainWindow->openDatabase(database.c_str(), parameters);
|
||||
}
|
||||
else if(parameters.size())
|
||||
{
|
||||
mainWindow->updateParameters(parameters);
|
||||
}
|
||||
|
||||
// Now wait for application to finish
|
||||
app->connect( app, SIGNAL( lastWindowClosed() ),
|
||||
app, SLOT( quit() ) );
|
||||
app->exec();// MUST be called by the Main Thread
|
||||
|
||||
/* Remove handlers */
|
||||
UEventsManager::removeHandler(mainWindow);
|
||||
UEventsManager::removeHandler(rtabmap);
|
||||
|
||||
rtabmap->join(true);
|
||||
|
||||
printf("Closing RTAB-Map...\n");
|
||||
delete rtabmap;
|
||||
delete mainWindow;
|
||||
delete app;
|
||||
printf("All done!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user