RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
OdometryCuVSLAM.h
1/*
2Copyright (c) 2025 Felix Toft
3Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the Universite de Sherbrooke nor the
14 names of its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
21DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#ifndef ODOMETRYCUVSLAM_H_
30#define ODOMETRYCUVSLAM_H_
31
32#include <rtabmap/core/Odometry.h>
33#include <memory>
34#include <deque>
35#include <array>
36
37#ifdef RTABMAP_CUVSLAM
38#include <cuvslam.h>
39#include <ground_constraint.h>
40#include <cuda_runtime.h>
41#endif
42
43namespace rtabmap {
44
45class RTABMAP_CORE_EXPORT OdometryCuVSLAM : public Odometry
46{
47public:
49 virtual ~OdometryCuVSLAM();
50
51 virtual void reset(const Transform & initialPose = Transform::getIdentity());
52 virtual Odometry::Type getType() {return Odometry::kTypeCuVSLAM;}
53
54private:
55 virtual Transform computeTransform(SensorData & image, const Transform & guess = Transform(), OdometryInfo * info = 0);
56 virtual void cleanupCuVSLAMResources();
57
58private:
59#ifdef RTABMAP_CUVSLAM
60 CUVSLAM_TrackerHandle cuvslam_handle_;
61 CUVSLAM_GroundConstraintHandle ground_constraint_handle_;
62
63 std::vector<CUVSLAM_Camera> cuvslam_cameras_;
64 std::vector<std::array<float, 12>> intrinsics_;
65
66 // State tracking
67 bool initialized_;
68 bool lost_;
69 bool tracking_;
70 bool planar_constraints_;
71 int multicam_mode_;
72 Transform previous_pose_;
73 double last_timestamp_;
74
75 // Configuration Thresholds
76 double velocity_ratio_threshold_high_ = 1.5; // The maximum velocity ratio of guess / estimated velocity needed to detect lost state.
77 double velocity_ratio_threshold_low_ = 0.5; // The minimum velocity ratio of guess / estimated velocity needed to detect lost state.
78 double velocity_difference_threshold_ = 0.1; // The maximum velocity difference between the guess and the estimated velocity needed to detect lost state.
79 double zero_estimated_velocity_threshold_ = 0.00001; // The minimum cuVSLAM estimated velocity needed to detect lost state.
80 double min_landmarks_threshold_ = 30; // The minimum number of landmarks needed to start tracking after an initialization.
81
82 // Forward cuVLSAM covariance directly to RTAB-Map.
83 // When true this disables covariance based lost detection.
84 bool use_raw_covariance_ = false;
85
86 //visualization
87 std::vector<CUVSLAM_Observation> observations_;
88 std::vector<CUVSLAM_Landmark> landmarks_;
89
90 // GPU memory management
91 std::vector<uint8_t *> gpu_left_image_data_; // pointers to all gpu images
92 std::vector<uint8_t *> gpu_right_image_data_;
93 std::vector<size_t> gpu_left_image_sizes_; // size of one image
94 std::vector<size_t> gpu_right_image_sizes_;
95 cudaStream_t cuda_stream_;
96#endif
97};
98
99}
100
101#endif /* ODOMETRYCUVSLAM_H_ */
virtual void reset(const Transform &initialPose=Transform::getIdentity())
Resets internal state and sets the initial pose.
virtual Odometry::Type getType()
What one Odometry iteration produced, beyond the pose.
Abstract base class for visual, lidar and visual-inertial odometry backends.
Definition Odometry.h:57
Type
Odometry backend selected by Parameters::kOdomStrategy().
Definition Odometry.h:60
Container class for all sensor data captured at a specific time.
Definition SensorData.h:97
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44