comparison_widget.cpp
Go to the documentation of this file.
1 #include <QVBoxLayout>
2 #include <QPushButton>
3 #include <QLabel>
4 #include <QFuture>
5 #include <QtConcurrent/QtConcurrentRun>
6 
7 #include "comparison_widget.h"
8 
10 {
11  setObjectName("ComparisonWidget_");
12  comparison_button_ = new QPushButton("Start comparison");
13  QVBoxLayout* comparison_layout = new QVBoxLayout(this);
14  comparison_layout->addWidget(comparison_button_);
15 
16  // Connect handlers
17  connect(comparison_button_, SIGNAL(released()), this, SLOT(comparisonButtonHandler()));
18 
19  //Setup client
20  comparison_service_ = nh_.serviceClient<fanuc_grinding_comparison::ComparisonService>("comparison_service");
21 
22  QFuture<void> future = QtConcurrent::run(this, &fanuc_grinding_rviz_plugin::ComparisonWidget::connectToServices);
23 }
24 
26 {
27  Q_EMIT guiChanged();
29  updateGUI();
30 }
31 
32 void fanuc_grinding_rviz_plugin::ComparisonWidget::setComparisonParams(const fanuc_grinding_comparison::ComparisonService::Request &params)
33 {
34  srv_comparison_.request = params;
35  updateGUI();
36 }
37 
39 {
40  // Not implemented yet
41 }
42 
44 {
45  // Not implemented yet
46 }
47 
49  const QString scan_filename)
50 {
51  srv_comparison_.request.CADFileName = cad_filename.toStdString();
52  srv_comparison_.request.ScanFileName = scan_filename.toStdString();
53 }
54 
56 {
57  // get CAD and Scan params which are stored in grinding rviz plugin
58  Q_EMIT getCADAndScanParams();
59 // Start client service call in an other thread
60  QFuture<void> future = QtConcurrent::run(this, &ComparisonWidget::comparison);
61 }
62 
64 {
65  // Disable UI
66  Q_EMIT enablePanel(false);
67 
68  // Call client service
70  Q_EMIT sendStatus(QString::fromStdString(srv_comparison_.response.ReturnMessage));
71 
72  if(srv_comparison_.response.ReturnStatus == true)
73  Q_EMIT enablePanelPathPlanning();
74  else
75  {
76  Q_EMIT sendMsgBox("Error comparing meshes",
77  QString::fromStdString(srv_comparison_.response.ReturnMessage), "");
78  }
79 
80  // Re-enable UI
81  Q_EMIT enablePanel(true); // Enable UI
82 }
83 
85 {
86  Q_EMIT enablePanel(false);
87 
88  // Check offset_move_robot_ connection
89  Q_EMIT sendStatus("Connecting to service");
90  while (ros::ok())
91  {
93  {
94  ROS_INFO_STREAM(objectName().toStdString() + " RViz panel connected to the service " << comparison_service_.getService());
95  Q_EMIT sendStatus(QString::fromStdString("RViz panel connected to the service: " + comparison_service_.getService()));
96  break;
97  }
98  else
99  {
100  ROS_WARN_STREAM(objectName().toStdString() + " RViz panel could not connect to ROS service:\n\t" << comparison_service_.getService());
101  Q_EMIT sendStatus(QString::fromStdString("RViz panel could not connect to ROS service: " + comparison_service_.getService()));
102  sleep(1);
103  }
104  }
105 
106  ROS_INFO_STREAM(objectName().toStdString() + " service connections have been made");
107  Q_EMIT sendStatus("Ready to take commands");
108  Q_EMIT enablePanel(true);
109 }
110 
111 // Save all configuration data from this panel to the given Config object
113 {
114  // NOT IMPLEMENTED YET
115 }
116 
117 // Load all configuration data for this panel from the given Config object.
119 {
120  // NOT IMPLEMENTED YET
121 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
fanuc_grinding_comparison::ComparisonService srv_comparison_
bool call(MReq &req, MRes &res)
void setComparisonParams(const fanuc_grinding_comparison::ComparisonService::Request &params)
void sendMsgBox(const QString title, const QString msg, const QString info_msg)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
ROSCPP_DECL bool ok()
#define ROS_WARN_STREAM(args)
#define ROS_INFO_STREAM(args)
void setCADAndScanParams(const QString cad_filename, const QString scan_filename)
std::string getService()


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