31 #include "rtabmap/core/rtabmap_core_export.h"
43 #include <opencv2/core/core.hpp>
44 #include <opencv2/features2d/features2d.hpp>
45 #include <pcl/pcl_config.h>
56 class RegistrationInfo;
57 class RegistrationIcp;
58 class RegistrationVis;
62 class GlobalDescriptorExtractor;
75 virtual void parseParameters(
const ParametersMap & parameters);
81 const cv::Mat & covariance,
82 const std::vector<float> & velocity = std::vector<float>(),
84 bool init(
const std::string & dbUrl,
85 bool dbOverwritten =
false,
87 bool postInitClosingEvents =
false);
88 void close(
bool databaseSaved =
true,
bool postInitClosingEvents =
false,
const std::string & ouputDatabasePath =
"");
89 std::map<int, float> computeLikelihood(
const Signature * signature,
90 const std::list<int> & ids);
91 int incrementMapId(std::map<int, int> * reducedIds = 0);
92 void updateAge(
int signatureId);
94 std::list<int> forget(
const std::set<int> & ignoredIds = std::set<int>());
95 std::set<int> reactivateSignatures(
const std::list<int> & ids,
unsigned int maxLoaded,
double & timeDbAccess);
98 void saveStatistics(
const Statistics & statistics,
bool saveWMState);
99 void savePreviewImage(
const cv::Mat & image)
const;
100 cv::Mat loadPreviewImage()
const;
101 void saveOptimizedPoses(
const std::map<int, Transform> & optimizedPoses,
const Transform & lastlocalizationPose)
const;
102 std::map<int, Transform> loadOptimizedPoses(
Transform * lastlocalizationPose)
const;
103 void save2DMap(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const;
104 cv::Mat load2DMap(
float & xMin,
float & yMin,
float & cellSize)
const;
105 void saveOptimizedMesh(
106 const cv::Mat & cloud,
107 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons = std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > >(),
108 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
111 const std::vector<std::vector<Eigen::Vector2f> > & texCoords = std::vector<std::vector<Eigen::Vector2f> >(),
113 const cv::Mat & textures = cv::Mat())
const;
114 cv::Mat loadOptimizedMesh(
115 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons = 0,
116 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
119 std::vector<std::vector<Eigen::Vector2f> > * texCoords = 0,
121 cv::Mat * textures = 0)
const;
123 void joinTrashThread();
124 bool addLink(
const Link & link,
bool addInDatabase =
false);
125 void updateLink(
const Link & link,
bool updateInDatabase =
false);
126 void removeAllVirtualLinks();
127 void removeVirtualLinks(
int signatureId);
128 std::map<int, int> getNeighborsId(
131 int maxCheckedInDatabase = -1,
132 bool incrementMarginOnLoop =
false,
133 bool ignoreLoopIds =
false,
134 bool ignoreIntermediateNodes =
false,
135 bool ignoreLocalSpaceLoopIds =
false,
136 const std::set<int> & nodesSet = std::set<int>(),
137 double * dbAccessTime = 0)
const;
138 std::map<int, float> getNeighborsIdRadius(
141 const std::map<int, Transform> & optimizedPoses,
142 int maxGraphDepth)
const;
143 void deleteLocation(
int locationId, std::list<int> * deletedWords = 0);
144 void saveLocationData(
int locationId);
145 void removeLink(
int idA,
int idB);
146 void removeRawData(
int id,
bool image =
true,
bool scan =
true,
bool userData =
true);
150 const std::set<int> &
getStMem()
const {
return _stMem;}
152 std::multimap<int, Link> getNeighborLinks(
int signatureId,
153 bool lookInDatabase =
false)
const;
154 std::multimap<int, Link> getLoopClosureLinks(
int signatureId,
155 bool lookInDatabase =
false)
const;
156 std::multimap<int, Link> getLinks(
int signatureId,
157 bool lookInDatabase =
false,
158 bool withLandmarks =
false)
const;
159 std::multimap<int, Link> getAllLinks(
bool lookInDatabase,
bool ignoreNullLinks =
true,
bool withLandmarks =
false)
const;
162 std::map<int, int> getWeights()
const;
163 int getLastSignatureId()
const;
164 const Signature * getLastWorkingSignature()
const;
165 std::map<int, Link> getNodesObservingLandmark(
int landmarkId,
bool lookInDatabase)
const;
166 int getSignatureIdByLabel(
const std::string & label,
bool lookInDatabase =
true)
const;
167 bool labelSignature(
int id,
const std::string & label);
168 const std::map<int, std::string> &
getAllLabels()
const {
return _labels;}
179 bool setUserData(
int id,
const cv::Mat & data);
180 int getDatabaseMemoryUsed()
const;
181 std::string getDatabaseVersion()
const;
182 std::string getDatabaseUrl()
const;
183 double getDbSavingTime()
const;
184 int getMapId(
int id,
bool lookInDatabase =
false)
const;
185 Transform getOdomPose(
int signatureId,
bool lookInDatabase =
false)
const;
186 Transform getGroundTruthPose(
int signatureId,
bool lookInDatabase =
false)
const;
188 void getGPS(
int id,
GPS & gps,
Transform & offsetENU,
bool lookInDatabase,
int maxGraphDepth = 0)
const;
189 bool getNodeInfo(
int signatureId,
196 std::vector<float> & velocity,
199 bool lookInDatabase =
false)
const;
200 cv::Mat getImageCompressed(
int signatureId)
const;
201 SensorData getNodeData(
int locationId,
bool images,
bool scan,
bool userData,
bool occupancyGrid)
const;
202 void getNodeWordsAndGlobalDescriptors(
int nodeId,
203 std::multimap<int, int> & words,
204 std::vector<cv::KeyPoint> & wordsKpts,
205 std::vector<cv::Point3f> & words3,
206 cv::Mat & wordsDescriptors,
207 std::vector<GlobalDescriptor> & globalDescriptors)
const;
208 void getNodeCalibration(
int nodeId,
209 std::vector<CameraModel> & models,
210 std::vector<StereoCameraModel> & stereoModels)
const;
211 std::set<int> getAllSignatureIds(
bool ignoreChildren =
true)
const;
215 const Signature * getSignature(
int id)
const;
216 bool isInSTM(
int signatureId)
const {
return _stMem.find(signatureId) != _stMem.end();}
217 bool isInWM(
int signatureId)
const {
return _workingMem.find(signatureId) != _workingMem.end();}
218 bool isInLTM(
int signatureId)
const {
return !this->isInSTM(signatureId) && !this->isInWM(signatureId);}
226 void dumpMemoryTree(
const char * fileNameTree)
const;
227 virtual void dumpMemory(std::string directory)
const;
228 virtual void dumpSignatures(
const char * fileNameSign,
bool words3D)
const;
229 void dumpDictionary(
const char * fileNameRef,
const char * fileNameDesc)
const;
230 unsigned long getMemoryUsed()
const;
232 void generateGraph(
const std::string & fileName,
const std::set<int> & ids = std::set<int>());
233 int cleanupLocalGrids(
234 const std::map<int, Transform> & poses,
240 bool filterScans =
false);
246 void getMetricConstraints(
247 const std::set<int> & ids,
248 std::map<int, Transform> & poses,
249 std::multimap<int, Link> & links,
250 bool lookInDatabase =
false,
251 bool landmarksAdded =
false);
259 const std::map<int, Transform> & poses,
264 void addSignatureToStm(
Signature * signature,
const cv::Mat & covariance);
266 void loadDataFromDb(
bool postInitClosingEvents);
267 void moveToTrash(
Signature * s,
bool keepLinkedToGraph =
true, std::list<int> * deletedWords = 0);
269 void moveSignatureToWMFromSTM(
int id,
int * reducedTo = 0);
270 void addSignatureToWmFromLTM(
Signature * signature);
272 std::list<Signature *> getRemovableSignatures(
int count,
273 const std::set<int> & ignoredIds = std::set<int>());
277 bool rehearsalMerge(
int oldId,
int newId);
279 const std::map<int, Signature*> &
getSignatures()
const {
return _signatures;}
288 void disableWordsRef(
int signatureId);
289 void enableWordsRef(
const std::list<int> & signatureIds);
290 void cleanUnusedWords();
291 int getNi(
int signatureId)
const;