mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-07 02:07:45 +08:00
Fixed loadDatabase and backup services fatal error when database is read-only
This commit is contained in:
@@ -908,8 +908,7 @@ CoreWrapper::~CoreWrapper()
|
||||
saveDatabase = false;
|
||||
}
|
||||
}
|
||||
|
||||
rtabmap_.close();
|
||||
rtabmap_.close(saveDatabase);
|
||||
printf("rtabmap: Saving database/long-term memory...done! (located at %s, %ld MB)\n", databasePath_.c_str(), UFile::length(databasePath_)/(1024*1024));
|
||||
|
||||
delete interOdomSync_;
|
||||
@@ -2970,18 +2969,27 @@ bool CoreWrapper::loadDatabaseCallback(rtabmap_msgs::LoadDatabase::Request& req,
|
||||
|
||||
// Close old database
|
||||
NODELET_INFO("LoadDatabase: Saving current map (%s)...", databasePath_.c_str());
|
||||
bool saveDatabase = true;
|
||||
if(rtabmap_.getMemory())
|
||||
{
|
||||
// save the grid map
|
||||
float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
|
||||
cv::Mat pixels = mapsManager_.getGridMap(xMin, yMin, gridCellSize);
|
||||
if(!pixels.empty())
|
||||
if(!rtabmap_.getMemory()->isReadOnly())
|
||||
{
|
||||
printf("rtabmap: 2D occupancy grid map saved.\n");
|
||||
rtabmap_.getMemory()->save2DMap(pixels, xMin, yMin, gridCellSize);
|
||||
// save the grid map
|
||||
float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
|
||||
cv::Mat pixels = mapsManager_.getGridMap(xMin, yMin, gridCellSize);
|
||||
if(!pixels.empty())
|
||||
{
|
||||
printf("rtabmap: 2D occupancy grid map saved.\n");
|
||||
rtabmap_.getMemory()->save2DMap(pixels, xMin, yMin, gridCellSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("rtabmap: Database is read-only, the current state of the memory is not saved.\n");
|
||||
saveDatabase = false;
|
||||
}
|
||||
}
|
||||
rtabmap_.close();
|
||||
rtabmap_.close(saveDatabase);
|
||||
NODELET_INFO("LoadDatabase: Saving current map (%s, %ld MB)... done!", databasePath_.c_str(), UFile::length(databasePath_)/(1024*1024));
|
||||
|
||||
covariance_ = cv::Mat();
|
||||
@@ -3113,18 +3121,27 @@ bool CoreWrapper::triggerNewMapCallback(std_srvs::Empty::Request&, std_srvs::Emp
|
||||
bool CoreWrapper::backupDatabaseCallback(std_srvs::Empty::Request&, std_srvs::Empty::Response&)
|
||||
{
|
||||
NODELET_INFO("Backup: Saving memory...");
|
||||
bool saveDatabase = true;
|
||||
if(rtabmap_.getMemory())
|
||||
{
|
||||
// save the grid map
|
||||
float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
|
||||
cv::Mat pixels = mapsManager_.getGridMap(xMin, yMin, gridCellSize);
|
||||
if(!pixels.empty())
|
||||
if(!rtabmap_.getMemory()->isReadOnly())
|
||||
{
|
||||
printf("rtabmap: 2D occupancy grid map saved.\n");
|
||||
rtabmap_.getMemory()->save2DMap(pixels, xMin, yMin, gridCellSize);
|
||||
// save the grid map
|
||||
float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
|
||||
cv::Mat pixels = mapsManager_.getGridMap(xMin, yMin, gridCellSize);
|
||||
if(!pixels.empty())
|
||||
{
|
||||
printf("rtabmap: 2D occupancy grid map saved.\n");
|
||||
rtabmap_.getMemory()->save2DMap(pixels, xMin, yMin, gridCellSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("rtabmap: Database is read-only, the current state of the memory is not saved.\n");
|
||||
saveDatabase = false;
|
||||
}
|
||||
}
|
||||
rtabmap_.close();
|
||||
rtabmap_.close(saveDatabase);
|
||||
NODELET_INFO("Backup: Saving memory... done!");
|
||||
|
||||
covariance_ = cv::Mat();
|
||||
|
||||
Reference in New Issue
Block a user