fanuc_grinding_rviz_plugin.cpp
Go to the documentation of this file.
1 #include <QVBoxLayout>
2 #include <QLabel>
3 #include <QMessageBox>
4 #include <QFuture>
5 #include <QtConcurrent/QtConcurrentRun>
6 #include <QWidget>
7 #include <QTabWidget>
8 
10 
12 {
14  rviz::Panel(parent)
15 {
16  // Create Tabs
17  tab_widget_ = new QTabWidget();
23 
24  tab_widget_->addTab(scanning_widget_, "Scanning");
25  tab_widget_->addTab(alignment_widget_, "Alignment");
26  tab_widget_->addTab(comparison_widget_, "Comparison");
27  tab_widget_->addTab(path_planning_widget_, "Path planning");
28  tab_widget_->addTab(post_processor_widget_, "Post processor");
29  tab_widget_->setTabEnabled(0, true);
30  tab_widget_->setTabEnabled(1, false);
31  tab_widget_->setTabEnabled(2, false);
32  tab_widget_->setTabEnabled(3, false);
33  tab_widget_->setTabEnabled(4, false);
34 
35  // Bottom status layout
36  QVBoxLayout* status_layout = new QVBoxLayout;
37  status_layout->addWidget(new QLabel("Status:"));
38 
39  // Global Layout
40  QVBoxLayout* global_layout = new QVBoxLayout;
41  global_layout->addWidget(tab_widget_);
42  global_layout->addLayout(status_layout);
43  status_label_ = new QLabel;
44  global_layout->addWidget(status_label_);
45  setLayout(global_layout);
46 
47  // Connect handlers
48  // SCANNING
49  // Will display a status in general status label ( from scanning widget )
50  connect(scanning_widget_, SIGNAL(sendStatus(QString)), this, SLOT(displayStatusHandler(QString)));
51  connect(scanning_widget_, SIGNAL(sendMsgBox(QString, QString , QString)), this,
52  SLOT(displayMsgBoxHandler(QString, QString, QString)));
53 
54  // Call configChanged at each time that scanning_widget_ is modified
55  connect(scanning_widget_, SIGNAL(guiChanged()), this, SLOT(triggerSave()));
56  // Enable AlignementPanel when scanning_widget_ will send the SIGNAL
57  connect(scanning_widget_, SIGNAL(enablePanelAlignment()), this, SLOT(enablePanelAlignmentHandler()));
58  // Enable general panel when scanning_widget_ send the SIGNAL
59  connect(scanning_widget_, SIGNAL(enablePanel(bool)), this, SLOT(enablePanelHandler(bool)));
60 
61  // Will send information about cad and scan in the other widgets
62  connect(scanning_widget_, SIGNAL(sendCADDatas(QString)), this, SLOT(setCADDatas(QString)));
63  connect(scanning_widget_, SIGNAL(sendScanDatas(QString)), this, SLOT(setScanDatas(QString)));
64  // For the demonstrator, we will skip alignment and comparison parts for the moment
65  connect(scanning_widget_, SIGNAL(enablePanelPathPlanning()), this, SLOT(enablePanelPathPlanningHandler()));
66 
67  //ALIGNMENT
68  // Will display a status in general status label ( from alignment widget )
69  connect(alignment_widget_, SIGNAL(sendStatus(QString)), this, SLOT(displayStatusHandler(QString)));
70  connect(alignment_widget_, SIGNAL(sendMsgBox(QString, QString , QString)), this,
71  SLOT(displayMsgBoxHandler(QString, QString, QString)));
72  // Call configChanged at each time that alignment_widget_ is modified
73  connect(alignment_widget_, SIGNAL(guiChanged()), this, SLOT(triggerSave()));
74  // Enable compoarison_panel when alignment_widget_ will send the SIGNAL
75  connect(alignment_widget_, SIGNAL(enablePanelComparison()), this, SLOT(enablePanelComparisonHandler()));
76  // Enable general panel when alignment_widget_ send the SIGNAL
77  connect(alignment_widget_, SIGNAL(enablePanel(bool)), this, SLOT(enablePanelHandler(bool)));
78  // Received a signal from alignment widget in order to get CAD and scan params
79  connect(alignment_widget_, SIGNAL(getCADAndScanParams()), this, SLOT(sendCADAndScanDatasSlot()));
80  // Send a signal to alignment widget in order to give CAD and scan params
81  connect(this, SIGNAL(sendCADAndScanDatas(const QString, const QString)),
82  alignment_widget_, SLOT(setCADAndScanParams(const QString, const QString)));
83 
84 
85  //COMPARISON
86  // Will display a status in general status label ( from comparison widget )
87  connect(comparison_widget_, SIGNAL(sendStatus(QString)), this, SLOT(displayStatusHandler(QString)));
88  connect(comparison_widget_, SIGNAL(sendMsgBox(QString, QString , QString)), this,
89  SLOT(displayMsgBoxHandler(QString, QString, QString)));
90  // Call configChanged at each time that comparison_widget_ is modified
91  connect(comparison_widget_, SIGNAL(guiChanged()), this, SLOT(triggerSave()));
92  // Enable path_planning_widget when comparison_widget_ will send the SIGNAL
93  connect(comparison_widget_, SIGNAL(enablePanelPathPlanning()), this, SLOT(enablePanelPathPlanningHandler()));
94  // Enable general panel when comparison_widget_ send the SIGNAL
95  connect(comparison_widget_, SIGNAL(enablePanel(bool)), this, SLOT(enablePanelHandler(bool)));
96  // Received a signal from comparison widget in order to get CAD and scan params
97  connect(comparison_widget_, SIGNAL(getCADAndScanParams()), this, SLOT(sendCADAndScanDatasSlot()));
98  // Send a signal to comparison widget in order to give CAD and scan params
99  connect(this, SIGNAL(sendCADAndScanDatas(const QString, const QString)),
100  comparison_widget_, SLOT(setCADAndScanParams(const QString, const QString)));
101 
102 
103  //PATH PLANNING
104  // Will display a status in general status label ( from path_planning widget )
105  connect(path_planning_widget_, SIGNAL(sendStatus(QString)), this, SLOT(displayStatusHandler(QString)));
106  connect(path_planning_widget_, SIGNAL(sendMsgBox(QString, QString , QString)), this,
107  SLOT(displayMsgBoxHandler(QString, QString, QString)));
108  // Call configChanged at each time that path_planning_widget is modified
109  connect(path_planning_widget_, SIGNAL(guiChanged()), this, SLOT(triggerSave()));
110  // Enable path_planning_widget when comparison_widget_ will send the SIGNAL
111  connect(path_planning_widget_, SIGNAL(enablePanelPostProcessor()), this, SLOT(enablePanelPostProcessorHandler()));
112  // Enable general panel when path_planning send the SIGNAL
113  connect(path_planning_widget_, SIGNAL(enablePanel(bool)), this, SLOT(enablePanelHandler(bool)));
114  // Received a signal from comparison widget in order to get CAD and scan params
115  connect(path_planning_widget_, SIGNAL(getCADAndScanParams()), this, SLOT(sendCADAndScanDatasSlot()));
116  // Send a signal to comparison widget in order to give CAD and scan params
117  connect(this, SIGNAL(sendCADAndScanDatas(const QString, const QString)),
118  path_planning_widget_, SLOT(setCADAndScanParams(const QString, const QString)));
119 
120  //POST_PROCESSOR
121  // Will display a status in general status label ( from post_processor widget )
122  connect(post_processor_widget_, SIGNAL(sendStatus(QString)), this, SLOT(displayStatusHandler(QString)));
123  connect(post_processor_widget_, SIGNAL(sendMsgBox(QString, QString, QString)), this,
124  SLOT(displayMsgBoxHandler(QString, QString, QString)));
125  // Call configChanged at each time that post_processor_widget is modified
126  connect(post_processor_widget_, SIGNAL(guiChanged()), this, SLOT(triggerSave()));
127  // Enable general panel when post_processor send the SIGNAL
128  connect(post_processor_widget_, SIGNAL(enablePanel(bool)), this, SLOT(enablePanelHandler(bool)));
129  // Receive a signal from post processor widget in order to send robot poses data
130  connect(post_processor_widget_, SIGNAL(getRobotTrajectoryData()), this, SLOT(setRobotTrajectoryData()));
131 
132  connect(this, SIGNAL(displayStatus(const QString)), this, SLOT(displayStatusHandler(const QString)));
133 }
134 
136 {}
137 
139 {
140  tab_widget_->setTabEnabled(1, true);
141 }
142 
144 {
145  tab_widget_->setTabEnabled(2, true);
146 }
147 
149 {
150  tab_widget_->setTabEnabled(3, true);
151 }
152 
154 {
155  tab_widget_->setTabEnabled(4, true);
156 }
157 
159 {
160  setEnabled(status);
161 }
162 
164 {
165  status_label_->setText(message);
166 }
167 
168 void FanucGrindingRvizPlugin::displayMsgBoxHandler(const QString title, const QString msg, const QString info_msg)
169 {
170  enablePanelHandler(false);
171  QMessageBox msg_box;
172  msg_box.setWindowTitle(title);
173  msg_box.setText(msg);
174  msg_box.setInformativeText(info_msg);
175  msg_box.setIcon(QMessageBox::Critical);
176  msg_box.setStandardButtons(QMessageBox::Ok);
177  msg_box.exec();
178  enablePanelHandler(true);
179 }
180 
182 {
183  Q_EMIT configChanged();
184 }
185 
186 void FanucGrindingRvizPlugin::setCADDatas(const QString cad_filename)
187 {
188  cad_filename_ = cad_filename;
189 }
190 
191 void FanucGrindingRvizPlugin::setScanDatas(const QString scan_filename)
192 {
193  scan_filename_ = scan_filename;
194 }
195 
197 {
200 }
201 
203 {
205 }
206 
207 // Save all configuration data from this panel to the given Config object
209 {
210  rviz::Panel::save(config);
211  scanning_widget_->save(config);
212  alignment_widget_->save(config);
213  comparison_widget_->save(config);
214  path_planning_widget_->save(config);
215  post_processor_widget_->save(config);
216 }
217 
218 // Load all configuration data for this panel from the given Config object.
220 {
221  rviz::Panel::load(config);
222  scanning_widget_->load(config);
223  alignment_widget_->load(config);
224  comparison_widget_->load(config);
225  path_planning_widget_->load(config);
226  post_processor_widget_->load(config);
227 }
228 
229 } // end namespace
230 
void load(const rviz::Config &config)
void load(const rviz::Config &config)
void configChanged()
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
void setRobotPoses(const std::vector< geometry_msgs::Pose > &robot_poses)
void displayMsgBoxHandler(const QString title, const QString msg, const QString info_msg)
void sendCADAndScanDatas(const QString, const QString)
void setIsGrindingPose(const std::vector< bool > &is_grinding_pose)
virtual void save(Config config) const
virtual void load(const Config &config)
std::vector< geometry_msgs::Pose > getRobotPoses()


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