Files
rtabmap/cmake_modules/FindCuVSLAM.cmake

106 lines
4.3 KiB
CMake
Raw Normal View History

CuVSLAM VO Strategy (#1583) * integrating cuvslam, stereo cam initialization * fixing transformations * use isaac ros TocuVSLAMPose * organizing * handling covariance conversion * cleaning up config * moving cmake instructions to FindCuVSLAM.cmake file * fixing ui integration * updating software license for cuvslam * improving memory management * cleaning up header more * reverting mistake in GUI * using opaque pointers for header definitions, compiles * back to typed definitions using forward-referencing * fixing dangling pointer * cleaning up * fixing variable scope issues * Using cuda to allocate gpu memory * fixing transfrom from cuvslam back to ros coordinate frame * reducing excessive logs * removing redundant if true in cuvslam cmake * moving find cuda into cuvslam cmake * cleaning cmake to use modern target * adding copyright line * Finding tf2 and eigen3 in cmake * simplifying clean up logic * better logs * moving cuvslam implementation methods into cpp * fixing build with implmentation function declarations moved to the cpp * cleaning transformation logic and adding grayscale support * typo * removing unecessary class member variable for processed images * remove trailing underscore from initialize cuvslam function signature * locally scoping config params since they are copied by cuvslam * removing unecessary member variables and using locally scoped values since cuvslam seems to copy them * more cleaning and refactoring * fixing cmake inconsistancies and surpress warning * fixing up baseline transform * trying to remove tf2 for transformations * fixing incorect baseline transform swap * comment, begin reset logic investigation * better handling of previous pose and transform during error cases * hunting for reset bug, not found * observation export implementatin, currently getting strange errors * multi cam support * Memory fixes * comments * make cuda stream a member variable so it isn't initialized and destroyed on every frame * preparing to add ground constraints * adding ground constraints, working * adding wheel odom fusion into cuvslam tracker * parsing parameter to apply planar constraints * removing planar constraint in config, doesn't do anything * using proper cuda stream type for member variable * cleaning up for merge * only parse params when cuvslam is compiled * updating error message if using rgb-d instead of stereo * removing wheel odom testing logs * reverting bgr to rgb conversion * fixing initial pose logic * return null transform on invalid covariance * debugging covariance * guard against low velocity situations where cuvslam covariance spikes, but we aren't lost * cleaning things up --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-10-03 11:49:21 -07:00
# - Find cuVSLAM library (https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_visual_slam)
#
# CUVSLAM_ROOT_DIR environment variable can be set to find the library.
#
# It sets the following variables:
# CUVSLAM_FOUND - Set to false, or undefined, if cuVSLAM isn't found.
CuVSLAM 14 Update (#1618) * update cuvslam api call to adhere to new v4.0 changes * update comment * parse cuvslam major version from the header and throw an error if theversion doesn't match the expected * moving average filter + extensive debug logging * lots more logs * improvement by turning off use_motion_model in cuvslam config. lots of debug logs. * slight improvements to velocity guard logic. lots of debug logs * removing debug logs. working. * let find_package_handle_standard_args handle the version comparison logic. Custom logic to handle newer then requested major version * proper warning message if the major version doesn't match * add back debug logs. Handle no guess transform case. * adding warnings when no guess transform is provided * clean up comments * lowering average window to 5 * moderate odometry mode, 5 value averaging window * adding comment * add reset logs to investigate reset issue * try returning guess or identity on init to avoid reset cascade * disable motion model again * big log when tracking * remove some debug logs * flag to use original covariance from cuVSLAM * use raw covariance * data collection for revised lost detection * compare guess to estimated transform for lost detection * re-enable motion model, it appears to reduce false-positives for the new lost detection * run pose estimation afer init on first frame * don't initialize if we don't have enough features * dont warm up GPU everytime we reset * low estimate velocity guard. Passes all challenges. Debug comments still everywhere. * Remove debug logs. Add thresholds to header in a config section. * Cleanup logs * exposing multi-cam mode as a rtabmap param * remove max frame delta * change to use assertion instead of conditional * replaced some UERROR by UWARN --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-12-15 14:21:32 -08:00
# CUVSLAM_VERSION - The version of cuVSLAM found (e.g., "14.0.0").
CuVSLAM VO Strategy (#1583) * integrating cuvslam, stereo cam initialization * fixing transformations * use isaac ros TocuVSLAMPose * organizing * handling covariance conversion * cleaning up config * moving cmake instructions to FindCuVSLAM.cmake file * fixing ui integration * updating software license for cuvslam * improving memory management * cleaning up header more * reverting mistake in GUI * using opaque pointers for header definitions, compiles * back to typed definitions using forward-referencing * fixing dangling pointer * cleaning up * fixing variable scope issues * Using cuda to allocate gpu memory * fixing transfrom from cuvslam back to ros coordinate frame * reducing excessive logs * removing redundant if true in cuvslam cmake * moving find cuda into cuvslam cmake * cleaning cmake to use modern target * adding copyright line * Finding tf2 and eigen3 in cmake * simplifying clean up logic * better logs * moving cuvslam implementation methods into cpp * fixing build with implmentation function declarations moved to the cpp * cleaning transformation logic and adding grayscale support * typo * removing unecessary class member variable for processed images * remove trailing underscore from initialize cuvslam function signature * locally scoping config params since they are copied by cuvslam * removing unecessary member variables and using locally scoped values since cuvslam seems to copy them * more cleaning and refactoring * fixing cmake inconsistancies and surpress warning * fixing up baseline transform * trying to remove tf2 for transformations * fixing incorect baseline transform swap * comment, begin reset logic investigation * better handling of previous pose and transform during error cases * hunting for reset bug, not found * observation export implementatin, currently getting strange errors * multi cam support * Memory fixes * comments * make cuda stream a member variable so it isn't initialized and destroyed on every frame * preparing to add ground constraints * adding ground constraints, working * adding wheel odom fusion into cuvslam tracker * parsing parameter to apply planar constraints * removing planar constraint in config, doesn't do anything * using proper cuda stream type for member variable * cleaning up for merge * only parse params when cuvslam is compiled * updating error message if using rgb-d instead of stereo * removing wheel odom testing logs * reverting bgr to rgb conversion * fixing initial pose logic * return null transform on invalid covariance * debugging covariance * guard against low velocity situations where cuvslam covariance spikes, but we aren't lost * cleaning things up --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-10-03 11:49:21 -07:00
# CUVSLAM_INCLUDE_DIRS - The cuVSLAM include directory.
# CUVSLAM_LIBRARIES - The cuVSLAM library to link against.
find_package(CUDA REQUIRED)
find_package(Eigen3 REQUIRED)
find_path(CUVSLAM_INCLUDE_DIRS
NAMES cuvslam.h
PATHS
/usr/include
/usr/local/include
/opt/cuvslam/include
/opt/ros/humble/share/isaac_ros_nitros/cuvslam/include
$ENV{CUVSLAM_ROOT}/include
$ENV{CUVSLAM_ROOT_DIR}/include
)
find_library(CUVSLAM_LIBRARY
NAMES cuvslam
PATHS
/usr/lib
/usr/local/lib
/opt/cuvslam/lib
/opt/ros/humble/share/isaac_ros_nitros/cuvslam/lib
$ENV{CUVSLAM_ROOT}/lib
$ENV{CUVSLAM_ROOT_DIR}/lib
)
if(CUVSLAM_INCLUDE_DIRS AND CUVSLAM_LIBRARY)
CuVSLAM 14 Update (#1618) * update cuvslam api call to adhere to new v4.0 changes * update comment * parse cuvslam major version from the header and throw an error if theversion doesn't match the expected * moving average filter + extensive debug logging * lots more logs * improvement by turning off use_motion_model in cuvslam config. lots of debug logs. * slight improvements to velocity guard logic. lots of debug logs * removing debug logs. working. * let find_package_handle_standard_args handle the version comparison logic. Custom logic to handle newer then requested major version * proper warning message if the major version doesn't match * add back debug logs. Handle no guess transform case. * adding warnings when no guess transform is provided * clean up comments * lowering average window to 5 * moderate odometry mode, 5 value averaging window * adding comment * add reset logs to investigate reset issue * try returning guess or identity on init to avoid reset cascade * disable motion model again * big log when tracking * remove some debug logs * flag to use original covariance from cuVSLAM * use raw covariance * data collection for revised lost detection * compare guess to estimated transform for lost detection * re-enable motion model, it appears to reduce false-positives for the new lost detection * run pose estimation afer init on first frame * don't initialize if we don't have enough features * dont warm up GPU everytime we reset * low estimate velocity guard. Passes all challenges. Debug comments still everywhere. * Remove debug logs. Add thresholds to header in a config section. * Cleanup logs * exposing multi-cam mode as a rtabmap param * remove max frame delta * change to use assertion instead of conditional * replaced some UERROR by UWARN --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-12-15 14:21:32 -08:00
# Extract version from cuvslam.h header
file(STRINGS "${CUVSLAM_INCLUDE_DIRS}/cuvslam.h" CUVSLAM_VERSION_MAJOR_LINE
REGEX "^#define CUVSLAM_API_VERSION_MAJOR")
file(STRINGS "${CUVSLAM_INCLUDE_DIRS}/cuvslam.h" CUVSLAM_VERSION_MINOR_LINE
REGEX "^#define CUVSLAM_API_VERSION_MINOR")
if(CUVSLAM_VERSION_MAJOR_LINE AND CUVSLAM_VERSION_MINOR_LINE)
string(REGEX MATCH "[0-9]+" CUVSLAM_VERSION_MAJOR "${CUVSLAM_VERSION_MAJOR_LINE}")
string(REGEX MATCH "[0-9]+" CUVSLAM_VERSION_MINOR "${CUVSLAM_VERSION_MINOR_LINE}")
set(CUVSLAM_VERSION "${CUVSLAM_VERSION_MAJOR}.${CUVSLAM_VERSION_MINOR}.0")
endif()
CuVSLAM VO Strategy (#1583) * integrating cuvslam, stereo cam initialization * fixing transformations * use isaac ros TocuVSLAMPose * organizing * handling covariance conversion * cleaning up config * moving cmake instructions to FindCuVSLAM.cmake file * fixing ui integration * updating software license for cuvslam * improving memory management * cleaning up header more * reverting mistake in GUI * using opaque pointers for header definitions, compiles * back to typed definitions using forward-referencing * fixing dangling pointer * cleaning up * fixing variable scope issues * Using cuda to allocate gpu memory * fixing transfrom from cuvslam back to ros coordinate frame * reducing excessive logs * removing redundant if true in cuvslam cmake * moving find cuda into cuvslam cmake * cleaning cmake to use modern target * adding copyright line * Finding tf2 and eigen3 in cmake * simplifying clean up logic * better logs * moving cuvslam implementation methods into cpp * fixing build with implmentation function declarations moved to the cpp * cleaning transformation logic and adding grayscale support * typo * removing unecessary class member variable for processed images * remove trailing underscore from initialize cuvslam function signature * locally scoping config params since they are copied by cuvslam * removing unecessary member variables and using locally scoped values since cuvslam seems to copy them * more cleaning and refactoring * fixing cmake inconsistancies and surpress warning * fixing up baseline transform * trying to remove tf2 for transformations * fixing incorect baseline transform swap * comment, begin reset logic investigation * better handling of previous pose and transform during error cases * hunting for reset bug, not found * observation export implementatin, currently getting strange errors * multi cam support * Memory fixes * comments * make cuda stream a member variable so it isn't initialized and destroyed on every frame * preparing to add ground constraints * adding ground constraints, working * adding wheel odom fusion into cuvslam tracker * parsing parameter to apply planar constraints * removing planar constraint in config, doesn't do anything * using proper cuda stream type for member variable * cleaning up for merge * only parse params when cuvslam is compiled * updating error message if using rgb-d instead of stereo * removing wheel odom testing logs * reverting bgr to rgb conversion * fixing initial pose logic * return null transform on invalid covariance * debugging covariance * guard against low velocity situations where cuvslam covariance spikes, but we aren't lost * cleaning things up --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-10-03 11:49:21 -07:00
set(CUVSLAM_LIBRARIES
${CUVSLAM_LIBRARY}
${CUDA_LIBRARIES}
# Eigen3 is header-only, so we don't need to link to it
)
set(CUVSLAM_INCLUDE_DIRS
${CUVSLAM_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
endif()
CuVSLAM 14 Update (#1618) * update cuvslam api call to adhere to new v4.0 changes * update comment * parse cuvslam major version from the header and throw an error if theversion doesn't match the expected * moving average filter + extensive debug logging * lots more logs * improvement by turning off use_motion_model in cuvslam config. lots of debug logs. * slight improvements to velocity guard logic. lots of debug logs * removing debug logs. working. * let find_package_handle_standard_args handle the version comparison logic. Custom logic to handle newer then requested major version * proper warning message if the major version doesn't match * add back debug logs. Handle no guess transform case. * adding warnings when no guess transform is provided * clean up comments * lowering average window to 5 * moderate odometry mode, 5 value averaging window * adding comment * add reset logs to investigate reset issue * try returning guess or identity on init to avoid reset cascade * disable motion model again * big log when tracking * remove some debug logs * flag to use original covariance from cuVSLAM * use raw covariance * data collection for revised lost detection * compare guess to estimated transform for lost detection * re-enable motion model, it appears to reduce false-positives for the new lost detection * run pose estimation afer init on first frame * don't initialize if we don't have enough features * dont warm up GPU everytime we reset * low estimate velocity guard. Passes all challenges. Debug comments still everywhere. * Remove debug logs. Add thresholds to header in a config section. * Cleanup logs * exposing multi-cam mode as a rtabmap param * remove max frame delta * change to use assertion instead of conditional * replaced some UERROR by UWARN --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-12-15 14:21:32 -08:00
# Version compatibility check - cuVSLAM only guarantees API compatibility within the same major version
set(CUVSLAM_VERSION_MISMATCH_REASON "")
if(CuVSLAM_FIND_VERSION AND CUVSLAM_VERSION)
string(REGEX MATCH "^[0-9]+" REQUESTED_MAJOR_VERSION "${CuVSLAM_FIND_VERSION}")
if(NOT CUVSLAM_VERSION_MAJOR EQUAL REQUESTED_MAJOR_VERSION)
set(CUVSLAM_VERSION_MISMATCH_REASON "Major version mismatch: found ${CUVSLAM_VERSION_MAJOR}.x but requested ${REQUESTED_MAJOR_VERSION}.x.\ncuVSLAM only guarantees API compatibility within the same major version.\nPlease install cuVSLAM ${REQUESTED_MAJOR_VERSION}.x or update CMakeLists.txt to request version ${CUVSLAM_VERSION_MAJOR}.0.0")
if(CuVSLAM_FIND_REQUIRED)
message(FATAL_ERROR
"cuVSLAM major version mismatch: found version ${CUVSLAM_VERSION} but version ${CuVSLAM_FIND_VERSION} is required.\n"
"cuVSLAM only guarantees API compatibility within the same major version.\n"
"Found major version ${CUVSLAM_VERSION_MAJOR} is not compatible with requested major version ${REQUESTED_MAJOR_VERSION}.\n"
"Please install cuVSLAM ${REQUESTED_MAJOR_VERSION}.x or update CMakeLists.txt to request version ${CUVSLAM_VERSION_MAJOR}.x."
)
else()
# Clear the found variables to indicate incompatibility
unset(CUVSLAM_LIBRARIES)
unset(CUVSLAM_INCLUDE_DIRS)
endif()
endif()
endif()
CuVSLAM VO Strategy (#1583) * integrating cuvslam, stereo cam initialization * fixing transformations * use isaac ros TocuVSLAMPose * organizing * handling covariance conversion * cleaning up config * moving cmake instructions to FindCuVSLAM.cmake file * fixing ui integration * updating software license for cuvslam * improving memory management * cleaning up header more * reverting mistake in GUI * using opaque pointers for header definitions, compiles * back to typed definitions using forward-referencing * fixing dangling pointer * cleaning up * fixing variable scope issues * Using cuda to allocate gpu memory * fixing transfrom from cuvslam back to ros coordinate frame * reducing excessive logs * removing redundant if true in cuvslam cmake * moving find cuda into cuvslam cmake * cleaning cmake to use modern target * adding copyright line * Finding tf2 and eigen3 in cmake * simplifying clean up logic * better logs * moving cuvslam implementation methods into cpp * fixing build with implmentation function declarations moved to the cpp * cleaning transformation logic and adding grayscale support * typo * removing unecessary class member variable for processed images * remove trailing underscore from initialize cuvslam function signature * locally scoping config params since they are copied by cuvslam * removing unecessary member variables and using locally scoped values since cuvslam seems to copy them * more cleaning and refactoring * fixing cmake inconsistancies and surpress warning * fixing up baseline transform * trying to remove tf2 for transformations * fixing incorect baseline transform swap * comment, begin reset logic investigation * better handling of previous pose and transform during error cases * hunting for reset bug, not found * observation export implementatin, currently getting strange errors * multi cam support * Memory fixes * comments * make cuda stream a member variable so it isn't initialized and destroyed on every frame * preparing to add ground constraints * adding ground constraints, working * adding wheel odom fusion into cuvslam tracker * parsing parameter to apply planar constraints * removing planar constraint in config, doesn't do anything * using proper cuda stream type for member variable * cleaning up for merge * only parse params when cuvslam is compiled * updating error message if using rgb-d instead of stereo * removing wheel odom testing logs * reverting bgr to rgb conversion * fixing initial pose logic * return null transform on invalid covariance * debugging covariance * guard against low velocity situations where cuvslam covariance spikes, but we aren't lost * cleaning things up --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-10-03 11:49:21 -07:00
# Handle the QUIET and REQUIRED arguments
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CuVSLAM
FOUND_VAR CUVSLAM_FOUND
REQUIRED_VARS CUVSLAM_LIBRARIES CUVSLAM_INCLUDE_DIRS
CuVSLAM 14 Update (#1618) * update cuvslam api call to adhere to new v4.0 changes * update comment * parse cuvslam major version from the header and throw an error if theversion doesn't match the expected * moving average filter + extensive debug logging * lots more logs * improvement by turning off use_motion_model in cuvslam config. lots of debug logs. * slight improvements to velocity guard logic. lots of debug logs * removing debug logs. working. * let find_package_handle_standard_args handle the version comparison logic. Custom logic to handle newer then requested major version * proper warning message if the major version doesn't match * add back debug logs. Handle no guess transform case. * adding warnings when no guess transform is provided * clean up comments * lowering average window to 5 * moderate odometry mode, 5 value averaging window * adding comment * add reset logs to investigate reset issue * try returning guess or identity on init to avoid reset cascade * disable motion model again * big log when tracking * remove some debug logs * flag to use original covariance from cuVSLAM * use raw covariance * data collection for revised lost detection * compare guess to estimated transform for lost detection * re-enable motion model, it appears to reduce false-positives for the new lost detection * run pose estimation afer init on first frame * don't initialize if we don't have enough features * dont warm up GPU everytime we reset * low estimate velocity guard. Passes all challenges. Debug comments still everywhere. * Remove debug logs. Add thresholds to header in a config section. * Cleanup logs * exposing multi-cam mode as a rtabmap param * remove max frame delta * change to use assertion instead of conditional * replaced some UERROR by UWARN --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-12-15 14:21:32 -08:00
VERSION_VAR CUVSLAM_VERSION
REASON_FAILURE_MESSAGE "${CUVSLAM_VERSION_MISMATCH_REASON}"
CuVSLAM VO Strategy (#1583) * integrating cuvslam, stereo cam initialization * fixing transformations * use isaac ros TocuVSLAMPose * organizing * handling covariance conversion * cleaning up config * moving cmake instructions to FindCuVSLAM.cmake file * fixing ui integration * updating software license for cuvslam * improving memory management * cleaning up header more * reverting mistake in GUI * using opaque pointers for header definitions, compiles * back to typed definitions using forward-referencing * fixing dangling pointer * cleaning up * fixing variable scope issues * Using cuda to allocate gpu memory * fixing transfrom from cuvslam back to ros coordinate frame * reducing excessive logs * removing redundant if true in cuvslam cmake * moving find cuda into cuvslam cmake * cleaning cmake to use modern target * adding copyright line * Finding tf2 and eigen3 in cmake * simplifying clean up logic * better logs * moving cuvslam implementation methods into cpp * fixing build with implmentation function declarations moved to the cpp * cleaning transformation logic and adding grayscale support * typo * removing unecessary class member variable for processed images * remove trailing underscore from initialize cuvslam function signature * locally scoping config params since they are copied by cuvslam * removing unecessary member variables and using locally scoped values since cuvslam seems to copy them * more cleaning and refactoring * fixing cmake inconsistancies and surpress warning * fixing up baseline transform * trying to remove tf2 for transformations * fixing incorect baseline transform swap * comment, begin reset logic investigation * better handling of previous pose and transform during error cases * hunting for reset bug, not found * observation export implementatin, currently getting strange errors * multi cam support * Memory fixes * comments * make cuda stream a member variable so it isn't initialized and destroyed on every frame * preparing to add ground constraints * adding ground constraints, working * adding wheel odom fusion into cuvslam tracker * parsing parameter to apply planar constraints * removing planar constraint in config, doesn't do anything * using proper cuda stream type for member variable * cleaning up for merge * only parse params when cuvslam is compiled * updating error message if using rgb-d instead of stereo * removing wheel odom testing logs * reverting bgr to rgb conversion * fixing initial pose logic * return null transform on invalid covariance * debugging covariance * guard against low velocity situations where cuvslam covariance spikes, but we aren't lost * cleaning things up --------- Co-authored-by: Felix Toft <felix@robust.ai> Co-authored-by: matlabbe <matlabbe@gmail.com>
2025-10-03 11:49:21 -07:00
HANDLE_COMPONENTS
)
if(CUVSLAM_FOUND)
# Create imported target for modern CMake usage
if(NOT TARGET cuvslam::cuvslam)
add_library(cuvslam::cuvslam UNKNOWN IMPORTED)
set_target_properties(cuvslam::cuvslam PROPERTIES
IMPORTED_LOCATION "${CUVSLAM_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CUVSLAM_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CUVSLAM_LIBRARIES};Eigen3::Eigen"
)
endif()
endif()
mark_as_advanced(CUVSLAM_INCLUDE_DIRS CUVSLAM_LIBRARY)