28 #ifndef MAPBUILDERWIFI_H_ 29 #define MAPBUILDERWIFI_H_ 51 return 2 * (dBm + 100);
65 this->unregisterFromEventsManager();
71 processingStatistics_ =
true;
73 const std::map<int, Transform> & poses = stats.
poses();
74 QMap<std::string, Transform> clouds = cloudViewer_->getAddedClouds();
79 std::map<double, int> nodeStamps;
81 for(std::map<int, Signature>::const_iterator iter=stats.
getSignatures().begin();
86 nodeStamps.insert(std::make_pair(iter->second.getStamp(), iter->first));
88 if(!iter->second.sensorData().userDataRaw().empty())
90 UASSERT(iter->second.sensorData().userDataRaw().type() == CV_64FC1 &&
91 iter->second.sensorData().userDataRaw().cols == 2 &&
92 iter->second.sensorData().userDataRaw().rows == 1);
95 int level = iter->second.sensorData().userDataRaw().at<
double>(0);
96 double stamp = iter->second.sensorData().userDataRaw().at<
double>(1);
97 wifiLevels_.insert(std::make_pair(stamp, level));
102 for(std::map<double, int>::iterator iter=wifiLevels_.begin(); iter!=wifiLevels_.end(); ++iter, ++id)
105 double stampWifi = iter->first;
106 std::map<double, int>::iterator previousNode = nodeStamps.lower_bound(stampWifi);
107 if(previousNode!=nodeStamps.end() && previousNode->first > stampWifi && previousNode != nodeStamps.begin())
111 std::map<double, int>::iterator nextNode = nodeStamps.upper_bound(stampWifi);
113 if(previousNode != nodeStamps.end() &&
114 nextNode != nodeStamps.end() &&
115 previousNode->second != nextNode->second &&
118 Transform poseA = poses.at(previousNode->second);
119 Transform poseB = poses.at(nextNode->second);
120 double stampA = previousNode->first;
121 double stampB = nextNode->first;
122 UASSERT(stampWifi>=stampA && stampWifi <=stampB);
125 double ratio = (stampWifi-stampA)/(stampB-stampA);
131 Transform wifiPose = (poseA*v).translation();
133 std::string cloudName =
uFormat(
"level%d",
id);
134 if(clouds.contains(cloudName))
136 if(!cloudViewer_->updateCloudPose(cloudName, wifiPose))
138 UERROR(
"Updating pose cloud %d failed!",
id);
145 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
146 for(
int i=0; i<10; ++i)
151 pt.z = float(i+1)*0.02f;
161 pt.r = pt.g = pt.b = 100;
163 cloud->push_back(pt);
165 pcl::PointXYZRGB anchor(255, 0, 0);
166 cloud->push_back(anchor);
168 if(!cloudViewer_->addCloud(cloudName, cloud, wifiPose, Qt::yellow))
170 UERROR(
"Adding cloud %d to viewer failed!",
id);
174 cloudViewer_->setCloudPointSize(cloudName, 5);
MapBuilderWifi(CameraThread *camera=0)
virtual ~MapBuilderWifi()
const std::map< int, Signature > & getSignatures() const
void processStatistics(const rtabmap::Statistics &stats)
std::map< double, int > wifiLevels_
#define UASSERT(condition)
virtual void processStatistics(const rtabmap::Statistics &stats)
bool uContains(const std::list< V > &list, const V &value)
const std::map< int, Transform > & poses() const
std::string UTILITE_EXP uFormat(const char *fmt,...)