|
cuVSLAM API Reference
|
Visual Inertial Odometry (VIO) Tracker. More...
Classes | |
| struct | Config |
| Configuration parameters of the VIO tracker. More... | |
| struct | ImuState |
| IMU state: velocity, gyro bias, accelerometer bias. More... | |
| struct | MultisensorSettings |
| Multisensor odometry settings. More... | |
| struct | RGBDSettings |
| RGBD odometry settings. More... | |
| struct | State |
| State of the odometry tracker. More... | |
Public Types | |
| enum class | MulticameraMode : uint8_t { Performance , Precision , Moderate } |
| Multicamera mode. More... | |
| enum class | OdometryMode : uint8_t { Multicamera , Inertial , RGBD , Mono , Multisensor } |
| Odometry mode. More... | |
| using | ImageSet = std::vector< Image > |
| Image set. | |
| using | Gravity = Vector3f |
Public Member Functions | |
| Odometry (const Rig &rig, const Config &cfg=GetDefaultConfig()) | |
| Construct a tracker. More... | |
| Odometry (Odometry &&other) noexcept | |
| Move constructor. More... | |
| ~Odometry () | |
| Destructor. | |
| PoseEstimate | Track (const ImageSet &images, const ImageSet &masks={}, const ImageSet &depths={}, const cuvslam::internal::Internals *internals=nullptr) |
| Track a rig pose using current frame. More... | |
| void | RegisterImuMeasurement (uint32_t sensor_index, const ImuMeasurement &imu) |
| Register IMU measurement. More... | |
| std::vector< Observation > | GetLastObservations (uint32_t camera_index) const |
| Get Last Observations. More... | |
| std::vector< Landmark > | GetLastLandmarks () const |
| Get Last Landmarks. More... | |
| std::optional< Gravity > | GetLastGravity () const |
| Get Last Gravity. More... | |
| std::optional< ImuState > | GetImuState () const |
| Get current IMU state (velocity, gyro bias, acc bias). More... | |
| void | GetState (State &state) const |
| Get tracker state. More... | |
| std::unordered_map< uint64_t, Vector3f > | GetFinalLandmarks () const |
| Get all final landmarks from all frames. More... | |
| const std::vector< uint8_t > & | GetPrimaryCameras () const |
| Get primary camera indices used for tracking. More... | |
| void | ApplyPersistentInternalParameters (const std::vector< cuvslam::internal::InternalParameter > ¶meters) |
| Apply internal parameters by string key/value pairs. More... | |
Static Public Member Functions | |
| static Config | GetDefaultConfig () |
| Get default configuration. More... | |
Visual Inertial Odometry (VIO) Tracker.
| struct cuvslam::Odometry::Config |
Configuration parameters of the VIO tracker.
| Class Members | ||
|---|---|---|
| MulticameraMode | multicam_mode | Multicamera mode. Default: MulticameraMode::Precision. |
| OdometryMode | odometry_mode | Odometry mode. Default: OdometryMode::Multicamera. |
| bool | use_gpu | Enable tracking using GPU. Default: true. |
| bool | async_sba | Enable SBA asynchronous mode. Default: true. |
| bool | use_motion_model |
Enable internal pose prediction mechanism. Default: true. If frame rate is high enough it improves tracking performance and stability. As a general rule it is better to use a pose prediction mechanism tailored to a specific application. If you have an IMU, consider using it to provide pose predictions to cuVSLAM. |
| bool | use_denoising |
Enable image denoising. Disable if the input images have already passed through a denoising filter. Default: false |
| bool | rectified_stereo_camera |
Enable fast and robust tracking between rectified cameras with principal points on the horizontal line. Default: false |
| bool | enable_observations_export |
Enable GetLastObservations(). Warning: export flags slow down execution and result in additional memory usage. Default: false |
| bool | enable_landmarks_export |
Enable GetLastLandmarks(). Warning: export flags slow down execution and result in additional memory usage. Default: false |
| bool | enable_final_landmarks_export |
Enable GetFinalLandmarks(). Warning: export flags slow down execution and result in additional memory usage. This flag also sets enable_landmarks_export and enable_observations_export. Default: false |
| float | max_frame_delta_s |
Maximum frame delta in seconds. Odometry will warn if time delta between frames is higher than the threshold. Default: 1.f |
| string_view | debug_dump_directory | Directory where input data will be dumped in edex format. |
| bool | debug_imu_mode | Enable IMU debug mode. Default: false. |
| RGBDSettings | rgbd_settings | RGBD odometry settings. |
| MultisensorSettings | multisensor_settings | Multisensor odometry settings. Used only when odometry_mode == OdometryMode::Multisensor. |
| struct cuvslam::Odometry::ImuState |
| struct cuvslam::Odometry::MultisensorSettings |
Multisensor odometry settings.
Used only when Config::odometry_mode == OdometryMode::Multisensor.
Multisensor mode supports any mix of:
The rig's IMU presence drives IMU fusion automatically — there is no separate with_imu flag. The only fields here describe depth handling.
| Class Members | ||
|---|---|---|
| vector< int32_t > | depth_camera_ids |
Camera ids (matching Rig::cameras indices) that supply depth images at Track() time. Empty means: no depth (pure multi-camera-RGB). Cameras not listed here are treated as RGB-only. Mixed rigs (some RGB, some RGB-D) are supported by listing only the depth-capable cameras. |
| float | depth_scale_factor | Scale factor for depth measurements (denominator: raw depth divided by this is meters). Applied uniformly across all depth cameras. Default: 1.f. |
| bool | enable_depth_stereo_tracking |
Allow stereo 2D tracking between depth-aligned cameras and other cameras. Default: true. Multisensor mode benefits from cross-camera 2D tracks (depth-aligned cameras are typically informative anchors), so we enable this by default. Set to false to opt out. |
| struct cuvslam::Odometry::RGBDSettings |
RGBD odometry settings.
| Class Members | ||
|---|---|---|
| float | depth_scale_factor |
Scale of provided depth measurements. Default: 1.f. The scale factor is the denominator used to convert raw depth values from the input depth image to actual distance measurements in meters. For example, in TUM RGB-D a factor of 5000 is used for 16-bit PNG images, meaning each pixel value should be divided by 5000 to get the depth in meters, while a factor of 1 is used for 32-bit float images, where the depth values are already in meters. |
| int32_t | depth_camera_id |
Depth camera id. Depth image is supposed to be pixel-to-pixel aligned with some RGB camera image. This field specifies camera id, that depth is aligned with. Default: -1 |
| bool | enable_depth_stereo_tracking | Allows stereo 2D tracking between depth-aligned camera and any other camera. Default: false. |
| struct cuvslam::Odometry::State |
| Class Members | ||
|---|---|---|
| typedef unordered_map< uint8_t, shared_ptr< Context > > | ContextMap | |
| Class Members | ||
|---|---|---|
| uint64_t | frame_id | Internal frame id. |
| int64_t | timestamp_ns | Timestamp in nanoseconds. |
| Pose | delta | Pose change since last keyframe. |
| bool | keyframe | Is this frame a keyframe? |
| bool | warming_up | Is the tracker in warming up phase? |
| optional< Gravity > | gravity | Optional gravity. Available in Inertial or Multisensor mode with an IMU. |
| vector< Observation > | observations | Observations for this frame. |
| vector< Landmark > | landmarks | Landmarks for this frame. |
| ContextMap | context | Opaque context information for this frame (used internally by Slam) |
| using cuvslam::Odometry::Gravity = Vector3f |
Gravity acceleration vector (magnitude ~9.81 m/s²) in the rig / VO frame; +Y is down (OpenCV), so it is approximately (0, +g, 0) when the rig is upright.
|
strong |
Multicamera mode.
Multicamera mode defines which cameras will be used for mono SOF (primary cameras)
|
strong |
Odometry mode.
Odometry mode defines what data is expected and how it will be used by odometry tracker
|
explicit |
Construct a tracker.
| [in] | rig | rig setup |
| [in] | cfg | tracker configuration |
| std::runtime_error | if tracker fails to initialize |
| std::invalid_argument | if rig or config is invalid |
|
noexcept |
Move constructor.
| [in] | other | other tracker |
|
inlinestatic |
| PoseEstimate cuvslam::Odometry::Track | ( | const ImageSet & | images, |
| const ImageSet & | masks = {}, |
||
| const ImageSet & | depths = {}, |
||
| const cuvslam::internal::Internals * | internals = nullptr |
||
| ) |
Track a rig pose using current frame.
Track current frame synchronously: the function blocks until the tracker has computed a pose. By default, this function uses visual odometry to compute a pose. If visual odometry tracker fails to compute a pose, in Inertial mode or Multisensor mode with an IMU the function returns the position calculated from user-provided IMU data. If after several calls of Track() visual odometry is not able to recover, then invalid pose will be returned.
The track will output poses in the same coordinate system until a loss of tracking.
Image timestamps have to match. cuVSLAM will use timestamp from the camera 0 image. If a camera rig provides "almost synchronized" frames, the timestamps should be within 1 millisecond. The number of images for tracker should not exceed rig->num_cameras.
| [in] | images | an array of synchronized images no more than rig->num_cameras. Must use ImageData::DataType::UINT8. Partial ImageSet is supported, for example due to frame drops. Corresponding cameras are identified by Image::camera_index. |
| [in] | masks | (Optional) an array of corresponding masks no more than rig->num_cameras. Must use ImageData::DataType::UINT8. Partial ImageSet is supported, for example if mask is calculated on for some cameras. Corresponding cameras are identified by Image::camera_index. |
| [in] | depths | (Optional) an array of depth images. In OdometryMode::RGBD exactly one depth image must be provided. In OdometryMode::Multisensor pass one depth image per depth-providing camera; each entry is matched to its rig camera by Image::camera_index and every camera_index must appear in MultisensorSettings::depth_camera_ids. Other modes must pass an empty array. Must use ImageData::Encoding::MONO and ImageData::DataType::UINT16 or ImageData::DataType::FLOAT32. |
| [in] | internals | (Optional) pointer to internal per-frame development parameters; pass nullptr (default) to use built-in defaults. Not intended for production use. |
PoseEstimate contains estimated rig pose, on failure PoseEstimate::world_from_rig will be nullopt. | std::invalid_argument | if image parameters are invalid |
| std::runtime_error | in case of unexpected errors |
| void cuvslam::Odometry::RegisterImuMeasurement | ( | uint32_t | sensor_index, |
| const ImuMeasurement & | imu | ||
| ) |
Register IMU measurement.
If visual odometry loses camera position, it briefly continues execution using user-provided IMU measurements while trying to recover the position. You should call these functions in monotonic timestamp order however many IMU measurements you have between image acquisitions:
IMU measurements and frame images both have timestamps, so calls to Track() and RegisterImuMeasurement() on the same Odometry instance must be made in non-decreasing timestamp order and externally serialized. Do not call them concurrently from different threads. If IMU samples are captured on a separate thread, buffer them and submit them in timestamp order from the same sequence that calls Track(), or protect all calls with caller-owned synchronization.
| [in] | sensor_index | Sensor index; must be 0, as only one sensor is supported now |
| [in] | imu | IMU measurements |
| std::invalid_argument | if IMU fusion is disabled or if called out of the order of timestamps |
| std::vector<Observation> cuvslam::Odometry::GetLastObservations | ( | uint32_t | camera_index | ) | const |
Get Last Observations.
Get an array of observations from the last VO frame for a specific camera
| [in] | camera_index | Index of the camera to get observations for |
| std::invalid_argument | if stats export is disabled |
| std::vector<Landmark> cuvslam::Odometry::GetLastLandmarks | ( | ) | const |
Get Last Landmarks.
Get an array of landmarks from the last VO frame; Landmarks are 3D points in the last camera frame.
| std::invalid_argument | if stats export is disabled |
| std::optional<Gravity> cuvslam::Odometry::GetLastGravity | ( | ) | const |
Get Last Gravity.
Get gravity acceleration vector in the last VO / rig frame (+Y down, OpenCV convention).
| std::invalid_argument | if IMU fusion is disabled |
| std::optional<ImuState> cuvslam::Odometry::GetImuState | ( | ) | const |
Get current IMU state (velocity, gyro bias, acc bias).
| void cuvslam::Odometry::GetState | ( | State & | state | ) | const |
| std::unordered_map<uint64_t, Vector3f> cuvslam::Odometry::GetFinalLandmarks | ( | ) | const |
Get all final landmarks from all frames.
Landmarks are 3D points in the odometry start frame.
| std::invalid_argument | if stats export is disabled |
| const std::vector<uint8_t>& cuvslam::Odometry::GetPrimaryCameras | ( | ) | const |
Get primary camera indices used for tracking.
| void cuvslam::Odometry::ApplyPersistentInternalParameters | ( | const std::vector< cuvslam::internal::InternalParameter > & | parameters | ) |
Apply internal parameters by string key/value pairs.
Allows setting internal runtime settings by name. Unknown keys log a warning and are ignored. Invalid values or keys not applicable to the current odometry mode throw std::invalid_argument.
For internal use only.
Supported keys (grouped by prefix):
SBA (all modes): sba.num_sba_frames, sba.num_inertial_sba_frames, sba.num_fixed_sba_frames, sba.num_sba_iterations, sba.robustifier_scale, sba.use_sba_winsorizer
Note: sba.async and sba.mode are construction-time settings that determine whether the SBA background thread is spawned and which bundler is used. They cannot be changed after the tracker is created. Set Odometry::Config::async_sba and Odometry::Config::odometry_mode before constructing the Odometry object instead.
StateMachine / IMU gravity estimation (Inertial mode only): sm.gravity_update_period_ns, sm.max_integration_time_ns, sm.min_num_kf_for_gravity, sm.min_time_period_ns, sm.max_time_period_ns
| [in] | parameters | Key/value pairs to apply. |