DBDriver.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #include "rtabmap/core/DBDriver.h"
29 
30 #include "rtabmap/core/Signature.h"
34 #include "rtabmap/utilite/UMath.h"
36 #include "rtabmap/utilite/UTimer.h"
37 #include "rtabmap/utilite/UStl.h"
38 
39 namespace rtabmap {
40 
42 {
43  return new DBDriverSqlite3(parameters);
44 }
45 
46 DBDriver::DBDriver(const ParametersMap & parameters) :
47  _emptyTrashesTime(0),
48  _timestampUpdate(true)
49 {
50  this->parseParameters(parameters);
51 }
52 
54 {
55  join(true);
56  this->emptyTrashes();
57 }
58 
59 void DBDriver::parseParameters(const ParametersMap & parameters)
60 {
61  Parameters::parse(parameters, Parameters::kDbTargetVersion(), _targetVersion);
62 }
63 
64 void DBDriver::closeConnection(bool save, const std::string & outputUrl)
65 {
66  UDEBUG("isRunning=%d", this->isRunning());
67  this->join(true);
68  UDEBUG("");
69  if(save)
70  {
71  this->emptyTrashes();
72  }
73  else
74  {
76  _trashSignatures.clear();
77  _trashVisualWords.clear();
79  }
81  this->disconnectDatabaseQuery(save, outputUrl);
83  UDEBUG("");
84 }
85 
86 bool DBDriver::openConnection(const std::string & url, bool overwritten)
87 {
88  UDEBUG("");
89  _url = url;
91  if(this->connectDatabaseQuery(url, overwritten))
92  {
94  return true;
95  }
97  return false;
98 }
99 
101 {
102  bool r;
104  r = isConnectedQuery();
106  return r;
107 }
108 
109 // In bytes
110 unsigned long DBDriver::getMemoryUsed() const
111 {
112  unsigned long bytes;
116  return bytes;
117 }
118 
120 {
121  long bytes;
125  return bytes;
126 }
128 {
129  long bytes;
133  return bytes;
134 }
136 {
137  long bytes;
141  return bytes;
142 }
144 {
145  long bytes;
149  return bytes;
150 }
152 {
153  long bytes;
157  return bytes;
158 }
160 {
161  long bytes;
165  return bytes;
166 }
168 {
169  long bytes;
173  return bytes;
174 }
176 {
177  long bytes;
181  return bytes;
182 }
184 {
185  long bytes;
189  return bytes;
190 }
192 {
193  long bytes;
197  return bytes;
198 }
200 {
201  long bytes;
205  return bytes;
206 }
208 {
209  int nodes;
213  return nodes;
214 }
216 {
217  int words;
219  words = getLastDictionarySizeQuery();
221  return words;
222 }
224 {
225  int words;
227  words = getTotalNodesSizeQuery();
229  return words;
230 }
232 {
233  int words;
235  words = getTotalDictionarySizeQuery();
237  return words;
238 }
240 {
241  ParametersMap parameters;
243  parameters = getLastParametersQuery();
245  return parameters;
246 }
247 
248 std::map<std::string, float> DBDriver::getStatistics(int nodeId, double & stamp, std::vector<int> * wmState) const
249 {
250  std::map<std::string, float> statistics;
252  statistics = getStatisticsQuery(nodeId, stamp, wmState);
254  return statistics;
255 }
256 
257 std::map<int, std::pair<std::map<std::string, float>, double> > DBDriver::getAllStatistics() const
258 {
259  std::map<int, std::pair<std::map<std::string, float>, double> > statistics;
261  statistics = getAllStatisticsQuery();
263  return statistics;
264 }
265 
266 std::map<int, std::vector<int> > DBDriver::getAllStatisticsWmStates() const
267 {
268  std::map<int, std::vector<int> > wmStates;
270  wmStates = getAllStatisticsWmStatesQuery();
272  return wmStates;
273 }
274 
275 std::string DBDriver::getDatabaseVersion() const
276 {
277  std::string version = "0.0.0";
281  return version;
282 }
283 
285 {
286  this->emptyTrashes();
287  this->kill(); // Do it only once
288 }
289 
291 {
293  ULOGGER_DEBUG("");
294  this->executeNoResultQuery("BEGIN TRANSACTION;");
295 }
296 
297 void DBDriver::commit() const
298 {
299  ULOGGER_DEBUG("");
300  this->executeNoResultQuery("COMMIT;");
302 }
303 
304 void DBDriver::executeNoResult(const std::string & sql) const
305 {
307  this->executeNoResultQuery(sql);
309 }
310 
311 void DBDriver::emptyTrashes(bool async)
312 {
313  if(async)
314  {
315  ULOGGER_DEBUG("Async emptying, start the trash thread");
316  this->start();
317  return;
318  }
319 
320  UTimer totalTime;
321  totalTime.start();
322 
323  std::map<int, Signature*> signatures;
324  std::map<int, VisualWord*> visualWords;
326  {
327  ULOGGER_DEBUG("signatures=%d, visualWords=%d", _trashSignatures.size(), _trashVisualWords.size());
328  signatures = _trashSignatures;
329  visualWords = _trashVisualWords;
330  _trashSignatures.clear();
331  _trashVisualWords.clear();
332 
334  }
336 
337  if(signatures.size() || visualWords.size())
338  {
339  this->beginTransaction();
340  UTimer timer;
341  timer.start();
342  if(signatures.size())
343  {
344  if(this->isConnected())
345  {
346  //Only one query to the database
347  this->saveOrUpdate(uValues(signatures));
348  }
349 
350  for(std::map<int, Signature *>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter)
351  {
352  delete iter->second;
353  }
354  signatures.clear();
355  ULOGGER_DEBUG("Time emptying memory signatures trash = %f...", timer.ticks());
356  }
357  if(visualWords.size())
358  {
359  if(this->isConnected())
360  {
361  //Only one query to the database
362  this->saveOrUpdate(uValues(visualWords));
363  }
364 
365  for(std::map<int, VisualWord *>::iterator iter=visualWords.begin(); iter!=visualWords.end(); ++iter)
366  {
367  delete (*iter).second;
368  }
369  visualWords.clear();
370  ULOGGER_DEBUG("Time emptying memory visualWords trash = %f...", timer.ticks());
371  }
372 
373  this->commit();
374  }
375 
376  _emptyTrashesTime = totalTime.ticks();
377  ULOGGER_DEBUG("Total time emptying trashes = %fs...", _emptyTrashesTime);
378 
380 }
381 
383 {
384  if(s)
385  {
386  UDEBUG("s=%d", s->id());
388  {
389  _trashSignatures.insert(std::pair<int, Signature*>(s->id(), s));
390  }
392  }
393 }
394 
396 {
397  if(vw)
398  {
400  {
401  _trashVisualWords.insert(std::pair<int, VisualWord*>(vw->id(), vw));
402  }
404  }
405 }
406 
407 void DBDriver::saveOrUpdate(const std::vector<Signature *> & signatures)
408 {
409  ULOGGER_DEBUG("");
410  std::list<Signature *> toSave;
411  std::list<Signature *> toUpdate;
412  if(this->isConnected() && signatures.size())
413  {
414  for(std::vector<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end();++i)
415  {
416  if((*i)->isSaved())
417  {
418  toUpdate.push_back(*i);
419  }
420  else
421  {
422  toSave.push_back(*i);
423  }
424  }
425 
426  if(toUpdate.size())
427  {
428  this->updateQuery(toUpdate, _timestampUpdate);
429  }
430  if(toSave.size())
431  {
432  this->saveQuery(toSave);
433  }
434  }
435 }
436 
437 void DBDriver::saveOrUpdate(const std::vector<VisualWord *> & words) const
438 {
439  ULOGGER_DEBUG("words.size=%d", (int)words.size());
440  std::list<VisualWord *> toSave;
441  std::list<VisualWord *> toUpdate;
442  if(this->isConnected() && words.size())
443  {
444  for(std::vector<VisualWord *>::const_iterator i=words.begin(); i!=words.end();++i)
445  {
446  if((*i)->isSaved())
447  {
448  toUpdate.push_back(*i);
449  }
450  else
451  {
452  toSave.push_back(*i);
453  }
454  }
455 
456  if(toUpdate.size())
457  {
458  this->updateQuery(toUpdate, _timestampUpdate);
459  }
460  if(toSave.size())
461  {
462  this->saveQuery(toSave);
463  }
464  }
465 }
466 
467 void DBDriver::addLink(const Link & link)
468 {
470  this->addLinkQuery(link);
472 }
473 void DBDriver::removeLink(int from, int to)
474 {
475  this->executeNoResult(uFormat("DELETE FROM Link WHERE from_id=%d and to_id=%d", from, to).c_str());
476 }
477 void DBDriver::updateLink(const Link & link)
478 {
480  this->updateLinkQuery(link);
482 }
484  int nodeId,
485  const cv::Mat & ground,
486  const cv::Mat & obstacles,
487  const cv::Mat & empty,
488  float cellSize,
489  const cv::Point3f & viewpoint)
490 {
492  //just to make sure the occupancy grids are compressed for convenience
494  data.setOccupancyGrid(ground, obstacles, empty, cellSize, viewpoint);
496  nodeId,
497  data.gridGroundCellsCompressed(),
498  data.gridObstacleCellsCompressed(),
499  data.gridEmptyCellsCompressed(),
500  cellSize,
501  viewpoint);
503 }
504 
505 void DBDriver::updateCalibration(int nodeId, const std::vector<CameraModel> & models, const std::vector<StereoCameraModel> & stereoModels)
506 {
509  nodeId,
510  models,
511  stereoModels);
513 }
514 
515 void DBDriver::updateDepthImage(int nodeId, const cv::Mat & image)
516 {
518  this->updateDepthImageQuery(
519  nodeId,
520  image);
522 }
523 
524 void DBDriver::updateLaserScan(int nodeId, const LaserScan & scan)
525 {
527  this->updateLaserScanQuery(
528  nodeId,
529  scan);
531 }
532 
533 void DBDriver::load(VWDictionary * dictionary, bool lastStateOnly) const
534 {
536  this->loadQuery(dictionary, lastStateOnly);
538 }
539 
540 void DBDriver::loadLastNodes(std::list<Signature *> & signatures) const
541 {
543  this->loadLastNodesQuery(signatures);
545 }
546 
547 Signature * DBDriver::loadSignature(int id, bool * loadedFromTrash)
548 {
549  std::list<int> ids;
550  ids.push_back(id);
551  std::list<Signature*> signatures;
552  std::set<int> loadedFromTrashSet;
553  loadSignatures(ids, signatures, &loadedFromTrashSet);
554  if(loadedFromTrash && loadedFromTrashSet.size())
555  {
556  *loadedFromTrash = true;
557  }
558  if(!signatures.empty())
559  {
560  return signatures.front();
561  }
562  return 0;
563 }
564 void DBDriver::loadSignatures(const std::list<int> & signIds,
565  std::list<Signature *> & signatures,
566  std::set<int> * loadedFromTrash)
567 {
568  UDEBUG("");
569  // look up in the trash before the database
570  std::list<int> ids = signIds;
571  bool valueFound = false;
573  {
574  for(std::list<int>::iterator iter = ids.begin(); iter != ids.end();)
575  {
576  valueFound = false;
577  for(std::map<int, Signature*>::iterator sIter = _trashSignatures.begin(); sIter!=_trashSignatures.end();)
578  {
579  if(sIter->first == *iter)
580  {
581  signatures.push_back(sIter->second);
582  _trashSignatures.erase(sIter++);
583 
584  valueFound = true;
585  break;
586  }
587  else
588  {
589  ++sIter;
590  }
591  }
592  if(valueFound)
593  {
594  if(loadedFromTrash)
595  {
596  loadedFromTrash->insert(*iter);
597  }
598  iter = ids.erase(iter);
599  }
600  else
601  {
602  ++iter;
603  }
604  }
605  }
607  UDEBUG("");
608  if(ids.size())
609  {
611  this->loadSignaturesQuery(ids, signatures);
613  }
614 }
615 
616 void DBDriver::loadWords(const std::set<int> & wordIds, std::list<VisualWord *> & vws)
617 {
618  // look up in the trash before the database
619  std::set<int> ids = wordIds;
620  std::map<int, VisualWord*>::iterator wIter;
621  std::list<VisualWord *> puttedBack;
623  {
624  if(_trashVisualWords.size())
625  {
626  for(std::set<int>::iterator iter = ids.begin(); iter != ids.end();)
627  {
628  UASSERT(*iter>0);
629  wIter = _trashVisualWords.find(*iter);
630  if(wIter != _trashVisualWords.end())
631  {
632  UDEBUG("put back word %d from trash", *iter);
633  puttedBack.push_back(wIter->second);
634  _trashVisualWords.erase(wIter);
635  ids.erase(iter++);
636  }
637  else
638  {
639  ++iter;
640  }
641  }
642  }
643  }
645  if(ids.size())
646  {
648  this->loadWordsQuery(ids, vws);
650  uAppend(vws, puttedBack);
651  }
652  else if(puttedBack.size())
653  {
654  uAppend(vws, puttedBack);
655  }
656 }
657 
658 void DBDriver::loadNodeData(Signature * signature, bool images, bool scan, bool userData, bool occupancyGrid) const
659 {
660  std::list<Signature *> signatures;
661  signatures.push_back(signature);
662  this->loadNodeData(signatures, images, scan, userData, occupancyGrid);
663 }
664 
665 void DBDriver::loadNodeData(std::list<Signature *> & signatures, bool images, bool scan, bool userData, bool occupancyGrid) const
666 {
667  // Don't look in the trash, we assume that if we want to load
668  // data of a signature, it is not in thrash! Print an error if so.
670  if(_trashSignatures.size())
671  {
672  for(std::list<Signature *>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter)
673  {
674  UASSERT(*iter != 0);
675  UASSERT_MSG(!uContains(_trashSignatures, (*iter)->id()), uFormat("Signature %d should not be used when transferred to trash!!!!", (*iter)->id()).c_str());
676  }
677  }
679 
681  this->loadNodeDataQuery(signatures, images, scan, userData, occupancyGrid);
683 }
684 
686  int signatureId,
687  SensorData & data,
688  bool images, bool scan, bool userData, bool occupancyGrid) const
689 {
690  bool found = false;
691  // look in the trash
693  if(uContains(_trashSignatures, signatureId))
694  {
695  const Signature * s = _trashSignatures.at(signatureId);
696  if((!s->isSaved() ||
697  ((!images || !s->sensorData().imageCompressed().empty()) &&
698  (!scan || !s->sensorData().laserScanCompressed().isEmpty()) &&
699  (!userData || !s->sensorData().userDataCompressed().empty()) &&
700  (!occupancyGrid || s->sensorData().gridCellSize() != 0.0f))))
701  {
702  data = (SensorData)s->sensorData();
703  if(!images)
704  {
705  data.setRGBDImage(cv::Mat(), cv::Mat(), std::vector<CameraModel>());
706  }
707  if(!scan)
708  {
709  data.setLaserScan(LaserScan());
710  }
711  if(!userData)
712  {
713  data.setUserData(cv::Mat());
714  }
715  if(!occupancyGrid)
716  {
717  data.setOccupancyGrid(cv::Mat(), cv::Mat(), cv::Mat(), 0, cv::Point3f());
718  }
719  found = true;
720  }
721  }
723 
724  if(!found)
725  {
727  std::list<Signature *> signatures;
728  Signature tmp(signatureId);
729  signatures.push_back(&tmp);
730  loadNodeDataQuery(signatures, images, scan, userData, occupancyGrid);
731  data = signatures.front()->sensorData();
733  }
734 }
735 
737  int signatureId,
738  std::vector<CameraModel> & models,
739  std::vector<StereoCameraModel> & stereoModels) const
740 {
741  UDEBUG("");
742  bool found = false;
743  // look in the trash
745  if(uContains(_trashSignatures, signatureId))
746  {
747  models = _trashSignatures.at(signatureId)->sensorData().cameraModels();
748  stereoModels = _trashSignatures.at(signatureId)->sensorData().stereoCameraModels();
749  found = true;
750  }
752 
753  if(!found)
754  {
756  found = this->getCalibrationQuery(signatureId, models, stereoModels);
758  }
759  return found;
760 }
761 
763  int signatureId,
764  LaserScan & info) const
765 {
766  UDEBUG("");
767  bool found = false;
768  // look in the trash
770  if(uContains(_trashSignatures, signatureId))
771  {
772  info = _trashSignatures.at(signatureId)->sensorData().laserScanCompressed();
773  found = true;
774  }
776 
777  if(!found)
778  {
780  found = this->getLaserScanInfoQuery(signatureId, info);
782  }
783  return found;
784 }
785 
787  int signatureId,
788  Transform & pose,
789  int & mapId,
790  int & weight,
791  std::string & label,
792  double & stamp,
793  Transform & groundTruthPose,
794  std::vector<float> & velocity,
795  GPS & gps,
796  EnvSensors & sensors) const
797 {
798  bool found = false;
799  // look in the trash
801  if(uContains(_trashSignatures, signatureId))
802  {
803  pose = _trashSignatures.at(signatureId)->getPose().clone();
804  mapId = _trashSignatures.at(signatureId)->mapId();
805  weight = _trashSignatures.at(signatureId)->getWeight();
806  label = std::string(_trashSignatures.at(signatureId)->getLabel());
807  stamp = _trashSignatures.at(signatureId)->getStamp();
808  groundTruthPose = _trashSignatures.at(signatureId)->getGroundTruthPose().clone();
809  velocity = std::vector<float>(_trashSignatures.at(signatureId)->getVelocity());
810  gps = GPS(_trashSignatures.at(signatureId)->sensorData().gps());
811  sensors = EnvSensors(_trashSignatures.at(signatureId)->sensorData().envSensors());
812  found = true;
813  }
815 
816  if(!found)
817  {
819  found = this->getNodeInfoQuery(signatureId, pose, mapId, weight, label, stamp, groundTruthPose, velocity, gps, sensors);
821  }
822  return found;
823 }
824 
825 void DBDriver::loadLinks(int signatureId, std::multimap<int, Link> & links, Link::Type type) const
826 {
827  bool found = false;
828  // look in the trash
830  if(uContains(_trashSignatures, signatureId))
831  {
832  const Signature * s = _trashSignatures.at(signatureId);
833  UASSERT(s != 0);
834  for(std::map<int, Link>::const_iterator nIter = s->getLinks().begin();
835  nIter!=s->getLinks().end();
836  ++nIter)
837  {
838  if(type == Link::kAllWithoutLandmarks || type == Link::kAllWithLandmarks || nIter->second.type() == type)
839  {
840  links.insert(*nIter);
841  }
842  }
844  {
845  links.insert(s->getLandmarks().begin(), s->getLandmarks().end());
846  }
847  found = true;
848  }
850 
851  if(!found)
852  {
854  this->loadLinksQuery(signatureId, links, type);
856  }
857 }
858 
859 void DBDriver::getWeight(int signatureId, int & weight) const
860 {
861  bool found = false;
862  // look in the trash
864  if(uContains(_trashSignatures, signatureId))
865  {
866  weight = _trashSignatures.at(signatureId)->getWeight();
867  found = true;
868  }
870 
871  if(!found)
872  {
874  this->getWeightQuery(signatureId, weight);
876  }
877 }
878 
879 void DBDriver::getLastNodeIds(std::set<int> & ids) const
880 {
882  this->getLastNodeIdsQuery(ids);
884 }
885 
886 void DBDriver::getAllNodeIds(std::set<int> & ids, bool ignoreChildren, bool ignoreBadSignatures, bool ignoreIntermediateNodes) const
887 {
888  // look in the trash
890  if(_trashSignatures.size())
891  {
892  for(std::map<int, Signature*>::const_iterator sIter = _trashSignatures.begin(); sIter!=_trashSignatures.end(); ++sIter)
893  {
894  bool hasNeighbors = !ignoreChildren;
895  if(ignoreChildren)
896  {
897  for(std::map<int, Link>::const_iterator nIter = sIter->second->getLinks().begin();
898  nIter!=sIter->second->getLinks().end();
899  ++nIter)
900  {
901  if(nIter->second.type() == Link::kNeighbor ||
902  nIter->second.type() == Link::kNeighborMerged)
903  {
904  hasNeighbors = true;
905  break;
906  }
907  }
908  }
909  if(hasNeighbors && (!ignoreIntermediateNodes || sIter->second->getWeight() != -1))
910  {
911  ids.insert(sIter->first);
912  }
913  }
914 
915  std::vector<int> keys = uKeys(_trashSignatures);
916 
917  }
919 
921  this->getAllNodeIdsQuery(ids, ignoreChildren, ignoreBadSignatures, ignoreIntermediateNodes);
923 }
924 
925 void DBDriver::getAllLinks(std::multimap<int, Link> & links, bool ignoreNullLinks, bool withLandmarks) const
926 {
928  this->getAllLinksQuery(links, ignoreNullLinks, withLandmarks);
930 
931  // look in the trash
933  if(_trashSignatures.size())
934  {
935  for(std::map<int, Signature*>::const_iterator iter=_trashSignatures.begin(); iter!=_trashSignatures.end(); ++iter)
936  {
937  links.erase(iter->first);
938  for(std::map<int, Link>::const_iterator jter=iter->second->getLinks().begin();
939  jter!=iter->second->getLinks().end();
940  ++jter)
941  {
942  if(!ignoreNullLinks || jter->second.isValid())
943  {
944  links.insert(std::make_pair(iter->first, jter->second));
945  }
946  }
947  if(withLandmarks)
948  {
949  for(std::map<int, Link>::const_iterator jter=iter->second->getLandmarks().begin();
950  jter!=iter->second->getLandmarks().end();
951  ++jter)
952  {
953  if(!ignoreNullLinks || jter->second.isValid())
954  {
955  links.insert(std::make_pair(iter->first, jter->second));
956  }
957  }
958  }
959  }
960  }
962 }
963 
964 void DBDriver::getLastNodeId(int & id) const
965 {
966  // look in the trash
968  if(_trashSignatures.size())
969  {
970  id = _trashSignatures.rbegin()->first;
971  }
973 
975  this->getLastIdQuery("Node", id);
976  int statisticsId = 0;
977  if(uStrNumCmp(this->getDatabaseVersion(), "0.11.11") >= 0)
978  {
979  this->getLastIdQuery("Statistics", statisticsId);
980  if(statisticsId > id)
981  {
982  id = statisticsId;
983  }
984  }
986 }
987 
988 void DBDriver::getLastMapId(int & mapId) const
989 {
990  // look in the trash
992  if(_trashSignatures.size())
993  {
994  mapId = _trashSignatures.rbegin()->second->mapId();
995  }
997 
999  this->getLastIdQuery("Node", mapId, "map_id");
1001 }
1002 
1003 void DBDriver::getLastWordId(int & id) const
1004 {
1005  // look in the trash
1006  _trashesMutex.lock();
1007  if(_trashVisualWords.size())
1008  {
1009  id = _trashVisualWords.rbegin()->first;
1010  }
1012 
1014  this->getLastIdQuery("Word", id);
1016 }
1017 
1018 void DBDriver::getInvertedIndexNi(int signatureId, int & ni) const
1019 {
1020  bool found = false;
1021  // look in the trash
1022  _trashesMutex.lock();
1023  if(uContains(_trashSignatures, signatureId))
1024  {
1025  ni = _trashSignatures.at(signatureId)->getWords().size();
1026  found = true;
1027  }
1029 
1030  if(!found)
1031  {
1033  this->getInvertedIndexNiQuery(signatureId, ni);
1035  }
1036 }
1037 
1038 void DBDriver::getNodesObservingLandmark(int landmarkId, std::map<int, Link> & nodes) const
1039 {
1040  if(landmarkId < 0)
1041  {
1042  // look in the trash
1043  _trashesMutex.lock();
1044  for(std::map<int, Signature*>::const_iterator sIter = _trashSignatures.begin(); sIter!=_trashSignatures.end(); ++sIter)
1045  {
1046  std::map<int, Link>::const_iterator kter = sIter->second->getLandmarks().find(landmarkId);
1047  if(kter != sIter->second->getLandmarks().end())
1048  {
1049  nodes.insert(std::make_pair(sIter->second->id(), kter->second));
1050  }
1051  }
1053 
1054  // then look in the database
1056  this->getNodesObservingLandmarkQuery(landmarkId, nodes);
1058  }
1059  else
1060  {
1061  UWARN("Can't search with an empty label!");
1062  }
1063 }
1064 
1065 void DBDriver::getNodeIdByLabel(const std::string & label, int & id) const
1066 {
1067  if(!label.empty())
1068  {
1069  int idFound = 0;
1070  // look in the trash
1071  _trashesMutex.lock();
1072  for(std::map<int, Signature*>::const_iterator sIter = _trashSignatures.begin(); sIter!=_trashSignatures.end(); ++sIter)
1073  {
1074  if(sIter->second->getLabel().compare(label) == 0)
1075  {
1076  idFound = sIter->first;
1077  break;
1078  }
1079  }
1081 
1082  // then look in the database
1083  if(idFound == 0)
1084  {
1086  this->getNodeIdByLabelQuery(label, id);
1088  }
1089  else
1090  {
1091  id = idFound;
1092  }
1093  }
1094  else
1095  {
1096  UWARN("Can't search with an empty label!");
1097  }
1098 }
1099 
1100 void DBDriver::getAllLabels(std::map<int, std::string> & labels) const
1101 {
1102  // look in the trash
1103  _trashesMutex.lock();
1104  for(std::map<int, Signature*>::const_iterator sIter = _trashSignatures.begin(); sIter!=_trashSignatures.end(); ++sIter)
1105  {
1106  if(!sIter->second->getLabel().empty())
1107  {
1108  labels.insert(std::make_pair(sIter->first, sIter->second->getLabel()));
1109  }
1110  }
1112 
1113  // then look in the database
1115  this->getAllLabelsQuery(labels);
1117 }
1118 
1120  int stMemSize,
1121  int lastSignAdded,
1122  int processMemUsed,
1123  int databaseMemUsed,
1124  int dictionarySize,
1125  const ParametersMap & parameters) const
1126 {
1127  ULOGGER_DEBUG("");
1128  if(this->isConnected())
1129  {
1130  std::stringstream query;
1131  if(uStrNumCmp(this->getDatabaseVersion(), "0.11.8") >= 0)
1132  {
1133  std::string param = Parameters::serialize(parameters);
1134  if(uStrNumCmp(this->getDatabaseVersion(), "0.11.11") >= 0)
1135  {
1136  query << "INSERT INTO Info(STM_size,last_sign_added,process_mem_used,database_mem_used,dictionary_size,parameters) values("
1137  << stMemSize << ","
1138  << lastSignAdded << ","
1139  << processMemUsed << ","
1140  << databaseMemUsed << ","
1141  << dictionarySize << ","
1142  "\"" << param.c_str() << "\");";
1143  }
1144  else
1145  {
1146  query << "INSERT INTO Statistics(STM_size,last_sign_added,process_mem_used,database_mem_used,dictionary_size,parameters) values("
1147  << stMemSize << ","
1148  << lastSignAdded << ","
1149  << processMemUsed << ","
1150  << databaseMemUsed << ","
1151  << dictionarySize << ","
1152  "\"" << param.c_str() << "\");";
1153  }
1154  }
1155  else
1156  {
1157  query << "INSERT INTO Statistics(STM_size,last_sign_added,process_mem_used,database_mem_used,dictionary_size) values("
1158  << stMemSize << ","
1159  << lastSignAdded << ","
1160  << processMemUsed << ","
1161  << databaseMemUsed << ","
1162  << dictionarySize << ");";
1163  }
1164 
1165  this->executeNoResultQuery(query.str());
1166  }
1167 }
1168 
1169 void DBDriver::addStatistics(const Statistics & statistics, bool saveWmState) const
1170 {
1172  addStatisticsQuery(statistics, saveWmState);
1174 }
1175 
1176 void DBDriver::savePreviewImage(const cv::Mat & image) const
1177 {
1179  savePreviewImageQuery(image);
1181 }
1182 
1184 {
1186  cv::Mat image = loadPreviewImageQuery();
1188  return image;
1189 }
1190 
1191 void DBDriver::saveOptimizedPoses(const std::map<int, Transform> & optimizedPoses, const Transform & lastlocalizationPose) const
1192 {
1194  saveOptimizedPosesQuery(optimizedPoses, lastlocalizationPose);
1196 }
1197 std::map<int, Transform> DBDriver::loadOptimizedPoses(Transform * lastlocalizationPose) const
1198 {
1200  std::map<int, Transform> poses = loadOptimizedPosesQuery(lastlocalizationPose);
1202  return poses;
1203 }
1204 
1205 void DBDriver::save2DMap(const cv::Mat & map, float xMin, float yMin, float cellSize) const
1206 {
1208  save2DMapQuery(map, xMin, yMin, cellSize);
1210 }
1211 
1212 cv::Mat DBDriver::load2DMap(float & xMin, float & yMin, float & cellSize) const
1213 {
1215  cv::Mat map = load2DMapQuery(xMin, yMin, cellSize);
1217  return map;
1218 }
1219 
1221  const cv::Mat & cloud,
1222  const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
1223 #if PCL_VERSION_COMPARE(>=, 1, 8, 0)
1224  const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
1225 #else
1226  const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
1227 #endif
1228  const cv::Mat & textures) const
1229 {
1231  saveOptimizedMeshQuery(cloud, polygons, texCoords, textures);
1233 }
1234 
1236  std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons,
1237 #if PCL_VERSION_COMPARE(>=, 1, 8, 0)
1238  std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
1239 #else
1240  std::vector<std::vector<Eigen::Vector2f> > * texCoords,
1241 #endif
1242  cv::Mat * textures) const
1243 {
1245  cv::Mat cloud = loadOptimizedMeshQuery(polygons, texCoords, textures);
1247  return cloud;
1248 }
1249 
1251  const std::string & fileName,
1252  const std::set<int> & idsInput,
1253  const std::map<int, Signature *> & otherSignatures)
1254 {
1255  if(this->isConnected())
1256  {
1257  if(!fileName.empty())
1258  {
1259  FILE* fout = 0;
1260  #ifdef _MSC_VER
1261  fopen_s(&fout, fileName.c_str(), "w");
1262  #else
1263  fout = fopen(fileName.c_str(), "w");
1264  #endif
1265 
1266  if (!fout)
1267  {
1268  UERROR("Cannot open file %s!", fileName.c_str());
1269  return;
1270  }
1271 
1272  std::set<int> ids;
1273  if(idsInput.size() == 0)
1274  {
1275  this->getAllNodeIds(ids);
1276  UDEBUG("ids.size()=%d", ids.size());
1277  for(std::map<int, Signature*>::const_iterator iter=otherSignatures.begin(); iter!=otherSignatures.end(); ++iter)
1278  {
1279  ids.insert(iter->first);
1280  }
1281  }
1282  else
1283  {
1284  ids = idsInput;
1285  }
1286 
1287  const char * colorG = "green";
1288  const char * colorP = "pink";
1289  const char * colorNM = "blue";
1290  UINFO("Generating map with %d locations", ids.size());
1291  fprintf(fout, "digraph G {\n");
1292  for(std::set<int>::iterator i=ids.begin(); i!=ids.end(); ++i)
1293  {
1294  if(otherSignatures.find(*i) == otherSignatures.end())
1295  {
1296  int id = *i;
1297  std::multimap<int, Link> links;
1298  this->loadLinks(id, links);
1299  int weight = 0;
1300  this->getWeight(id, weight);
1301  for(std::multimap<int, Link>::iterator iter = links.begin(); iter!=links.end(); ++iter)
1302  {
1303  int weightNeighbor = 0;
1304  if(otherSignatures.find(iter->first) == otherSignatures.end())
1305  {
1306  this->getWeight(iter->first, weightNeighbor);
1307  }
1308  else
1309  {
1310  weightNeighbor = otherSignatures.find(iter->first)->second->getWeight();
1311  }
1312  //UDEBUG("Add neighbor link from %d to %d", id, iter->first);
1313  if(iter->second.type() == Link::kNeighbor)
1314  {
1315  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\"\n",
1316  id,
1317  weight,
1318  iter->first,
1319  weightNeighbor);
1320  }
1321  else if(iter->second.type() == Link::kNeighborMerged)
1322  {
1323  //merged neighbor
1324  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\" [label=\"M\", fontcolor=%s, fontsize=8];\n",
1325  id,
1326  weight,
1327  iter->first,
1328  weightNeighbor,
1329  colorNM);
1330  }
1331  else if(iter->first > id)
1332  {
1333  //loop
1334  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\" [label=\"L\", fontcolor=%s, fontsize=8];\n",
1335  id,
1336  weight,
1337  iter->first,
1338  weightNeighbor,
1339  colorG);
1340  }
1341  else
1342  {
1343  //child
1344  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\" [label=\"C\", fontcolor=%s, fontsize=8];\n",
1345  id,
1346  weight,
1347  iter->first,
1348  weightNeighbor,
1349  colorP);
1350  }
1351  }
1352  }
1353  }
1354  for(std::map<int, Signature*>::const_iterator i=otherSignatures.begin(); i!=otherSignatures.end(); ++i)
1355  {
1356  if(ids.find(i->first) != ids.end())
1357  {
1358  int id = i->second->id();
1359  const std::multimap<int, Link> & links = i->second->getLinks();
1360  int weight = i->second->getWeight();
1361  for(std::multimap<int, Link>::const_iterator iter = links.begin(); iter!=links.end(); ++iter)
1362  {
1363  int weightNeighbor = 0;
1364  const Signature * s = uValue(otherSignatures, iter->first, (Signature*)0);
1365  if(s)
1366  {
1367  weightNeighbor = s->getWeight();
1368  }
1369  else
1370  {
1371  this->getWeight(iter->first, weightNeighbor);
1372  }
1373  //UDEBUG("Add neighbor link from %d to %d", id, iter->first);
1374  if(iter->second.type() == Link::kNeighbor)
1375  {
1376  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\"\n",
1377  id,
1378  weight,
1379  iter->first,
1380  weightNeighbor);
1381  }
1382  else if(iter->second.type() == Link::kNeighborMerged)
1383  {
1384  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\" [label=\"M\", fontcolor=%s, fontsize=8];\n",
1385  id,
1386  weight,
1387  iter->first,
1388  weightNeighbor,
1389  colorNM);
1390  }
1391  else if(iter->first > id)
1392  {
1393  //loop
1394  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\" [label=\"L\", fontcolor=%s, fontsize=8];\n",
1395  id,
1396  weight,
1397  iter->first,
1398  weightNeighbor,
1399  colorG);
1400  }
1401  else if(iter->first != id)
1402  {
1403  //child
1404  fprintf(fout, " \"%d\\n%d\" -> \"%d\\n%d\" [label=\"C\", fontcolor=%s, fontsize=8];\n",
1405  id,
1406  weight,
1407  iter->first,
1408  weightNeighbor,
1409  colorP);
1410  }
1411  }
1412  }
1413  }
1414  fprintf(fout, "}\n");
1415  fclose(fout);
1416  UINFO("Graph saved to \"%s\" (Tip: $ neato -Tpdf \"%s\" -o out.pdf)", fileName.c_str(), fileName.c_str());
1417  }
1418  }
1419 }
1420 
1421 } // namespace rtabmap
rtabmap::SensorData
Definition: SensorData.h:51
rtabmap::DBDriver::DBDriver
DBDriver(const ParametersMap &parameters=ParametersMap())
Definition: DBDriver.cpp:46
rtabmap::DBDriver::_trashVisualWords
std::map< int, VisualWord * > _trashVisualWords
Definition: DBDriver.h:307
rtabmap::DBDriver::loadWords
void loadWords(const std::set< int > &wordIds, std::list< VisualWord * > &vws)
Definition: DBDriver.cpp:616
UMutex::lock
int lock() const
Definition: UMutex.h:87
rtabmap::DBDriver::loadOptimizedPoses
std::map< int, Transform > loadOptimizedPoses(Transform *lastlocalizationPose=0) const
Definition: DBDriver.cpp:1197
rtabmap::DBDriver::getNodeData
void getNodeData(int signatureId, SensorData &data, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const
Definition: DBDriver.cpp:685
rtabmap::DBDriver::getTotalNodesSizeQuery
virtual int getTotalNodesSizeQuery() const =0
rtabmap::DBDriver::getCalibration
bool getCalibration(int signatureId, std::vector< CameraModel > &models, std::vector< StereoCameraModel > &stereoModels) const
Definition: DBDriver.cpp:736
rtabmap::DBDriver::getNodesObservingLandmark
void getNodesObservingLandmark(int landmarkId, std::map< int, Link > &nodes) const
Definition: DBDriver.cpp:1038
rtabmap::DBDriver::getNodesMemoryUsed
long getNodesMemoryUsed() const
Definition: DBDriver.cpp:119
rtabmap::DBDriver::beginTransaction
void beginTransaction() const
Definition: DBDriver.cpp:290
rtabmap::DBDriver::updateLink
void updateLink(const Link &link)
Definition: DBDriver.cpp:477
UINFO
#define UINFO(...)
rtabmap::DBDriver::getLastParameters
ParametersMap getLastParameters() const
Definition: DBDriver.cpp:239
rtabmap::DBDriver::addStatistics
void addStatistics(const Statistics &statistics, bool saveWmState) const
Definition: DBDriver.cpp:1169
rtabmap::Statistics
Definition: Statistics.h:53
rtabmap::DBDriver::getStatisticsMemoryUsedQuery
virtual long getStatisticsMemoryUsedQuery() const =0
bytes
rtabmap::DBDriver::isConnectedQuery
virtual bool isConnectedQuery() const =0
rtabmap::DBDriver::getTotalDictionarySizeQuery
virtual int getTotalDictionarySizeQuery() const =0
timer
s
RealScalar s
rtabmap::DBDriver::_timestampUpdate
bool _timestampUpdate
Definition: DBDriver.h:314
rtabmap::DBDriver::getImagesMemoryUsed
long getImagesMemoryUsed() const
Definition: DBDriver.cpp:135
keys
const KeyVector keys
rtabmap::DBDriver::openConnection
bool openConnection(const std::string &url, bool overwritten=false)
Definition: DBDriver.cpp:86
rtabmap::DBDriver::getLastNodesSize
int getLastNodesSize() const
Definition: DBDriver.cpp:207
rtabmap::DBDriver::save2DMapQuery
virtual void save2DMapQuery(const cv::Mat &map, float xMin, float yMin, float cellSize) const =0
rtabmap::DBDriver::loadSignaturesQuery
virtual void loadSignaturesQuery(const std::list< int > &ids, std::list< Signature * > &signatures) const =0
rtabmap::DBDriver::getLastIdQuery
virtual void getLastIdQuery(const std::string &tableName, int &id, const std::string &fieldName="id") const =0
UMutex::unlock
int unlock() const
Definition: UMutex.h:113
rtabmap::DBDriver::addLink
void addLink(const Link &link)
Definition: DBDriver.cpp:467
rtabmap::DBDriver::getLastNodesSizeQuery
virtual int getLastNodesSizeQuery() const =0
rtabmap::DBDriver::getGridsMemoryUsedQuery
virtual long getGridsMemoryUsedQuery() const =0
rtabmap::DBDriver::_trashSignatures
std::map< int, Signature * > _trashSignatures
Definition: DBDriver.h:306
rtabmap::DBDriver::updateCalibrationQuery
virtual void updateCalibrationQuery(int nodeId, const std::vector< CameraModel > &models, const std::vector< StereoCameraModel > &stereoModels) const =0
rtabmap::DBDriver::getAllStatisticsWmStatesQuery
virtual std::map< int, std::vector< int > > getAllStatisticsWmStatesQuery() const =0
rtabmap::DBDriver::loadSignature
Signature * loadSignature(int id, bool *loadedFromTrash=0)
Definition: DBDriver.cpp:547
rtabmap::DBDriver::getCalibrationQuery
virtual bool getCalibrationQuery(int signatureId, std::vector< CameraModel > &models, std::vector< StereoCameraModel > &stereoModels) const =0
UThread::join
void join(bool killFirst=false)
Definition: UThread.cpp:85
rtabmap::DBDriver::getLastParametersQuery
virtual ParametersMap getLastParametersQuery() const =0
rtabmap::GPS
Definition: GPS.h:35
type
rtabmap::DBDriver::getAllStatisticsWmStates
std::map< int, std::vector< int > > getAllStatisticsWmStates() const
Definition: DBDriver.cpp:266
rtabmap::DBDriver::executeNoResult
void executeNoResult(const std::string &sql) const
Definition: DBDriver.cpp:304
rtabmap::DBDriver::isConnected
bool isConnected() const
Definition: DBDriver.cpp:100
rtabmap::DBDriver::updateLaserScanQuery
virtual void updateLaserScanQuery(int nodeId, const LaserScan &scan) const =0
rtabmap::DBDriver::updateOccupancyGrid
void updateOccupancyGrid(int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewpoint)
Definition: DBDriver.cpp:483
rtabmap::DBDriver::loadOptimizedMeshQuery
virtual cv::Mat loadOptimizedMeshQuery(std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > *polygons, std::vector< std::vector< Eigen::Vector2f > > *texCoords, cv::Mat *textures) const =0
true
#define true
Definition: ConvertUTF.c:57
UTimer::start
void start()
Definition: UTimer.cpp:87
rtabmap::DBDriver::getDepthImagesMemoryUsedQuery
virtual long getDepthImagesMemoryUsedQuery() const =0
rtabmap::DBDriver::addStatisticsQuery
virtual void addStatisticsQuery(const Statistics &statistics, bool saveWmState) const =0
rtabmap::DBDriver::loadNodeData
void loadNodeData(Signature *signature, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const
Definition: DBDriver.cpp:658
rtabmap::DBDriver::getStatistics
std::map< std::string, float > getStatistics(int nodeId, double &stamp, std::vector< int > *wmState=0) const
Definition: DBDriver.cpp:248
rtabmap::DBDriver::addLinkQuery
virtual void addLinkQuery(const Link &link) const =0
rtabmap::LaserScan
Definition: LaserScan.h:37
rtabmap::ParametersMap
std::map< std::string, std::string > ParametersMap
Definition: Parameters.h:43
rtabmap::DBDriver::loadLastNodes
void loadLastNodes(std::list< Signature * > &signatures) const
Definition: DBDriver.cpp:540
rtabmap::DBDriver::loadQuery
virtual void loadQuery(VWDictionary *dictionary, bool lastStateOnly=true) const =0
UTimer.h
ULOGGER_DEBUG
#define ULOGGER_DEBUG(...)
Definition: ULogger.h:53
rtabmap::DBDriver::updateDepthImageQuery
virtual void updateDepthImageQuery(int nodeId, const cv::Mat &image) const =0
rtabmap::VisualWord
Definition: VisualWord.h:38
rtabmap::DBDriver::getUserDataMemoryUsed
long getUserDataMemoryUsed() const
Definition: DBDriver.cpp:175
UMath.h
Basic mathematics functions.
rtabmap::DBDriver::loadNodeDataQuery
virtual void loadNodeDataQuery(std::list< Signature * > &signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const =0
rtabmap::DBDriver::getImagesMemoryUsedQuery
virtual long getImagesMemoryUsedQuery() const =0
rtabmap::DBDriver::getDepthImagesMemoryUsed
long getDepthImagesMemoryUsed() const
Definition: DBDriver.cpp:143
rtabmap::Parameters::parse
static bool parse(const ParametersMap &parameters, const std::string &key, bool &value)
Definition: Parameters.cpp:500
rtabmap::DBDriver::save2DMap
void save2DMap(const cv::Mat &map, float xMin, float yMin, float cellSize) const
Definition: DBDriver.cpp:1205
rtabmap::DBDriver::savePreviewImageQuery
virtual void savePreviewImageQuery(const cv::Mat &image) const =0
VisualWord.h
rtabmap::DBDriver::connectDatabaseQuery
virtual bool connectDatabaseQuery(const std::string &url, bool overwritten=false)=0
labels
std::vector< std::string > labels
rtabmap::DBDriver::getAllStatisticsQuery
virtual std::map< int, std::pair< std::map< std::string, float >, double > > getAllStatisticsQuery() const =0
rtabmap::DBDriver::_emptyTrashesTime
double _emptyTrashesTime
Definition: DBDriver.h:311
rtabmap::DBDriver::getLastDictionarySize
int getLastDictionarySize() const
Definition: DBDriver.cpp:215
rtabmap::DBDriver::updateLinkQuery
virtual void updateLinkQuery(const Link &link) const =0
rtabmap::DBDriver::getUserDataMemoryUsedQuery
virtual long getUserDataMemoryUsedQuery() const =0
rtabmap::DBDriver::_url
std::string _url
Definition: DBDriver.h:312
uContains
bool uContains(const std::list< V > &list, const V &value)
Definition: UStl.h:407
rtabmap::DBDriver::getWordsMemoryUsedQuery
virtual long getWordsMemoryUsedQuery() const =0
rtabmap::DBDriver::getTotalNodesSize
int getTotalNodesSize() const
Definition: DBDriver.cpp:223
rtabmap::DBDriver::getStatisticsMemoryUsed
long getStatisticsMemoryUsed() const
Definition: DBDriver.cpp:199
uKeys
std::vector< K > uKeys(const std::multimap< K, V > &mm)
Definition: UStl.h:67
rtabmap::DBDriver::parseParameters
virtual void parseParameters(const ParametersMap &parameters)
Definition: DBDriver.cpp:59
uStrNumCmp
int uStrNumCmp(const std::string &a, const std::string &b)
Definition: UStl.h:717
data
int data[]
Eigen::aligned_allocator
rtabmap::DBDriver::getLastMapId
void getLastMapId(int &mapId) const
Definition: DBDriver.cpp:988
rtabmap::DBDriver::loadLinksQuery
virtual void loadLinksQuery(int signatureId, std::multimap< int, Link > &links, Link::Type type=Link::kUndef) const =0
UConversion.h
Some conversion functions.
rtabmap::DBDriverSqlite3
Definition: DBDriverSqlite3.h:40
rtabmap::DBDriver::getWeightQuery
virtual void getWeightQuery(int signatureId, int &weight) const =0
rtabmap::DBDriver::loadPreviewImage
cv::Mat loadPreviewImage() const
Definition: DBDriver.cpp:1183
Signature.h
rtabmap::DBDriver::_transactionMutex
UMutex _transactionMutex
Definition: DBDriver.h:305
rtabmap::DBDriver::mainLoop
virtual void mainLoop()
Definition: DBDriver.cpp:284
rtabmap::DBDriver::updateCalibration
void updateCalibration(int nodeId, const std::vector< CameraModel > &models, const std::vector< StereoCameraModel > &stereoModels)
Definition: DBDriver.cpp:505
rtabmap::DBDriver::getLastWordId
void getLastWordId(int &id) const
Definition: DBDriver.cpp:1003
DBDriverSqlite3.h
rtabmap::DBDriver::getNodesMemoryUsedQuery
virtual long getNodesMemoryUsedQuery() const =0
velocity
Velocity3 velocity(const NavState &X, OptionalJacobian< 3, 9 > H)
rtabmap::DBDriver::getAllLabelsQuery
virtual void getAllLabelsQuery(std::map< int, std::string > &labels) const =0
UThread::kill
void kill()
Definition: UThread.cpp:48
rtabmap::DBDriver::_targetVersion
std::string _targetVersion
Definition: DBDriver.h:313
rtabmap::DBDriver::getNodeInfo
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
Definition: DBDriver.cpp:786
info
else if n * info
rtabmap::DBDriver::getNodesObservingLandmarkQuery
virtual void getNodesObservingLandmarkQuery(int landmarkId, std::map< int, Link > &nodes) const =0
rtabmap::DBDriver::getFeaturesMemoryUsedQuery
virtual long getFeaturesMemoryUsedQuery() const =0
rtabmap::DBDriver::getMemoryUsedQuery
virtual unsigned long getMemoryUsedQuery() const =0
UASSERT
#define UASSERT(condition)
version
version
rtabmap::DBDriver::getDatabaseVersion
std::string getDatabaseVersion() const
Definition: DBDriver.cpp:275
uValue
V uValue(const std::map< K, V > &m, const K &key, const V &defaultValue=V())
Definition: UStl.h:238
rtabmap::DBDriver::getNodeIdByLabel
void getNodeIdByLabel(const std::string &label, int &id) const
Definition: DBDriver.cpp:1065
UThread::start
void start()
Definition: UThread.cpp:122
rtabmap::Parameters::serialize
static std::string serialize(const ParametersMap &parameters)
Definition: Parameters.cpp:93
rtabmap::DBDriver::getLaserScanInfo
bool getLaserScanInfo(int signatureId, LaserScan &info) const
Definition: DBDriver.cpp:762
rtabmap::DBDriver::getAllStatistics
std::map< int, std::pair< std::map< std::string, float >, double > > getAllStatistics() const
Definition: DBDriver.cpp:257
rtabmap::DBDriver::getWordsMemoryUsed
long getWordsMemoryUsed() const
Definition: DBDriver.cpp:183
DBDriver.h
rtabmap::DBDriver::getLastDictionarySizeQuery
virtual int getLastDictionarySizeQuery() const =0
uAppend
void uAppend(std::list< V > &list, const std::list< V > &newItems)
Definition: UStl.h:524
rtabmap::DBDriver::getCalibrationsMemoryUsed
long getCalibrationsMemoryUsed() const
Definition: DBDriver.cpp:151
rtabmap::DBDriver::executeNoResultQuery
virtual void executeNoResultQuery(const std::string &sql) const =0
rtabmap::DBDriver::emptyTrashes
void emptyTrashes(bool async=false)
Definition: DBDriver.cpp:311
rtabmap::DBDriver::getAllLabels
void getAllLabels(std::map< int, std::string > &labels) const
Definition: DBDriver.cpp:1100
rtabmap::DBDriver::loadLinks
void loadLinks(int signatureId, std::multimap< int, Link > &links, Link::Type type=Link::kUndef) const
Definition: DBDriver.cpp:825
UASSERT_MSG
#define UASSERT_MSG(condition, msg_str)
Definition: ULogger.h:67
UWARN
#define UWARN(...)
rtabmap::DBDriver::getLastNodeIds
void getLastNodeIds(std::set< int > &ids) const
Definition: DBDriver.cpp:879
rtabmap::DBDriver
Definition: DBDriver.h:62
rtabmap::DBDriver::getLinksMemoryUsed
long getLinksMemoryUsed() const
Definition: DBDriver.cpp:127
uFormat
std::string UTILITE_EXPORT uFormat(const char *fmt,...)
Definition: UConversion.cpp:365
nodes
KeyVector nodes
rtabmap::DBDriver::removeLink
void removeLink(int from, int to)
Definition: DBDriver.cpp:473
ULogger.h
ULogger class and convenient macros.
rtabmap::DBDriver::loadPreviewImageQuery
virtual cv::Mat loadPreviewImageQuery() const =0
rtabmap::Transform
Definition: Transform.h:41
empty
UTimer::ticks
double ticks()
Definition: UTimer.cpp:117
rtabmap::DBDriver::getMemoryUsed
unsigned long getMemoryUsed() const
Definition: DBDriver.cpp:110
rtabmap::VWDictionary
Definition: VWDictionary.h:46
rtabmap::EnvSensors
std::map< EnvSensor::Type, EnvSensor > EnvSensors
Definition: EnvSensor.h:81
rtabmap::DBDriver::getLinksMemoryUsedQuery
virtual long getLinksMemoryUsedQuery() const =0
rtabmap::DBDriver::updateQuery
virtual void updateQuery(const std::list< Signature * > &signatures, bool updateTimestamp) const =0
rtabmap::DBDriver::getWeight
void getWeight(int signatureId, int &weight) const
Definition: DBDriver.cpp:859
rtabmap::DBDriver::saveOrUpdate
void saveOrUpdate(const std::vector< Signature * > &signatures)
Definition: DBDriver.cpp:407
rtabmap::DBDriver::updateOccupancyGridQuery
virtual void updateOccupancyGridQuery(int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewpoint) const =0
rtabmap::DBDriver::_dbSafeAccessMutex
UMutex _dbSafeAccessMutex
Definition: DBDriver.h:309
rtabmap::DBDriver::getCalibrationsMemoryUsedQuery
virtual long getCalibrationsMemoryUsedQuery() const =0
rtabmap::DBDriver::getDatabaseVersionQuery
virtual bool getDatabaseVersionQuery(std::string &version) const =0
rtabmap::DBDriver::saveOptimizedPosesQuery
virtual void saveOptimizedPosesQuery(const std::map< int, Transform > &optimizedPoses, const Transform &lastlocalizationPose) const =0
rtabmap::DBDriver::getAllLinksQuery
virtual void getAllLinksQuery(std::multimap< int, Link > &links, bool ignoreNullLinks, bool withLandmarks) const =0
iter
iterator iter(handle obj)
rtabmap::DBDriver::loadOptimizedMesh
cv::Mat loadOptimizedMesh(std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > *polygons=0, std::vector< std::vector< Eigen::Vector2f > > *texCoords=0, cv::Mat *textures=0) const
Definition: DBDriver.cpp:1235
rtabmap::DBDriver::disconnectDatabaseQuery
virtual void disconnectDatabaseQuery(bool save=true, const std::string &outputUrl="")=0
rtabmap::DBDriver::addInfoAfterRun
void addInfoAfterRun(int stMemSize, int lastSignAdded, int processMemUsed, int databaseMemUsed, int dictionarySize, const ParametersMap &parameters) const
Definition: DBDriver.cpp:1119
c_str
const char * c_str(Args &&...args)
UStl.h
Wrappers of STL for convenient functions.
rtabmap::DBDriver::asyncSave
void asyncSave(Signature *s)
Definition: DBDriver.cpp:382
rtabmap::DBDriver::getFeaturesMemoryUsed
long getFeaturesMemoryUsed() const
Definition: DBDriver.cpp:191
UDEBUG
#define UDEBUG(...)
rtabmap::DBDriver::~DBDriver
virtual ~DBDriver()
Definition: DBDriver.cpp:53
UTimer
Definition: UTimer.h:46
rtabmap::DBDriver::_trashesMutex
UMutex _trashesMutex
Definition: DBDriver.h:308
rtabmap::DBDriver::load2DMap
cv::Mat load2DMap(float &xMin, float &yMin, float &cellSize) const
Definition: DBDriver.cpp:1212
rtabmap::DBDriver::getLastNodeIdsQuery
virtual void getLastNodeIdsQuery(std::set< int > &ids) const =0
rtabmap::DBDriver::loadOptimizedPosesQuery
virtual std::map< int, Transform > loadOptimizedPosesQuery(Transform *lastlocalizationPose=0) const =0
rtabmap::DBDriver::getNodeInfoQuery
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
rtabmap::DBDriver::loadLastNodesQuery
virtual void loadLastNodesQuery(std::list< Signature * > &signatures) const =0
rtabmap::DBDriver::getLastNodeId
void getLastNodeId(int &id) const
Definition: DBDriver.cpp:964
rtabmap::DBDriver::updateLaserScan
void updateLaserScan(int nodeId, const LaserScan &scan)
Definition: DBDriver.cpp:524
rtabmap::DBDriver::getLaserScansMemoryUsed
long getLaserScansMemoryUsed() const
Definition: DBDriver.cpp:167
UThread::isRunning
bool isRunning() const
Definition: UThread.cpp:245
url
url
rtabmap::DBDriver::load
void load(VWDictionary *dictionary, bool lastStateOnly=true) const
Definition: DBDriver.cpp:533
rtabmap::DBDriver::getAllNodeIds
void getAllNodeIds(std::set< int > &ids, bool ignoreChildren=false, bool ignoreBadSignatures=false, bool ignoreIntermediateNodes=false) const
Definition: DBDriver.cpp:886
rtabmap::DBDriver::savePreviewImage
void savePreviewImage(const cv::Mat &image) const
Definition: DBDriver.cpp:1176
rtabmap::DBDriver::getLaserScanInfoQuery
virtual bool getLaserScanInfoQuery(int signatureId, LaserScan &info) const =0
rtabmap::DBDriver::updateDepthImage
void updateDepthImage(int nodeId, const cv::Mat &image)
Definition: DBDriver.cpp:515
uValues
std::vector< V > uValues(const std::multimap< K, V > &mm)
Definition: UStl.h:100
rtabmap::DBDriver::generateGraph
void generateGraph(const std::string &fileName, const std::set< int > &ids=std::set< int >(), const std::map< int, Signature * > &otherSignatures=std::map< int, Signature * >())
Definition: DBDriver.cpp:1250
rtabmap::DBDriver::commit
void commit() const
Definition: DBDriver.cpp:297
rtabmap::DBDriver::saveOptimizedPoses
void saveOptimizedPoses(const std::map< int, Transform > &optimizedPoses, const Transform &lastlocalizationPose) const
Definition: DBDriver.cpp:1191
rtabmap::DBDriver::getInvertedIndexNiQuery
virtual void getInvertedIndexNiQuery(int signatureId, int &ni) const =0
rtabmap::DBDriver::load2DMapQuery
virtual cv::Mat load2DMapQuery(float &xMin, float &yMin, float &cellSize) const =0
rtabmap::DBDriver::getNodeIdByLabelQuery
virtual void getNodeIdByLabelQuery(const std::string &label, int &id) const =0
rtabmap::DBDriver::getTotalDictionarySize
int getTotalDictionarySize() const
Definition: DBDriver.cpp:231
rtabmap::DBDriver::loadWordsQuery
virtual void loadWordsQuery(const std::set< int > &wordIds, std::list< VisualWord * > &vws) const =0
rtabmap::DBDriver::getInvertedIndexNi
void getInvertedIndexNi(int signatureId, int &ni) const
Definition: DBDriver.cpp:1018
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::DBDriver::saveQuery
virtual void saveQuery(const std::list< Signature * > &signatures)=0
rtabmap::DBDriver::getGridsMemoryUsed
long getGridsMemoryUsed() const
Definition: DBDriver.cpp:159
rtabmap::DBDriver::getStatisticsQuery
virtual std::map< std::string, float > getStatisticsQuery(int nodeId, double &stamp, std::vector< int > *wmState) const =0
UERROR
#define UERROR(...)
rtabmap::VisualWord::id
int id() const
Definition: VisualWord.h:49
rtabmap::DBDriver::getAllNodeIdsQuery
virtual void getAllNodeIdsQuery(std::set< int > &ids, bool ignoreChildren, bool ignoreBadSignatures, bool ignoreIntermediateNodes) const =0
rtabmap::DBDriver::saveOptimizedMeshQuery
virtual void saveOptimizedMeshQuery(const cv::Mat &cloud, const std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > &polygons, const std::vector< std::vector< Eigen::Vector2f > > &texCoords, const cv::Mat &textures) const =0
rtabmap::DBDriver::loadSignatures
void loadSignatures(const std::list< int > &ids, std::list< Signature * > &signatures, std::set< int > *loadedFromTrash=0)
Definition: DBDriver.cpp:564
i
int i
rtabmap::DBDriver::getAllLinks
void getAllLinks(std::multimap< int, Link > &links, bool ignoreNullLinks=true, bool withLandmarks=false) const
Definition: DBDriver.cpp:925
rtabmap::DBDriver::getLaserScansMemoryUsedQuery
virtual long getLaserScansMemoryUsedQuery() const =0
rtabmap::DBDriver::closeConnection
void closeConnection(bool save=true, const std::string &outputUrl="")
Definition: DBDriver.cpp:64
rtabmap::Signature
Definition: Signature.h:48
rtabmap::DBDriver::saveOptimizedMesh
void saveOptimizedMesh(const cv::Mat &cloud, const std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > &polygons=std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > >(), const std::vector< std::vector< Eigen::Vector2f > > &texCoords=std::vector< std::vector< Eigen::Vector2f > >(), const cv::Mat &textures=cv::Mat()) const
Definition: DBDriver.cpp:1220
rtabmap::DBDriver::create
static DBDriver * create(const ParametersMap &parameters=ParametersMap())
Definition: DBDriver.cpp:41


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:08