fixed a warning where no scans are found when calling the service to publish the 3D map

This commit is contained in:
matlabbe
2015-07-19 20:51:32 -04:00
parent de98828dc3
commit 9822159f4b
3 changed files with 20 additions and 7 deletions
+8 -6
View File
@@ -1687,7 +1687,9 @@ bool CoreWrapper::publishMapCallback(rtabmap_ros::PublishMap::Request& req, rtab
{
ROS_INFO("rtabmap: Publishing map...");
if(mapDataPub_.getNumSubscribers())
if(mapDataPub_.getNumSubscribers() ||
(!req.graphOnly && mapsManager_.hasSubscribers()) ||
(req.graphOnly && labelsPub_.getNumSubscribers()))
{
std::map<int, Transform> poses;
std::multimap<int, Link> constraints;
@@ -1714,7 +1716,7 @@ bool CoreWrapper::publishMapCallback(rtabmap_ros::PublishMap::Request& req, rtab
if(poses.size() && poses.size() != signatures.size())
{
ROS_ERROR("poses and signatures are not the same size!? %d vs %d", (int)poses.size(), (int)signatures.size());
ROS_WARN("poses and signatures are not the same size!? %d vs %d", (int)poses.size(), (int)signatures.size());
}
ros::Time now = ros::Time::now();
@@ -1733,7 +1735,7 @@ bool CoreWrapper::publishMapCallback(rtabmap_ros::PublishMap::Request& req, rtab
mapDataPub_.publish(msg);
}
if(!req.graphOnly)
if(!req.graphOnly && mapsManager_.hasSubscribers())
{
std::map<int, Transform> filteredPoses;
if(signatures.size())
@@ -1741,9 +1743,9 @@ bool CoreWrapper::publishMapCallback(rtabmap_ros::PublishMap::Request& req, rtab
filteredPoses = mapsManager_.updateMapCaches(
poses,
rtabmap_.getMemory(),
true,
true,
true,
false,
false,
false,
signatures);
}
else
+11 -1
View File
@@ -94,6 +94,13 @@ void MapsManager::clear()
laserScanIncrement_ = 0;
}
bool MapsManager::hasSubscribers() const
{
return cloudMapPub_.getNumSubscribers() != 0 ||
projMapPub_.getNumSubscribers() != 0 ||
gridMapPub_.getNumSubscribers() != 0;
}
void MapsManager::setLaserScanParameters(
float maxRange,
float minAngle,
@@ -192,7 +199,10 @@ std::map<int, rtabmap::Transform> MapsManager::updateMapCaches(
{
// Which data should we decompress?
cv::Mat image, depth, scan;
data.uncompressData(rgbDepthRequired||data.stereoCameraModel().isValid()?&image:0, rgbDepthRequired||depthRequired?&depth:0, scanRequired?&scan:0);
data.uncompressData(
(rgbDepthRequired||data.stereoCameraModel().isValid()) ? &image:0,
(rgbDepthRequired||depthRequired) ? &depth:0,
scanRequired?&scan:0);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudRGB;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudXYZ;
+1
View File
@@ -29,6 +29,7 @@ public:
MapsManager();
virtual ~MapsManager();
void clear();
bool hasSubscribers() const;
std::map<int, rtabmap::Transform> getFilteredPoses(
const std::map<int, rtabmap::Transform> & poses);