92 const std::string &
getUrl()
const {
return _url;}
118 double getEmptyTrashesTime()
const {
return _emptyTrashesTime;}
119 void setTimestampUpdateEnabled(
bool enabled) {_timestampUpdate = enabled;}
129 const std::string & fileName,
130 const std::set<int> & ids = std::set<int>(),
131 const std::map<int, Signature *> & otherSignatures = std::map<int, Signature *>());
153 const cv::Mat & ground,
154 const cv::Mat & obstacles,
155 const cv::Mat & empty,
157 const cv::Point3f & viewpoint);
161 const std::vector<CameraModel> & models,
162 const std::vector<StereoCameraModel> & stereoModels);
183 void addInfoAfterRun(
int stMemSize,
int lastSignAdded,
int processMemUsed,
int databaseMemUsed,
int dictionarySize,
const ParametersMap & parameters)
const;
203 void save2DMap(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const;
205 cv::Mat
load2DMap(
float & xMin,
float & yMin,
float & cellSize)
const;
214 const cv::Mat & cloud,
215 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons = std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > >(),
216#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
217 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords = std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > >(),
219 const std::vector<std::vector<Eigen::Vector2f> > & texCoords = std::vector<std::vector<Eigen::Vector2f> >(),
221 const cv::Mat & textures = cv::Mat())
const;
222 cv::Mat loadOptimizedMesh(
223 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons = 0,
224#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
225 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords = 0,
227 std::vector<std::vector<Eigen::Vector2f> > * texCoords = 0,
229 cv::Mat * textures = 0)
const;
244 bool openConnection(
const std::string & url,
bool overwritten =
false,
bool readOnly =
false);
249 unsigned long getMemoryUsed()
const;
252 long getNodesMemoryUsed()
const;
253 long getLinksMemoryUsed()
const;
254 long getImagesMemoryUsed()
const;
255 long getDepthImagesMemoryUsed()
const;
256 long getCalibrationsMemoryUsed()
const;
257 long getGridsMemoryUsed()
const;
258 long getLaserScansMemoryUsed()
const;
259 long getUserDataMemoryUsed()
const;
260 long getWordsMemoryUsed()
const;
261 long getFeaturesMemoryUsed()
const;
262 long getStatisticsMemoryUsed()
const;
263 int getLastNodesSize()
const;
264 int getLastDictionarySize()
const;
265 int getTotalNodesSize()
const;
266 int getTotalDictionarySize()
const;
268 std::map<std::string, float> getStatistics(
int nodeId,
double & stamp, std::vector<int> * wmState=0)
const;
269 std::map<int, std::pair<std::map<std::string, float>,
double> > getAllStatistics()
const;
270 std::map<int, std::vector<int> > getAllStatisticsWmStates()
const;
296 void load(
VWDictionary & dictionary,
bool lastStateOnly =
true,
bool idsOnly =
false)
const;
297 void loadLastNodes(std::list<Signature *> & signatures,
bool loadWordIdsOnly =
false)
const;
300 void loadSignatures(
const std::list<int> & ids, std::list<Signature *> & signatures, std::set<int> * loadedFromTrash = 0,
bool loadWordIdsOnly =
false);
307 void loadWords(
const std::set<int> & wordIds, std::list<VisualWord *> & vws,
bool missingWordsExpected =
false);
310 void loadNodeData(
Signature & signature,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
311 void loadNodeData(std::list<Signature *> & signatures,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
312 void getNodeData(
int signatureId,
SensorData & data,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
313 bool getCalibration(
int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels)
const;
314 bool getLaserScanInfo(
int signatureId,
LaserScan & info)
const;
315 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;
316 void getLocalFeatures(
int signatureId, std::multimap<int, int> & words, std::vector<cv::KeyPoint> & keypoints, std::vector<cv::Point3f> & points, cv::Mat & descriptors)
const;
319 void getWeight(
int signatureId,
int & weight)
const;
320 void getLastNodeIds(std::set<int> & ids)
const;
321 void getAllNodeIds(std::set<int> & ids,
bool ignoreChildren =
false,
bool ignoreBadSignatures =
false,
bool ignoreIntermediateNodes =
false)
const;
322 void getAllOdomPoses(std::map<int, Transform> & poses,
bool ignoreChildren =
false,
bool ignoreIntermediateNodes =
false)
const;
323 void getAllLinks(std::multimap<int, Link> & links,
bool ignoreNullLinks =
true,
bool withLandmarks =
false)
const;
324 void getLastNodeId(
int &
id)
const;
325 void getLastMapId(
int & mapId)
const;
334 void getInvertedIndexNi(
int signatureId,
int & ni)
const;
335 void getNodesObservingLandmark(
int landmarkId, std::map<int, Link> & nodes)
const;
336 void getNodeIdByLabel(
const std::string & label,
int &
id)
const;
337 void getAllLabels(std::map<int, std::string> & labels)
const;
356 virtual bool connectDatabaseQuery(
const std::string & url,
bool overwritten =
false,
bool readOnly =
false) = 0;
357 virtual void disconnectDatabaseQuery(
bool save =
true,
const std::string & outputUrl =
"") = 0;
358 virtual bool isConnectedQuery()
const = 0;
359 virtual unsigned long getMemoryUsedQuery()
const = 0;
360 virtual bool getDatabaseVersionQuery(std::string & version)
const = 0;
361 virtual long getNodesMemoryUsedQuery()
const = 0;
362 virtual long getLinksMemoryUsedQuery()
const = 0;
363 virtual long getImagesMemoryUsedQuery()
const = 0;
364 virtual long getDepthImagesMemoryUsedQuery()
const = 0;
365 virtual long getCalibrationsMemoryUsedQuery()
const = 0;
366 virtual long getGridsMemoryUsedQuery()
const = 0;
367 virtual long getLaserScansMemoryUsedQuery()
const = 0;
368 virtual long getUserDataMemoryUsedQuery()
const = 0;
369 virtual long getWordsMemoryUsedQuery()
const = 0;
370 virtual long getFeaturesMemoryUsedQuery()
const = 0;
371 virtual long getStatisticsMemoryUsedQuery()
const = 0;
372 virtual int getLastNodesSizeQuery()
const = 0;
373 virtual int getLastDictionarySizeQuery()
const = 0;
374 virtual int getTotalNodesSizeQuery()
const = 0;
375 virtual int getTotalDictionarySizeQuery()
const = 0;
377 virtual std::map<std::string, float> getStatisticsQuery(
int nodeId,
double & stamp, std::vector<int> * wmState)
const = 0;
378 virtual std::map<int, std::pair<std::map<std::string, float>,
double> > getAllStatisticsQuery()
const = 0;
379 virtual std::map<int, std::vector<int> > getAllStatisticsWmStatesQuery()
const = 0;
381 virtual void executeNoResultQuery(
const std::string & sql)
const = 0;
383 virtual void getWeightQuery(
int signatureId,
int & weight)
const = 0;
385 virtual void saveQuery(
const std::list<Signature *> & signatures) = 0;
386 virtual void saveQuery(
const std::list<VisualWord *> & words)
const = 0;
387 virtual void updateQuery(
const std::list<Signature *> & signatures,
bool updateTimestamp)
const = 0;
388 virtual void updateQuery(
const std::list<VisualWord *> & words,
bool updateTimestamp)
const = 0;
390 virtual void addLinkQuery(
const Link & link)
const = 0;
391 virtual void updateLinkQuery(
const Link & link)
const = 0;
393 virtual void updateOccupancyGridQuery(
395 const cv::Mat & ground,
396 const cv::Mat & obstacles,
397 const cv::Mat & empty,
399 const cv::Point3f & viewpoint)
const = 0;
401 virtual void updateCalibrationQuery(
403 const std::vector<CameraModel> & models,
404 const std::vector<StereoCameraModel> & stereoModels)
const = 0;
406 virtual void updateDepthImageQuery(
408 const cv::Mat & image,
409 const std::string & format)
const = 0;
411 virtual void updateLaserScanQuery(
415 virtual void addStatisticsQuery(
const Statistics & statistics,
bool saveWmState)
const = 0;
416 virtual void savePreviewImageQuery(
const cv::Mat & image)
const = 0;
417 virtual cv::Mat loadPreviewImageQuery()
const = 0;
418 virtual void saveOptimizedPosesQuery(
const std::map<int, Transform> & optimizedPoses,
const Transform & lastlocalizationPose)
const = 0;
419 virtual std::map<int, Transform> loadOptimizedPosesQuery(
Transform * lastlocalizationPose = 0)
const = 0;
420 virtual void save2DMapQuery(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const = 0;
421 virtual cv::Mat load2DMapQuery(
float & xMin,
float & yMin,
float & cellSize)
const = 0;
422 virtual void saveOptimizedMeshQuery(
423 const cv::Mat & cloud,
424 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
425#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
426 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
428 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
430 const cv::Mat & textures)
const = 0;
431 virtual cv::Mat loadOptimizedMeshQuery(
432 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons,
433#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
434 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
436 std::vector<std::vector<Eigen::Vector2f> > * texCoords,
438 cv::Mat * textures)
const = 0;
439 virtual void saveFlannIndexQuery(
const std::vector<unsigned char> & indexData)
const = 0;
442 virtual void loadQuery(
VWDictionary & dictionary,
bool lastStateOnly =
true,
bool idsOnly =
false)
const = 0;
443 virtual void loadLastNodesQuery(std::list<Signature *> & signatures,
bool loadWordIdsOnly)
const = 0;
444 virtual void loadSignaturesQuery(
const std::list<int> & ids, std::list<Signature *> & signatures,
bool loadWordIdsOnly)
const = 0;
445 virtual void loadWordsQuery(
const std::set<int> & wordIds, std::list<VisualWord *> & vws,
bool missingWordsExpected)
const = 0;
446 virtual void loadLinksQuery(
int signatureId, std::multimap<int, Link> & links,
Link::Type type = Link::kUndef)
const = 0;
448 virtual void loadNodeDataQuery(std::list<Signature *> & signatures,
bool images=
true,
bool scan=
true,
bool userData=
true,
bool occupancyGrid=
true)
const = 0;
449 virtual bool getCalibrationQuery(
int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels)
const = 0;
450 virtual bool getLaserScanInfoQuery(
int signatureId,
LaserScan & info)
const = 0;
451 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;
452 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;
453 virtual void getLastNodeIdsQuery(std::set<int> & ids)
const = 0;
454 virtual void getAllNodeIdsQuery(std::set<int> & ids,
bool ignoreChildren,
bool ignoreBadSignatures,
bool ignoreIntermediateNodes)
const = 0;
455 virtual void getAllOdomPosesQuery(std::map<int, Transform> & poses,
bool ignoreChildren,
bool ignoreIntermediateNodes)
const = 0;
456 virtual void getAllLinksQuery(std::multimap<int, Link> & links,
bool ignoreNullLinks,
bool withLandmarks)
const = 0;
457 virtual void getLastIdQuery(
const std::string & tableName,
int &
id,
const std::string & fieldName=
"id")
const = 0;
458 virtual void getInvertedIndexNiQuery(
int signatureId,
int & ni)
const = 0;
459 virtual void getNodesObservingLandmarkQuery(
int landmarkId, std::map<int, Link> & nodes)
const = 0;
460 virtual void getNodeIdByLabelQuery(
const std::string & label,
int &
id)
const = 0;
461 virtual void getAllLabelsQuery(std::map<int, std::string> & labels)
const = 0;
466 void beginTransaction()
const;
471 void saveOrUpdate(
const std::vector<Signature *> & signatures);
472 void saveOrUpdate(
const std::vector<VisualWord *> & words)
const;
475 virtual void mainLoop();
479 std::map<int, Signature *> _trashSignatures;
480 std::map<int, VisualWord *> _trashVisualWords;
485 UMutex _dbSafeAccessMutex;
487 double _emptyTrashesTime;
489 std::string _targetVersion;
490 int _descriptorQuantization;
491 bool _timestampUpdate;