31 #include <QVBoxLayout> 32 #include <QtCore/QMetaType> 35 #ifndef Q_MOC_RUN // Mac OS X issue 59 odometryCorrection_(
Transform::getIdentity()),
60 processingStatistics_(
false),
61 lastOdometryProcessed_(
true)
63 this->setWindowFlags(Qt::Dialog);
64 this->setWindowTitle(tr(
"3D Map"));
65 this->setMinimumWidth(800);
66 this->setMinimumHeight(600);
70 QVBoxLayout *layout =
new QVBoxLayout();
71 layout->addWidget(cloudViewer_);
72 this->setLayout(layout);
74 qRegisterMetaType<rtabmap::OdometryEvent>(
"rtabmap::OdometryEvent");
75 qRegisterMetaType<rtabmap::Statistics>(
"rtabmap::Statistics");
77 QAction * pause =
new QAction(
this);
78 this->addAction(pause);
79 pause->setShortcut(Qt::Key_Space);
80 connect(pause, SIGNAL(triggered()),
this, SLOT(pauseDetection()));
85 this->unregisterFromEventsManager();
94 if(camera_->isCapturing())
107 if(!this->isVisible())
116 cloudViewer_->setBackgroundColor(Qt::darkRed);
118 pose = lastOdomPose_;
122 cloudViewer_->setBackgroundColor(cloudViewer_->getDefaultBackgroundColor());
126 lastOdomPose_ = pose;
140 if(!cloudViewer_->addCloud(
"cloudOdom", cloud, odometryCorrection_*pose))
142 UERROR(
"Adding cloudOdom to viewer failed!");
147 cloudViewer_->setCloudVisibility(
"cloudOdom",
false);
148 UWARN(
"Empty cloudOdom!");
155 cloudViewer_->updateCameraTargetPosition(odometryCorrection_*odom.
pose());
158 cloudViewer_->update();
160 lastOdometryProcessed_ =
true;
166 processingStatistics_ =
true;
171 const std::map<int, Transform> & poses = stats.
poses();
172 QMap<std::string, Transform> clouds = cloudViewer_->getAddedClouds();
173 for(std::map<int, Transform>::const_iterator iter = poses.begin(); iter!=poses.end(); ++iter)
175 if(!iter->second.isNull())
177 std::string cloudName =
uFormat(
"cloud%d", iter->first);
180 if(clouds.contains(cloudName))
184 cloudViewer_->getPose(cloudName, tCloud);
185 if(tCloud.
isNull() || iter->second != tCloud)
187 if(!cloudViewer_->updateCloudPose(cloudName, iter->second))
189 UERROR(
"Updating pose cloud %d failed!", iter->first);
192 cloudViewer_->setCloudVisibility(cloudName,
true);
205 if(!cloudViewer_->addCloud(cloudName, cloud, iter->second))
207 UERROR(
"Adding cloud %d to viewer failed!", iter->first);
212 UWARN(
"Empty cloud %d!", iter->first);
218 UWARN(
"Null pose for %d ?!?", iter->first);
225 cloudViewer_->removeAllGraphs();
226 cloudViewer_->removeCloud(
"graph_nodes");
230 pcl::PointCloud<pcl::PointXYZ>::Ptr graph(
new pcl::PointCloud<pcl::PointXYZ>);
231 pcl::PointCloud<pcl::PointXYZ>::Ptr graphNodes(
new pcl::PointCloud<pcl::PointXYZ>);
232 for(std::map<int, Transform>::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
234 graph->push_back(pcl::PointXYZ(iter->second.x(), iter->second.y(), iter->second.z()));
236 *graphNodes = *graph;
240 cloudViewer_->addOrUpdateGraph(
"graph", graph, Qt::gray);
242 cloudViewer_->setCloudPointSize(
"graph_nodes", 5);
247 cloudViewer_->update();
249 processingStatistics_ =
false;
259 if(this->isVisible())
264 else if(event->
getClassName().compare(
"OdometryEvent") == 0)
268 if(this->isVisible() &&
269 lastOdometryProcessed_ &&
270 !processingStatistics_)
272 lastOdometryProcessed_ =
false;
284 bool processingStatistics_;
285 bool lastOdometryProcessed_;
virtual void pauseDetection()
const std::map< int, Signature > & getSignatures() const
const Statistics & getStats() const
Some conversion functions.
MapBuilder(CameraThread *camera=0)
const cv::Mat & imageRaw() const
Wrappers of STL for convenient functions.
const Transform & pose() const
bool isValidForProjection() const
virtual std::string getClassName() const =0
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudRGBFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >())
virtual void processOdometry(const rtabmap::OdometryEvent &odom)
const cv::Mat & depthOrRightRaw() const
bool uContains(const std::list< V > &list, const V &value)
const std::map< int, Transform > & poses() const
const std::vector< CameraModel > & cameraModels() const
SensorData & sensorData()
ULogger class and convenient macros.
const StereoCameraModel & stereoCameraModel() const
virtual void processStatistics(const rtabmap::Statistics &stats)
virtual bool handleEvent(UEvent *event)
const Transform & mapCorrection() const
std::string UTILITE_EXP uFormat(const char *fmt,...)