NVIDIA cuVSLAM
repository·main·Indexed 23 days ago
https://github.com/nvidia-isaac/cuvslamA CUDA-accelerated library providing high-performance Visual Odometry and Simultaneous Localization and Mapping (SLAM) capabilities for various camera configurations. It includes Python bindings (PyCuVSLAM) and supports multiple tracking modes including Stereo, Stereo-Inertial, Mono-Depth (RGB-D), Monocular, and Multisensor. The library provides support for various camera distortion models (Pinhole, Fisheye, Brown, Polynomial) and integrates with datasets such as KITTI and EuRoC.
What's inside cuVSLAM
- PyCuVSLAM provides Python bindings for the cuVSLAM (CUDA-accelerated Visual SLAM) library. It allows developers to leverage CUDA-accelerated Visual Odometry and Mapping capabilities directly within Python environments.
Overview of cuVSLAM Agent Skills
mainThe
cuvslam-skillsrepository provides specialized agent skills for interacting with NVIDIA cuVSLAM. These skills are categorized into three main areas:- cuvslam-onboard: Handles environment setup, building (source, wheel, or Docker), dataset preparation (KITTI, EuRoC, TUM RGB-D, etc.), running various tracking modes (stereo, mono, multisensor, etc.), SLAM workflows (mapping, localization, loop closure), live camera setup (RealSense, ZED, OAK-D, Orbbec), and ROS 2 integration.
- cuvslam-troubleshoot: Provides a diagnostic workflow to fix tracking or pose accuracy issues, including triage, a 14-step diagnostic process, debug data dumps for C++, Python, and ROS 2 APIs, and checks for calibration, synchronization, and image quality.
- cuvslam-ci: Facilitates working on cuVSLAM CI/CD via GitHub Actions, covering PR verification, nightly pipelines, dataset provisioning, KPI reporting, and build/test matrix management.
Use the cuvslam Python module
mainThecuvslammodule provides Python bindings for the CUDA-accelerated Visual Odometry and Mapping library. It allows users to interface with core SLAM and Odometry functionalities, including camera calibration, IMU measurements, and pose estimation.SLAM and Advanced Feature Examples
mainBeyond basic odometry, cuVSLAM provides examples for:
- SLAM: Visual mapping, localization, and saving/loading maps (e.g., KITTI).
- Distorted Images: Handling camera distortion models (e.g., EuRoC, OAK-D, ZED).
- Image Masking: Using static masks to prevent feature selection in specific regions or dynamic masks using PyTorch tensors.
- PyTorch Integration: Handling PyTorch GPU tensors for real-time tasks like segmentation.
- C++ API: High-performance implementations like EuRoC VIO and SLAM.
Core classes in the cuVSLAM C++ API
mainThe cuVSLAM C++ API is primarily built around two main classes:
cuvslam::Odometry: Used for visual odometry tasks.cuvslam::Slam: Used for full SLAM (Simultaneous Localization and Mapping) capabilities.
Depending on whether you need pure odometry or full mapping and relocalization, you should choose between these two entry points.
Visual Tracking Mode Examples Overview
maincuVSLAM supports various visual tracking modes depending on your sensor configuration:
- Monocular Visual Odometry: Single camera input (e.g., EuRoC dataset).
- Monocular-Depth Visual Odometry: Monocular camera + depth information (e.g., TUM dataset, RealSense, ZED, Orbbec).
- Stereo Visual Odometry: Dual camera input (e.g., KITTI dataset, RealSense, ZED, OAK-D, Orbbec).
- Stereo Visual-Inertial Odometry: Stereo cameras + IMU (e.g., EuRoC, RealSense).
- Multi-Camera Stereo Visual Odometry: Multiple stereo pairs (e.g., Tartan Ground, R2B Galileo, RealSense).
- Multisensor Odometry: Flexible mix of RGB, RGB-D, and optional IMU (e.g., Tartan Ground, RealSense).
Note: All Python examples use the Rerun viewer for interactive visualization of trajectories, camera frames, and mapped features. The Rerun UI remains open after the script finishes for inspection.
Understand grayscale-only internal processing
mainAll image data is converted to grayscale before feature detection. RGB images are converted using
cast_rgb2gs_cpu()(standard luminance weighting).Consequences:
- Color information is discarded. If objects are only distinguishable by color and not luminance, tracking may fail.
Tip: If one color channel is significantly noisier (e.g., the blue channel on some Bayer sensors), pre-select the cleanest channel and pass it as a mono image instead of using the automatic RGB conversion.
Organize traces using Domains and DomainHelper
mainYou can group related events and marks into a
Domain. This is useful for separating different subsystems in your trace.Using Domain directly
Requires managing the domain handle manually:
auto domain = Domain("my_domain_name"); // create a mark in this domain DomainMark(domain.get_handle(), "something_happend_inside_my_domain_name"); // also trace an event auto ev_id = DomainTraceEventStart(domain.get_handle(), "track"); tracker->track(); DomainTraceEventEnd(domain.get_handle(), ev_id);Using DomainHelper (Recommended)
DomainHelperprovides a more convenient interface so you don't have to pass the handle manually for every call:auto helper = DomainHelper("new_domain"); helper.mark("something_happend_in_new_domain"); { auto ev_ = helper.trace_event("scope_event"); foo(); } auto ev_id_ = helper.trace_start("bar"); bar(); helper.trace_event_end(ev_id_);Select a cuVSLAM tracking mode
maincuVSLAM supports several odometry modes that can be selected via
Odometry::Config::odometry_mode(C++) orcuvslam.Tracker.OdometryMode(Python). The choice of mode depends on your sensor rig's capabilities and requirements for scale and robustness.Mode Required sensors Optional sensors Mode-specific settings When to use Mono1 camera — — Single-camera tracking; cheapest setup but scale-ambiguous. RGBD1 RGB-D camera (aligned RGB + depth) — RGBDSettingsSingle depth-aligned camera (e.g. RealSense, TUM RGB-D). Multicamera≥2 cameras with at least one overlapping pair (a stereo pair) up to 32 cameras total — Stereo or multi-stereo rigs. Most accurate purely-visual mode. Inertial1 stereo pair + 1 IMU — — Stereo VIO. Adds robustness to brief visual failures. Multisensor≥1 RGB-D camera or ≥1 overlapping camera pair; cuNLS-enabled build Additional RGB/RGB-D cameras, 0 or 1 IMU MultisensorSettingsAny-mix RGB / RGB-D rigs with optional IMU, including one RGB-D camera with IMU. Important Notes:
Multisensormode requires a cuNLS-enabled build. All other modes work with the default build.- IMU fusion is always on in
Inertialmode and is auto-enabled inMultisensormode whenRig::imusis non-empty.
How optional inputs are resolved at the API boundary
maincuVSLAM follows a pattern where optionality is resolved at the public API boundary to prevent 'optional noise' in internal functions.
- The public API (like
Odometry::Track()) accepts optional or nullable inputs (e.g., a nullInternals*pointer). - The boundary layer (e.g.,
BuildTrackFrameSettings()) resolves these optionals into concrete, non-optional settings structs. - Internal functions (e.g.,
IVisualOdometry::track,IMonoSOF::track) receive these concrete structs and do not need to performhas_value()checks.
Example of the resolution flow:
Internals*(null or overrides) $\rightarrow$Internals{}(if null) $\rightarrow$BuildTrackFrameSettings()$\rightarrow$TrackPerFrameSettings(concrete) $\rightarrow$ Internal tracking functions (no optionals).- The public API (like
Avoid using setters for per-frame parameter changes
mainDo not use setter methods (e.g.,
odometry.SetNumDesiredTracks(200)) to change a parameter for a single frame. Setters mutate the long-lived state of theOdometryobject, which can cause parameter changes to 'bleed' into subsequent frames, making behavior difficult to reproduce and test.Incorrect Pattern:
// BAD — setter mutates shared state and can bleed across frames. odometry.SetNumDesiredTracks(200); odometry.Track(images);How the cuVSLAM system architecture works
maincuVSLAM operates using a decoupled architecture that separates real-time tracking from non-real-time SLAM processing (mapping and localization) via a thread-safe message queue.
Core Components:
- Real-time (RT) SLAM: Handles high-frequency tasks including
Track(real-time odometry),Localize(finding position in the map), andSaveMap. - ThreadSafeMessageQueue: Acts as the intermediary between the real-time tracking thread and the background processing thread. It handles messages such as
AddKF(adding a keyframe),FindLC(finding loop closure), andSaveMaprequests. - Background (BG) SLAM: A non-real-time thread that continuously processes messages from the queue to update the global
map. - ThreadSafe Tail (Keyframe Chain): A specialized data structure that allows the real-time tracking thread to interact with the background thread without blocking, facilitating continuous pose estimation even while the map is being updated.
- Real-time (RT) SLAM: Handles high-frequency tasks including