2011-06-05 14:45:39 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke
|
|
|
|
|
*
|
|
|
|
|
* This file is part of RTAB-Map.
|
|
|
|
|
*
|
|
|
|
|
* RTAB-Map is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* RTAB-Map is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with RTAB-Map. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef DBDRIVERSQLITE3_H_
|
|
|
|
|
#define DBDRIVERSQLITE3_H_
|
|
|
|
|
|
|
|
|
|
#include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
|
|
|
|
|
#include "rtabmap/core/DBDriver.h"
|
2012-12-11 18:05:05 +00:00
|
|
|
#include <opencv2/features2d/features2d.hpp>
|
2014-01-24 21:42:35 +00:00
|
|
|
#include "sqlite3/sqlite3.h"
|
2013-12-11 00:12:44 +00:00
|
|
|
#include <pcl/point_types.h>
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
namespace rtabmap {
|
|
|
|
|
|
|
|
|
|
class RTABMAP_EXP DBDriverSqlite3: public DBDriver {
|
|
|
|
|
public:
|
|
|
|
|
DBDriverSqlite3(const ParametersMap & parameters = ParametersMap());
|
|
|
|
|
virtual ~DBDriverSqlite3();
|
|
|
|
|
|
|
|
|
|
virtual void parseParameters(const ParametersMap & parameters);
|
|
|
|
|
void setDbInMemory(bool dbInMemory);
|
|
|
|
|
void setJournalMode(int journalMode);
|
|
|
|
|
void setCacheSize(unsigned int cacheSize);
|
2012-03-03 01:46:30 +00:00
|
|
|
void setSynchronous(int synchronous);
|
|
|
|
|
void setTempStore(int tempStore);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
private:
|
2012-03-03 01:46:30 +00:00
|
|
|
virtual bool connectDatabaseQuery(const std::string & url, bool overwirtten = false);
|
2011-06-05 14:45:39 +00:00
|
|
|
virtual void disconnectDatabaseQuery();
|
|
|
|
|
virtual bool isConnectedQuery() const;
|
|
|
|
|
virtual long getMemoryUsedQuery() const; // In bytes
|
|
|
|
|
|
2012-12-11 18:05:05 +00:00
|
|
|
virtual void executeNoResultQuery(const std::string & sql) const;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2012-12-11 18:05:05 +00:00
|
|
|
virtual void getWeightQuery(int signatureId, int & weight) const;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2012-12-11 18:05:05 +00:00
|
|
|
virtual void saveQuery(const std::list<Signature *> & signatures) const;
|
2012-12-12 16:40:18 +00:00
|
|
|
virtual void saveQuery(const std::list<VisualWord *> & words) const;
|
|
|
|
|
virtual void updateQuery(const std::list<Signature *> & signatures) const;
|
|
|
|
|
virtual void updateQuery(const std::list<VisualWord *> & words) const;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
// Load objects
|
2012-12-11 18:05:05 +00:00
|
|
|
virtual void loadQuery(VWDictionary * dictionary) const;
|
|
|
|
|
virtual void loadLastNodesQuery(std::list<Signature *> & signatures) const;
|
|
|
|
|
virtual void loadSignaturesQuery(const std::list<int> & ids, std::list<Signature *> & signatures) const;
|
|
|
|
|
virtual void loadWordsQuery(const std::set<int> & wordIds, std::list<VisualWord *> & vws) const;
|
2013-12-11 00:12:44 +00:00
|
|
|
virtual void loadNeighborsQuery(int signatureId, std::map<int, Transform> & neighbors) const;
|
|
|
|
|
virtual void loadLoopClosuresQuery(
|
|
|
|
|
int signatureId,
|
|
|
|
|
std::map<int, Transform> & loopIds,
|
|
|
|
|
std::map<int, Transform> & childIds) const;
|
|
|
|
|
|
|
|
|
|
virtual void loadNodeDataQuery(std::list<Signature *> & signatures, bool loadMetricData) const;
|
|
|
|
|
virtual void getNodeDataQuery(
|
|
|
|
|
int signatureId,
|
|
|
|
|
std::vector<unsigned char> & image,
|
|
|
|
|
std::vector<unsigned char> & depth,
|
|
|
|
|
std::vector<unsigned char> & depth2d,
|
2014-07-26 04:36:00 +00:00
|
|
|
float & fx,
|
|
|
|
|
float & fy,
|
|
|
|
|
float & cx,
|
|
|
|
|
float & cy,
|
2013-12-11 00:12:44 +00:00
|
|
|
Transform & localTransform) const;
|
|
|
|
|
virtual void getNodeDataQuery(int signatureId, std::vector<unsigned char> & image) const;
|
|
|
|
|
virtual void getPoseQuery(int signatureId, Transform & pose, int & mapId) const;
|
2012-12-11 18:05:05 +00:00
|
|
|
virtual void getAllNodeIdsQuery(std::set<int> & ids) const;
|
|
|
|
|
virtual void getLastIdQuery(const std::string & tableName, int & id) const;
|
|
|
|
|
virtual void getInvertedIndexNiQuery(int signatureId, int & ni) const;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2012-03-03 01:46:30 +00:00
|
|
|
private:
|
2012-06-24 17:19:34 +00:00
|
|
|
std::string queryStepNode() const;
|
2012-12-11 18:05:05 +00:00
|
|
|
std::string queryStepImage() const;
|
2013-12-11 00:12:44 +00:00
|
|
|
std::string queryStepDepth() const;
|
2012-06-24 17:19:34 +00:00
|
|
|
std::string queryStepLink() const;
|
2012-03-03 01:46:30 +00:00
|
|
|
std::string queryStepWordsChanged() const;
|
|
|
|
|
std::string queryStepKeypoint() const;
|
2012-12-11 18:05:05 +00:00
|
|
|
void stepNode(sqlite3_stmt * ppStmt, const Signature * s) const;
|
2013-12-11 00:12:44 +00:00
|
|
|
void stepImage(
|
|
|
|
|
sqlite3_stmt * ppStmt,
|
|
|
|
|
int id,
|
|
|
|
|
const std::vector<unsigned char> & image) const;
|
|
|
|
|
void stepDepth(
|
|
|
|
|
sqlite3_stmt * ppStmt,
|
|
|
|
|
int id,
|
|
|
|
|
const std::vector<unsigned char> & depth,
|
|
|
|
|
const std::vector<unsigned char> & depth2d,
|
2014-07-26 04:36:00 +00:00
|
|
|
float fx,
|
|
|
|
|
float fy,
|
|
|
|
|
float cx,
|
|
|
|
|
float cy,
|
2013-12-11 00:12:44 +00:00
|
|
|
const Transform & localTransform) const;
|
|
|
|
|
void stepLink(sqlite3_stmt * ppStmt, int fromId, int toId, int type, const Transform & transform) const;
|
2012-12-11 18:05:05 +00:00
|
|
|
void stepWordsChanged(sqlite3_stmt * ppStmt, int signatureId, int oldWordId, int newWordId) const;
|
2013-12-11 00:12:44 +00:00
|
|
|
void stepKeypoint(sqlite3_stmt * ppStmt, int signatureId, int wordId, const cv::KeyPoint & kp, const pcl::PointXYZ & pt) const;
|
2012-03-03 01:46:30 +00:00
|
|
|
|
2011-06-05 14:45:39 +00:00
|
|
|
private:
|
2012-12-11 18:05:05 +00:00
|
|
|
void loadLinksQuery(std::list<Signature *> & signatures) const;
|
2011-06-05 14:45:39 +00:00
|
|
|
int loadOrSaveDb(sqlite3 *pInMemory, const std::string & fileName, int isSave) const;
|
2014-07-26 04:36:00 +00:00
|
|
|
bool getVersion(std::string &) const;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
sqlite3 * _ppDb;
|
2014-07-26 04:36:00 +00:00
|
|
|
std::string _version;
|
2011-06-05 14:45:39 +00:00
|
|
|
bool _dbInMemory;
|
|
|
|
|
unsigned int _cacheSize;
|
|
|
|
|
int _journalMode;
|
2012-03-03 01:46:30 +00:00
|
|
|
int _synchronous;
|
|
|
|
|
int _tempStore;
|
2011-06-05 14:45:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* DBDRIVERSQLITE3_H_ */
|