Added "Test" button in the Source panel in Preferences to test alone the RGB-D camera.

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1810 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-10-01 17:30:44 +00:00
parent 9c59a6cf5e
commit 1367143171
4 changed files with 134 additions and 10 deletions
@@ -235,6 +235,8 @@ private slots:
void openDatabaseViewer(); void openDatabaseViewer();
void cleanOdometryTest(); void cleanOdometryTest();
void testOdometry(); void testOdometry();
void cleanRGBDCameraTest();
void testRGBDCamera();
void calibrate(); void calibrate();
void resetCalibration(); void resetCalibration();
+6 -6
View File
@@ -48,6 +48,7 @@ DataRecorder::DataRecorder(QWidget * parent) :
{ {
qRegisterMetaType<rtabmap::SensorData>("rtabmap::SensorData"); qRegisterMetaType<rtabmap::SensorData>("rtabmap::SensorData");
imageView_->setImageDepthShown(true);
QHBoxLayout * layout = new QHBoxLayout(this); QHBoxLayout * layout = new QHBoxLayout(this);
layout->addWidget(imageView_); layout->addWidget(imageView_);
this->setLayout(layout); this->setLayout(layout);
@@ -111,10 +112,6 @@ void DataRecorder::addData(const rtabmap::SensorData & data)
UDEBUG("Time to process a message = %f s", time.ticks()); UDEBUG("Time to process a message = %f s", time.ticks());
} }
else
{
UWARN("CloudRecorder not initialized!");
}
--dataQueue_; --dataQueue_;
} }
@@ -139,8 +136,11 @@ void DataRecorder::handleEvent(UEvent * event)
if(camEvent->data().isValid()) if(camEvent->data().isValid())
{ {
UINFO("Receiving rate = %f Hz", 1.0f/timer_.ticks()); UINFO("Receiving rate = %f Hz", 1.0f/timer_.ticks());
QMetaObject::invokeMethod(this, "addData", Q_ARG(rtabmap::SensorData, camEvent->data())); if(memory_)
++dataQueue_; {
QMetaObject::invokeMethod(this, "addData", Q_ARG(rtabmap::SensorData, camEvent->data()));
++dataQueue_;
}
if(dataQueue_ < 2 && this->isVisible()) if(dataQueue_ < 2 && this->isVisible())
{ {
+115
View File
@@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/core/VWDictionary.h" #include "rtabmap/core/VWDictionary.h"
#include "rtabmap/gui/LoopClosureViewer.h" #include "rtabmap/gui/LoopClosureViewer.h"
#include "rtabmap/gui/DataRecorder.h"
#include <rtabmap/utilite/ULogger.h> #include <rtabmap/utilite/ULogger.h>
#include <rtabmap/utilite/UConversion.h> #include <rtabmap/utilite/UConversion.h>
@@ -125,6 +126,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->pushButton_resetConfig, SIGNAL(clicked()), this, SLOT(resetConfig())); connect(_ui->pushButton_resetConfig, SIGNAL(clicked()), this, SLOT(resetConfig()));
connect(_ui->radioButton_basic, SIGNAL(toggled(bool)), this, SLOT(setupTreeView())); connect(_ui->radioButton_basic, SIGNAL(toggled(bool)), this, SLOT(setupTreeView()));
connect(_ui->pushButton_testOdometry, SIGNAL(clicked()), this, SLOT(testOdometry())); connect(_ui->pushButton_testOdometry, SIGNAL(clicked()), this, SLOT(testOdometry()));
connect(_ui->pushButton_test_rgbd_camera, SIGNAL(clicked()), this, SLOT(testRGBDCamera()));
// General panel // General panel
connect(_ui->general_checkBox_imagesKept, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->general_checkBox_imagesKept, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel()));
@@ -2866,6 +2868,14 @@ void PreferencesDialog::testOdometry()
void PreferencesDialog::testOdometry(int type) void PreferencesDialog::testOdometry(int type)
{ {
if(_cameraThread)
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("A camera is already running!"));
return;
}
UASSERT(_odomThread == 0 && _cameraThread == 0); UASSERT(_odomThread == 0 && _cameraThread == 0);
CameraRGBD * camera = 0; CameraRGBD * camera = 0;
@@ -2936,6 +2946,7 @@ void PreferencesDialog::testOdometry(int type)
_odomThread = new OdometryThread(odometry); // take ownership of odometry _odomThread = new OdometryThread(odometry); // take ownership of odometry
QWidget * window = new QWidget(this, Qt::Popup); QWidget * window = new QWidget(this, Qt::Popup);
window->setWindowModality(Qt::WindowModal);
window->setAttribute(Qt::WA_DeleteOnClose); window->setAttribute(Qt::WA_DeleteOnClose);
window->setWindowFlags(Qt::Dialog); window->setWindowFlags(Qt::Dialog);
window->setWindowTitle(tr("Odometry viewer")); window->setWindowTitle(tr("Odometry viewer"));
@@ -2990,6 +3001,110 @@ void PreferencesDialog::cleanOdometryTest()
_ui->pushButton_testOdometry->setEnabled(true); _ui->pushButton_testOdometry->setEnabled(true);
} }
void PreferencesDialog::cleanRGBDCameraTest()
{
UDEBUG("");
if(_cameraThread)
{
_cameraThread->join(true);
delete _cameraThread;
_cameraThread = 0;
}
_ui->pushButton_test_rgbd_camera->setEnabled(true);
}
void PreferencesDialog::testRGBDCamera()
{
if(_cameraThread)
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("A camera is already running!"));
}
CameraRGBD * camera = 0;
if(this->getSourceRGBD() == kSrcOpenNI_PCL)
{
camera = new CameraOpenni(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI2)
{
camera = new CameraOpenNI2(
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcFreenect)
{
camera = new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI_CV || this->getSourceRGBD() == kSrcOpenNI_CV_ASUS)
{
camera = new CameraOpenNICV(
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS,
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else
{
UFATAL("RGBD Source type undefined!");
}
if(!camera->init())
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("RGBD camera initialization failed!"));
delete camera;
camera = 0;
}
if(camera)
{
_ui->pushButton_test_rgbd_camera->setEnabled(false);
// Create DataRecorder without init it, just to show images...
DataRecorder * window = new DataRecorder(this);
window->setWindowModality(Qt::WindowModal);
window->setAttribute(Qt::WA_DeleteOnClose);
window->setWindowFlags(Qt::Dialog);
window->setWindowTitle(tr("RGBD camera viewer"));
window->setMinimumWidth(800);
window->setMinimumHeight(600);
connect( window, SIGNAL(destroyed(QObject*)), this, SLOT(cleanRGBDCameraTest()) );
window->registerToEventsManager();
_cameraThread = new CameraThread(camera);
UEventsManager::createPipe(_cameraThread, window, "CameraEvent");
window->showNormal();
_cameraThread->start();
}
}
void PreferencesDialog::calibrate() void PreferencesDialog::calibrate()
{ {
+11 -4
View File
@@ -63,9 +63,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>-293</y>
<width>732</width> <width>744</width>
<height>1198</height> <height>978</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -86,7 +86,7 @@
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>7</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="page_22"> <widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29"> <layout class="QVBoxLayout" name="verticalLayout_29">
@@ -1711,6 +1711,13 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="pushButton_test_rgbd_camera">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>