36 #include "DatabaseSchema_sql.h" 37 #include "DatabaseSchema_0_18_3_sql.h" 38 #include "DatabaseSchema_0_18_0_sql.h" 39 #include "DatabaseSchema_0_17_0_sql.h" 40 #include "DatabaseSchema_0_16_2_sql.h" 41 #include "DatabaseSchema_0_16_1_sql.h" 42 #include "DatabaseSchema_0_16_0_sql.h" 55 _memoryUsedEstimate(0),
56 _dbInMemory(
Parameters::defaultDbSqlite3InMemory()),
57 _cacheSize(
Parameters::defaultDbSqlite3CacheSize()),
58 _journalMode(
Parameters::defaultDbSqlite3JournalMode()),
59 _synchronous(
Parameters::defaultDbSqlite3Synchronous()),
60 _tempStore(
Parameters::defaultDbSqlite3TempStore())
73 ParametersMap::const_iterator iter;
74 if((iter=parameters.find(Parameters::kDbSqlite3CacheSize())) != parameters.end())
78 if((iter=parameters.find(Parameters::kDbSqlite3JournalMode())) != parameters.end())
82 if((iter=parameters.find(Parameters::kDbSqlite3Synchronous())) != parameters.end())
86 if((iter=parameters.find(Parameters::kDbSqlite3TempStore())) != parameters.end())
90 if((iter=parameters.find(Parameters::kDbSqlite3InMemory())) != parameters.end())
102 std::string query =
"PRAGMA cache_size = ";
110 if(journalMode >= 0 && journalMode < 5)
144 if(synchronous >= 0 && synchronous < 3)
172 if(tempStore >= 0 && tempStore < 3)
200 UDEBUG(
"dbInMemory=%d", dbInMemory?1:0);
254 pFrom = (isSave ? pInMemory : pFile);
255 pTo = (isSave ? pFile : pInMemory);
292 std::stringstream query;
294 query <<
"SELECT version FROM Admin;";
329 bool dbFileExist =
false;
333 if(dbFileExist && overwritten)
335 UINFO(
"Deleting database %s...", url.c_str());
349 ULOGGER_INFO(
"Using database \"%s\" in the memory.", url.c_str());
359 ULOGGER_INFO(
"Using database \"%s\" from the hard drive.", url.c_str());
364 UFATAL(
"DB error : %s (path=\"%s\"). Make sure that your user has write " 365 "permission on the target directory (you may have to change the working directory). ",
sqlite3_errmsg(
_ppDb), url.c_str());
390 ULOGGER_INFO(
"Database \"%s\" doesn't exist, creating a new one...", url.c_str());
393 std::string schema = DATABASESCHEMA_SQL;
395 if(!targetVersion.empty())
398 std::vector<std::pair<std::string, std::string> > schemas;
399 schemas.push_back(std::make_pair(
"0.16.0", DATABASESCHEMA_0_16_0_SQL));
400 schemas.push_back(std::make_pair(
"0.16.1", DATABASESCHEMA_0_16_1_SQL));
401 schemas.push_back(std::make_pair(
"0.16.2", DATABASESCHEMA_0_16_2_SQL));
402 schemas.push_back(std::make_pair(
"0.17.0", DATABASESCHEMA_0_17_0_SQL));
403 schemas.push_back(std::make_pair(
"0.18.0", DATABASESCHEMA_0_18_0_SQL));
404 schemas.push_back(std::make_pair(
"0.18.3", DATABASESCHEMA_0_18_3_SQL));
405 schemas.push_back(std::make_pair(
uNumber2Str(RTABMAP_VERSION_MAJOR)+
"."+
uNumber2Str(RTABMAP_VERSION_MINOR), DATABASESCHEMA_SQL));
406 for(
size_t i=0; i<schemas.size(); ++i)
408 if(
uStrNumCmp(targetVersion, schemas[i].first) < 0)
412 UERROR(
"Cannot create database with target version \"%s\" (not implemented), using latest version.", targetVersion.c_str());
418 schema = schemas[i].second;
432 UERROR(
"Opened database version (%s) is more recent than rtabmap " 433 "installed version (%s). Please update rtabmap to new version!",
468 std::string outputFile = this->
getUrl();
469 if(!outputUrl.empty())
471 outputFile = outputUrl;
473 if(outputFile.empty())
475 UWARN(
"Database was initialized with an empty url (in memory). To save it, " 476 "the output url should not be empty. The database is thus closed without being saved!");
480 UINFO(
"Saving database to %s ...", outputFile.c_str());
483 "permission on the target directory (you may have to change the working directory). ",
_version.c_str(), outputFile.c_str(),
sqlite3_errmsg(
_ppDb)).c_str());
489 UINFO(
"Disconnecting database %s...", this->
getUrl().c_str());
493 if(save && !
_dbInMemory && !outputUrl.empty() && !this->
getUrl().empty() && outputUrl.compare(this->
getUrl()) != 0)
495 UWARN(
"Output database path (%s) is different than the opened database " 496 "path (%s). Opened database path is overwritten then renamed to output path.",
497 outputUrl.c_str(), this->
getUrl().c_str());
500 UERROR(
"Failed to rename just closed db %s to %s", this->
getUrl().c_str(), outputUrl.c_str());
503 UINFO(
"Disconnected database %s!", this->
getUrl().c_str());
547 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose) + ifnull(length(velocity),0) + ifnull(length(gps),0) + ifnull(length(env_sensors),0) + length(time_enter)) from Node;";
551 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose) + ifnull(length(velocity),0) + ifnull(length(gps),0) + length(time_enter)) from Node;";
555 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose) + ifnull(length(velocity),0) + length(time_enter)) from Node;";
559 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose)+ length(time_enter)) from Node;";
563 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(time_enter)) from Node;";
567 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose)+ length(time_enter)) from Node;";
595 query =
"SELECT sum(length(type) + length(information_matrix) + length(transform) + ifnull(length(user_data),0) + length(from_id) + length(to_id)) from Link;";
599 query =
"SELECT sum(length(type) + length(rot_variance) + length(trans_variance) + length(transform) + ifnull(length(user_data),0) + length(from_id) + length(to_id)) from Link;";
603 query =
"SELECT sum(length(type) + length(rot_variance) + length(trans_variance) + length(transform) + length(from_id) + length(to_id)) from Link;";
607 query =
"SELECT sum(length(type) + length(variance) + length(transform) + length(from_id) + length(to_id)) from Link;";
611 query =
"SELECT sum(length(type) + length(transform) + length(from_id) + length(to_id)) from Link;";
639 query =
"SELECT sum(ifnull(length(image),0) + ifnull(length(time_enter),0)) from Data;";
643 query =
"SELECT sum(length(data) + ifnull(length(time_enter),0)) from Image;";
671 query =
"SELECT sum(ifnull(length(depth),0) + ifnull(length(time_enter),0)) from Data;";
675 query =
"SELECT sum(length(data) + ifnull(length(time_enter),0)) from Depth;";
704 query =
"SELECT sum(length(calibration)) from Data;";
708 query =
"SELECT sum(length(fx) + length(fy) + length(cx) + length(cy) + length(local_transform)) from Depth;";
712 query =
"SELECT sum(length(constant) + length(local_transform)) from Depth;";
741 query =
"SELECT sum(ifnull(length(ground_cells),0) + ifnull(length(obstacle_cells),0) + ifnull(length(empty_cells),0) + length(cell_size) + length(view_point_x) + length(view_point_y) + length(view_point_z)) from Data;";
745 query =
"SELECT sum(ifnull(length(ground_cells),0) + ifnull(length(obstacle_cells),0) + length(cell_size) + length(view_point_x) + length(view_point_y) + length(view_point_z)) from Data;";
778 query =
"SELECT sum(ifnull(length(scan_info),0) + ifnull(length(scan),0)) from Data;";
782 query =
"SELECT sum(length(scan_max_pts) + length(scan_max_range) + ifnull(length(scan),0)) from Data;";
786 query =
"SELECT sum(length(scan_max_pts) + ifnull(length(scan),0)) from Data;";
790 query =
"SELECT sum(length(data2d) + length(data2d_max_pts)) from Depth;";
794 query =
"SELECT sum(length(data2d)) from Depth;";
822 query =
"SELECT sum(length(user_data)) from Data;";
826 query =
"SELECT sum(length(user_data)) from Node;";
855 std::string query =
"SELECT sum(length(id) + length(descriptor_size) + length(descriptor) + length(time_enter)) from Word;";
882 query =
"SELECT sum(length(node_id) + length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(octave) + ifnull(length(depth_x),0) + ifnull(length(depth_y),0) + ifnull(length(depth_z),0) + ifnull(length(descriptor_size),0) + ifnull(length(descriptor),0)) " 887 query =
"SELECT sum(length(node_id) + length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(octave) + ifnull(length(depth_x),0) + ifnull(length(depth_y),0) + ifnull(length(depth_z),0) + ifnull(length(descriptor_size),0) + ifnull(length(descriptor),0)) " 888 "FROM Map_Node_Word";
892 query =
"SELECT sum(length(node_id) + length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + ifnull(length(depth_x),0) + ifnull(length(depth_y),0) + ifnull(length(depth_z),0) + ifnull(length(descriptor_size),0) + ifnull(length(descriptor),0)) " 893 "FROM Map_Node_Word";
897 query =
"SELECT sum(length(node_id) + length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + ifnull(length(depth_x),0) + ifnull(length(depth_y),0) + ifnull(length(depth_z),0) " 898 "FROM Map_Node_Word";
926 query =
"SELECT sum(length(id) + length(stamp) + ifnull(length(data),0) + ifnull(length(wm_state),0)) FROM Statistics;";
930 query =
"SELECT sum(length(id) + length(stamp) + length(data)) FROM Statistics;";
962 query =
"SELECT count(id) from Node WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
966 query =
"SELECT count(id) from Node WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
994 query =
"SELECT count(id) from Word WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
998 query =
"SELECT count(id) from Word WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
1023 std::string query =
"SELECT count(id) from Node;";
1047 std::string query =
"SELECT count(id) from Word;";
1077 query =
"SELECT parameters " 1079 "WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
1083 query =
"SELECT parameters " 1085 "WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
1114 UDEBUG(
"nodeId=%d", nodeId);
1115 std::map<std::string, float>
data;
1120 std::stringstream query;
1124 query <<
"SELECT stamp, data, wm_state " 1125 <<
"FROM Statistics " 1126 <<
"WHERE id=" << nodeId <<
";";
1130 query <<
"SELECT stamp, data " 1131 <<
"FROM Statistics " 1132 <<
"WHERE id=" << nodeId <<
";";
1150 if(dataSize>0 && dataPtr)
1169 if(dataSize>0 && dataPtr)
1171 cv::Mat wmStateMat =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)dataPtr));
1172 UASSERT(wmStateMat.type() == CV_32SC1 && wmStateMat.rows == 1);
1173 wmState->resize(wmStateMat.cols);
1174 memcpy(wmState->data(), wmStateMat.data, wmState->size()*
sizeof(int));
1191 std::map<int, std::pair<std::map<std::string, float>,
double> >
data;
1196 std::stringstream query;
1198 query <<
"SELECT id, stamp, data " 1199 <<
"FROM Statistics;";
1215 const void * dataPtr = 0;
1219 if(dataSize>0 && dataPtr)
1248 std::map<int, std::vector<int> >
data;
1253 std::stringstream query;
1255 query <<
"SELECT id, wm_state " 1256 <<
"FROM Statistics;";
1268 std::vector<int> wmState;
1271 if(dataSize>0 && dataPtr)
1273 cv::Mat wmStateMat =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)dataPtr));
1274 UASSERT(wmStateMat.type() == CV_32SC1 && wmStateMat.rows == 1);
1275 wmState.resize(wmStateMat.cols);
1276 memcpy(wmState.data(), wmStateMat.data, wmState.size()*
sizeof(int));
1279 if(!wmState.empty())
1281 data.insert(std::make_pair(
id, wmState));
1297 UDEBUG(
"load data for %d signatures images=%d scan=%d userData=%d, grid=%d",
1298 (
int)signatures.size(), images?1:0, scan?1:0, userData?1:0, occupancyGrid?1:0);
1300 if(!images && !scan && !userData && !occupancyGrid)
1302 UWARN(
"All requested data fields are false! Nothing loaded...");
1312 std::stringstream query;
1316 std::stringstream fields;
1320 fields <<
"image, depth, calibration";
1321 if(scan || userData || occupancyGrid)
1328 fields <<
"scan_info, scan";
1329 if(userData || occupancyGrid)
1336 fields <<
"user_data";
1346 fields <<
"ground_cells, obstacle_cells, empty_cells, cell_size, view_point_x, view_point_y, view_point_z";
1350 fields <<
"ground_cells, obstacle_cells, cell_size, view_point_x, view_point_y, view_point_z";
1354 query <<
"SELECT " << fields.str().c_str() <<
" " 1361 query <<
"SELECT image, depth, calibration, scan_max_pts, scan_max_range, scan, user_data " 1368 query <<
"SELECT image, depth, calibration, scan_max_pts, scan, user_data " 1375 query <<
"SELECT Data.image, Data.depth, Data.calibration, Data.scan_max_pts, Data.scan, Node.user_data " 1377 <<
"INNER JOIN Node " 1378 <<
"ON Data.id = Node.id " 1379 <<
"WHERE Data.id = ?" 1384 query <<
"SELECT Image.data, " 1385 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d_max_pts, Depth.data2d, Node.user_data " 1387 <<
"INNER JOIN Node " 1388 <<
"on Image.id = Node.id " 1389 <<
"LEFT OUTER JOIN Depth " 1390 <<
"ON Image.id = Depth.id " 1391 <<
"WHERE Image.id = ?" 1396 query <<
"SELECT Image.data, " 1397 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d, Node.user_data " 1399 <<
"INNER JOIN Node " 1400 <<
"on Image.id = Node.id " 1401 <<
"LEFT OUTER JOIN Depth " 1402 <<
"ON Image.id = Depth.id " 1403 <<
"WHERE Image.id = ?" 1408 query <<
"SELECT Image.data, " 1409 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d " 1411 <<
"LEFT OUTER JOIN Depth " 1412 <<
"ON Image.id = Depth.id " 1413 <<
"WHERE Image.id = ?" 1418 query <<
"SELECT Image.data, " 1419 "Depth.data, Depth.local_transform, Depth.constant, Depth.data2d " 1421 <<
"LEFT OUTER JOIN Depth " 1422 <<
"ON Image.id = Depth.id " 1423 <<
"WHERE Image.id = ?" 1430 const void *
data = 0;
1434 for(std::list<Signature*>::iterator iter = signatures.begin(); iter!=signatures.end(); ++iter)
1449 cv::Mat imageCompressed;
1450 cv::Mat depthOrRightCompressed;
1451 std::vector<CameraModel> models;
1452 std::vector<StereoCameraModel> stereoModels;
1454 cv::Mat scanCompressed;
1455 cv::Mat userDataCompressed;
1462 if(dataSize>4 && data)
1464 imageCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1470 if(dataSize>4 && data)
1472 depthOrRightCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1479 if((
unsigned int)dataSize == localTransform.
size()*
sizeof(float) && data)
1481 memcpy(localTransform.
data(), data, dataSize);
1496 if(dataSize > 0 && data)
1500 if(dataSize >=
int(
sizeof(
int)*4))
1502 const int * dataInt = (
const int *)data;
1503 int type = dataInt[3];
1507 int bytesReadTotal = 0;
1508 unsigned int bytesRead = 0;
1509 while(bytesReadTotal < dataSize &&
1510 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
1512 bytesReadTotal+=bytesRead;
1513 models.push_back(model);
1515 UASSERT(bytesReadTotal == dataSize);
1520 int bytesReadTotal = 0;
1521 unsigned int bytesRead = 0;
1522 while(bytesReadTotal < dataSize &&
1523 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
1525 bytesReadTotal+=bytesRead;
1526 stereoModels.push_back(model);
1528 UASSERT(bytesReadTotal == dataSize);
1532 UFATAL(
"Unknown calibration type %d", type);
1537 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1542 float * dataFloat = (
float*)data;
1544 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
1546 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
1547 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1548 int max = cameraCount*(6+localTransform.
size());
1549 for(
int i=0; i<
max; i+=6+localTransform.
size())
1553 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
1559 (
double)dataFloat[i],
1560 (
double)dataFloat[i+1],
1561 (
double)dataFloat[i+2],
1562 (
double)dataFloat[i+3],
1564 models.back().setImageSize(cv::Size(dataFloat[i+4], dataFloat[i+5]));
1565 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
1566 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
1571 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
1573 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
1574 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1575 int max = cameraCount*(4+localTransform.
size());
1576 for(
int i=0; i<
max; i+=4+localTransform.
size())
1580 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
1586 (
double)dataFloat[i],
1587 (
double)dataFloat[i+1],
1588 (
double)dataFloat[i+2],
1589 (
double)dataFloat[i+3],
1593 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
1595 UDEBUG(
"Loading calibration of a stereo camera");
1596 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
1608 cv::Size(dataFloat[5],dataFloat[6])));
1610 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
1612 UDEBUG(
"Loading calibration of a stereo camera");
1613 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
1628 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1636 UDEBUG(
"Loading calibration version >= 0.7.0");
1641 if(fyOrBaseline < 1.0)
1644 stereoModels.push_back(
StereoCameraModel(fx,fx,cx,cy,fyOrBaseline, localTransform));
1648 models.push_back(
CameraModel(fx, fyOrBaseline, cx, cy, localTransform));
1653 UDEBUG(
"Loading calibration version < 0.7.0");
1655 float fx = 1.0f/depthConstant;
1656 float fy = 1.0f/depthConstant;
1659 models.push_back(
CameraModel(fx, fy, cx, cy, localTransform));
1663 int laserScanMaxPts = 0;
1664 float laserScanMinRange = 0.0f;
1665 float laserScanMaxRange = 0.0f;
1666 int laserScanFormat = 0;
1667 float laserScanAngleMin = 0.0f;
1668 float laserScanAngleMax = 0.0f;
1669 float laserScanAngleInc = 0.0f;
1679 if(dataSize > 0 && data)
1681 float * dataFloat = (
float*)data;
1685 UASSERT(dataSize == (
int)((scanLocalTransform.
size()+7)*
sizeof(
float)));
1686 laserScanFormat = (int)dataFloat[0];
1687 laserScanMinRange = dataFloat[1];
1688 laserScanMaxRange = dataFloat[2];
1689 laserScanAngleMin = dataFloat[3];
1690 laserScanAngleMax = dataFloat[4];
1691 laserScanAngleInc = dataFloat[5];
1692 laserScanMaxPts = (int)dataFloat[6];
1693 memcpy(scanLocalTransform.
data(), dataFloat+7, scanLocalTransform.
size()*
sizeof(float));
1697 if(
uStrNumCmp(
_version,
"0.16.1") >= 0 && dataSize == (
int)((scanLocalTransform.
size()+3)*
sizeof(
float)))
1700 laserScanFormat = (int)dataFloat[2];
1701 memcpy(scanLocalTransform.
data(), dataFloat+3, scanLocalTransform.
size()*
sizeof(float));
1703 else if(dataSize == (
int)((scanLocalTransform.
size()+2)*
sizeof(
float)))
1705 memcpy(scanLocalTransform.
data(), dataFloat+2, scanLocalTransform.
size()*
sizeof(float));
1709 UFATAL(
"Unexpected size %d for laser scan info!", dataSize);
1716 laserScanMaxPts = (int)dataFloat[0];
1717 laserScanMaxRange = dataFloat[1];
1737 if(dataSize>4 && data)
1739 scanCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1750 if(dataSize>4 && data)
1754 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1759 userDataCompressed =
compressData2(cv::Mat(1, dataSize, CV_8SC1, (
void *)data));
1766 cv::Mat groundCellsCompressed;
1767 cv::Mat obstacleCellsCompressed;
1768 cv::Mat emptyCellsCompressed;
1769 float cellSize = 0.0f;
1770 cv::Point3f viewPoint;
1776 if(dataSize > 0 && data)
1778 groundCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1779 memcpy((
void*)groundCellsCompressed.data, data, dataSize);
1785 if(dataSize > 0 && data)
1787 obstacleCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1788 memcpy((
void*)obstacleCellsCompressed.data, data, dataSize);
1796 if(dataSize > 0 && data)
1798 emptyCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1799 memcpy((
void*)emptyCellsCompressed.data, data, dataSize);
1812 if(laserScanAngleMin < laserScanAngleMax && laserScanAngleInc != 0.0
f)
1814 laserScan =
LaserScan(scanCompressed, (
LaserScan::Format)laserScanFormat, laserScanMinRange, laserScanMaxRange, laserScanAngleMin, laserScanAngleMax, laserScanAngleInc, scanLocalTransform);
1818 laserScan =
LaserScan(scanCompressed, laserScanMaxPts, laserScanMaxRange, (
LaserScan::Format)laserScanFormat, scanLocalTransform);
1820 (*iter)->sensorData().setLaserScan(laserScan);
1826 (*iter)->sensorData().setRGBDImage(imageCompressed, depthOrRightCompressed, models);
1830 (*iter)->sensorData().setStereoImage(imageCompressed, depthOrRightCompressed, stereoModels);
1835 (*iter)->sensorData().setUserData(userDataCompressed);
1840 (*iter)->sensorData().setOccupancyGrid(groundCellsCompressed, obstacleCellsCompressed, emptyCellsCompressed, cellSize, viewPoint);
1861 std::vector<CameraModel> & models,
1862 std::vector<StereoCameraModel> & stereoModels)
const 1865 if(
_ppDb && signatureId)
1869 std::stringstream query;
1873 query <<
"SELECT calibration " 1875 <<
"WHERE id = " << signatureId
1880 query <<
"SELECT local_transform, fx, fy, cx, cy " 1882 <<
"WHERE id = " << signatureId
1887 query <<
"SELECT local_transform, constant " 1889 <<
"WHERE id = " << signatureId
1896 const void *
data = 0;
1912 if((
unsigned int)dataSize == localTransform.
size()*
sizeof(float) && data)
1914 memcpy(localTransform.
data(), data, dataSize);
1925 if(dataSize > 0 && data)
1929 if(dataSize >=
int(
sizeof(
int)*4))
1931 const int * dataInt = (
const int *)data;
1932 int type = dataInt[3];
1936 int bytesReadTotal = 0;
1937 unsigned int bytesRead = 0;
1938 while(bytesReadTotal < dataSize &&
1939 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
1941 bytesReadTotal+=bytesRead;
1942 models.push_back(model);
1944 UASSERT(bytesReadTotal == dataSize);
1949 int bytesReadTotal = 0;
1950 unsigned int bytesRead = 0;
1951 while(bytesReadTotal < dataSize &&
1952 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
1954 bytesReadTotal+=bytesRead;
1955 stereoModels.push_back(model);
1957 UASSERT(bytesReadTotal == dataSize);
1961 UFATAL(
"Unknown calibration type %d", type);
1966 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1971 float * dataFloat = (
float*)data;
1973 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
1975 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
1976 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1977 int max = cameraCount*(6+localTransform.
size());
1978 for(
int i=0; i<
max; i+=6+localTransform.
size())
1982 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
1988 (
double)dataFloat[i],
1989 (
double)dataFloat[i+1],
1990 (
double)dataFloat[i+2],
1991 (
double)dataFloat[i+3],
1993 models.back().setImageSize(cv::Size(dataFloat[i+4], dataFloat[i+5]));
1994 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
1995 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
2000 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
2002 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
2003 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
2004 int max = cameraCount*(4+localTransform.
size());
2005 for(
int i=0; i<
max; i+=4+localTransform.
size())
2009 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
2015 (
double)dataFloat[i],
2016 (
double)dataFloat[i+1],
2017 (
double)dataFloat[i+2],
2018 (
double)dataFloat[i+3],
2022 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
2024 UDEBUG(
"Loading calibration of a stereo camera");
2025 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
2037 cv::Size(dataFloat[5],dataFloat[6])));
2039 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
2041 UDEBUG(
"Loading calibration of a stereo camera");
2042 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
2057 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
2065 UDEBUG(
"Loading calibration version >= 0.7.0");
2070 UDEBUG(
"fx=%f fyOrBaseline=%f cx=%f cy=%f", fx, fyOrBaseline, cx, cy);
2071 if(fyOrBaseline < 1.0)
2074 stereoModels.push_back(
StereoCameraModel(fx,fx,cx,cy,fyOrBaseline, localTransform));
2078 models.push_back(
CameraModel(fx, fyOrBaseline, cx, cy, localTransform));
2083 UDEBUG(
"Loading calibration version < 0.7.0");
2085 float fx = 1.0f/depthConstant;
2086 float fy = 1.0f/depthConstant;
2089 models.push_back(
CameraModel(fx, fy, cx, cy, localTransform));
2108 if(
_ppDb && signatureId)
2112 std::stringstream query;
2116 query <<
"SELECT scan_info " 2118 <<
"WHERE id = " << signatureId
2129 const void *
data = 0;
2134 float minRange = 0.0f;
2135 float maxRange = 0.0f;
2136 float angleMin = 0.0f;
2137 float angleMax = 0.0f;
2138 float angleInc = 0.0f;
2151 if(dataSize > 0 && data)
2153 float * dataFloat = (
float*)data;
2156 UASSERT(dataSize == (
int)((localTransform.
size()+7)*
sizeof(
float)));
2157 format = (int)dataFloat[0];
2158 minRange = dataFloat[1];
2159 maxRange = dataFloat[2];
2160 angleMin = dataFloat[3];
2161 angleMax = dataFloat[4];
2162 angleInc = dataFloat[5];
2163 maxPts = (int)dataFloat[6];
2164 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
2171 format = (int)dataFloat[2];
2172 memcpy(localTransform.
data(), dataFloat+3, localTransform.
size()*
sizeof(float));
2174 else if(dataSize == (
int)((localTransform.
size()+2)*
sizeof(
float)))
2176 memcpy(localTransform.
data(), dataFloat+2, localTransform.
size()*
sizeof(float));
2180 UFATAL(
"Unexpected size %d for laser scan info!", dataSize);
2186 maxPts = (int)dataFloat[0];
2187 maxRange = dataFloat[1];
2190 if(angleInc != 0.0
f && angleMin < angleMax)
2215 std::string & label,
2218 std::vector<float> & velocity,
2223 if(
_ppDb && signatureId)
2227 std::stringstream query;
2231 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity, gps, env_sensors " 2233 "WHERE id = " << signatureId <<
2238 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity, gps " 2240 "WHERE id = " << signatureId <<
2245 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity " 2247 "WHERE id = " << signatureId <<
2252 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose " 2254 "WHERE id = " << signatureId <<
2259 query <<
"SELECT pose, map_id, weight, label, stamp " 2261 "WHERE id = " << signatureId <<
2266 query <<
"SELECT pose, map_id, weight " 2268 "WHERE id = " << signatureId <<
2275 const void *
data = 0;
2286 if((
unsigned int)dataSize == pose.
size()*
sizeof(float) && data)
2288 memcpy(pose.
data(), data, dataSize);
2303 label =
reinterpret_cast<const char*
>(p);
2311 if((
unsigned int)dataSize == groundTruthPose.
size()*
sizeof(float) && data)
2313 memcpy(groundTruthPose.
data(), data, dataSize);
2322 velocity.resize(6,0);
2325 if((
unsigned int)dataSize == velocity.size()*
sizeof(float) && data)
2327 memcpy(velocity.data(), data, dataSize);
2335 if((
unsigned int)dataSize == 6*
sizeof(
double) && data)
2337 const double * dataDouble = (
const double *)data;
2338 gps =
GPS(dataDouble[0], dataDouble[1], dataDouble[2], dataDouble[3], dataDouble[4], dataDouble[5]);
2347 UASSERT(dataSize%
sizeof(
double)==0 && (dataSize/
sizeof(
double))%3 == 0);
2348 const double * dataDouble = (
const double *)data;
2349 int sensorsNum = (dataSize/
sizeof(double))/3;
2350 for(
int i=0; i<sensorsNum;++i)
2353 sensors.insert(std::make_pair(type,
EnvSensor(type, dataDouble[i*3+1], dataDouble[i*3+2])));
2384 query =
"SELECT n.id " 2386 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Info) " 2391 query =
"SELECT n.id " 2393 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Statistics) " 2424 std::stringstream query;
2426 query <<
"SELECT DISTINCT id " 2430 query <<
"INNER JOIN Link ";
2431 query <<
"ON id = to_id ";
2432 query <<
"WHERE from_id != to_id ";
2433 query <<
"AND weight>-9 ";
2434 if(ignoreIntermediateNodes)
2436 query <<
"AND weight!=-1 ";
2439 else if(ignoreIntermediateNodes)
2441 query <<
"WHERE weight!=-1 ";
2444 if(ignoreBadSignatures)
2446 if(ignoreChildren || ignoreIntermediateNodes)
2456 query <<
" id in (select node_id from Feature) ";
2460 query <<
" id in (select node_id from Map_Node_Word) ";
2464 query <<
"ORDER BY id";
2495 std::stringstream query;
2499 query <<
"SELECT from_id, to_id, type, transform, information_matrix, user_data FROM Link WHERE type!=" <<
Link::kLandmark <<
" ORDER BY from_id, to_id";
2503 query <<
"SELECT from_id, to_id, type, transform, information_matrix, user_data FROM Link ORDER BY from_id, to_id";
2507 query <<
"SELECT from_id, to_id, type, transform, rot_variance, trans_variance, user_data FROM Link ORDER BY from_id, to_id";
2511 query <<
"SELECT from_id, to_id, type, transform, rot_variance, trans_variance FROM Link ORDER BY from_id, to_id";
2515 query <<
"SELECT from_id, to_id, type, transform, variance FROM Link ORDER BY from_id, to_id";
2519 query <<
"SELECT from_id, to_id, type, transform FROM Link ORDER BY from_id, to_id";
2528 const void *
data = 0;
2545 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
2547 memcpy(transform.
data(), data, dataSize);
2555 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", fromId, toId);
2558 if(!ignoreNullLinks || !transform.
isNull())
2560 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
2567 UASSERT(dataSize==36*
sizeof(
double) && data);
2568 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
2574 UASSERT(rotVariance > 0.0 && transVariance>0.0);
2575 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
2576 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
2577 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
2578 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
2579 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
2580 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
2583 cv::Mat userDataCompressed;
2589 if(dataSize>4 && data)
2591 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
2595 links.insert(links.end(), std::make_pair(fromId,
Link(fromId, toId, (
Link::Type)type, transform, informationMatrix, userDataCompressed)));
2601 informationMatrix *= 1.0/variance;
2602 links.insert(links.end(), std::make_pair(fromId,
Link(fromId, toId, (
Link::Type)type, transform, informationMatrix)));
2626 UDEBUG(
"get last %s from table \"%s\"", fieldName.c_str(), tableName.c_str());
2631 std::stringstream query;
2633 query <<
"SELECT COALESCE(MAX(" << fieldName <<
"), " <<
id <<
") " 2634 <<
"FROM " << tableName
2651 UDEBUG(
"No result from the DB for table %s with field %s", tableName.c_str(), fieldName.c_str());
2670 std::stringstream query;
2674 query <<
"SELECT count(word_id) " 2676 <<
"WHERE node_id=" << nodeId <<
";";
2680 query <<
"SELECT count(word_id) " 2681 <<
"FROM Map_Node_Word " 2682 <<
"WHERE node_id=" << nodeId <<
";";
2718 std::stringstream query;
2720 query <<
"SELECT from_id, type, information_matrix, transform, user_data FROM Link WHERE to_id=" << landmarkId <<
"";
2728 std::list<Link> links;
2729 const void *
data = 0;
2740 cv::Mat userDataCompressed;
2741 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
2745 UASSERT(dataSize==36*
sizeof(
double) && data);
2746 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
2751 if(dataSize>4 && data)
2753 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
2760 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
2762 memcpy(transform.
data(), data, dataSize);
2766 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", fromId, landmarkId);
2771 nodes.insert(std::make_pair(fromId,
Link(fromId, landmarkId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed)));
2775 UFATAL(
"Not supported link type %d ! (fromId=%d, toId=%d)",
2776 linkType, fromId, landmarkId);
2798 std::stringstream query;
2799 query <<
"SELECT id FROM Node WHERE label='" << label <<
"'";
2828 std::stringstream query;
2829 query <<
"SELECT id,label FROM Node WHERE label IS NOT NULL";
2843 std::string label =
reinterpret_cast<const char*
>(p);
2846 labels.insert(std::make_pair(
id, label));
2869 std::stringstream query;
2871 query <<
"SELECT weight FROM node WHERE id = " 2898 if(
_ppDb && ids.size())
2905 std::stringstream query;
2906 unsigned int loaded = 0;
2911 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps, env_sensors " 2917 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps " 2923 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity " 2929 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose " 2935 query <<
"SELECT id, map_id, weight, pose, stamp, label " 2941 query <<
"SELECT id, map_id, weight, pose " 2949 for(std::list<int>::const_iterator iter=ids.begin(); iter!=ids.end(); ++iter)
2962 std::vector<float> velocity;
2963 std::vector<double> gps;
2965 const void *
data = 0;
2980 if((
unsigned int)dataSize == pose.
size()*
sizeof(float) && data)
2982 memcpy(pose.
data(), data, dataSize);
2995 label =
reinterpret_cast<const char*
>(p);
3002 if((
unsigned int)dataSize == groundTruthPose.
size()*
sizeof(float) && data)
3004 memcpy(groundTruthPose.
data(), data, dataSize);
3013 velocity.resize(6,0);
3016 if((
unsigned int)dataSize == velocity.size()*
sizeof(float) && data)
3018 memcpy(velocity.data(), data, dataSize);
3027 if((
unsigned int)dataSize == gps.size()*
sizeof(double) && data)
3029 memcpy(gps.data(), data, dataSize);
3038 UASSERT(dataSize%
sizeof(
double)==0 && (dataSize/
sizeof(
double))%3 == 0);
3039 const double * dataDouble = (
const double *)data;
3040 int sensorsNum = (dataSize/
sizeof(double))/3;
3041 for(
int i=0; i<sensorsNum;++i)
3044 sensors.insert(std::make_pair(type,
EnvSensor(type, dataDouble[i*3+1], dataDouble[i*3+2])));
3068 if(velocity.size() == 6)
3070 s->setVelocity(velocity[0], velocity[1], velocity[2], velocity[3], velocity[4], velocity[5]);
3074 s->sensorData().setGPS(
GPS(gps[0], gps[1], gps[2], gps[3], gps[4], gps[5]));
3076 s->sensorData().setEnvSensors(sensors);
3083 UERROR(
"Signature %d not found in database!", *iter);
3098 std::stringstream query2;
3101 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor " 3103 "WHERE node_id = ? ";
3107 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor " 3108 "FROM Map_Node_Word " 3109 "WHERE node_id = ? ";
3113 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z, descriptor_size, descriptor " 3114 "FROM Map_Node_Word " 3115 "WHERE node_id = ? ";
3119 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z " 3120 "FROM Map_Node_Word " 3121 "WHERE node_id = ? ";
3124 query2 <<
" ORDER BY word_id";
3130 float nanFloat = std::numeric_limits<float>::quiet_NaN ();
3132 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
3139 int visualWordId = 0;
3140 int descriptorSize = 0;
3141 const void * descriptor = 0;
3144 std::multimap<int, int> visualWords;
3145 std::vector<cv::KeyPoint> visualWordsKpts;
3146 std::vector<cv::Point3f> visualWords3;
3147 cv::Mat descriptors;
3148 bool allWords3NaN =
true;
3149 cv::Point3f depth(0,0,0);
3197 visualWordsKpts.push_back(kpt);
3198 visualWords.insert(visualWords.end(), std::make_pair(visualWordId, visualWordsKpts.size()-1));
3199 visualWords3.push_back(depth);
3203 allWords3NaN =
false;
3212 if(descriptor && descriptorSize>0 && dRealSize>0)
3215 if(dRealSize == descriptorSize)
3218 d = cv::Mat(1, descriptorSize, CV_8U);
3220 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3223 d = cv::Mat(1, descriptorSize, CV_32F);
3227 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3230 memcpy(d.data, descriptor, dRealSize);
3232 descriptors.push_back(d);
3240 if(visualWords.size()==0)
3242 UDEBUG(
"Empty signature detected! (id=%d)", (*iter)->id());
3248 visualWords3.clear();
3250 (*iter)->setWords(visualWords, visualWordsKpts, visualWords3, descriptors);
3251 ULOGGER_DEBUG(
"Add %d keypoints, %d 3d points and %d descriptors to node %d", (
int)visualWords.size(), allWords3NaN?0:(int)visualWords3.size(), (int)descriptors.rows, (*iter)->id());
3268 for(std::list<Signature*>::iterator iter = nodes.begin(); iter!=nodes.end(); ++iter)
3270 (*iter)->setModified(
false);
3276 std::stringstream query3;
3277 query3 <<
"SELECT calibration " 3284 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
3294 const void *
data = 0;
3297 std::vector<CameraModel> models;
3298 std::vector<StereoCameraModel> stereoModels;
3305 if(dataSize > 0 && data)
3309 if(dataSize >=
int(
sizeof(
int)*4))
3311 const int * dataInt = (
const int *)data;
3312 int type = dataInt[3];
3316 int bytesReadTotal = 0;
3317 unsigned int bytesRead = 0;
3318 while(bytesReadTotal < dataSize &&
3319 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
3321 bytesReadTotal+=bytesRead;
3322 models.push_back(model);
3324 UASSERT(bytesReadTotal == dataSize);
3329 int bytesReadTotal = 0;
3330 unsigned int bytesRead = 0;
3331 while(bytesReadTotal < dataSize &&
3332 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
3334 bytesReadTotal+=bytesRead;
3335 stereoModels.push_back(model);
3337 UASSERT(bytesReadTotal == dataSize);
3341 UFATAL(
"Unknown calibration type %d", type);
3346 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
3351 float * dataFloat = (
float*)data;
3353 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
3355 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
3356 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
3357 int max = cameraCount*(6+localTransform.
size());
3358 for(
int i=0; i<
max; i+=6+localTransform.
size())
3362 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
3368 (
double)dataFloat[i],
3369 (
double)dataFloat[i+1],
3370 (
double)dataFloat[i+2],
3371 (
double)dataFloat[i+3],
3374 cv::Size(dataFloat[i+4], dataFloat[i+5])));
3375 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
3376 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
3381 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
3383 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
3384 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
3385 int max = cameraCount*(4+localTransform.
size());
3386 for(
int i=0; i<
max; i+=4+localTransform.
size())
3390 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
3396 (
double)dataFloat[i],
3397 (
double)dataFloat[i+1],
3398 (
double)dataFloat[i+2],
3399 (
double)dataFloat[i+3],
3403 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
3405 UDEBUG(
"Loading calibration of a stereo camera");
3406 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
3418 cv::Size(dataFloat[5], dataFloat[6])));
3420 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
3422 UDEBUG(
"Loading calibration of a stereo camera");
3423 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
3438 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes, db version=%s)", dataSize,
_version.c_str());
3442 (*iter)->sensorData().setCameraModels(models);
3443 (*iter)->sensorData().setStereoCameraModels(stereoModels);
3463 std::stringstream query3;
3464 query3 <<
"SELECT type, info, data " 3465 "FROM GlobalDescriptor " 3466 "WHERE node_id = ? ";
3471 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
3477 std::vector<GlobalDescriptor> globalDescriptors;
3483 const void *
data = 0;
3492 if(dataSize && data)
3498 if(dataSize && data)
3510 if(!globalDescriptors.empty())
3512 (*iter)->sensorData().setGlobalDescriptors(globalDescriptors);
3513 ULOGGER_DEBUG(
"Add %d global descriptors to node %d", (
int)globalDescriptors.size(), (*iter)->id());
3524 ULOGGER_DEBUG(
"Time load %d global descriptors=%fs", (
int)nodes.size(), timer.
ticks());
3527 if(ids.size() != loaded)
3529 UERROR(
"Some signatures not found in database");
3549 query =
"SELECT n.id " 3551 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Info) " 3556 query =
"SELECT n.id " 3558 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Statistics) " 3588 if(
_ppDb && dictionary)
3595 std::stringstream query;
3596 std::list<VisualWord *> visualWords;
3599 query <<
"SELECT id, descriptor_size, descriptor FROM Word ";
3604 query <<
"WHERE time_enter >= (SELECT MAX(time_enter) FROM Info) ";
3608 query <<
"WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics) ";
3611 query <<
"ORDER BY id;";
3618 int descriptorSize = 0;
3619 const void * descriptor = 0;
3633 if(dRealSize == descriptorSize)
3636 d = cv::Mat(1, descriptorSize, CV_8U);
3638 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3641 d = cv::Mat(1, descriptorSize, CV_32F);
3645 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3648 memcpy(d.data, descriptor, dRealSize);
3653 if(++count % 5000 == 0)
3676 if(
_ppDb && wordIds.size())
3683 std::stringstream query;
3684 std::set<int> loaded;
3687 query <<
"SELECT vw.descriptor_size, vw.descriptor " 3695 const void * descriptor;
3697 unsigned long dRealSizeTotal = 0;
3698 for(std::set<int>::const_iterator iter=wordIds.begin(); iter!=wordIds.end(); ++iter)
3714 if(dRealSize == descriptorSize)
3717 d = cv::Mat(1, descriptorSize, CV_8U);
3719 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3722 d = cv::Mat(1, descriptorSize, CV_32F);
3726 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3729 memcpy(d.data, descriptor, dRealSize);
3730 dRealSizeTotal+=dRealSize;
3737 loaded.insert(loaded.end(), *iter);
3752 UDEBUG(
"Time=%fs (%d words, %lu MB)", timer.
ticks(), (int)vws.size(), dRealSizeTotal/1000000);
3754 if(wordIds.size() != loaded.size())
3756 for(std::set<int>::const_iterator iter = wordIds.begin(); iter!=wordIds.end(); ++iter)
3758 if(loaded.find(*iter) == loaded.end())
3760 UDEBUG(
"Not found word %d", *iter);
3763 UERROR(
"Query (%d) doesn't match loaded words (%d)", wordIds.size(), loaded.size());
3770 std::multimap<int, Link> & links,
3780 std::stringstream query;
3784 query <<
"SELECT to_id, type, transform, information_matrix, user_data FROM Link ";
3788 query <<
"SELECT to_id, type, transform, rot_variance, trans_variance, user_data FROM Link ";
3792 query <<
"SELECT to_id, type, transform, rot_variance, trans_variance FROM Link ";
3796 query <<
"SELECT to_id, type, transform, variance FROM Link ";
3800 query <<
"SELECT to_id, type, transform FROM Link ";
3802 query <<
"WHERE from_id = " << signatureId;
3807 query <<
" AND type = " << typeIn;
3811 query <<
" AND type = 0";
3815 query <<
" AND type > 0";
3823 query <<
" ORDER BY to_id";
3830 const void *
data = 0;
3846 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
3848 memcpy(transform.
data(), data, dataSize);
3856 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", signatureId, toId);
3859 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
3866 UASSERT(dataSize==36*
sizeof(
double) && data);
3867 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
3873 UASSERT(rotVariance > 0.0 && transVariance>0.0);
3874 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
3875 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
3876 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
3877 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
3878 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
3879 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
3882 cv::Mat userDataCompressed;
3888 if(dataSize>4 && data)
3890 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
3894 links.insert(links.end(), std::make_pair(toId,
Link(signatureId, toId, (
Link::Type)type, transform, informationMatrix, userDataCompressed)));
3900 informationMatrix *= 1.0/variance;
3901 links.insert(links.end(), std::make_pair(toId,
Link(signatureId, toId, (
Link::Type)type, transform, informationMatrix)));
3918 if(links.size() == 0)
3933 std::stringstream query;
3937 query <<
"SELECT to_id, type, information_matrix, user_data, transform FROM Link " 3938 <<
"WHERE from_id = ? " 3939 <<
"ORDER BY to_id";
3943 query <<
"SELECT to_id, type, rot_variance, trans_variance, user_data, transform FROM Link " 3944 <<
"WHERE from_id = ? " 3945 <<
"ORDER BY to_id";
3949 query <<
"SELECT to_id, type, rot_variance, trans_variance, transform FROM Link " 3950 <<
"WHERE from_id = ? " 3951 <<
"ORDER BY to_id";
3955 query <<
"SELECT to_id, type, variance, transform FROM Link " 3956 <<
"WHERE from_id = ? " 3957 <<
"ORDER BY to_id";
3961 query <<
"SELECT to_id, type, transform FROM Link " 3962 <<
"WHERE from_id = ? " 3963 <<
"ORDER BY to_id";
3969 for(std::list<Signature*>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter)
3977 std::list<Link> links;
3978 const void *
data = 0;
3989 cv::Mat userDataCompressed;
3990 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
3997 UASSERT(dataSize==36*
sizeof(
double) && data);
3998 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
4004 UASSERT(rotVariance > 0.0 && transVariance>0.0);
4005 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
4006 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
4007 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
4008 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
4009 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
4010 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
4018 if(dataSize>4 && data)
4020 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
4028 informationMatrix *= 1.0/variance;
4035 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
4037 memcpy(transform.
data(), data, dataSize);
4045 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", (*iter)->id(), toId);
4052 (*iter)->addLandmark(
Link((*iter)->id(), toId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed));
4058 links.push_back(
Link((*iter)->id(), toId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed));
4068 UFATAL(
"Not supported link type %d ! (fromId=%d, toId=%d)",
4069 linkType, (*iter)->id(), toId);
4077 (*iter)->addLinks(links);
4082 UDEBUG(
"time=%fs, node=%d, links.size=%d", timer.
ticks(), (*iter)->id(), links.size());
4093 UDEBUG(
"nodes = %d", nodes.size());
4094 if(
_ppDb && nodes.size())
4107 query =
"UPDATE Node SET weight=?, label=?, time_enter = DATETIME('NOW') WHERE id=?;";
4111 query =
"UPDATE Node SET weight=?, label=? WHERE id=?;";
4118 query =
"UPDATE Node SET weight=?, time_enter = DATETIME('NOW') WHERE id=?;";
4122 query =
"UPDATE Node SET weight=? WHERE id=?;";
4128 for(std::list<Signature *>::const_iterator i=nodes.begin(); i!=nodes.end(); ++i)
4175 query =
uFormat(
"DELETE FROM Link WHERE from_id=?;");
4179 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
4181 if((*j)->isLinksModified())
4201 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
4203 if((*j)->isLinksModified())
4206 const std::multimap<int, Link> & links = (*j)->getLinks();
4207 for(std::multimap<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
4222 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
4224 if((*j)->getWordsChanged().size())
4226 const std::map<int, int> & wordsChanged = (*j)->getWordsChanged();
4227 for(std::map<int, int>::const_iterator iter=wordsChanged.begin(); iter!=wordsChanged.end(); ++iter)
4243 if(
_ppDb && words.size() && updateTimestamp)
4252 std::string query =
"UPDATE Word SET time_enter = DATETIME('NOW') WHERE id=?;";
4256 for(std::list<VisualWord *>::const_iterator i=words.begin(); i!=words.end(); ++i)
4284 if(
_ppDb && signatures.size())
4297 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4301 _memoryUsedEstimate -= (*i)->sensorData().imageRaw().total() * (*i)->sensorData().imageRaw().elemSize();
4302 _memoryUsedEstimate -= (*i)->sensorData().depthOrRightRaw().total() * (*i)->sensorData().depthOrRightRaw().elemSize();
4303 _memoryUsedEstimate -= (*i)->sensorData().laserScanRaw().data().total() * (*i)->sensorData().laserScanRaw().data().elemSize();
4317 for(std::list<Signature *>::const_iterator jter=signatures.begin(); jter!=signatures.end(); ++jter)
4320 const std::multimap<int, Link> & links = (*jter)->getLinks();
4321 for(std::multimap<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
4328 const std::map<int, Link> & links = (*jter)->getLandmarks();
4329 for(std::map<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
4346 float nanFloat = std::numeric_limits<float>::quiet_NaN ();
4347 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4349 UASSERT((*i)->getWords().size() == (*i)->getWordsKpts().size());
4350 UASSERT((*i)->getWords3().empty() || (*i)->getWords().size() == (*i)->getWords3().size());
4351 UASSERT((*i)->getWordsDescriptors().empty() || (int)(*i)->getWords().size() == (*i)->getWordsDescriptors().rows);
4353 for(std::multimap<int, int>::const_iterator w=(*i)->getWords().begin(); w!=(*i)->getWords().end(); ++w)
4355 cv::Point3f pt(nanFloat,nanFloat,nanFloat);
4356 if(!(*i)->getWords3().empty())
4358 pt = (*i)->getWords3()[w->second];
4362 if(!(*i)->getWordsDescriptors().empty())
4364 descriptor = (*i)->getWordsDescriptors().row(w->second);
4367 stepKeypoint(ppStmt, (*i)->id(), w->first, (*i)->getWordsKpts()[w->second], pt, descriptor);
4382 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4384 for(
size_t d=0;
d<(*i)->sensorData().globalDescriptors().size(); ++
d)
4402 UDEBUG(
"Saving %d images", signatures.size());
4404 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4406 if(!(*i)->sensorData().imageCompressed().empty() ||
4407 !(*i)->sensorData().depthOrRightCompressed().empty() ||
4408 !(*i)->sensorData().laserScanCompressed().isEmpty() ||
4409 !(*i)->sensorData().userDataCompressed().empty() ||
4410 !(*i)->sensorData().cameraModels().empty() ||
4411 !(*i)->sensorData().stereoCameraModels().empty())
4413 UASSERT((*i)->id() == (*i)->sensorData().id());
4429 UDEBUG(
"Saving %d images", signatures.size());
4431 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4433 if(!(*i)->sensorData().imageCompressed().empty())
4435 stepImage(ppStmt, (*i)->id(), (*i)->sensorData().imageCompressed());
4448 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4451 if(!(*i)->sensorData().depthOrRightCompressed().empty() || !(*i)->sensorData().laserScanCompressed().isEmpty())
4453 UASSERT((*i)->id() == (*i)->sensorData().id());
4468 UDEBUG(
"visualWords size=%d", words.size());
4481 query = std::string(
"INSERT INTO Word(id, descriptor_size, descriptor) VALUES(?,?,?);");
4484 for(std::list<VisualWord *>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
4581 const cv::Mat & ground,
4582 const cv::Mat & obstacles,
4583 const cv::Mat & empty,
4585 const cv::Point3f & viewpoint)
const 4620 const cv::Mat & image)
const 4695 if(param.size() && statistics.
refImageId()>0)
4700 query =
"INSERT INTO Statistics(id, stamp, data, wm_state) values(?,?,?,?);";
4704 query =
"INSERT INTO Statistics(id, stamp, data) values(?,?,?);";
4715 cv::Mat compressedParam;
4728 cv::Mat compressedWmState;
4731 if(saveWmState && !statistics.
wmState().empty())
4773 query =
uFormat(
"UPDATE Admin SET preview_image=? WHERE version='%s';",
_version.c_str());
4778 cv::Mat compressedImage;
4787 if(image.rows == 1 && image.type() == CV_8UC1)
4790 compressedImage = image;
4821 std::stringstream query;
4823 query <<
"SELECT preview_image " 4825 <<
"WHERE version='" <<
_version.c_str()
4836 const void *
data = 0;
4843 if(dataSize>0 && data)
4847 UDEBUG(
"Image=%dx%d", image.cols, image.rows);
4864 UDEBUG(
"poses=%d lastlocalizationPose=%s", (
int)poses.size(), lastlocalizationPose.
prettyPrint().c_str());
4874 query =
uFormat(
"UPDATE Admin SET opt_ids=?, opt_poses=?, opt_last_localization=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
4881 cv::Mat compressedIds;
4882 cv::Mat compressedPoses;
4892 std::vector<int> serializedIds(poses.size());
4893 std::vector<float> serializedPoses(poses.size()*12);
4895 for(std::map<int, Transform>::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
4897 serializedIds[i] = iter->first;
4898 memcpy(serializedPoses.data()+(12*i), iter->second.data(), 12*
sizeof(float));
4902 compressedIds =
compressData2(cv::Mat(1,serializedIds.size(), CV_32SC1, serializedIds.data()));
4903 compressedPoses =
compressData2(cv::Mat(1,serializedPoses.size(), CV_32FC1, serializedPoses.data()));
4911 if(lastlocalizationPose.
isNull())
4938 std::map<int, Transform> poses;
4945 std::stringstream query;
4947 query <<
"SELECT opt_ids, opt_poses, opt_last_localization " 4949 <<
"WHERE version='" <<
_version.c_str()
4960 const void *
data = 0;
4965 cv::Mat serializedIds;
4968 if(dataSize>0 && data)
4970 serializedIds =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4971 UDEBUG(
"serializedIds=%d", serializedIds.cols);
4976 if(dataSize>0 && data)
4978 cv::Mat serializedPoses =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4979 UDEBUG(
"serializedPoses=%d", serializedPoses.cols);
4981 UASSERT(serializedIds.cols == serializedPoses.cols/12);
4982 UASSERT(serializedPoses.type() == CV_32FC1);
4983 UASSERT(serializedIds.type() == CV_32SC1);
4984 for(
int i=0; i<serializedIds.cols; ++i)
4986 Transform t(serializedPoses.at<
float>(i*12), serializedPoses.at<
float>(i*12+1), serializedPoses.at<
float>(i*12+2), serializedPoses.at<
float>(i*12+3),
4987 serializedPoses.at<
float>(i*12+4), serializedPoses.at<
float>(i*12+5), serializedPoses.at<
float>(i*12+6), serializedPoses.at<
float>(i*12+7),
4988 serializedPoses.at<
float>(i*12+8), serializedPoses.at<
float>(i*12+9), serializedPoses.at<
float>(i*12+10), serializedPoses.at<
float>(i*12+11));
4989 poses.insert(std::make_pair(serializedIds.at<
int>(i), t));
4990 UDEBUG(
"Optimized pose %d: %s", serializedIds.at<
int>(i), t.
prettyPrint().c_str());
4996 if(lastlocalizationPose)
4998 if((
unsigned int)dataSize == lastlocalizationPose->
size()*
sizeof(float) && data)
5000 memcpy(lastlocalizationPose->
data(), data, dataSize);
5030 query =
uFormat(
"UPDATE Admin SET opt_map=?, opt_map_x_min=?, opt_map_y_min=?, opt_map_resolution=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
5037 cv::Mat compressedMap;
5080 std::stringstream query;
5082 query <<
"SELECT opt_map, opt_map_x_min, opt_map_y_min, opt_map_resolution " 5084 <<
"WHERE version='" <<
_version.c_str()
5095 const void *
data = 0;
5102 if(dataSize>0 && data)
5104 map =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5105 UDEBUG(
"map=%d/%d", map.cols, map.rows);
5113 UDEBUG(
"cellSize=%f", cellSize);
5129 const cv::Mat & cloud,
5130 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
5131 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
5132 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
5134 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
5136 const cv::Mat & textures)
const 5148 query =
uFormat(
"UPDATE Admin SET opt_cloud=?, opt_polygons_size=?, opt_polygons=?, opt_tex_coords=?, opt_tex_materials=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
5155 for(
int i=1; i<=5; ++i)
5170 cv::Mat compressedCloud;
5171 if(cloud.rows == 1 && cloud.type() == CV_8UC1)
5174 compressedCloud = cloud;
5178 UDEBUG(
"Cloud points=%d", cloud.cols);
5181 UDEBUG(
"Cloud compressed bytes=%d", compressedCloud.cols);
5186 cv::Mat compressedPolygons;
5187 cv::Mat compressedTexCoords;
5188 cv::Mat compressedTextures;
5190 if(polygons.empty())
5207 std::vector<int> serializedPolygons;
5208 std::vector<float> serializedTexCoords;
5209 int polygonSize = 0;
5210 int totalPolygonIndices = 0;
5211 UASSERT(texCoords.empty() || polygons.size() == texCoords.size());
5212 for(
unsigned int t=0; t<polygons.size(); ++t)
5214 UDEBUG(
"t=%d, polygons=%d", t, (
int)polygons[t].size());
5215 unsigned int materialPolygonIndices = 0;
5216 for(
unsigned int p=0; p<polygons[t].size(); ++p)
5218 if(polygonSize == 0)
5220 UASSERT(polygons[t][p].size());
5221 polygonSize = polygons[t][p].size();
5225 UASSERT(polygonSize == (
int)polygons[t][p].size());
5228 materialPolygonIndices += polygons[t][p].size();
5230 totalPolygonIndices += materialPolygonIndices;
5232 if(!texCoords.empty())
5234 UASSERT(materialPolygonIndices == texCoords[t].size());
5237 UASSERT(totalPolygonIndices>0);
5238 serializedPolygons.resize(totalPolygonIndices+polygons.size());
5239 if(!texCoords.empty())
5241 serializedTexCoords.resize(totalPolygonIndices*2+polygons.size());
5246 for(
unsigned int t=0; t<polygons.size(); ++t)
5248 serializedPolygons[oi++] = polygons[t].size();
5249 if(!texCoords.empty())
5251 serializedTexCoords[ci++] = texCoords[t].size();
5253 for(
unsigned int p=0; p<polygons[t].size(); ++p)
5255 int texIndex = p*polygonSize;
5256 for(
unsigned int i=0; i<polygons[t][p].size(); ++i)
5258 serializedPolygons[oi++] = polygons[t][p][i];
5260 if(!texCoords.empty())
5262 serializedTexCoords[ci++] = texCoords[t][texIndex+i][0];
5263 serializedTexCoords[ci++] = texCoords[t][texIndex+i][1];
5269 UDEBUG(
"serializedPolygons=%d", (
int)serializedPolygons.size());
5270 compressedPolygons =
compressData2(cv::Mat(1,serializedPolygons.size(), CV_32SC1, serializedPolygons.data()));
5280 if(texCoords.empty())
5291 UDEBUG(
"serializedTexCoords=%d", (
int)serializedTexCoords.size());
5292 compressedTexCoords =
compressData2(cv::Mat(1,serializedTexCoords.size(), CV_32FC1, serializedTexCoords.data()));
5296 UASSERT(!textures.empty() && textures.cols % textures.rows == 0 && textures.cols/textures.rows == (int)texCoords.size());
5297 if(textures.rows == 1 && textures.type() == CV_8UC1)
5300 compressedTextures = textures;
5325 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons,
5326 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
5327 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
5329 std::vector<std::vector<Eigen::Vector2f> > * texCoords,
5331 cv::Mat * textures)
const 5341 std::stringstream query;
5343 query <<
"SELECT opt_cloud, opt_polygons_size, opt_polygons, opt_tex_coords, opt_tex_materials " 5345 <<
"WHERE version='" <<
_version.c_str()
5356 const void *
data = 0;
5363 if(dataSize>0 && data)
5365 cloud =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5367 UDEBUG(
"Cloud=%d points", cloud.cols);
5371 UDEBUG(
"polygonSize=%d", polygonSize);
5376 if(dataSize>0 && data)
5381 cv::Mat serializedPolygons =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5382 UDEBUG(
"serializedPolygons=%d", serializedPolygons.cols);
5383 UASSERT(serializedPolygons.total());
5384 for(
int t=0; t<serializedPolygons.cols; ++t)
5386 UASSERT(serializedPolygons.at<
int>(t) > 0);
5387 std::vector<std::vector<RTABMAP_PCL_INDEX> > materialPolygons(serializedPolygons.at<
int>(t), std::vector<RTABMAP_PCL_INDEX>(polygonSize));
5389 UASSERT(t < serializedPolygons.cols);
5390 UDEBUG(
"materialPolygons=%d", (
int)materialPolygons.size());
5391 for(
int p=0; p<(int)materialPolygons.size(); ++p)
5393 for(
int i=0; i<polygonSize; ++i)
5395 materialPolygons[p][i] = serializedPolygons.at<
int>(t + p*polygonSize + i);
5398 t+=materialPolygons.size()*polygonSize;
5399 polygons->push_back(materialPolygons);
5406 if(dataSize>0 && data)
5410 cv::Mat serializedTexCoords =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5411 UDEBUG(
"serializedTexCoords=%d", serializedTexCoords.cols);
5412 UASSERT(serializedTexCoords.total());
5413 for(
int t=0; t<serializedTexCoords.cols; ++t)
5415 UASSERT(
int(serializedTexCoords.at<
float>(t)) > 0);
5416 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 5417 std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > materialtexCoords(
int(serializedTexCoords.at<
float>(t)));
5419 std::vector<Eigen::Vector2f> materialtexCoords(
int(serializedTexCoords.at<
float>(t)));
5422 UASSERT(t < serializedTexCoords.cols);
5423 UDEBUG(
"materialtexCoords=%d", (
int)materialtexCoords.size());
5424 for(
int p=0; p<(int)materialtexCoords.size(); ++p)
5426 materialtexCoords[p][0] = serializedTexCoords.at<
float>(t + p*2);
5427 materialtexCoords[p][1] = serializedTexCoords.at<
float>(t + p*2 + 1);
5429 t+=materialtexCoords.size()*2;
5430 texCoords->push_back(materialtexCoords);
5437 if(dataSize>0 && data)
5441 *textures =
uncompressImage(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5442 UDEBUG(
"textures=%dx%d", textures->cols, textures->rows);
5465 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps, env_sensors) VALUES(?,?,?,?,?,?,?,?,?,?);";
5469 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps) VALUES(?,?,?,?,?,?,?,?,?);";
5473 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity) VALUES(?,?,?,?,?,?,?,?);";
5477 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose) VALUES(?,?,?,?,?,?,?);";
5481 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label) VALUES(?,?,?,?,?,?);";
5485 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, user_data) VALUES(?,?,?,?,?,?,?);";
5489 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label) VALUES(?,?,?,?,?,?);";
5491 return "INSERT INTO Node(id, map_id, weight, pose) VALUES(?,?,?,?);";
5529 std::vector<double> gps;
5530 std::vector<double> envSensors;
5577 if(sensors.size() == 0)
5585 envSensors.resize(sensors.size()*3,0.0);
5587 for(std::map<EnvSensor::Type, EnvSensor>::const_iterator iter=sensors.begin(); iter!=sensors.end(); ++iter, j+=3)
5589 envSensors[j] = (double)iter->second.type();
5590 envSensors[j+1] = iter->second.value();
5591 envSensors[j+2] = iter->second.stamp();
5625 return "INSERT INTO Image(id, data) VALUES(?,?);";
5629 const cv::Mat & imageBytes)
const 5632 UDEBUG(
"Save image %d (size=%d)",
id, (
int)imageBytes.cols);
5644 if(!imageBytes.empty())
5667 return "INSERT INTO Depth(id, data, fx, fy, cx, cy, local_transform, data2d, data2d_max_pts) VALUES(?,?,?,?,?,?,?,?,?);";
5671 return "INSERT INTO Depth(id, data, fx, fy, cx, cy, local_transform, data2d) VALUES(?,?,?,?,?,?,?,?);";
5675 return "INSERT INTO Depth(id, data, constant, local_transform, data2d) VALUES(?,?,?,?,?);";
5681 UDEBUG(
"Save depth %d (size=%d) depth2d = %d",
5706 float fx=0, fyOrBaseline=0, cx=0, cy=0;
5711 uFormat(
"Database version %s doesn't support multi-camera!",
_version.c_str()).c_str());
5717 localTransform = sensorData.
cameraModels()[0].localTransform();
5722 uFormat(
"Database version %s doesn't support multi-camera!",
_version.c_str()).c_str());
5778 return "UPDATE Depth SET data=? WHERE id=?;";
5782 return "UPDATE Data SET depth=? WHERE id=?;";
5795 cv::Mat imageCompressed;
5796 if(!image.empty() && (image.type()!=CV_8UC1 || image.rows > 1))
5803 imageCompressed = image;
5805 if(!imageCompressed.empty())
5832 return "UPDATE Data SET scan_info=?, scan=? WHERE id=?;";
5836 return "UPDATE Data SET scan_max_pts=?, scan_max_range=?, scan=? WHERE id=?;";
5840 return "UPDATE Data SET scan_max_pts=? scan=? WHERE id=?;";
5853 std::vector<float> scanInfo;
5865 scanInfo.resize(7 +
Transform().size());
5866 scanInfo[0] = scan.
format();
5874 memcpy(scanInfo.data()+7, localTransform.
data(), localTransform.
size()*
sizeof(float));
5878 scanInfo.resize(3 +
Transform().size());
5881 scanInfo[2] = scan.
format();
5883 memcpy(scanInfo.data()+3, localTransform.
data(), localTransform.
size()*
sizeof(float));
5888 scanInfo.resize(2 +
Transform().size());
5892 memcpy(scanInfo.data()+2, localTransform.
data(), localTransform.
size()*
sizeof(float));
5922 cv::Mat scanCompressed;
5925 scanCompressed = scan.
data();
5931 if(!scanCompressed.empty())
5958 return "INSERT INTO Data(id, image, depth, calibration, scan_info, scan, user_data, ground_cells, obstacle_cells, empty_cells, cell_size, view_point_x, view_point_y, view_point_z) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
5962 return "INSERT INTO Data(id, image, depth, calibration, scan_info, scan, user_data, ground_cells, obstacle_cells, cell_size, view_point_x, view_point_y, view_point_z) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);";
5966 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan_max_range, scan, user_data) VALUES(?,?,?,?,?,?,?,?);";
5970 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan, user_data) VALUES(?,?,?,?,?,?,?);";
5974 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan) VALUES(?,?,?,?,?,?);";
5981 UDEBUG(
"Save sensor data %d (image=%d depth=%d) depth2d = %d",
6021 std::vector<unsigned char> calibrationData;
6022 std::vector<float> calibration;
6029 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
6032 std::vector<unsigned char>
data = sensorData.
cameraModels()[i].serialize();
6034 unsigned int oldSize = calibrationData.size();
6035 calibrationData.resize(calibrationData.size() + data.size());
6036 memcpy(calibrationData.data()+oldSize, data.data(), data.size());
6042 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
6046 calibration[i*(6+localTransform.size())] = sensorData.
cameraModels()[i].fx();
6047 calibration[i*(6+localTransform.size())+1] = sensorData.
cameraModels()[i].fy();
6048 calibration[i*(6+localTransform.size())+2] = sensorData.
cameraModels()[i].cx();
6049 calibration[i*(6+localTransform.size())+3] = sensorData.
cameraModels()[i].cy();
6050 calibration[i*(6+localTransform.size())+4] = sensorData.
cameraModels()[i].imageWidth();
6051 calibration[i*(6+localTransform.size())+5] = sensorData.
cameraModels()[i].imageHeight();
6052 memcpy(calibration.data()+i*(6+localTransform.size())+6, localTransform.data(), localTransform.size()*
sizeof(float));
6058 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
6062 calibration[i*(4+localTransform.size())] = sensorData.
cameraModels()[i].fx();
6063 calibration[i*(4+localTransform.size())+1] = sensorData.
cameraModels()[i].fy();
6064 calibration[i*(4+localTransform.size())+2] = sensorData.
cameraModels()[i].cx();
6065 calibration[i*(4+localTransform.size())+3] = sensorData.
cameraModels()[i].cy();
6066 memcpy(calibration.data()+i*(4+localTransform.size())+4, localTransform.data(), localTransform.size()*
sizeof(float));
6079 unsigned int oldSize = calibrationData.size();
6080 calibrationData.resize(calibrationData.size() + data.size());
6081 memcpy(calibrationData.data()+oldSize, data.data(), data.size());
6088 calibration.resize(7+localTransform.size());
6096 memcpy(calibration.data()+7, localTransform.data(), localTransform.size()*
sizeof(float));
6100 if(calibrationData.size())
6104 else if(calibration.size())
6114 std::vector<float> scanInfo;
6126 scanInfo.resize(7 +
Transform().size());
6135 memcpy(scanInfo.data()+7, localTransform.
data(), localTransform.
size()*
sizeof(float));
6139 scanInfo.resize(3 +
Transform().size());
6144 memcpy(scanInfo.data()+3, localTransform.
data(), localTransform.
size()*
sizeof(float));
6149 scanInfo.resize(2 +
Transform().size());
6153 memcpy(scanInfo.data()+2, localTransform.
data(), localTransform.
size()*
sizeof(float));
6274 return "UPDATE Link SET type=?, information_matrix=?, transform=?, user_data=? WHERE from_id=? AND to_id = ?;";
6278 return "UPDATE Link SET type=?, rot_variance=?, trans_variance=?, transform=?, user_data=? WHERE from_id=? AND to_id = ?;";
6282 return "UPDATE Link SET type=?, rot_variance=?, trans_variance=?, transform=? WHERE from_id=? AND to_id = ?;";
6286 return "UPDATE Link SET type=?, variance=?, transform=? WHERE from_id=? AND to_id = ?;";
6290 return "UPDATE Link SET type=?, transform=? WHERE from_id=? AND to_id = ?;";
6298 return "INSERT INTO Link(type, information_matrix, transform, user_data, from_id, to_id) VALUES(?,?,?,?,?,?);";
6302 return "INSERT INTO Link(type, rot_variance, trans_variance, transform, user_data, from_id, to_id) VALUES(?,?,?,?,?,?,?);";
6306 return "INSERT INTO Link(type, rot_variance, trans_variance, transform, from_id, to_id) VALUES(?,?,?,?,?,?);";
6310 return "INSERT INTO Link(type, variance, transform, from_id, to_id) VALUES(?,?,?,?,?);";
6314 return "INSERT INTO Link(type, transform, from_id, to_id) VALUES(?,?,?,?);";
6319 const Link & link)
const 6325 UDEBUG(
"Save link from %d to %d, type=%d", link.
from(), link.
to(), link.
type());
6330 UDEBUG(
"Virtual link ignored....");
6391 return "UPDATE Feature SET word_id = ? WHERE word_id = ? AND node_id = ?;";
6395 return "UPDATE Map_Node_Word SET word_id = ? WHERE word_id = ? AND node_id = ?;";
6424 return "INSERT INTO Feature(node_id, word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);";
6428 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);";
6432 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z, descriptor_size, descriptor) VALUES(?,?,?,?,?,?,?,?,?,?,?,?);";
6434 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z) VALUES(?,?,?,?,?,?,?,?,?,?);";
6439 const cv::KeyPoint & kp,
6440 const cv::Point3f & pt,
6441 const cv::Mat & descriptor)
const 6507 UASSERT(descriptor.empty() || descriptor.type() == CV_32F || descriptor.type() == CV_8U);
6508 if(descriptor.empty())
6514 if(descriptor.type() == CV_32F)
6538 return "INSERT INTO GlobalDescriptor(node_id, type, info, data) VALUES(?,?,?,?);";
6561 if(infoBytes.empty())
6573 if(infoBytes.empty())
6595 return "UPDATE Data SET ground_cells=?, obstacle_cells=?, empty_cells=?, cell_size=?, view_point_x=?, view_point_y=?, view_point_z=? WHERE id=?;";
6597 return "UPDATE Data SET ground_cells=?, obstacle_cells=?, cell_size=?, view_point_x=?, view_point_y=?, view_point_z=? WHERE id=?;";
6601 const cv::Mat & ground,
6602 const cv::Mat & obstacles,
6603 const cv::Mat & empty,
6605 const cv::Point3f & viewpoint)
const 6608 UASSERT(ground.empty() || ground.type() == CV_8UC1);
6609 UASSERT(obstacles.empty() || obstacles.type() == CV_8UC1);
6610 UASSERT(empty.empty() || empty.type() == CV_8UC1);
6611 UDEBUG(
"Update occupancy grid %d: ground=%d obstacles=%d empty=%d cell=%f viewpoint=(%f,%f,%f)",
6642 if(obstacles.empty())
const cv::Mat & infMatrix() const
#define sqlite3_memory_used
virtual void addLinkQuery(const Link &link) const
bool RTABMAP_EXP isFinite(const cv::Point3f &pt)
void setTempStore(int tempStore)
const std::vector< int > & wmState() const
const std::string & getTargetVersion() const
const double & error() const
cv::Mat RTABMAP_EXP uncompressData(const cv::Mat &bytes)
const cv::Mat & gridObstacleCellsCompressed() const
virtual ParametersMap getLastParametersQuery() const
virtual int getTotalNodesSizeQuery() const
std::string queryStepSensorData() const
double rotVariance(bool minimum=true) const
const double & stamp() const
const Transform & getGroundTruthPose() const
void stepKeypoint(sqlite3_stmt *ppStmt, int nodeID, int wordId, const cv::KeyPoint &kp, const cv::Point3f &pt, const cv::Mat &descriptor) const
virtual long getDepthImagesMemoryUsedQuery() const
const std::vector< float > & getVelocity() const
virtual std::map< int, Transform > loadOptimizedPosesQuery(Transform *lastlocalizationPose=0) const
const LaserScan & laserScanCompressed() const
virtual void getAllNodeIdsQuery(std::set< int > &ids, bool ignoreChildren, bool ignoreBadSignatures, bool ignoreIntermediateNodes) const
virtual void loadLinksQuery(int signatureId, std::multimap< int, Link > &links, Link::Type type=Link::kUndef) const
#define ULOGGER_INFO(...)
#define sqlite3_threadsafe
int uStrNumCmp(const std::string &a, const std::string &b)
const cv::Mat & gridGroundCellsCompressed() const
int loadOrSaveDb(sqlite3 *pInMemory, const std::string &fileName, int isSave) const
#define sqlite3_backup_finish
bool UTILITE_EXP uStr2Bool(const char *str)
virtual void addStatisticsQuery(const Statistics &statistics, bool saveWmState) const
void setCacheSize(unsigned int cacheSize)
#define sqlite3_backup_init
virtual long getFeaturesMemoryUsedQuery() const
unsigned int deserialize(const std::vector< unsigned char > &data)
static int erase(const std::string &filePath)
virtual long getUserDataMemoryUsedQuery() const
const cv::Mat & userDataCompressed() const
const std::vector< StereoCameraModel > & stereoCameraModels() const
const cv::Mat & data() const
struct sqlite3_stmt sqlite3_stmt
std::map< std::string, std::string > ParametersMap
virtual std::map< std::string, float > getStatisticsQuery(int nodeId, double &stamp, std::vector< int > *wmState) const
virtual void savePreviewImageQuery(const cv::Mat &image) const
virtual int getTotalDictionarySizeQuery() const
const cv::Mat info() const
const std::string & getLabel() const
virtual void loadWordsQuery(const std::set< int > &wordIds, std::list< VisualWord *> &vws) const
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
#define sqlite3_column_int64
virtual long getWordsMemoryUsedQuery() const
virtual long getNodesMemoryUsedQuery() const
virtual void getInvertedIndexNiQuery(int signatureId, int &ni) const
void setJournalMode(int journalMode)
float gridCellSize() const
const std::map< std::string, float > & data() const
virtual void getLastNodeIdsQuery(std::set< int > &ids) const
virtual void save2DMapQuery(const cv::Mat &map, float xMin, float yMin, float cellSize) const
#define sqlite3_column_int
bool uIsFinite(const T &value)
bool openConnection(const std::string &url, bool overwritten=false)
virtual long getImagesMemoryUsedQuery() const
void stepScanUpdate(sqlite3_stmt *ppStmt, int nodeId, const LaserScan &image) const
#define UASSERT(condition)
void setLastWordId(int id)
#define sqlite3_column_text
const double & altitude() const
const double & bearing() const
#define sqlite3_bind_zeroblob
virtual void updateOccupancyGridQuery(int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewpoint) const
static std::string serializeData(const std::map< std::string, float > &data)
#define SQLITE_OPEN_CREATE
const std::vector< CameraModel > & cameraModels() const
virtual void updateLinkQuery(const Link &link) const
virtual cv::Mat load2DMapQuery(float &xMin, float &yMin, float &cellSize) const
#define ULOGGER_DEBUG(...)
virtual void getNodesObservingLandmarkQuery(int landmarkId, std::map< int, Link > &nodes) const
static ParametersMap deserialize(const std::string ¶meters)
virtual std::map< int, std::vector< int > > getAllStatisticsWmStatesQuery() const
#define UASSERT_MSG(condition, msg_str)
void stepImage(sqlite3_stmt *ppStmt, int id, const cv::Mat &imageBytes) const
#define SQLITE_OPEN_READWRITE
void closeConnection(bool save=true, const std::string &outputUrl="")
std::string UTILITE_EXP uHex2Str(const std::string &hex)
virtual ~DBDriverSqlite3()
std::string queryStepGlobalDescriptor() const
#define sqlite3_bind_double
virtual void updateDepthImageQuery(int nodeId, const cv::Mat &image) const
virtual void loadSignaturesQuery(const std::list< int > &ids, std::list< Signature *> &signatures) const
std::vector< unsigned char > RTABMAP_EXP compressData(const cv::Mat &data)
const EnvSensors & envSensors() const
virtual void executeNoResultQuery(const std::string &sql) const
void stepDepthUpdate(sqlite3_stmt *ppStmt, int nodeId, const cv::Mat &imageCompressed) const
virtual void getLastIdQuery(const std::string &tableName, int &id, const std::string &fieldName="id") const
std::string queryStepDepth() const
virtual long getStatisticsMemoryUsedQuery() const
#define sqlite3_bind_null
std::string queryStepWordsChanged() const
unsigned long _memoryUsedEstimate
cv::Mat RTABMAP_EXP compressData2(const cv::Mat &data)
virtual cv::Mat loadPreviewImageQuery() const
std::string queryStepNode() const
virtual bool getCalibrationQuery(int signatureId, std::vector< CameraModel > &models, std::vector< StereoCameraModel > &stereoModels) const
#define sqlite3_column_type
#define sqlite3_bind_blob
virtual void loadNodeDataQuery(std::list< Signature *> &signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const
#define sqlite3_column_double
std::string queryStepDepthUpdate() const
virtual void loadLastNodesQuery(std::list< Signature *> &signatures) const
void stepGlobalDescriptor(sqlite3_stmt *ppStmt, int nodeId, const GlobalDescriptor &descriptor) const
const cv::Mat & depthOrRightCompressed() const
DBDriverSqlite3(const ParametersMap ¶meters=ParametersMap())
virtual std::map< int, std::pair< std::map< std::string, float >, double > > getAllStatisticsQuery() const
std::string queryStepImage() const
virtual void disconnectDatabaseQuery(bool save=true, const std::string &outputUrl="")
const cv::Mat data() const
virtual long getGridsMemoryUsedQuery() const
virtual bool isConnectedQuery() const
#define sqlite3_prepare_v2
virtual void getWeightQuery(int signatureId, int &weight) const
const cv::Point3f & gridViewPoint() const
#define sqlite3_next_stmt
void getLastWordId(int &id) const
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
SensorData & sensorData()
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
void setDbInMemory(bool dbInMemory)
cv::Mat RTABMAP_EXP compressString(const std::string &str)
void stepLink(sqlite3_stmt *ppStmt, const Link &link) const
const double & longitude() const
virtual void getAllLinksQuery(std::multimap< int, Link > &links, bool ignoreNullLinks, bool withLandmarks) const
const cv::Mat & userDataCompressed() const
bool isCompressed() const
virtual void parseParameters(const ParametersMap ¶meters)
std::string queryStepOccupancyGridUpdate() const
const Transform & getPose() const
virtual int getLastDictionarySizeQuery() const
std::string RTABMAP_EXP uncompressString(const cv::Mat &bytes)
virtual bool getDatabaseVersionQuery(std::string &version) const
unsigned int deserialize(const std::vector< unsigned char > &data)
virtual unsigned long getMemoryUsedQuery() const
virtual long getLaserScansMemoryUsedQuery() const
std::string queryStepLink() const
virtual void saveQuery(const std::list< Signature *> &signatures)
virtual void saveOptimizedPosesQuery(const std::map< int, Transform > &optimizedPoses, const Transform &lastlocalizationPose) const
double transVariance(bool minimum=true) const
void stepNode(sqlite3_stmt *ppStmt, const Signature *s) const
static int rename(const std::string &oldFilePath, const std::string &newFilePath)
void stepDepth(sqlite3_stmt *ppStmt, const SensorData &sensorData) const
std::string getDatabaseVersion() const
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
void setSynchronous(int synchronous)
const double & latitude() const
virtual bool connectDatabaseQuery(const std::string &url, bool overwritten=false)
virtual int getLastNodesSizeQuery() const
#define sqlite3_column_bytes
void stepWordsChanged(sqlite3_stmt *ppStmt, int signatureId, int oldWordId, int newWordId) const
std::map< EnvSensor::Type, EnvSensor > EnvSensors
float angleIncrement() const
#define sqlite3_backup_step
void setSaved(bool saved)
static std::map< std::string, float > deserializeData(const std::string &data)
const Transform & transform() const
void stepOccupancyGridUpdate(sqlite3_stmt *ppStmt, int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewpoint) const
void join(bool killFirst=false)
virtual bool getLaserScanInfoQuery(int signatureId, LaserScan &info) const
#define sqlite3_bind_text
virtual void addWord(VisualWord *vw)
std::string queryStepLinkUpdate() const
#define ULOGGER_ERROR(...)
virtual long getLinksMemoryUsedQuery() const
const cv::Mat & gridEmptyCellsCompressed() const
virtual void loadQuery(VWDictionary *dictionary, bool lastStateOnly=true) const
void stepSensorData(sqlite3_stmt *ppStmt, const SensorData &sensorData) const
std::string UTILITE_EXP uFormat(const char *fmt,...)
std::string UTILITE_EXP uNumber2Str(unsigned int number)
virtual long getCalibrationsMemoryUsedQuery() const
virtual void parseParameters(const ParametersMap ¶meters)
const cv::Mat & imageCompressed() const
virtual void updateQuery(const std::list< Signature *> &signatures, bool updateTimestamp) const
Transform localTransform() const
std::string queryStepKeypoint() const
const cv::Mat & getDescriptor() const
std::string queryStepScanUpdate() const
void emptyTrashes(bool async=false)
const std::string & getUrl() const
virtual void getAllLabelsQuery(std::map< int, std::string > &labels) const
cv::Mat RTABMAP_EXP uncompressImage(const cv::Mat &bytes)
virtual void getNodeIdByLabelQuery(const std::string &label, int &id) const
#define sqlite3_column_blob
void updateLaserScanQuery(int nodeId, const LaserScan &scan) const
cv::Mat RTABMAP_EXP compressImage2(const cv::Mat &image, const std::string &format=".png")