NDEVR
API Documentation
System.h
1#pragma once
2#include "DLLInfo.h"
3#include <thread>
4#include <opencv2/core/core.hpp>
5
6#include "OrbSLAM/Headers/Tracking.h"
7#include "OrbSLAM/Headers/Atlas.h"
8#include "OrbSLAM/Headers/LocalMapping.h"
9#include "OrbSLAM/Headers/LoopClosing.h"
10#include "OrbSLAM/Headers/KeyFrameDatabase.h"
11#include "OrbSLAM/Headers/ORBVocabulary.h"
12#include "OrbSLAM/Headers/Viewer.h"
13#include "OrbSLAM/Headers/SLAMParameters.h"
14#include <NDEVR/IntegratedRotation.h>
15namespace NDEVR
16{
17 class Viewer;
18 class FrameDrawer;
19 class MapDrawer;
20 class Atlas;
21 class Tracking;
22 class LocalMapping;
23 class LoopClosing;
24 class Model;
25 class Settings;
27 class KeyPointMap;
28 class KeyFrameMap;
29 class InfoPipe;
36 class ORBSLAM_API OrbSLAM
37 {
38 public:
42 const KeyFrame* lastKeyFrame() const;
46 bool needsMapReset() const;
51 OrbSLAM(const SLAMParameters& params, LogPtr log);
57 OrbSLAM(const File& vocab, const SLAMParameters& params, LogPtr log);
58
62 void setParams(const SLAMParameters& params);
67 void init(const File& vocab, const SLAMParameters& params);
72 Sophus::SE3f TrackStereo(OrbTrackingInfo& info);
73
78 Sophus::SE3f TrackRGBD(OrbTrackingInfo& info);
79
84 Sophus::SE3f TrackMonocular(OrbTrackingInfo& info);
85
94 void updateInfo(const Matrix<fltp08>& global_offset, DesignObjectLookup* lookup, const Model& frame_model, const Matrix<fltp08>& frame_model_transform, bool show_keyframes, bool show_map_points);
95
100
105
107 void reset();
110
112 void Shutdown();
117
139
146
147 private:
148
149 // Input sensor
150 Sensor m_sensor;
151
152 // ORB vocabulary used for place recognition and feature matching.
153 ORBVocabulary* m_vocabulary = nullptr;
154
155 // KeyFrame database for place recognition (relocalization and loop detection).
156 KeyFrameDatabase* m_key_frame_database = nullptr;
157
158 // Map structure that stores the pointers to all KeyFrames and MapPoints.
159 //Map* mpMap;
160 Atlas* m_atlas = nullptr;
161
162 // Tracker. It receives a frame and computes the associated camera pose.
163 // It also decides when to insert a new keyframe, create some new MapPoints and
164 // performs relocalization if tracking fails.
165 Tracking* m_tracker = nullptr;
166
167 // Local Mapper. It manages the local map and performs local bundle adjustment.
168 LocalMapping* m_local_mapper = nullptr;
169
170 // Loop Closer. It searches loops with every new keyframe. If there is a loop it performs
171 // a pose graph optimization and full bundle adjustment (in a new thread) afterwards.
172 LoopClosing* m_loop_closer = nullptr;
173
174 KeyPointMap* m_orb_point_map = nullptr;
175 KeyFrameMap* m_orb_frame_map = nullptr;
176 // OrbSLAM threads: Local Mapping, Loop Closing, Viewer.
177 // The Tracking thread "lives" in the main execution thread that creates the OrbSLAM object.
178 std::thread* mptLocalMapping = nullptr;
179 std::thread* mptLoopClosing = nullptr;
180
181 // reset flag
182 std::mutex mMutexReset;
183 bool mbReset = false;
184 bool mbResetActiveMap = false;
185
186 // Change mode flags
187 std::mutex mMutexMode;
188 bool mbActivateLocalizationMode = false;
189 bool mbDeactivateLocalizationMode = false;
190 // Shutdown flag
191 bool mbShutDown = false;
192 // Tracking state
194 Buffer<MapPoint*> mTrackedMapPoints;
195 std::mutex m_mutex_state;
196 LogPtr m_log;
197 fltp08 m_time_offset = Constant<fltp08>::Invalid;
198 int m_last_big_change_idx = 0;
199 };
200
205 static inline Matrix<fltp04> Convert(Eigen::Matrix4f mat)
206 {
208 for (uint01 i = 0; i < 4; i++)
209 {
210 for (uint01 x = 0; x < 4; x++)
211 {
212 transform[i][x] = mat.row(x).col(i).value();// at<fltp04>(x, i);
213 }
214 }
215 return transform;
216 }
217}
Manages a collection of maps for the ORB-SLAM system.
Definition Atlas.h:29
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core class where all Design Objects including models, materials, and geometries are stored.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
A light-weight base class for Log that allows processes to update, without the need for additional in...
Database of keyframes for place recognition and relocalization.
Manages the visualization of keyframes in the design model.
Definition KeyFrameMap.h:19
A keyframe in the SLAM map, derived from Frame.
Definition KeyFrame.h:31
Manages the visualization of map points in the design model.
Definition KeypointMap.h:17
Manages local map building, keyframe processing, and local bundle adjustment.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Detects and corrects loop closures and map merges.
Definition LoopClosing.h:29
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
const KeyFrame * lastKeyFrame() const
Returns the last processed keyframe.
double GetTimeFromIMUInit()
Returns the time elapsed since IMU initialization.
Sophus::SE3f TrackRGBD(OrbTrackingInfo &info)
Processes an RGB-D frame and returns the estimated camera pose.
bool isShutDown()
Checks whether the system has been shut down.
bool needsMapReset() const
Checks whether the map needs to be reset.
void setParams(const SLAMParameters &params)
Updates the SLAM configuration parameters.
Buffer< KeyFrame * > getAllKeyFrames() const
Returns all keyframes across all maps.
void ResetActiveMap()
Resets only the active map.
OrbSLAM(const SLAMParameters &params, LogPtr log)
Constructs and initializes the SLAM system without a vocabulary file.
void ActivateLocalizationMode()
Activates localization-only mode (stops map building).
void reset()
Resets the entire system, clearing the Atlas.
void updateInfo(const Matrix< fltp08 > &global_offset, DesignObjectLookup *lookup, const Model &frame_model, const Matrix< fltp08 > &frame_model_transform, bool show_keyframes, bool show_map_points)
Updates the visualization models with current SLAM data.
Sophus::SE3f TrackStereo(OrbTrackingInfo &info)
Processes a stereo frame and returns the estimated camera pose.
Tracking::eTrackingState GetTrackingState()
Returns the current tracking state.
Buffer< Sophus::SE3f > getAllKeyFramesAfter(uint04 index) const
Returns keyframe poses after a given index.
Buffer< MapPoint * > GetTrackedMapPoints()
Returns the tracked map points from the most recent frame.
OrbSLAM(const File &vocab, const SLAMParameters &params, LogPtr log)
Constructs and initializes the SLAM system with a vocabulary file.
bool MapChanged()
Checks whether the map has changed since the last call.
void init(const File &vocab, const SLAMParameters &params)
Initializes the system with a vocabulary file and parameters.
uint04 CurrentMapID() const
Returns the current map ID.
void Shutdown()
Shuts down all threads and waits for them to finish.
void DeactivateLocalizationMode()
Deactivates localization-only mode (resumes SLAM).
Sophus::SE3f TrackMonocular(OrbTrackingInfo &info)
Processes a monocular frame and returns the estimated camera pose.
void ChangeDataset()
Signals a dataset change for multi-sequence operation.
Configuration parameters for the ORB-SLAM system.
Main tracking thread that processes each frame and estimates camera pose.
Definition Tracking.h:33
eTrackingState
Tracking state enumeration.
Definition Tracking.h:37
@ NOT_INITIALIZED
Map not yet initialized.
Definition Tracking.h:40
The primary namespace for the NDEVR SDK.
TemplatedVocabulary< FORB::TDescriptor, FORB > ORBVocabulary
ORB visual vocabulary type for Bag-of-Words place recognition.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ transform
A 4x4 transform matrix that maps local coordinates into global space.
static Matrix< fltp04 > Convert(Eigen::Matrix4f mat)
Converts an Eigen 4x4 float matrix to an NDEVR Matrix.
Definition System.h:205
Aggregates input and output data for a single tracking frame.
Describes the input sensor type and IMU usage.