92 const std::string &
getUrl()
const {
return _url;}
116 double getEmptyTrashesTime()
const {
return _emptyTrashesTime;}
117 void setTimestampUpdateEnabled(
bool enabled) {_timestampUpdate = enabled;}
127 const std::string & fileName,
128 const std::set<int> & ids = std::set<int>(),
129 const std::map<int, Signature *> & otherSignatures = std::map<int, Signature *>());
151 const cv::Mat & ground,
152 const cv::Mat & obstacles,
153 const cv::Mat & empty,
155 const cv::Point3f & viewpoint);
159 const std::vector<CameraModel> & models,
160 const std::vector<StereoCameraModel> & stereoModels);
181 void addInfoAfterRun(
int stMemSize,
int lastSignAdded,
int processMemUsed,
int databaseMemUsed,
int dictionarySize,
const ParametersMap & parameters)
const;
201 void save2DMap(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const;
203 cv::Mat
load2DMap(
float & xMin,
float & yMin,
float & cellSize)
const;
212 const cv::Mat & cloud,
213 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons = std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > >(),
214#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
215 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords = std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > >(),
217 const std::vector<std::vector<Eigen::Vector2f> > & texCoords = std::vector<std::vector<Eigen::Vector2f> >(),
219 const cv::Mat & textures = cv::Mat())
const;
220 cv::Mat loadOptimizedMesh(
221 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons = 0,
222#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
223 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords = 0,
225 std::vector<std::vector<Eigen::Vector2f> > * texCoords = 0,
227 cv::Mat * textures = 0)
const;
242 bool openConnection(
const std::string & url,
bool overwritten =
false,
bool readOnly =
false);
247 unsigned long getMemoryUsed()
const;
250 long getNodesMemoryUsed()
const;
251 long getLinksMemoryUsed()
const;
252 long getImagesMemoryUsed()
const;
253 long getDepthImagesMemoryUsed()
const;
254 long getCalibrationsMemoryUsed()
const;
255 long getGridsMemoryUsed()
const;
256 long getLaserScansMemoryUsed()
const;
257 long getUserDataMemoryUsed()
const;
258 long getWordsMemoryUsed()
const;
259 long getFeaturesMemoryUsed()
const;
260 long getStatisticsMemoryUsed()
const;
261 int getLastNodesSize()
const;
262 int getLastDictionarySize()
const;
263 int getTotalNodesSize()
const;
264 int getTotalDictionarySize()
const;
266 std::map<std::string, float> getStatistics(
int nodeId,
double & stamp, std::vector<int> * wmState=0)
const;
267 std::map<int, std::pair<std::map<std::string, float>,
double> > getAllStatistics()
const;
268 std::map<int, std::vector<int> > getAllStatisticsWmStates()
const;
294 void load(
VWDictionary & dictionary,
bool lastStateOnly =
true,
bool idsOnly =
false)
const;
295 void loadLastNodes(std::list<Signature *> & signatures,
bool loadWordIdsOnly =
false)
const;
298 void loadSignatures(
const std::list<int> & ids, std::list<Signature *> & signatures, std::set<int> * loadedFromTrash = 0,
bool loadWordIdsOnly =
false);
299 void loadWords(
const std::set<int> & wordIds, std::list<VisualWord *> & vws);
302 void loadNodeData(
Signature & signature,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
303 void loadNodeData(std::list<Signature *> & signatures,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
304 void getNodeData(
int signatureId,
SensorData & data,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
305 bool getCalibration(
int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels)
const;
306 bool getLaserScanInfo(
int signatureId,
LaserScan & info)
const;
307 bool getNodeInfo(
int signatureId,
Transform & pose,
int & mapId,
int & weight, std::string & label,
double & stamp,
Transform & groundTruthPose, std::vector<float> & velocity,
GPS & gps,
EnvSensors & sensors)
const;
308 void getLocalFeatures(
int signatureId, std::multimap<int, int> & words, std::vector<cv::KeyPoint> & keypoints, std::vector<cv::Point3f> & points, cv::Mat & descriptors)
const;
311 void getWeight(
int signatureId,
int & weight)
const;
312 void getLastNodeIds(std::set<int> & ids)
const;
313 void getAllNodeIds(std::set<int> & ids,
bool ignoreChildren =
false,
bool ignoreBadSignatures =
false,
bool ignoreIntermediateNodes =
false)
const;
314 void getAllOdomPoses(std::map<int, Transform> & poses,
bool ignoreChildren =
false,
bool ignoreIntermediateNodes =
false)
const;
315 void getAllLinks(std::multimap<int, Link> & links,
bool ignoreNullLinks =
true,
bool withLandmarks =
false)
const;
316 void getLastNodeId(
int &
id)
const;
317 void getLastMapId(
int & mapId)
const;
318 void getLastWordId(
int &
id)
const;
319 void getInvertedIndexNi(
int signatureId,
int & ni)
const;
320 void getNodesObservingLandmark(
int landmarkId, std::map<int, Link> & nodes)
const;
321 void getNodeIdByLabel(
const std::string & label,
int &
id)
const;
322 void getAllLabels(std::map<int, std::string> & labels)
const;
341 virtual bool connectDatabaseQuery(
const std::string & url,
bool overwritten =
false,
bool readOnly =
false) = 0;
342 virtual void disconnectDatabaseQuery(
bool save =
true,
const std::string & outputUrl =
"") = 0;
343 virtual bool isConnectedQuery()
const = 0;
344 virtual unsigned long getMemoryUsedQuery()
const = 0;
345 virtual bool getDatabaseVersionQuery(std::string & version)
const = 0;
346 virtual long getNodesMemoryUsedQuery()
const = 0;
347 virtual long getLinksMemoryUsedQuery()
const = 0;
348 virtual long getImagesMemoryUsedQuery()
const = 0;
349 virtual long getDepthImagesMemoryUsedQuery()
const = 0;
350 virtual long getCalibrationsMemoryUsedQuery()
const = 0;
351 virtual long getGridsMemoryUsedQuery()
const = 0;
352 virtual long getLaserScansMemoryUsedQuery()
const = 0;
353 virtual long getUserDataMemoryUsedQuery()
const = 0;
354 virtual long getWordsMemoryUsedQuery()
const = 0;
355 virtual long getFeaturesMemoryUsedQuery()
const = 0;
356 virtual long getStatisticsMemoryUsedQuery()
const = 0;
357 virtual int getLastNodesSizeQuery()
const = 0;
358 virtual int getLastDictionarySizeQuery()
const = 0;
359 virtual int getTotalNodesSizeQuery()
const = 0;
360 virtual int getTotalDictionarySizeQuery()
const = 0;
362 virtual std::map<std::string, float> getStatisticsQuery(
int nodeId,
double & stamp, std::vector<int> * wmState)
const = 0;
363 virtual std::map<int, std::pair<std::map<std::string, float>,
double> > getAllStatisticsQuery()
const = 0;
364 virtual std::map<int, std::vector<int> > getAllStatisticsWmStatesQuery()
const = 0;
366 virtual void executeNoResultQuery(
const std::string & sql)
const = 0;
368 virtual void getWeightQuery(
int signatureId,
int & weight)
const = 0;
370 virtual void saveQuery(
const std::list<Signature *> & signatures) = 0;
371 virtual void saveQuery(
const std::list<VisualWord *> & words)
const = 0;
372 virtual void updateQuery(
const std::list<Signature *> & signatures,
bool updateTimestamp)
const = 0;
373 virtual void updateQuery(
const std::list<VisualWord *> & words,
bool updateTimestamp)
const = 0;
375 virtual void addLinkQuery(
const Link & link)
const = 0;
376 virtual void updateLinkQuery(
const Link & link)
const = 0;
378 virtual void updateOccupancyGridQuery(
380 const cv::Mat & ground,
381 const cv::Mat & obstacles,
382 const cv::Mat & empty,
384 const cv::Point3f & viewpoint)
const = 0;
386 virtual void updateCalibrationQuery(
388 const std::vector<CameraModel> & models,
389 const std::vector<StereoCameraModel> & stereoModels)
const = 0;
391 virtual void updateDepthImageQuery(
393 const cv::Mat & image,
394 const std::string & format)
const = 0;
396 virtual void updateLaserScanQuery(
400 virtual void addStatisticsQuery(
const Statistics & statistics,
bool saveWmState)
const = 0;
401 virtual void savePreviewImageQuery(
const cv::Mat & image)
const = 0;
402 virtual cv::Mat loadPreviewImageQuery()
const = 0;
403 virtual void saveOptimizedPosesQuery(
const std::map<int, Transform> & optimizedPoses,
const Transform & lastlocalizationPose)
const = 0;
404 virtual std::map<int, Transform> loadOptimizedPosesQuery(
Transform * lastlocalizationPose = 0)
const = 0;
405 virtual void save2DMapQuery(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const = 0;
406 virtual cv::Mat load2DMapQuery(
float & xMin,
float & yMin,
float & cellSize)
const = 0;
407 virtual void saveOptimizedMeshQuery(
408 const cv::Mat & cloud,
409 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
410#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
411 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
413 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
415 const cv::Mat & textures)
const = 0;
416 virtual cv::Mat loadOptimizedMeshQuery(
417 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons,
418#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
419 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
421 std::vector<std::vector<Eigen::Vector2f> > * texCoords,
423 cv::Mat * textures)
const = 0;
424 virtual void saveFlannIndexQuery(
const std::vector<unsigned char> & indexData)
const = 0;
427 virtual void loadQuery(
VWDictionary & dictionary,
bool lastStateOnly =
true,
bool idsOnly =
false)
const = 0;
428 virtual void loadLastNodesQuery(std::list<Signature *> & signatures,
bool loadWordIdsOnly)
const = 0;
429 virtual void loadSignaturesQuery(
const std::list<int> & ids, std::list<Signature *> & signatures,
bool loadWordIdsOnly)
const = 0;
430 virtual void loadWordsQuery(
const std::set<int> & wordIds, std::list<VisualWord *> & vws)
const = 0;
431 virtual void loadLinksQuery(
int signatureId, std::multimap<int, Link> & links,
Link::Type type = Link::kUndef)
const = 0;
433 virtual void loadNodeDataQuery(std::list<Signature *> & signatures,
bool images=
true,
bool scan=
true,
bool userData=
true,
bool occupancyGrid=
true)
const = 0;
434 virtual bool getCalibrationQuery(
int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels)
const = 0;
435 virtual bool getLaserScanInfoQuery(
int signatureId,
LaserScan & info)
const = 0;
436 virtual bool getNodeInfoQuery(
int signatureId,
Transform & pose,
int & mapId,
int & weight, std::string & label,
double & stamp,
Transform & groundTruthPose, std::vector<float> & velocity,
GPS & gps,
EnvSensors & sensors)
const = 0;
437 virtual void getLocalFeaturesQuery(
int signatureId, std::multimap<int, int> & words, std::vector<cv::KeyPoint> & keypoints, std::vector<cv::Point3f> & points, cv::Mat & descriptors)
const = 0;
438 virtual void getLastNodeIdsQuery(std::set<int> & ids)
const = 0;
439 virtual void getAllNodeIdsQuery(std::set<int> & ids,
bool ignoreChildren,
bool ignoreBadSignatures,
bool ignoreIntermediateNodes)
const = 0;
440 virtual void getAllOdomPosesQuery(std::map<int, Transform> & poses,
bool ignoreChildren,
bool ignoreIntermediateNodes)
const = 0;
441 virtual void getAllLinksQuery(std::multimap<int, Link> & links,
bool ignoreNullLinks,
bool withLandmarks)
const = 0;
442 virtual void getLastIdQuery(
const std::string & tableName,
int &
id,
const std::string & fieldName=
"id")
const = 0;
443 virtual void getInvertedIndexNiQuery(
int signatureId,
int & ni)
const = 0;
444 virtual void getNodesObservingLandmarkQuery(
int landmarkId, std::map<int, Link> & nodes)
const = 0;
445 virtual void getNodeIdByLabelQuery(
const std::string & label,
int &
id)
const = 0;
446 virtual void getAllLabelsQuery(std::map<int, std::string> & labels)
const = 0;
451 void beginTransaction()
const;
456 void saveOrUpdate(
const std::vector<Signature *> & signatures);
457 void saveOrUpdate(
const std::vector<VisualWord *> & words)
const;
460 virtual void mainLoop();
464 std::map<int, Signature *> _trashSignatures;
465 std::map<int, VisualWord *> _trashVisualWords;
470 UMutex _dbSafeAccessMutex;
472 double _emptyTrashesTime;
474 std::string _targetVersion;
475 bool _timestampUpdate;