00001
00018 #include "GUI/mainwindow.h"
00019 #include <QLabel>
00020 #include <string>
00021
00022 using namespace std;
00023
00024 MainWindow::MainWindow(QWidget *parent) :
00025 QMainWindow(parent)
00026 {
00027 calibrationObject = boost::shared_ptr<Calibration_Object>(new Calibration_Object());
00028 ros::NodeHandle mNodeHandle(ros::this_node::getName());
00029 double top_angle_ab, top_angle_bc, top_angle_ca;
00030 double side_a, side_b, side_c;
00031 double marker_edge_size;
00032 std::string marker_id_left, marker_id_right;
00033 double marker_left_rotation_z, marker_left_transformation_z, marker_left_transformation_x,marker_left_rotation_x;
00034 double laserscanner_segmentation_lambda, laserscanner_maxVariance, laserscanner_maxAngleDeviation, laserscanner_variationStep;
00035 double marker_right_rotation_z, marker_right_transformation_z, marker_right_transformation_x,marker_right_rotation_x;
00036 std::string tf_visualizer_camera_input_topic, tf_visualizer_camera_output_topic, tf_visualizer_frames;
00037 int laserscanner_variationStepCount;
00038 mNodeHandle.getParam("angle_ab", top_angle_ab);
00039 mNodeHandle.getParam("angle_bc", top_angle_bc);
00040 mNodeHandle.getParam("angle_ca", top_angle_ca);
00041 mNodeHandle.getParam("side_a", side_a);
00042 mNodeHandle.getParam("side_b", side_b);
00043 mNodeHandle.getParam("side_c", side_c);
00044 mNodeHandle.getParam("marker_edge_size", marker_edge_size);
00045 mNodeHandle.getParam("marker_ID_left", marker_id_left);
00046 mNodeHandle.getParam("marker_ID_right", marker_id_right);
00047 mNodeHandle.getParam("marker_left_rotation_z", marker_left_rotation_z);
00048 mNodeHandle.getParam("marker_left_transformation_z", marker_left_transformation_z);
00049 mNodeHandle.getParam("marker_left_transformation_x", marker_left_transformation_x);
00050 mNodeHandle.getParam("marker_left_rotation_x", marker_left_rotation_x);
00051 mNodeHandle.getParam("marker_right_rotation_z", marker_right_rotation_z);
00052 mNodeHandle.getParam("marker_right_transformation_z", marker_right_transformation_z);
00053 mNodeHandle.getParam("marker_right_transformation_x", marker_right_transformation_x);
00054 mNodeHandle.getParam("marker_right_rotation_x", marker_right_rotation_x);
00055 mNodeHandle.getParam("laserscanner_segmentation_lambda", laserscanner_segmentation_lambda);
00056 mNodeHandle.getParam("laserscanner_maxVariance", laserscanner_maxVariance);
00057 mNodeHandle.getParam("laserscanner_maxAngleDeviation", laserscanner_maxAngleDeviation);
00058 mNodeHandle.getParam("laserscanner_variationStep", laserscanner_variationStep);
00059 mNodeHandle.getParam("tf_visualizer_camera_input_topic", tf_visualizer_camera_input_topic);
00060 mNodeHandle.getParam("tf_visualizer_camera_output_topic", tf_visualizer_camera_output_topic);
00061 mNodeHandle.getParam("tf_visualizer_frames", tf_visualizer_frames);
00062 mNodeHandle.getParam("laserscanner_variationStepCount", laserscanner_variationStepCount);
00063 calibrationObject->top_angle_ab = top_angle_ab;
00064 calibrationObject->top_angle_bc = top_angle_bc;
00065 calibrationObject->top_angle_ca = top_angle_ca;
00066 calibrationObject->side_a = side_a;
00067 calibrationObject->side_b = side_b;
00068 calibrationObject->side_c = side_c;
00069 calibrationObject->marker_edge_size = marker_edge_size;
00070 calibrationObject->marker_id_left = marker_id_left;
00071 calibrationObject->marker_id_right = marker_id_right;
00072
00073 calibrationObject->marker_left_rotation_z = marker_left_rotation_z;
00074 calibrationObject->marker_left_transformation_z = marker_left_transformation_z;
00075 calibrationObject->marker_left_transformation_x = marker_left_transformation_x;
00076 calibrationObject->marker_left_rotation_x = marker_left_rotation_x;
00077
00078 calibrationObject->marker_right_rotation_z = marker_right_rotation_z;
00079 calibrationObject->marker_right_transformation_z = marker_right_transformation_z;
00080 calibrationObject->marker_right_transformation_x = marker_right_transformation_x;
00081 calibrationObject->marker_right_rotation_x = marker_right_rotation_x;
00082
00083 calibrationObject->calculateTransformationFrames();
00084
00085 ROS_INFO_STREAM("MarkerIDs: " << marker_id_left << ", " << marker_id_right);
00086
00087 double maxAngleDeviation;
00088 mNodeHandle.getParam("feasibilityChecker_maxAngleDeviation", maxAngleDeviation);
00089 feasibilityChecker = boost::shared_ptr<FeasibilityChecker>(new FeasibilityChecker(calibrationObject, Eigen::Vector3d(0.0,0.0,1.0), maxAngleDeviation));
00090 solver = boost::shared_ptr<ResectionSolver>(new ResectionSolver(calibrationObject, feasibilityChecker));
00091
00092 transformationPublisher = boost::shared_ptr<Transformation_Publisher>(new Transformation_Publisher(calibrationObject));
00093 transformationPublisher->start();
00094
00095
00096 std::vector<std::string> frame_ids;
00097 frame_ids.push_back(tf_visualizer_frames);
00098 tfVisualizer = boost::shared_ptr<TF_Visualizer>(new TF_Visualizer(frame_ids, tf_visualizer_camera_input_topic, tf_visualizer_camera_output_topic));
00099 tfVisualizer->start();
00100
00101
00102 std::string laserscanner_type;
00103 mNodeHandle.getParam("laserscanner_type", laserscanner_type);
00104 ROS_INFO_STREAM("Using laserscanner: " << laserscanner_type);
00105 if (laserscanner_type == "PLS101")
00106 {
00107 currentThread = new LaserScanThread(new Laserscanner_MILD(), laserscanner_segmentation_lambda,laserscanner_maxVariance,laserscanner_maxAngleDeviation,laserscanner_variationStep, laserscanner_variationStepCount);
00108 }
00109 else if (laserscanner_type == "LMS400")
00110 {
00111 std::string hostname = "192.168.0.1";
00112 currentThread = new LaserScanThread(new LaserScanner_LMS400(hostname, 10), laserscanner_segmentation_lambda,laserscanner_maxVariance,laserscanner_maxAngleDeviation,laserscanner_variationStep, laserscanner_variationStepCount);
00113 }
00114 else
00115 {
00116 ROS_ERROR_STREAM("Unknown laserscanner type: " << laserscanner_type);
00117 return;
00118 }
00119
00120 currentThread->start();
00121
00122 solutionFrames = new std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d> >();
00123 selectedTriangle = new std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> >();
00124
00125 showData = 1;
00126 widget = new LaserScanWidget(this, 0, showData, currentThread);
00127 widget->move(10,40);
00128
00129
00130 lblSolutions = new QLabel(this);
00131 lblSolutions->setText("");
00132
00133 lblTriangles = new QLabel(this);
00134 lblTriangles->setText("<span style='color:red'>Waiting for data...</span>");
00135 lblTriangles->setWordWrap(true);
00136 lblTriangles->setAlignment(Qt::AlignTop);
00137
00138 lblSolutionMatrix = new QLabel(this);
00139 lblSolutionMatrix->setText("");
00140 lblSolutionMatrix->setWordWrap(true);
00141 lblSolutionMatrix->setAlignment(Qt::AlignTop);
00142
00143 lblPossibleSolutions_Position = new QLabel(this);
00144 lblPossibleSolutions_Position->setText("");
00145 lblPossibleSolutions_Position->setWordWrap(true);
00146 lblPossibleSolutions_Position->setAlignment(Qt::AlignTop);
00147
00148 lblCurrentTriangle = new QLabel(this);
00149 lblCurrentTriangle->setText("");
00150 lblCurrentTriangle->setWordWrap(true);
00151 lblCurrentTriangle->setAlignment(Qt::AlignTop);
00152
00153 lblTriangles->resize(200, 60);
00154 lblSolutions->resize(200, 20);
00155 lblSolutionMatrix->resize(200, 150);
00156 lblCurrentTriangle->resize(200, 60);
00157
00158
00159 btnCapture = new QPushButton(this);
00160 btnCapture->setText("Start capture");
00161 btnCapture->resize(100, 25);
00162 btnCapture->setEnabled(false);
00163
00164 btnPossibleSolutions_Left = new QPushButton(this);
00165 btnPossibleSolutions_Left->setText("<");
00166 btnPossibleSolutions_Left->resize(20, 25);
00167 btnPossibleSolutions_Left->setVisible(false);
00168
00169 btnPossibleSolutions_Right = new QPushButton(this);
00170 btnPossibleSolutions_Right->setText(">");
00171 btnPossibleSolutions_Right->resize(20, 25);
00172 btnPossibleSolutions_Right->setVisible(false);
00173
00174 btnStartPTUCapture = new QPushButton(this);
00175 btnStartPTUCapture->setText("Start PTU");
00176 btnStartPTUCapture->resize(80, 25);
00177 btnStartPTUCapture->setVisible(true);
00178
00179 btnAddTopPose = new QPushButton(this);
00180 btnAddTopPose->setText("Add");
00181 btnAddTopPose->resize(60, 25);
00182 btnAddTopPose->setVisible(true);
00183 btnAddTopPose->setEnabled(false);
00184
00185 btnDeleteTopPose = new QPushButton(this);
00186 btnDeleteTopPose->setText("Delete");
00187 btnDeleteTopPose->resize(60, 25);
00188 btnDeleteTopPose->setVisible(true);
00189 btnDeleteTopPose->setEnabled(false);
00190
00191 btnClearTopPose = new QPushButton(this);
00192 btnClearTopPose->setText("Clear");
00193 btnClearTopPose->resize(60, 25);
00194 btnClearTopPose->setVisible(true);
00195 btnClearTopPose->setEnabled(false);
00196
00197
00198 lstTopPose = new QListWidget(this);
00199 lstTopPose->resize(180, 200);
00200 lstTopPose->setVisible(true);
00201 lstTopPose->setEnabled(false);
00202
00203
00204 chk_rawdata = new QCheckBox(this);
00205 chk_avgData = new QCheckBox(this);
00206 chk_filteredData = new QCheckBox(this);
00207 chk_segments = new QCheckBox(this);
00208 chk_edges = new QCheckBox(this);
00209 chk_avgData->setText("Average data");
00210 chk_rawdata->setText("Raw data");
00211 chk_filteredData->setText("Filtered data");
00212 chk_segments->setText("Segments");
00213 chk_edges->setText("Edges");
00214 chk_rawdata->setChecked(true);
00215
00216
00217 radio_polar = new QRadioButton(this);
00218 radio_flat = new QRadioButton(this);
00219 radio_polar->setText("Coordinates");
00220 radio_flat->setText("Distance");
00221 radio_polar->resize(180, 30);
00222 radio_flat->resize(180,30);
00223 radio_flat->setChecked(true);
00224
00225 isCapturing = false;
00226
00227 connect(currentThread, SIGNAL(trianglesFound(std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > *)),this, SLOT(trianglesFound(std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > *)));
00228
00229 connect(this, SIGNAL(newTransform_Laserscan(const Eigen::Matrix4d, double)), transformationPublisher.get(), SLOT(newTransform_Laserscan(const Eigen::Matrix4d, double)));
00230
00231 connect(btnCapture, SIGNAL(clicked()),this, SLOT(btnCapture_clicked()));
00232 connect(btnPossibleSolutions_Left, SIGNAL(clicked()),this, SLOT(btnPossibleSolutions_Left_clicked()));
00233 connect(btnPossibleSolutions_Right, SIGNAL(clicked()),this, SLOT(btnPossibleSolutions_Right_clicked()));
00234 connect(btnStartPTUCapture, SIGNAL(clicked()),this, SLOT(btnStartPTUCapture_clicked()));
00235
00236 connect(this, SIGNAL(setCurves(unsigned int)),widget, SLOT(setCurves(unsigned int)));
00237
00238 connect(radio_flat, SIGNAL(clicked(bool)),this, SLOT(radio_flat_stateChanged(bool)));
00239
00240 connect(radio_polar,SIGNAL(clicked(bool)),this, SLOT(radio_polar_stateChanged(bool)));
00241 connect(radio_flat, SIGNAL(clicked(bool)),this, SLOT(radio_flat_stateChanged(bool)));
00242
00243 connect(chk_rawdata, SIGNAL(clicked(bool)),this, SLOT(chk_rawData_stateChanged(bool)));
00244 connect(chk_avgData, SIGNAL(clicked(bool)),this, SLOT(chk_avgData_stateChanged(bool)));
00245 connect(chk_filteredData, SIGNAL(clicked(bool)),this, SLOT(chk_filteredData_stateChanged(bool)));
00246 connect(chk_segments, SIGNAL(clicked(bool)),this, SLOT(chk_segments_stateChanged(bool)));
00247 connect(chk_edges, SIGNAL(clicked(bool)),this, SLOT(chk_edges_stateChanged(bool)));
00248
00249 markerPublisher = boost::shared_ptr<MarkerPublisher>(new MarkerPublisher(calibrationObject));
00250 }
00251 void MainWindow::resizeEvent(QResizeEvent * event)
00252 {
00253 widget->resize(this->width()-220, this->height()-60);
00254 radio_polar->move(this->width()-200,40);
00255 radio_flat->move(this->width()-200,65);
00256
00257 chk_rawdata->move(this->width()-200,100);
00258 chk_avgData->move(this->width()-200,120);
00259 chk_filteredData->move(this->width()-200,140);
00260 chk_segments->move(this->width()-200,160);
00261 chk_edges->move(this->width()-200,180);
00262
00263 lblTriangles->move(this->width()-200,220);
00264 btnCapture->move(this->width()-200,290);
00265 lblSolutions->move(this->width()-200,320);
00266
00267 lblSolutionMatrix->move(this->width()-200,340);
00268
00269
00270 btnPossibleSolutions_Left->move(this->width()-97,424);
00271 btnPossibleSolutions_Right->move(this->width()-77,424);
00272 lblPossibleSolutions_Position->move(this->width()-200,427);
00273 lblCurrentTriangle->move(this->width()-200,470);
00274
00275 btnStartPTUCapture->move(this->width()-200,530);
00276
00277 btnAddTopPose->move(this->width()-200,580);
00278 btnDeleteTopPose->move(this->width()-140,580);
00279 btnClearTopPose->move(this->width()-80,580);
00280
00281 lstTopPose->move(this->width()-200,620);
00282
00283 QMainWindow::resizeEvent(event);
00284 }
00285
00286 void MainWindow::chk_rawData_stateChanged(bool state)
00287 {
00288 if (state == Qt::Unchecked) {showData = showData - (showData & 1);}
00289 else {showData = showData | 1;}
00290 setCurves(showData);
00291 }
00292 void MainWindow::chk_avgData_stateChanged(bool state)
00293 {
00294 if (state == Qt::Unchecked) {showData = showData - (showData & 2);}
00295 else {showData = showData | 2;}
00296 setCurves(showData);
00297 }
00298 void MainWindow::chk_filteredData_stateChanged(bool state)
00299 {
00300 if (state == Qt::Unchecked) {showData = showData - (showData & 4);}
00301 else {showData = showData | 4;}
00302 setCurves(showData);
00303 }
00304 void MainWindow::chk_segments_stateChanged(bool state)
00305 {
00306 if (state == Qt::Unchecked) {showData = showData - (showData & 8);}
00307 else {showData = showData | 8;}
00308 setCurves(showData);
00309 }
00310 void MainWindow::chk_edges_stateChanged(bool state)
00311 {
00312 if (state == Qt::Unchecked) {showData = showData - (showData & 16);}
00313 else {showData = showData | 16;}
00314 setCurves(showData);
00315 }
00316 void MainWindow::radio_polar_stateChanged(bool state)
00317 {
00318 if (state == true) widget->setGraph(1, showData);
00319 }
00320 void MainWindow::radio_flat_stateChanged(bool state)
00321 {
00322 if (state == true) widget->setGraph(0, showData);
00323 }
00324
00325 void MainWindow::btnCapture_clicked()
00326 {
00327 toggleCaptureMode();
00328 }
00329
00330 void MainWindow::btnAddTopPose_clicked()
00331 {
00332 if (solutionFrames->size() > 0)
00333 {
00334 Eigen::Matrix4d *temp;
00335 temp = &solutionFrames->at(possibleSolutions_Position);
00336 QListWidgetItem *newItem = new QListWidgetItem;
00337 QString text = QString::number((*temp)(0,3)) + ", " + QString::number((*temp)(1,3)) + ", " + QString::number((*temp)(2,3)) ;
00338 newItem->setText(text);
00339 lstTopPose->insertItem(lstTopPose->count(), newItem);
00340 }
00341 }
00342
00343 void MainWindow::btnDeleteTopPose_clicked()
00344 {
00345 QList<QListWidgetItem *> selected = lstTopPose->selectedItems();
00346 if (selected.count() > 0)
00347 {
00348 for(int i = 0; i < selected.count(); i++)
00349 {
00350
00351 }
00352 }
00353 }
00354
00355 void MainWindow::btnClearTopPose_clicked()
00356 {
00357 lstTopPose->clear();
00358 }
00359
00360 void MainWindow::btnPossibleSolutions_Left_clicked()
00361 {
00362 possibleSolutions_Position--;
00363 showPossibleSolutions();
00364 }
00365
00366 void MainWindow::btnPossibleSolutions_Right_clicked()
00367 {
00368 possibleSolutions_Position++;
00369 showPossibleSolutions();
00370 }
00371
00372 void MainWindow::btnStartPTUCapture_clicked()
00373 {
00374
00375 ROS_INFO("Main Window halting");
00376 currentThread->stop();
00377 if (isCapturing) toggleCaptureMode();
00378
00379 if (possibleSolutions_Position < 0 || possibleSolutions_Position >= (int)solutionFrames->size()) {possibleSolutions_Position = 0;}
00380 Eigen::Matrix4d temp = solutionFrames->at(possibleSolutions_Position);
00381 PTUWindow ptuWindow(markerPublisher, calibrationObject, transformationPublisher, temp, this);
00382 ptuWindow.resize( 1000, 600 );
00383 ptuWindow.exec();
00384
00385 ROS_INFO("Main Window resuming");
00386 currentThread->start();
00387 }
00388
00389 void MainWindow::toggleCaptureMode()
00390 {
00391 if (isCapturing)
00392 {
00393 btnCapture->setText("Start capturing");
00394 if (solutionFrames->size() > 0)
00395 {
00396 unsigned int size = solutionFrames->size();
00397 QString si;
00398
00399 if (size == 0)
00400 {
00401 si = "<span style='color:red'>No solutions found.";
00402 }
00403 else if (size == 1)
00404 {
00405 si = "<span style='color:green'>One solution found:";
00406 }
00407 else
00408 {
00409 si = "<span style='color:yellow'>";
00410 si += QString::number(size);
00411 si += " solutions found.";
00412 }
00413 si += "</span>";
00414
00415 lblSolutions->setText(si);
00416 btnStartPTUCapture->setVisible(size > 0);
00417 possibleSolutions_Position = 0;
00418 showPossibleSolutions();
00419 si = "<span>Selected triangle: ";
00420 for (unsigned int i = 0; i < selectedTriangle->size()/3; i++)
00421 {
00422 si = si + "<br/>";
00423 for (unsigned int j = 0; j < 3; j++)
00424 {
00425 si += "[";
00426 si += QString::number(selectedTriangle->at(i*3+j)[0],'.', 2);
00427 si += ", ";
00428 si += QString::number(selectedTriangle->at(i*3+j)[1],'.', 2);
00429 si += "] ";
00430 }
00431 si = si + "<br/>";
00432 double len = sqrt(pow(selectedTriangle->at(i*3)[0]-selectedTriangle->at(i*3+1)[0],2) + pow(selectedTriangle->at(i*3)[1]-selectedTriangle->at(i*3+1)[1],2));
00433 si += QString::number(len,'.', 3);
00434 si = si + " ";
00435 len = sqrt(pow(selectedTriangle->at(i*3+2)[0]-selectedTriangle->at(i*3+1)[0],2) + pow(selectedTriangle->at(i*3+2)[1]-selectedTriangle->at(i*3+1)[1],2));
00436 si += QString::number(len,'.', 3);
00437 }
00438 si += "</span>";
00439 lblCurrentTriangle->setText(si);
00440 }
00441 isCapturing = false;
00442 }
00443 else
00444 {
00445 btnPossibleSolutions_Right->setVisible(false);
00446 btnPossibleSolutions_Left->setVisible(false);
00447 lblPossibleSolutions_Position->setVisible(false);
00448 lblSolutionMatrix->setText("");
00449 possibleSolutions_Position = 0;
00450 solutionFrames->clear();
00451 lblSolutions->setText("Capturing...");
00452 lblCurrentTriangle->setText("");
00453 btnCapture->setText("Stop capturing");
00454 isCapturing = true;
00455 ROS_INFO("Capturing...");
00456 }
00457 }
00458
00459 void MainWindow::calculateTransformationFrames()
00460 {
00461 Eigen::Matrix4d temp;
00462 solutionFrames->clear();
00463 solver->solve(currentTriangles->at(0), currentTriangles->at(1), currentTriangles->at(2));
00464 for (unsigned i = 0; i< solver->solutions.size(); i++)
00465 {
00466 temp = solver->calculateTransformationMatrix(currentTriangles->at(0), currentTriangles->at(1), currentTriangles->at(2), solver->solutions[i]);
00467 if (feasibilityChecker->checkFeasibility_pose(temp))
00468 {
00469 ROS_INFO_STREAM("Triangle " << i << ": Feasability ok");
00470 solutionFrames->push_back(temp);
00471 }
00472 }
00473 if (solutionFrames->size() > 0)
00474 {
00475 ROS_INFO_STREAM("Found solution");
00476 selectedTriangle->clear();
00477 selectedTriangle->push_back(currentTriangles->at(0));
00478 selectedTriangle->push_back(currentTriangles->at(1));
00479 selectedTriangle->push_back(currentTriangles->at(2));
00480 toggleCaptureMode();
00481 }
00482 }
00483
00484 void MainWindow::showPossibleSolutions()
00485 {
00486 QString siMatrix, siSolutionCounter;
00487 if (solutionFrames->size() > 0)
00488 {
00489 if (possibleSolutions_Position < 0 || possibleSolutions_Position >= (int)solutionFrames->size()) {possibleSolutions_Position = 0;}
00490 Eigen::Matrix4d *temp;
00491 siMatrix = "<span> <table style='width:100%'>";
00492 temp = &solutionFrames->at(possibleSolutions_Position);
00493 siMatrix += "<tr>";
00494 addMatrixRow (&siMatrix, (*temp)(0,0) );
00495 addMatrixRow (&siMatrix, (*temp)(0,1) );
00496 addMatrixRow (&siMatrix, (*temp)(0,2) );
00497 addMatrixRow (&siMatrix, (*temp)(0,3) );
00498 siMatrix += "</tr>";
00499 siMatrix += "<tr>";
00500 addMatrixRow (&siMatrix, (*temp)(1,0) );
00501 addMatrixRow (&siMatrix, (*temp)(1,1) );
00502 addMatrixRow (&siMatrix, (*temp)(1,2) );
00503 addMatrixRow (&siMatrix, (*temp)(1,3) );
00504 siMatrix += "</tr>";
00505 siMatrix += "<tr>";
00506 addMatrixRow (&siMatrix, (*temp)(2,0) );
00507 addMatrixRow (&siMatrix, (*temp)(2,1) );
00508 addMatrixRow (&siMatrix, (*temp)(2,2) );
00509 addMatrixRow (&siMatrix, (*temp)(2,3) );
00510 siMatrix += "</tr>";
00511 siMatrix += "<tr>";
00512 addMatrixRow (&siMatrix, (*temp)(3,0) );
00513 addMatrixRow (&siMatrix, (*temp)(3,1) );
00514 addMatrixRow (&siMatrix, (*temp)(3,2) );
00515 addMatrixRow (&siMatrix, (*temp)(3,3) );
00516 siMatrix += "</tr>";
00517 siMatrix += "</table></span>";
00518
00519 siMatrix = siMatrix + "<br/>";
00520 siMatrix = siMatrix + "Distance to top: ";
00521 double distance1 = pow(selectedTriangle->at(0)[0] -(*temp)(0,3), 2);
00522 distance1 += pow(selectedTriangle->at(0)[1] - (*temp)(1,3), 2);
00523 distance1 += pow((*temp)(2,3), 2);
00524 distance1 = sqrt(distance1);
00525 double distance2 = pow(selectedTriangle->at(1)[0] -(*temp)(0,3), 2);
00526 distance2 += pow(selectedTriangle->at(1)[1] - (*temp)(1,3), 2);
00527 distance2 += pow((*temp)(2,3), 2);
00528 distance2 = sqrt(distance2);
00529 double distance3 = pow(selectedTriangle->at(2)[0] -(*temp)(0,3), 2);
00530 distance3 += pow(selectedTriangle->at(2)[1] - (*temp)(1,3), 2);
00531 distance3 += pow((*temp)(2,3), 2);
00532 distance3 = sqrt(distance3);
00533
00534 siMatrix += QString::number(distance1,'.', 3);
00535 siMatrix += " ";
00536 siMatrix += QString::number(distance2,'.', 3);
00537 siMatrix += " ";
00538 siMatrix += QString::number(distance3,'.', 3);
00539
00540 btnPossibleSolutions_Right->setVisible((solutionFrames->size() > 1) && possibleSolutions_Position < (int)solutionFrames->size()-1);
00541 btnPossibleSolutions_Left->setVisible((solutionFrames->size() > 1) && possibleSolutions_Position > 0);
00542 lblPossibleSolutions_Position->setVisible((solutionFrames->size() > 1));
00543 siSolutionCounter = "Solution ";
00544 siSolutionCounter += QString::number(possibleSolutions_Position+1);
00545 siSolutionCounter += " \\ ";
00546 siSolutionCounter += QString::number(solutionFrames->size());
00547
00548 this->newTransform_Laserscan(*temp, distance1);
00549
00550 markerPublisher->publishTetrahedon(selectedTriangle->at(0), selectedTriangle->at(1), selectedTriangle->at(2), Eigen::Vector3d((*temp)(0,3), (*temp)(1,3), (*temp)(2,3)));
00551 }
00552 lblPossibleSolutions_Position->setText(siSolutionCounter);
00553 lblSolutionMatrix->setText(siMatrix);
00554 }
00555
00556 void MainWindow::addMatrixRow(QString* text, double value)
00557 {
00558 (*text) += "<td style='width:25%'>";
00559 (*text) += QString::number(value, ' ', 3);
00560 (*text) += "</td>";
00561 }
00562
00563 void MainWindow::trianglesFound(std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > *triangles)
00564 {
00565 currentTriangles = triangles;
00566 unsigned int size = triangles->size();
00567 if (size % 3 == 0) {
00568 size = size / 3;
00569 QString si;
00570
00571 if (size == 0)
00572 {
00573 si = "<span style='color:red'>No triangles detected.";
00574 btnCapture->setEnabled(false);
00575 }
00576 else if (size == 1)
00577 {
00578 si = "<span style='color:green'>One triangle detected:";
00579 btnCapture->setEnabled(true);
00580 }
00581 else
00582 {
00583 si = "<span style='color:yellow'>";
00584 si += QString::number(size);
00585 si += " triangles found.";
00586 btnCapture->setEnabled(false);
00587 }
00588 markerPublisher->publishTriangles(triangles);
00589 for (unsigned int i = 0; i < size; i++)
00590 {
00591 ROS_DEBUG_STREAM("Triangle found at [" << QString::number(triangles->at(i*3)[0]).toStdString() << ", " << QString::number(triangles->at(i*3)[1]).toStdString() << "], "
00592 << "[" << QString::number(triangles->at(i*3+1)[0]).toStdString() << ", " << QString::number(triangles->at(i*3+1)[1]).toStdString() << "], "
00593 << "[" << QString::number(triangles->at(i*3+2)[0]).toStdString() << ", " << QString::number(triangles->at(i*3+2)[1]).toStdString() << "]");
00594 si = si + "<br/>";
00595 for (unsigned int j = 0; j < 3; j++)
00596 {
00597 si += "[";
00598 si += QString::number(triangles->at(i*3+j)[0],'.', 2);
00599 si += ", ";
00600 si += QString::number(triangles->at(i*3+j)[1],'.', 2);
00601 si += "] ";
00602 }
00603 }
00604 si += "</span>";
00605 lblTriangles->setText(si);
00606 if (isCapturing)
00607 {
00608 calculateTransformationFrames();
00609 }
00610 }
00611 }
00612