scanning_widget.cpp
Go to the documentation of this file.
1 #include <QHBoxLayout>
2 #include <QVBoxLayout>
3 #include <QTabWidget>
4 #include <QPushButton>
5 #include <QLabel>
6 #include <QDoubleSpinBox>
7 #include <QLineEdit>
8 #include <QFileDialog>
9 #include <QFileInfo>
10 #include <QFuture>
11 #include <QtConcurrent/QtConcurrentRun>
12 
13 #include "scanning_widget.h"
14 
16  QWidget(parent),
17  package_name_("fanuc_grinding_scanning")
18 {
19  setObjectName("ScanningWidget_");
20  QLabel* cad_meshname_label = new QLabel("CAD mesh file:");
21  cad_meshname_ = new QLineEdit;
22  cad_meshname_->setReadOnly(true);
23  cad_meshname_browse_button_ = new QPushButton("...");
24  cad_meshname_browse_button_->setMaximumSize(QSize(30,30));
25  QHBoxLayout* cad_meshname_layout = new QHBoxLayout;
26  cad_meshname_layout->addWidget(cad_meshname_);
27  cad_meshname_layout->addWidget(cad_meshname_browse_button_);
28 
29  QLabel* cad_marker_name_label = new QLabel("CAD marker name:");
30  cad_marker_name_line_ = new QLineEdit;
31  QHBoxLayout* cad_marker_name_layout = new QHBoxLayout;
32  cad_marker_name_layout->addWidget(cad_marker_name_label);
33  cad_marker_name_layout->addWidget(cad_marker_name_line_);
34 
35  import_cad_button_ = new QPushButton("Import CAD file");
36 
37  scan_choice_container_ = new QWidget;
38  scan_choice_container_->setEnabled(false);
39  QVBoxLayout* scan_choice_layout = new QVBoxLayout(scan_choice_container_);
40 
41  scan_choice_widget_ = new QTabWidget;
42  scan_choice_layout->addWidget(scan_choice_widget_);
43  start_scan_tab_ = new QWidget();
44  import_scan_tab_ = new QWidget();
45  scan_choice_widget_->addTab(import_scan_tab_, "Import scan");
46  scan_choice_widget_->addTab(start_scan_tab_, "Scan");
47 
48  // Import a yaml file to load robot's joint states and start scan
49  QLabel* trajectory_yaml_label = new QLabel("Scan trajectory YAML file:");
50  traj_yaml_file_ = new QLineEdit;
51  traj_yaml_file_->setReadOnly(true);
52  traj_yaml_browse_button_ = new QPushButton("...");
53  traj_yaml_browse_button_->setMaximumSize(QSize(30,30));
54  QHBoxLayout* traj_yaml_layout = new QHBoxLayout;
55  traj_yaml_layout->addWidget(traj_yaml_file_);
56  traj_yaml_layout->addWidget(traj_yaml_browse_button_);
57  // Parameters of the SLS-2
58  QLabel* sls_2_server_name_label = new QLabel("SLS-2 server name:");
59  sls_2_server_name_ = new QLineEdit;
60  QHBoxLayout* sls_2_server_name_layout = new QHBoxLayout;
61  sls_2_server_name_layout->addWidget(sls_2_server_name_label);
62  sls_2_server_name_layout->addWidget(sls_2_server_name_);
63  QLabel* sls_2_ip_address_label = new QLabel("SLS-2 IP address:");
64  sls_2_ip_address_ = new QLineEdit;
65  sls_2_ip_address_->setInputMask("000.000.000.000;_");
66  QHBoxLayout* sls_2_ip_address_layout = new QHBoxLayout;
67  sls_2_ip_address_layout->addWidget(sls_2_ip_address_label);
68  sls_2_ip_address_layout->addWidget(sls_2_ip_address_);
69  // Import SLS-2 calibration matrix
70  QLabel* calibration_yaml_label = new QLabel("SLS-2 calibration YAML file:");
71  calibration_yaml_file_ = new QLineEdit;
72  calibration_yaml_file_->setReadOnly(true);
73  calibration_yaml_browse_button_ = new QPushButton("...");
74  calibration_yaml_browse_button_->setMaximumSize(QSize(30,30));
75  QHBoxLayout* calibration_yaml_layout = new QHBoxLayout;
76  calibration_yaml_layout->addWidget(calibration_yaml_file_);
77  calibration_yaml_layout->addWidget(calibration_yaml_browse_button_);
78 
79  QVBoxLayout* scan_yaml_widget_layout = new QVBoxLayout(start_scan_tab_);
80  scan_yaml_widget_layout->addWidget(trajectory_yaml_label);
81  scan_yaml_widget_layout->addLayout(traj_yaml_layout);
82  scan_yaml_widget_layout->addStretch(1);
83  scan_yaml_widget_layout->addWidget(calibration_yaml_label);
84  scan_yaml_widget_layout->addLayout(calibration_yaml_layout);
85  scan_yaml_widget_layout->addStretch(1);
86  scan_yaml_widget_layout->addLayout(sls_2_server_name_layout);
87  scan_yaml_widget_layout->addLayout(sls_2_ip_address_layout);
88 
89  QLabel* down_sampling_label = new QLabel("Point cloud down-sampling leaf size:");
90  down_sampling_leaf_size_ = new QDoubleSpinBox;
91  down_sampling_leaf_size_->setRange(0.0001, 0.5);
92  down_sampling_leaf_size_->setDecimals(4);
93  down_sampling_leaf_size_->setSingleStep(0.001);
94  down_sampling_leaf_size_->setSuffix(" meters");
95  scan_yaml_widget_layout->addWidget(down_sampling_label);
96  scan_yaml_widget_layout->addWidget(down_sampling_leaf_size_);
97 
98  start_scan_ = new QPushButton("Start scanning");
99  scan_yaml_widget_layout->addWidget(start_scan_);
100 
101  //Import point cloud from an older scan
102  QLabel* scan_mesh_label = new QLabel("Import a scan file:");
103  scan_file_ = new QLineEdit;
104  scan_file_->setReadOnly(true);
105  scan_file_browse_button_ = new QPushButton("...");
106  scan_file_browse_button_->setMaximumSize(QSize(30,30));
107  QHBoxLayout* scan_file_label_layout = new QHBoxLayout;
108  scan_file_label_layout->addWidget(scan_file_);
109  scan_file_label_layout->addWidget(scan_file_browse_button_);
110  import_scan_ = new QPushButton("Import scan mesh or point cloud");
111  QVBoxLayout* import_scan_widget_layout = new QVBoxLayout (import_scan_tab_);
112  import_scan_widget_layout->addWidget(scan_mesh_label);
113  import_scan_widget_layout->addLayout(scan_file_label_layout);
114  import_scan_widget_layout->addStretch(1);
115  import_scan_widget_layout->addWidget(import_scan_);
116 
117  QLabel* scan_marker_name_label = new QLabel("Scan marker name:");
118  scan_marker_name_line_ = new QLineEdit;
119  QVBoxLayout* scan_marker_name_layout = new QVBoxLayout;
120  scan_choice_layout->addLayout(scan_marker_name_layout);
121  scan_marker_name_layout->addWidget(scan_marker_name_label);
122  scan_marker_name_layout->addWidget(scan_marker_name_line_);
123 
124  QVBoxLayout* scanning_layout = new QVBoxLayout(this);
125  scanning_layout->addWidget(cad_meshname_label);
126  scanning_layout->addLayout(cad_meshname_layout);
127  scanning_layout->addLayout(cad_marker_name_layout);
128  scanning_layout->addWidget(import_cad_button_);
129  scanning_layout->addStretch(2);
130  scanning_layout->addWidget(scan_choice_container_);
131  scanning_layout->addStretch(1);
132 
133  connect(cad_meshname_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
134  connect(traj_yaml_file_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
135  connect(sls_2_server_name_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
136  connect(sls_2_ip_address_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
137  connect(down_sampling_leaf_size_, SIGNAL(valueChanged(double)), this, SLOT(triggerSave()));
138  connect(calibration_yaml_file_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
139  connect(cad_marker_name_line_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
140  connect(scan_file_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
141  connect(scan_marker_name_line_, SIGNAL(textChanged(QString)), this, SLOT(triggerSave()));
142  connect(start_scan_, SIGNAL(released()), this, SLOT(scanningButtonHandler()));
143  connect(cad_meshname_browse_button_, SIGNAL(released()), this, SLOT(browseCADFiles()));
144  connect(traj_yaml_browse_button_, SIGNAL(released()), this, SLOT(browseTrajectoryFiles()));
145  connect(calibration_yaml_browse_button_, SIGNAL(released()), this, SLOT(browseCalibrationFiles()));
146  connect(scan_file_browse_button_, SIGNAL(released()), this, SLOT(browseScannedFiles()));
147  connect(import_scan_, SIGNAL(released()), this, SLOT(importScanFileButtonHandler()));
148  connect(import_cad_button_, SIGNAL(released()), this, SLOT(importCADFileButtonHandler()));
149 
150  connect(this, SIGNAL(enableScanWidget()), this, SLOT(enableScanWidgetHandler()));
151 
152  // Subscriber to receive messages from the exterior
154 
155  // Setup client
156  scanning_service_ = nh_.serviceClient<fanuc_grinding_scanning::ScanningService>("scanning_service");
157  publish_meshfile_service_ = nh_.serviceClient<fanuc_grinding_publish_meshfile::PublishMeshfileService>("publish_meshfile_service");
158 
159  QFuture<void> future = QtConcurrent::run(this, &fanuc_grinding_rviz_plugin::ScanningWidget::connectToServices);
160 }
161 
162 void fanuc_grinding_rviz_plugin::ScanningWidget::newStatusMessage(const std_msgs::String::ConstPtr &msg)
163 {
164  Q_EMIT sendStatus(QString::fromStdString(msg->data));
165 }
166 
167 void fanuc_grinding_rviz_plugin::ScanningWidget::setScanningParams(const fanuc_grinding_scanning::ScanningService::Request &params)
168 {
169  srv_scanning_.request.YamlFileName = params.YamlFileName;
170  srv_scanning_.request.SLS2ServerName = params.SLS2ServerName;
171  srv_scanning_.request.SLS2IpAddress = params.SLS2IpAddress;
172  srv_scanning_.request.YamlCalibrationFileName = params.YamlCalibrationFileName;
173  srv_scanning_.request.CADName = params.CADName;
174  srv_scanning_.request.MarkerName = params.MarkerName;
175  updateGUI();
176 }
177 
178 void fanuc_grinding_rviz_plugin::ScanningWidget::setPublishParams(const fanuc_grinding_publish_meshfile::PublishMeshfileService::Request &params)
179 {
180  srv_publish_meshfile_.request.MeshName = params.MeshName;
181  srv_publish_meshfile_.request.MarkerName = params.MarkerName;
182  srv_publish_meshfile_.request.PosX = params.PosX;
183  srv_publish_meshfile_.request.PosY = params.PosY;
184  srv_publish_meshfile_.request.PosZ = params.PosZ;
185  srv_publish_meshfile_.request.RotX = params.RotX;
186  srv_publish_meshfile_.request.RotY = params.RotY;
187  srv_publish_meshfile_.request.RotZ = params.RotZ;
188  srv_publish_meshfile_.request.RotW = params.RotW;
189  srv_publish_meshfile_.request.ColorR = params.ColorR;
190  srv_publish_meshfile_.request.ColorG = params.ColorG;
191  srv_publish_meshfile_.request.ColorB = params.ColorB;
192  srv_publish_meshfile_.request.ColorA = params.ColorA;
193  srv_publish_meshfile_.request.WaitForSubscriber = params.WaitForSubscriber;
194  updateGUI();
195 }
196 
198 {
199  traj_yaml_file_->setText(QString::fromStdString(srv_scanning_.request.YamlFileName));
200  sls_2_server_name_->setText(QString::fromStdString(srv_scanning_.request.SLS2ServerName));
201  sls_2_ip_address_->setText(QString::fromStdString(srv_scanning_.request.SLS2IpAddress));
202  calibration_yaml_file_->setText(QString::fromStdString(srv_scanning_.request.YamlCalibrationFileName));
203  cad_meshname_->setText(QString::fromStdString(srv_publish_meshfile_.request.MeshName));
204  cad_marker_name_line_->setText(QString::fromStdString(srv_publish_meshfile_.request.MarkerName));
205  scan_marker_name_line_->setText(QString::fromStdString(srv_scanning_.request.MarkerName));
206  down_sampling_leaf_size_->setValue(srv_scanning_.request.VoxelGridLeafSize);
207 }
208 
210 {
211  srv_scanning_.request.YamlFileName = traj_yaml_file_->text().toStdString();
212  srv_scanning_.request.SLS2ServerName = sls_2_server_name_->text().toStdString();
213  srv_scanning_.request.SLS2IpAddress = sls_2_ip_address_->text().toStdString();
214  srv_scanning_.request.YamlCalibrationFileName = calibration_yaml_file_->text().toStdString();
215  srv_scanning_.request.MarkerName = scan_marker_name_line_->text().toStdString();
216  srv_scanning_.request.CADName = cad_meshname_->text().toStdString();
217  srv_scanning_.request.VoxelGridLeafSize = down_sampling_leaf_size_->value();
218  srv_publish_meshfile_.request.MeshName = cad_meshname_->text().toStdString();
219  srv_publish_meshfile_.request.MarkerName = cad_marker_name_line_->text().toStdString();
220 }
221 
223 {
224  QFileDialog cad_mesh_browser;
225  std::string meshes_path = ros::package::getPath(package_name_) + "/meshes/";
226  QString file_path = cad_mesh_browser.getOpenFileName(0, tr("Import File Dialog"), QString::fromStdString(meshes_path), tr("Meshfiles (*.ply *.stl *.obj)"));
227  if(file_path != "")
228  {
229  cad_meshname_->setText(file_path);
230  }
231 }
232 
234 {
235  QFileDialog yaml_browser;
236  std::string yaml_path = ros::package::getPath(package_name_) + "/yaml/";
237  QString file_path = yaml_browser.getOpenFileName(0, tr("Import File Dialog"), QString::fromStdString(yaml_path), tr("Yaml files (*.yaml)"));
238  if(file_path != "")
239  {
240  traj_yaml_file_->setText(file_path);
241  }
242 }
243 
245 {
246  QFileDialog yaml_browser;
247  std::string yaml_path = ros::package::getPath(package_name_) + "/yaml/";
248  QString file_path = yaml_browser.getOpenFileName(0, tr("Import File Dialog"), QString::fromStdString(yaml_path), tr("Yaml files (*.yaml)"));
249  if(file_path != "")
250  {
251  calibration_yaml_file_->setText(file_path);
252  }
253 }
254 
256 {
257  QFileDialog scan_file_browser;
258  QString file_path = scan_file_browser.getOpenFileName(0, tr("Import File Dialog"), "/home/dell/catkin_ws/src/fanuc_grinding/meshes");
259  if(file_path != "")
260  {
261  scan_file_->setText(file_path);
262  }
263 }
264 
266 {
267  scan_choice_container_->setEnabled(true);
268 }
269 
271 {
272  QFileInfo Fout(cad_meshname_->text());
273  if (!Fout.exists())
274  {
275  Q_EMIT sendMsgBox("Error loading CAD file",
276  "The specified file does not exist",
277  cad_meshname_->text());
278  Q_EMIT sendStatus("CAD file does not exist");
279  return;
280  }
281 
282  if (cad_marker_name_line_->text().isEmpty())
283  {
284  Q_EMIT sendMsgBox("Error publishing CAD marker",
285  "The marker name cannot be empty", "");
286  Q_EMIT sendStatus("Marker name is empty");
287  return;
288  }
289 
290  // Fill in the request
291  srv_publish_meshfile_.request.MeshName = cad_meshname_->text().toStdString();
292  srv_publish_meshfile_.request.MarkerName = cad_marker_name_line_->text().toStdString();
293  srv_publish_meshfile_.request.PosX = 1.4;
294  srv_publish_meshfile_.request.PosY = 0.0;
295  srv_publish_meshfile_.request.PosZ = -0.065;
296  srv_publish_meshfile_.request.RotX = 0.0;
297  srv_publish_meshfile_.request.RotY = 0.0;
298  srv_publish_meshfile_.request.RotZ = 0.0;
299  srv_publish_meshfile_.request.RotW = 1.0;
300  srv_publish_meshfile_.request.ColorR = 130 / 255.0;
301  srv_publish_meshfile_.request.ColorG = 75 / 255.0;
302  srv_publish_meshfile_.request.ColorB = 75 / 255.0;
303  srv_publish_meshfile_.request.ColorA = 1.0;
304  srv_publish_meshfile_.request.WaitForSubscriber = false;
305 
306  // Start client service call in an other thread
307  QFuture<void> future = QtConcurrent::run(this, &ScanningWidget::publishCADMeshOrCloudFile);
308 }
309 
311 {
312  QFileInfo Fout(cad_meshname_->text());
313  if(!Fout.exists())
314  {
315  Q_EMIT sendMsgBox("Error loading scan file",
316  "The specified file does not exist",
317  cad_meshname_->text());
318  Q_EMIT sendStatus("Scan file does not exist");
319  return;
320  }
321  if(scan_marker_name_line_->text().isEmpty())
322  {
323  Q_EMIT sendMsgBox("Error publishing scan marker",
324  "The marker name cannot be empty","");
325  Q_EMIT sendStatus("Marker name is empty");
326  return;
327  }
328  else
329  {
330  // Fill in the request
331  srv_publish_meshfile_.request.MeshName = scan_file_->text().toStdString();
332  srv_publish_meshfile_.request.MarkerName = scan_marker_name_line_->text().toStdString();
333  srv_publish_meshfile_.request.PosX = 0.0;
334  srv_publish_meshfile_.request.PosY = 0.0;
335  srv_publish_meshfile_.request.PosZ = 0.0;
336  srv_publish_meshfile_.request.RotX = 0.0;
337  srv_publish_meshfile_.request.RotY = 0.0;
338  srv_publish_meshfile_.request.RotZ = 0.0;
339  srv_publish_meshfile_.request.RotW = 1.0;
340  srv_publish_meshfile_.request.ColorR = 75 / 255.0;
341  srv_publish_meshfile_.request.ColorG = 75 / 255.0;
342  srv_publish_meshfile_.request.ColorB = 130 / 255.0;
343  srv_publish_meshfile_.request.ColorA = 1.0;
344  srv_publish_meshfile_.request.WaitForSubscriber = true;
345 
346  // Start client service call in an other thread
347  QFuture<void> future = QtConcurrent::run(this, &ScanningWidget::publishScanMeshOrCloudFile);
348  }
349 }
350 
352 {
353  // Disable UI
354  Q_EMIT enablePanel(false);
355 
356  // Call client service
358  Q_EMIT sendStatus(QString::fromStdString(srv_publish_meshfile_.response.ReturnMessage));
359 
360  if(srv_publish_meshfile_.response.ReturnStatus == true)
361  {
362  Q_EMIT enableScanWidget();
363  Q_EMIT sendCADDatas(QString::fromStdString(srv_publish_meshfile_.request.MeshName));
364  }
365  else
366  {
367  Q_EMIT sendMsgBox("Error importing mesh/point cloud file",
368  QString::fromStdString(srv_publish_meshfile_.response.ReturnMessage),
369  QString::fromStdString(srv_publish_meshfile_.request.MeshName));
370  }
371 
372  // Re-enable UI
373  Q_EMIT enablePanel(true); // Enable UI
374 }
375 
377 {
378  // Disable UI
379  Q_EMIT enablePanel(false);
380 
381  // Call client service
383  Q_EMIT sendStatus(QString::fromStdString(srv_publish_meshfile_.response.ReturnMessage));
384 
385  if(srv_publish_meshfile_.response.ReturnStatus == true)
386  {
387  //Q_EMIT enablePanelAlignment();
388  Q_EMIT enablePanelPathPlanning();
389  Q_EMIT sendScanDatas(QString::fromStdString(srv_publish_meshfile_.request.MeshName));
390  }
391  else
392  {
393  Q_EMIT sendMsgBox("Error importing mesh/point cloud file",
394  QString::fromStdString(srv_publish_meshfile_.response.ReturnMessage),
395  QString::fromStdString(srv_publish_meshfile_.request.MeshName));
396  }
397 
398  // Re-enable UI
399  Q_EMIT enablePanel(true); // Enable UI
400 }
401 
403 {
404  QFileInfo traj_yaml_file(traj_yaml_file_->text());
405  if (!traj_yaml_file.exists())
406  {
407  Q_EMIT sendMsgBox("Error starting scanning",
408  "The specified trajectory YAML file does not exist", "");
409  Q_EMIT sendStatus("Trajectory YAML file does not exist");
410  return;
411  }
412 
413  QFileInfo calibration_yaml_file(calibration_yaml_file_->text());
414  if (!calibration_yaml_file.exists())
415  {
416  Q_EMIT sendMsgBox("Error starting scanning",
417  "The specified calibration YAML file does not exist", "");
418  return;
419  }
420 
421  if (scan_marker_name_line_->text().isEmpty())
422  {
423  Q_EMIT sendMsgBox("Error starting scanning", "Please specify the scan marker name", "");
424  Q_EMIT sendStatus("Scan marker name is empty");
425  return;
426  }
427 
428  if(sls_2_server_name_->text().isEmpty())
429  {
430  Q_EMIT sendMsgBox("Error starting scanning",
431  "Please specify the SLS-2 server name", "");
432  Q_EMIT sendStatus("SLS-2 server name is empty");
433  return;
434  }
435 
436  // Start client service call in an other thread
437  QFuture<void> future = QtConcurrent::run(this, &ScanningWidget::scanning);
438 }
439 
441 {
442  // Disable UI
443  Q_EMIT enablePanel(false);
444 
445  // Call client service
447  Q_EMIT sendStatus(QString::fromStdString(srv_scanning_.response.ReturnMessage));
448 
449  if(srv_scanning_.response.ReturnStatus == true)
450  {
451  //Q_EMIT enablePanelAlignment();
452  Q_EMIT enablePanelPathPlanning();
453  Q_EMIT sendScanDatas(QString::fromStdString(srv_scanning_.response.ScanMeshName));
454  }
455  else
456  {
457  Q_EMIT sendMsgBox("Error scanning",
458  QString::fromStdString(srv_scanning_.response.ReturnMessage),
459  "");
460  }
461 
462  // Re-enable UI
463  Q_EMIT enablePanel(true); // Enable UI
464 }
465 
467 {
468  Q_EMIT enablePanel(false);
469 
470  // Check offset_move_robot_ connection
471  Q_EMIT sendStatus("Connecting to service");
472  while (ros::ok())
473  {
474  // We don't check status_sub_ number of publishers, it is not mandatory to have a status publisher.
475 
477  {
478  ROS_INFO_STREAM(objectName().toStdString() + " RViz panel connected to the service " << scanning_service_.getService());
479  Q_EMIT sendStatus(QString::fromStdString("RViz panel connected to the service: " + scanning_service_.getService()));
480  break;
481  }
482  else
483  {
484  ROS_WARN_STREAM(objectName().toStdString() + " RViz panel could not connect to ROS service:\n\t" << scanning_service_.getService());
485  Q_EMIT sendStatus(QString::fromStdString("RViz panel could not connect to ROS service: " + scanning_service_.getService()));
486  sleep(1);
487  }
488  }
489  while (ros::ok())
490  {
492  {
493  ROS_INFO_STREAM(objectName().toStdString() + " RViz panel connected to the service " << publish_meshfile_service_.getService());
494  Q_EMIT sendStatus(QString::fromStdString("RViz panel connected to the service: " + publish_meshfile_service_.getService()));
495  break;
496  }
497  else
498  {
499  ROS_WARN_STREAM(objectName().toStdString() + " RViz panel could not connect to ROS service:\n\t" << publish_meshfile_service_.getService());
500  Q_EMIT sendStatus(QString::fromStdString("RViz panel connected to the service: " + publish_meshfile_service_.getService()));
501  sleep(1);
502  }
503  }
504 
505  ROS_INFO_STREAM(objectName().toStdString() + " service connections have been made");
506  Q_EMIT sendStatus("Ready to take commands");
507  Q_EMIT enablePanel(true);
508 }
509 
511 {
512  Q_EMIT guiChanged();
514  updateGUI();
515 }
516 
517 // Save all configuration data from this panel to the given Config object
519 {
520  // Save offset value into the config file
521  config.mapSetValue(objectName() + "traj_yaml_file", traj_yaml_file_->text());
522  config.mapSetValue(objectName() + "sls_2_server_name", sls_2_server_name_->text());
523  config.mapSetValue(objectName() + "sls_2_ip_address", sls_2_ip_address_->text());
524  config.mapSetValue(objectName() + "cad_file", cad_meshname_->text());
525  config.mapSetValue(objectName() + "cad_marker_name", cad_marker_name_line_->text());
526  config.mapSetValue(objectName() + "scan_marker_name", scan_marker_name_line_->text());
527  config.mapSetValue(objectName() + "calibration_yaml_file", calibration_yaml_file_->text());
528  config.mapSetValue(objectName() + "scan_filename", scan_file_->text());
529  config.mapSetValue(objectName() + "down_sampling_leaf_size", down_sampling_leaf_size_->value());
530 }
531 
532 // Load all configuration data for this panel from the given Config object.
534 {
535  QString tmp;
536  // Load offset value from config file (if it exists)
537 
538  if (config.mapGetString(objectName() + "cad_file", &tmp))
539  cad_meshname_->setText(tmp);
540  else
541  {
542  std::string meshes_path = ros::package::getPath(package_name_) + "/meshes/";
543  cad_meshname_->setText(QString::fromStdString(meshes_path+"DAC_580813.stl"));
544  }
545 
546  if (config.mapGetString(objectName() + "cad_marker_name", &tmp))
547  cad_marker_name_line_->setText(tmp);
548  else
549  cad_marker_name_line_->setText("cad");
550 
551  if (config.mapGetString(objectName() + "traj_yaml_file", &tmp))
552  traj_yaml_file_->setText(tmp);
553  else
554  {
555  std::string meshes_path = ros::package::getPath(package_name_) + "/yaml/";
556  traj_yaml_file_->setText(QString::fromStdString(meshes_path+"trajectory_DaC.yaml"));
557  }
558 
559  if (config.mapGetString(objectName() + "sls_2_server_name", &tmp))
560  sls_2_server_name_->setText(tmp);
561  else
562  sls_2_server_name_->setText("m4500");
563 
564  if (config.mapGetString(objectName() + "sls_2_ip_address", &tmp))
565  sls_2_ip_address_->setText(tmp);
566  else
567  sls_2_ip_address_->setText("192.168.100.50");
568 
569  if (config.mapGetString(objectName() + "calibration_yaml_file", &tmp))
570  calibration_yaml_file_->setText(tmp);
571  else
572  {
573  std::string yaml_path = ros::package::getPath(package_name_) + "/yaml/";
574  calibration_yaml_file_->setText(QString::fromStdString(yaml_path+"camera_calibration.yaml"));
575  }
576 
577  if (config.mapGetString(objectName() + "scan_file", &tmp))
578  scan_file_->setText(tmp);
579  else
580  {
581  std::string yaml_path = ros::package::getPath(package_name_) + "/meshes/";
582  scan_file_->setText(QString::fromStdString(yaml_path+"DAC_580813_scan.ply"));
583  }
584 
585  if (config.mapGetString(objectName() + "scan_marker_name", &tmp))
586  scan_marker_name_line_->setText(tmp);
587  else
588  scan_marker_name_line_->setText("scan");
589 
590  float tmp_float;
591  if (config.mapGetFloat(objectName() + "down_sampling_leaf_size", &tmp_float))
592  down_sampling_leaf_size_->setValue(tmp_float);
593  else
594  down_sampling_leaf_size_->setValue(0.03);
595 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void sendScanDatas(const QString scan_path)
void load(const rviz::Config &config)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void sendMsgBox(const QString title, const QString msg, const QString info_msg)
bool call(MReq &req, MRes &res)
bool mapGetFloat(const QString &key, float *value_out) const
void sendCADDatas(const QString cad_path)
fanuc_grinding_publish_meshfile::PublishMeshfileService srv_publish_meshfile_
bool mapGetString(const QString &key, QString *value_out) const
void mapSetValue(const QString &key, QVariant value)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
void setPublishParams(const fanuc_grinding_publish_meshfile::PublishMeshfileService::Request &params)
fanuc_grinding_scanning::ScanningService srv_scanning_
ROSCPP_DECL bool ok()
void newStatusMessage(const std_msgs::String::ConstPtr &msg)
#define ROS_WARN_STREAM(args)
ROSLIB_DECL std::string getPath(const std::string &package_name)
void sendStatus(const QString status)
#define ROS_INFO_STREAM(args)
std::string getService()
void setScanningParams(const fanuc_grinding_scanning::ScanningService::Request &params)


rviz_plugin
Author(s): Kévin Bolloré, Victor Lamoine - Institut Maupertuis
autogenerated on Thu Dec 19 2019 03:38:28