92 const std::string &
getUrl()
const {
return _url;}
105 double getEmptyTrashesTime()
const {
return _emptyTrashesTime;}
106 void setTimestampUpdateEnabled(
bool enabled) {_timestampUpdate = enabled;}
116 const std::string & fileName,
117 const std::set<int> & ids = std::set<int>(),
118 const std::map<int, Signature *> & otherSignatures = std::map<int, Signature *>());
140 const cv::Mat & ground,
141 const cv::Mat & obstacles,
142 const cv::Mat & empty,
144 const cv::Point3f & viewpoint);
148 const std::vector<CameraModel> & models,
149 const std::vector<StereoCameraModel> & stereoModels);
170 void addInfoAfterRun(
int stMemSize,
int lastSignAdded,
int processMemUsed,
int databaseMemUsed,
int dictionarySize,
const ParametersMap & parameters)
const;
190 void save2DMap(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const;
192 cv::Mat
load2DMap(
float & xMin,
float & yMin,
float & cellSize)
const;
201 const cv::Mat & cloud,
202 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons = std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > >(),
203#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
204 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords = std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > >(),
206 const std::vector<std::vector<Eigen::Vector2f> > & texCoords = std::vector<std::vector<Eigen::Vector2f> >(),
208 const cv::Mat & textures = cv::Mat())
const;
209 cv::Mat loadOptimizedMesh(
210 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons = 0,
211#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
212 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords = 0,
214 std::vector<std::vector<Eigen::Vector2f> > * texCoords = 0,
216 cv::Mat * textures = 0)
const;
231 bool openConnection(
const std::string & url,
bool overwritten =
false,
bool readOnly =
false);
236 unsigned long getMemoryUsed()
const;
239 long getNodesMemoryUsed()
const;
240 long getLinksMemoryUsed()
const;
241 long getImagesMemoryUsed()
const;
242 long getDepthImagesMemoryUsed()
const;
243 long getCalibrationsMemoryUsed()
const;
244 long getGridsMemoryUsed()
const;
245 long getLaserScansMemoryUsed()
const;
246 long getUserDataMemoryUsed()
const;
247 long getWordsMemoryUsed()
const;
248 long getFeaturesMemoryUsed()
const;
249 long getStatisticsMemoryUsed()
const;
250 int getLastNodesSize()
const;
251 int getLastDictionarySize()
const;
252 int getTotalNodesSize()
const;
253 int getTotalDictionarySize()
const;
255 std::map<std::string, float> getStatistics(
int nodeId,
double & stamp, std::vector<int> * wmState=0)
const;
256 std::map<int, std::pair<std::map<std::string, float>,
double> > getAllStatistics()
const;
257 std::map<int, std::vector<int> > getAllStatisticsWmStates()
const;
283 void load(
VWDictionary & dictionary,
bool lastStateOnly =
true,
bool idsOnly =
false)
const;
284 void loadLastNodes(std::list<Signature *> & signatures,
bool loadWordIdsOnly =
false)
const;
287 void loadSignatures(
const std::list<int> & ids, std::list<Signature *> & signatures, std::set<int> * loadedFromTrash = 0,
bool loadWordIdsOnly =
false);
288 void loadWords(
const std::set<int> & wordIds, std::list<VisualWord *> & vws);
291 void loadNodeData(
Signature & signature,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
292 void loadNodeData(std::list<Signature *> & signatures,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
293 void getNodeData(
int signatureId,
SensorData & data,
bool images =
true,
bool scan =
true,
bool userData =
true,
bool occupancyGrid =
true)
const;
294 bool getCalibration(
int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels)
const;
295 bool getLaserScanInfo(
int signatureId,
LaserScan & info)
const;
296 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;
297 void getLocalFeatures(
int signatureId, std::multimap<int, int> & words, std::vector<cv::KeyPoint> & keypoints, std::vector<cv::Point3f> & points, cv::Mat & descriptors)
const;
300 void getWeight(
int signatureId,
int & weight)
const;
301 void getLastNodeIds(std::set<int> & ids)
const;
302 void getAllNodeIds(std::set<int> & ids,
bool ignoreChildren =
false,
bool ignoreBadSignatures =
false,
bool ignoreIntermediateNodes =
false)
const;
303 void getAllOdomPoses(std::map<int, Transform> & poses,
bool ignoreChildren =
false,
bool ignoreIntermediateNodes =
false)
const;
304 void getAllLinks(std::multimap<int, Link> & links,
bool ignoreNullLinks =
true,
bool withLandmarks =
false)
const;
305 void getLastNodeId(
int &
id)
const;
306 void getLastMapId(
int & mapId)
const;
307 void getLastWordId(
int &
id)
const;
308 void getInvertedIndexNi(
int signatureId,
int & ni)
const;
309 void getNodesObservingLandmark(
int landmarkId, std::map<int, Link> & nodes)
const;
310 void getNodeIdByLabel(
const std::string & label,
int &
id)
const;
311 void getAllLabels(std::map<int, std::string> & labels)
const;
324 virtual bool connectDatabaseQuery(
const std::string & url,
bool overwritten =
false,
bool readOnly =
false) = 0;
325 virtual void disconnectDatabaseQuery(
bool save =
true,
const std::string & outputUrl =
"") = 0;
326 virtual bool isConnectedQuery()
const = 0;
327 virtual unsigned long getMemoryUsedQuery()
const = 0;
328 virtual bool getDatabaseVersionQuery(std::string & version)
const = 0;
329 virtual long getNodesMemoryUsedQuery()
const = 0;
330 virtual long getLinksMemoryUsedQuery()
const = 0;
331 virtual long getImagesMemoryUsedQuery()
const = 0;
332 virtual long getDepthImagesMemoryUsedQuery()
const = 0;
333 virtual long getCalibrationsMemoryUsedQuery()
const = 0;
334 virtual long getGridsMemoryUsedQuery()
const = 0;
335 virtual long getLaserScansMemoryUsedQuery()
const = 0;
336 virtual long getUserDataMemoryUsedQuery()
const = 0;
337 virtual long getWordsMemoryUsedQuery()
const = 0;
338 virtual long getFeaturesMemoryUsedQuery()
const = 0;
339 virtual long getStatisticsMemoryUsedQuery()
const = 0;
340 virtual int getLastNodesSizeQuery()
const = 0;
341 virtual int getLastDictionarySizeQuery()
const = 0;
342 virtual int getTotalNodesSizeQuery()
const = 0;
343 virtual int getTotalDictionarySizeQuery()
const = 0;
345 virtual std::map<std::string, float> getStatisticsQuery(
int nodeId,
double & stamp, std::vector<int> * wmState)
const = 0;
346 virtual std::map<int, std::pair<std::map<std::string, float>,
double> > getAllStatisticsQuery()
const = 0;
347 virtual std::map<int, std::vector<int> > getAllStatisticsWmStatesQuery()
const = 0;
349 virtual void executeNoResultQuery(
const std::string & sql)
const = 0;
351 virtual void getWeightQuery(
int signatureId,
int & weight)
const = 0;
353 virtual void saveQuery(
const std::list<Signature *> & signatures) = 0;
354 virtual void saveQuery(
const std::list<VisualWord *> & words)
const = 0;
355 virtual void updateQuery(
const std::list<Signature *> & signatures,
bool updateTimestamp)
const = 0;
356 virtual void updateQuery(
const std::list<VisualWord *> & words,
bool updateTimestamp)
const = 0;
358 virtual void addLinkQuery(
const Link & link)
const = 0;
359 virtual void updateLinkQuery(
const Link & link)
const = 0;
361 virtual void updateOccupancyGridQuery(
363 const cv::Mat & ground,
364 const cv::Mat & obstacles,
365 const cv::Mat & empty,
367 const cv::Point3f & viewpoint)
const = 0;
369 virtual void updateCalibrationQuery(
371 const std::vector<CameraModel> & models,
372 const std::vector<StereoCameraModel> & stereoModels)
const = 0;
374 virtual void updateDepthImageQuery(
376 const cv::Mat & image,
377 const std::string & format)
const = 0;
379 virtual void updateLaserScanQuery(
383 virtual void addStatisticsQuery(
const Statistics & statistics,
bool saveWmState)
const = 0;
384 virtual void savePreviewImageQuery(
const cv::Mat & image)
const = 0;
385 virtual cv::Mat loadPreviewImageQuery()
const = 0;
386 virtual void saveOptimizedPosesQuery(
const std::map<int, Transform> & optimizedPoses,
const Transform & lastlocalizationPose)
const = 0;
387 virtual std::map<int, Transform> loadOptimizedPosesQuery(
Transform * lastlocalizationPose = 0)
const = 0;
388 virtual void save2DMapQuery(
const cv::Mat & map,
float xMin,
float yMin,
float cellSize)
const = 0;
389 virtual cv::Mat load2DMapQuery(
float & xMin,
float & yMin,
float & cellSize)
const = 0;
390 virtual void saveOptimizedMeshQuery(
391 const cv::Mat & cloud,
392 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
393#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
394 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
396 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
398 const cv::Mat & textures)
const = 0;
399 virtual cv::Mat loadOptimizedMeshQuery(
400 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons,
401#
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
402 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
404 std::vector<std::vector<Eigen::Vector2f> > * texCoords,
406 cv::Mat * textures)
const = 0;
407 virtual void saveFlannIndexQuery(
const std::vector<unsigned char> & indexData)
const = 0;
410 virtual void loadQuery(
VWDictionary & dictionary,
bool lastStateOnly =
true,
bool idsOnly =
false)
const = 0;
411 virtual void loadLastNodesQuery(std::list<Signature *> & signatures,
bool loadWordIdsOnly)
const = 0;
412 virtual void loadSignaturesQuery(
const std::list<int> & ids, std::list<Signature *> & signatures,
bool loadWordIdsOnly)
const = 0;
413 virtual void loadWordsQuery(
const std::set<int> & wordIds, std::list<VisualWord *> & vws)
const = 0;
414 virtual void loadLinksQuery(
int signatureId, std::multimap<int, Link> & links,
Link::Type type = Link::kUndef)
const = 0;
416 virtual void loadNodeDataQuery(std::list<Signature *> & signatures,
bool images=
true,
bool scan=
true,
bool userData=
true,
bool occupancyGrid=
true)
const = 0;
417 virtual bool getCalibrationQuery(
int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels)
const = 0;
418 virtual bool getLaserScanInfoQuery(
int signatureId,
LaserScan & info)
const = 0;
419 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;
420 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;
421 virtual void getLastNodeIdsQuery(std::set<int> & ids)
const = 0;
422 virtual void getAllNodeIdsQuery(std::set<int> & ids,
bool ignoreChildren,
bool ignoreBadSignatures,
bool ignoreIntermediateNodes)
const = 0;
423 virtual void getAllOdomPosesQuery(std::map<int, Transform> & poses,
bool ignoreChildren,
bool ignoreIntermediateNodes)
const = 0;
424 virtual void getAllLinksQuery(std::multimap<int, Link> & links,
bool ignoreNullLinks,
bool withLandmarks)
const = 0;
425 virtual void getLastIdQuery(
const std::string & tableName,
int &
id,
const std::string & fieldName=
"id")
const = 0;
426 virtual void getInvertedIndexNiQuery(
int signatureId,
int & ni)
const = 0;
427 virtual void getNodesObservingLandmarkQuery(
int landmarkId, std::map<int, Link> & nodes)
const = 0;
428 virtual void getNodeIdByLabelQuery(
const std::string & label,
int &
id)
const = 0;
429 virtual void getAllLabelsQuery(std::map<int, std::string> & labels)
const = 0;
434 void beginTransaction()
const;
439 void saveOrUpdate(
const std::vector<Signature *> & signatures);
440 void saveOrUpdate(
const std::vector<VisualWord *> & words)
const;
443 virtual void mainLoop();
447 std::map<int, Signature *> _trashSignatures;
448 std::map<int, VisualWord *> _trashVisualWords;
450 UMutex _dbSafeAccessMutex;
452 double _emptyTrashesTime;
454 std::string _targetVersion;
455 bool _timestampUpdate;