LoopClosureViewer.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
29 #include "ui_loopClosureViewer.h"
30 
31 #include "rtabmap/core/Memory.h"
34 #include "rtabmap/core/util3d.h"
35 #include "rtabmap/core/Signature.h"
37 #include "rtabmap/utilite/UStl.h"
38 
39 #include <QtCore/QTimer>
40 
41 namespace rtabmap {
42 
44  QWidget(parent),
45  decimation_(1),
46  maxDepth_(0),
47  minDepth_(0)
48 {
49  ui_ = new Ui_loopClosureViewer();
50  ui_->setupUi(this);
51  ui_->cloudViewerTransform->setCameraLockZ(false);
52 
53  connect(ui_->checkBox_rawCloud, SIGNAL(clicked()), this, SLOT(updateView()));
54 }
55 
57  delete ui_;
58 }
59 
60 void LoopClosureViewer::setData(const Signature & sA, const Signature & sB)
61 {
62  sA_ = sA;
63  sB_ = sB;
64  if(sA_.id()>0 && sB_.id()>0)
65  {
66  ui_->label_idA->setText(QString("[%1-%2]").arg(sA.id()).arg(sB.id()));
67  }
68 }
69 
70 void LoopClosureViewer::updateView(const Transform & transform, const ParametersMap & parameters)
71 {
72  if(sA_.id()>0 && sB_.id()>0)
73  {
74  int decimation = 1;
75  float maxDepth = 0;
76  float minDepth = 0;
77 
78  if(!ui_->checkBox_rawCloud->isChecked())
79  {
80  decimation = decimation_;
81  maxDepth = maxDepth_;
82  minDepth = minDepth_;
83  }
84 
85  UDEBUG("decimation = %d", decimation);
86  UDEBUG("maxDepth = %f", maxDepth);
87  UDEBUG("minDepth = %d", minDepth);
88 
89  Transform t;
90  if(!transform.isNull())
91  {
93  t = transform;
94  }
95  else if(!transform_.isNull())
96  {
97  t = transform_;
98  }
99  else
100  {
101  t = sB_.getPose();
102  }
103 
104  UDEBUG("t= %s", t.prettyPrint().c_str());
105  ui_->label_transform->setText(QString("(%1)").arg(t.prettyPrint().c_str()));
106  if(!t.isNull())
107  {
108  //cloud 3d
109  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudA, cloudB;
110  cloudA = util3d::cloudRGBFromSensorData(sA_.sensorData(), decimation, maxDepth, minDepth, 0, parameters);
111  cloudB = util3d::cloudRGBFromSensorData(sB_.sensorData(), decimation, maxDepth, minDepth, 0, parameters);
112 
113  //cloud 2d
114  pcl::PointCloud<pcl::PointXYZ>::Ptr scanA, scanB;
117 
118  ui_->label_idA->setText(QString("[%1 (%2) -> %3 (%4)]").arg(sB_.id()).arg(cloudB->size()).arg(sA_.id()).arg(cloudA->size()));
119 
120  if(cloudA->size())
121  {
122  ui_->cloudViewerTransform->addCloud("cloud0", cloudA);
123  }
124  if(cloudB->size())
125  {
126  cloudB = util3d::transformPointCloud(cloudB, t);
127  ui_->cloudViewerTransform->addCloud("cloud1", cloudB);
128  }
129  if(scanA->size())
130  {
131  ui_->cloudViewerTransform->addCloud("scan0", scanA);
132  }
133  if(scanB->size())
134  {
135  scanB = util3d::transformPointCloud(scanB, t);
136  ui_->cloudViewerTransform->addCloud("scan1", scanB);
137  }
138  }
139  else
140  {
141  UERROR("loop transform is null !?!?");
142  ui_->cloudViewerTransform->removeAllClouds();
143  }
144  ui_->cloudViewerTransform->refreshView();
145  }
146 }
147 
148 
149 void LoopClosureViewer::showEvent(QShowEvent * event)
150 {
151  QWidget::showEvent( event );
152  QTimer::singleShot(500, this, SLOT(updateView())); // make sure the QVTKWidget is shown!
153 }
154 
155 } /* namespace rtabmap */
rtabmap::LoopClosureViewer::showEvent
virtual void showEvent(QShowEvent *event)
Definition: LoopClosureViewer.cpp:149
rtabmap::LoopClosureViewer::sA
const Signature & sA() const
Definition: LoopClosureViewer.h:53
rtabmap::LaserScan::localTransform
Transform localTransform() const
Definition: LaserScan.h:127
rtabmap::LoopClosureViewer::updateView
void updateView(const Transform &AtoB=Transform(), const ParametersMap &parameters=ParametersMap())
Definition: LoopClosureViewer.cpp:70
arg::arg
constexpr arg(const char *name=nullptr)
LoopClosureViewer.h
rtabmap::LoopClosureViewer::LoopClosureViewer
LoopClosureViewer(QWidget *parent=0)
Definition: LoopClosureViewer.cpp:43
rtabmap::LoopClosureViewer::minDepth_
float minDepth_
Definition: LoopClosureViewer.h:74
rtabmap::LoopClosureViewer::sA_
Signature sA_
Definition: LoopClosureViewer.h:68
util3d.h
rtabmap::LoopClosureViewer::sB_
Signature sB_
Definition: LoopClosureViewer.h:69
rtabmap::ParametersMap
std::map< std::string, std::string > ParametersMap
Definition: Parameters.h:43
rtabmap::Transform::isNull
bool isNull() const
Definition: Transform.cpp:107
rtabmap::util3d::transformPointCloud
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT transformPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const Transform &transform)
Definition: util3d_transforms.cpp:107
rtabmap::util3d::cloudRGBFromSensorData
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_CORE_EXPORT 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 >())
Definition: util3d.cpp:1268
rtabmap::SensorData::laserScanRaw
const LaserScan & laserScanRaw() const
Definition: SensorData.h:185
util3d_transforms.h
util3d_filtering.h
Signature.h
arg
rtabmap::LoopClosureViewer::decimation_
int decimation_
Definition: LoopClosureViewer.h:72
rtabmap::LoopClosureViewer::~LoopClosureViewer
virtual ~LoopClosureViewer()
Definition: LoopClosureViewer.cpp:56
rtabmap::Signature::getPose
const Transform & getPose() const
Definition: Signature.h:133
ULogger.h
ULogger class and convenient macros.
rtabmap::Transform
Definition: Transform.h:41
Memory.h
rtabmap::LoopClosureViewer::setData
void setData(const Signature &sA, const Signature &sB)
Definition: LoopClosureViewer.cpp:60
rtabmap::Signature::id
int id() const
Definition: Signature.h:70
UStl.h
Wrappers of STL for convenient functions.
rtabmap::LoopClosureViewer::sB
const Signature & sB() const
Definition: LoopClosureViewer.h:54
UDEBUG
#define UDEBUG(...)
rtabmap::util3d::laserScanToPointCloud
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud(const LaserScan &laserScan, const Transform &transform=Transform())
Definition: util3d.cpp:2269
transform
EIGEN_DONT_INLINE void transform(const Quaternion< Scalar > &t, Data &data)
rtabmap::LoopClosureViewer::ui_
Ui_loopClosureViewer * ui_
Definition: LoopClosureViewer.h:66
rtabmap::LoopClosureViewer::maxDepth_
float maxDepth_
Definition: LoopClosureViewer.h:73
t
Point2 t(10, 10)
rtabmap::Signature::sensorData
SensorData & sensorData()
Definition: Signature.h:138
rtabmap
Definition: CameraARCore.cpp:35
UERROR
#define UERROR(...)
rtabmap::LoopClosureViewer::transform_
Transform transform_
Definition: LoopClosureViewer.h:70
rtabmap::Signature
Definition: Signature.h:48


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11