From 26a9715cdac7fa6163e170da0ab072a8738e0d70 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Sun, 25 Sep 2022 22:47:38 -0700 Subject: [PATCH 1/3] Added compatibility with upstream rtabmap targets --- CMakeLists.txt | 59 ++++++++++---------------------------------------- package.xml | 2 +- 2 files changed, 13 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f67488e3..4e231130d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,16 +32,9 @@ find_package(fiducial_msgs) ## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) -find_package(RTABMap 0.20.20 REQUIRED) +find_package(RTABMap 0.21.0 REQUIRED) -find_package(OpenCV REQUIRED QUIET COMPONENTS core calib3d imgproc highgui stitching optflow photo video OPTIONAL_COMPONENTS aruco xfeatures2d nonfree gpu cudafeatures2d) - -IF(RTABMAP_GUI) -FIND_PACKAGE(PCL 1.7 REQUIRED QUIET COMPONENTS common io kdtree search surface filters registration sample_consensus segmentation visualization) -ELSE() -FIND_PACKAGE(PCL 1.7 REQUIRED QUIET COMPONENTS common io kdtree search surface filters registration sample_consensus segmentation ) -ENDIF() -add_definitions(${PCL_DEFINITIONS}) # To include -march=native if set +add_definitions(${RTABMap_DEFINITIONS}) # To include -march=native if set IF(WIN32) add_compile_options(-bigobj) @@ -71,27 +64,6 @@ IF(RTABMAP_SYNC_USER_DATA) add_definitions("-DRTABMAP_SYNC_USER_DATA") ENDIF(RTABMAP_SYNC_USER_DATA) -#Qt stuff -# If librtabmap_gui.so is found, rtabmapviz will be built -# If rviz is found, plugins will be built -IF(RTABMAP_GUI OR rviz_FOUND) - IF(RTABMAP_QT_VERSION EQUAL 4) - FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) - INCLUDE(${QT_USE_FILE}) - ELSE() - IF(RTABMAP_GUI) - FIND_PACKAGE(Qt5 COMPONENTS Widgets Core Gui REQUIRED) - ELSE() - # For rviz plugins, look for Qt5 before Qt4 - FIND_PACKAGE(Qt5 COMPONENTS Widgets Core Gui QUIET) - IF(NOT Qt5_FOUND) - FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) - INCLUDE(${QT_USE_FILE}) - ENDIF(NOT Qt5_FOUND) - ENDIF() - ENDIF() -ENDIF(RTABMAP_GUI OR rviz_FOUND) - ## Uncomment this if the package has a setup.py. This macro ensures ## modules and global scripts declared therein get installed ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html @@ -188,8 +160,8 @@ catkin_package( CATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs std_srvs nav_msgs geometry_msgs visualization_msgs image_transport tf tf_conversions tf2_ros eigen_conversions laser_geometry pcl_conversions pcl_ros nodelet dynamic_reconfigure message_filters class_loader rosgraph_msgs - stereo_msgs move_base_msgs image_geometry ${optional_dependencies} - DEPENDS RTABMap OpenCV + stereo_msgs move_base_msgs image_geometry rtabmap ${optional_dependencies} + DEPENDS RTABMap ) ########### @@ -201,18 +173,13 @@ catkin_package( # include_directories(include) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include - ${RTABMap_INCLUDE_DIRS} - ${OpenCV_INCLUDE_DIRS} - ${PCL_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} ) # libraries SET(Libraries - ${OpenCV_LIBRARIES} - ${PCL_LIBRARIES} + rtabmap ${catkin_LIBRARIES} - ${RTABMap_LIBRARIES} ) SET(rtabmap_sync_lib_src @@ -335,8 +302,9 @@ target_link_libraries(rtabmap_plugins add_dependencies(rtabmap_ros ${${PROJECT_NAME}_EXPORTED_TARGETS}) add_dependencies(rtabmap_plugins ${${PROJECT_NAME}_EXPORTED_TARGETS}) -add_executable(rtabmap src/CoreNode.cpp) -target_link_libraries(rtabmap ${Libraries}) +add_executable(rtabmap_node src/CoreNode.cpp) +target_link_libraries(rtabmap_node ${Libraries}) +set_target_properties(rtabmap_node PROPERTIES OUTPUT_NAME "rtabmap") add_executable(rtabmap_rgbd_odometry src/RGBDOdometryNode.cpp) target_link_libraries(rtabmap_rgbd_odometry ${Libraries}) @@ -417,12 +385,9 @@ add_executable(rtabmap_stereo_camera src/StereoCameraNode.cpp) target_link_libraries(rtabmap_stereo_camera rtabmap_ros) set_target_properties(rtabmap_stereo_camera PROPERTIES OUTPUT_NAME "stereo_camera") -IF(RTABMAP_GUI) +IF(RTABMap_gui_FOUND) add_executable(rtabmapviz src/GuiNode.cpp src/GuiWrapper.cpp src/PreferencesDialogROS.cpp) - target_link_libraries(rtabmapviz rtabmap_sync ${QT_LIBRARIES}) - IF(Qt5_FOUND) - QT5_USE_MODULES(rtabmapviz Widgets Core Gui) - ENDIF() + target_link_libraries(rtabmapviz rtabmap_sync rtabmap_gui) ELSE() MESSAGE(WARNING "Found RTAB-Map built without its GUI library. Node rtabmapviz will not be built!") ENDIF() @@ -590,7 +555,7 @@ install(TARGETS rtabmap_sync rtabmap_ros rtabmap_plugins - rtabmap + rtabmap_node rtabmap_rgbd_odometry rtabmap_icp_odometry rtabmap_rgbdicp_odometry @@ -611,7 +576,7 @@ install(TARGETS LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) -IF(RTABMAP_GUI) +IF(RTABMap_gui_FOUND) install(TARGETS rtabmapviz ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} diff --git a/package.xml b/package.xml index 3c1af103c..fa6de5247 100644 --- a/package.xml +++ b/package.xml @@ -1,7 +1,7 @@ rtabmap_ros - 0.20.20 + 0.21.0 RTAB-Map's ros-pkg. RTAB-Map is a RGB-D SLAM approach with real-time constraints. Mathieu Labbe Mathieu Labbe From 510e226e24c4b5919f202b7f5817c4ca194fc33b Mon Sep 17 00:00:00 2001 From: matlabbe Date: Sat, 11 Feb 2023 12:28:52 -0800 Subject: [PATCH 2/3] cmake warning --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e231130d..430e93e59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -583,7 +583,7 @@ IF(RTABMap_gui_FOUND) LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) -ENDIF(RTABMAP_GUI) +ENDIF(RTABMap_gui_FOUND) ## Mark cpp header files for installation install(DIRECTORY include/${PROJECT_NAME}/ From a8d58dd0ad14a67870a8276843eda122adff1c9c Mon Sep 17 00:00:00 2001 From: matlabbe Date: Sat, 11 Feb 2023 20:46:49 -0800 Subject: [PATCH 3/3] fixed rtabmap_sync lib export, added rtabmap_ros namespace to MspManager class --- CMakeLists.txt | 4 ++-- include/rtabmap_ros/MapsManager.h | 4 ++++ src/MapAssemblerNode.cpp | 2 +- src/MapsManager.cpp | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 430e93e59..683c0eff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,11 +156,11 @@ ENDIF(find_object_2d_FOUND) catkin_package( INCLUDE_DIRS include - LIBRARIES rtabmap_ros + LIBRARIES rtabmap_ros rtabmap_sync CATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs std_srvs nav_msgs geometry_msgs visualization_msgs image_transport tf tf_conversions tf2_ros eigen_conversions laser_geometry pcl_conversions pcl_ros nodelet dynamic_reconfigure message_filters class_loader rosgraph_msgs - stereo_msgs move_base_msgs image_geometry rtabmap ${optional_dependencies} + stereo_msgs move_base_msgs image_geometry ${optional_dependencies} DEPENDS RTABMap ) diff --git a/include/rtabmap_ros/MapsManager.h b/include/rtabmap_ros/MapsManager.h index a1092931a..556ce70ca 100644 --- a/include/rtabmap_ros/MapsManager.h +++ b/include/rtabmap_ros/MapsManager.h @@ -43,6 +43,8 @@ class OccupancyGrid; } // namespace rtabmap +namespace rtabmap_ros { + class MapsManager { public: MapsManager(); @@ -136,4 +138,6 @@ class MapsManager { std::map latched_; }; +} // namespace rtabmap_ros + #endif /* MAPSMANAGER_H_ */ diff --git a/src/MapAssemblerNode.cpp b/src/MapAssemblerNode.cpp index f79e17167..892727b20 100644 --- a/src/MapAssemblerNode.cpp +++ b/src/MapAssemblerNode.cpp @@ -342,7 +342,7 @@ class MapAssembler #endif private: - MapsManager mapsManager_; + rtabmap_ros::MapsManager mapsManager_; std::map nodes_; std::map optimizedPoses_; std::string mapFrameId_; diff --git a/src/MapsManager.cpp b/src/MapsManager.cpp index a4623769f..4d3ce822f 100644 --- a/src/MapsManager.cpp +++ b/src/MapsManager.cpp @@ -56,6 +56,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace rtabmap; +namespace rtabmap_ros { + MapsManager::MapsManager() : cloudOutputVoxelized_(true), cloudSubtractFiltering_(false), @@ -1557,3 +1559,5 @@ cv::Mat MapsManager::getGridProbMap( return occupancyGrid_->getProbMap(xMin, yMin); } +} // namespace rtabmap_ros +