HandEyeCalibrationWidgetController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotComponents::gui-plugins::HandEyeCalibrationWidgetController
17  * @author Stefan Reither ( stef dot reither at web dot de )
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
26 
30 
31 #include <RobotAPI/interface/core/RobotState.h>
32 
33 #include <RobotComponents/gui-plugins/HandEyeCalibration/ui_HandEyeCalibrationWidget.h>
34 
35 #include <Inventor/sensors/SoTimerSensor.h>
36 
37 //Point Cloud Processor
39 
40 //VisionX
42 #include <VisionX/interface/core/PointCloudProviderInterface.h>
43 
44 // Qt
45 #include <QColorDialog>
46 #include <QFile>
47 
50 
51 namespace armarx
52 {
53  /**
54  \page RobotComponents-GuiPlugins-HandEyeCalibration HandEyeCalibration
55  \brief The HandEyeCalibration allows visualizing ...
56 
57  \image html HandEyeCalibration.png
58  The user can
59 
60  API Documentation \ref HandEyeCalibrationWidgetController
61 
62  \see HandEyeCalibrationGuiPlugin
63  */
64 
65  /**
66  * \class HandEyeCalibrationWidgetController
67  * \brief HandEyeCalibrationWidgetController brief one line description
68  *
69  * Detailed description
70  */
72  public armarx::ArmarXComponentWidgetControllerTemplate<HandEyeCalibrationWidgetController>,
74  {
75  Q_OBJECT
76 
77  public:
78  /**
79  * Controller Constructor
80  */
82 
83  /**
84  * Controller destructor
85  */
87 
88  /**
89  * @see ArmarXWidgetController::loadSettings()
90  */
91  void loadSettings(QSettings* settings) override;
92 
93  /**
94  * @see ArmarXWidgetController::saveSettings()
95  */
96  void saveSettings(QSettings* settings) override;
97 
98  /**
99  * Returns the Widget name displayed in the ArmarXGui to create an
100  * instance of this class.
101  */
102  static QString
104  {
105  return "RobotControl.HandEyeCalibrationGUI";
106  }
107 
108  QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
109  void configured() override;
110 
111  // PointCloudProcessor interface
112  void onInitPointCloudProcessor() override;
113  void onConnectPointCloudProcessor() override;
114  void onDisconnectPointCloudProcessor() override;
115  void onExitPointCloudProcessor() override;
116  void process() override;
117 
118  private:
119  void setupEndEffectorSelection(VirtualRobot::RobotPtr robot);
120  void setupCameraNodeSlider(VirtualRobot::RobotPtr robot);
121  VirtualRobot::RobotPtr loadRobotFromFile() const;
122  std::string getProviderFrame() const;
123  void cropOriginalPointCloud(const pcl::PointCloud<PointT>& cloud,
124  const VirtualRobot::EndEffectorPtr eef) const;
125  std::string formatTransformationMatrix(Eigen::Matrix4f mat,
126  int decimalPlacesOrientation = 6,
127  int decimalPlacesPosition = 2) const;
128  void enableGuiElements();
129  void disableGuiElements();
130  void updateManipulatorVisualization();
131  bool findStringIC(const std::string& strHaystack, const std::string& strNeedle) const;
132 
133  private slots:
134  void processPointCloud();
135  void activeEndEffectorChanged(QString endEffectorName);
136 
137  void slider_croppingRange_changed(int value);
138  void cb_croppingActive_changed(int state);
139  void cb_inverted_changed(bool checked);
140  void btn_copyToClipboard_pressed();
141  void btn_resetToModel_pressed();
142  void btn_backgroundColor_pressed();
143  void btn_pointCloudColor_pressed();
144  void sB_pointSize_changed(int value);
145 
146  void cameraNodeTransformationChanged(double value);
147 
148  void connectQt();
149  void disconnectQt();
150  void initUI();
151  void saveDatapoint();
152  void selectFile();
153 
154  signals:
155  void pointCloudUpdated();
156 
157  private:
158  QPointer<QWidget> m_widget;
159 
160  /**
161  * Widget Form
162  */
163  Ui::HandEyeCalibrationWidget widget;
164  QPointer<SimpleConfigDialog> dialog;
165 
166  std::string providerName;
167  visionx::PointCloudProviderInfo providerInfo;
168  std::string referenceFrame;
169  pcl::PointCloud<PointT>::Ptr providerBuffer;
170 
171  // PointCloudVisualization
172  PointCloudVisualization* pointCloudVisu;
173  bool showPointCloud;
174  // ManipulatorVisualization
175  ManipulatorVisualization* manipulatorVisu;
176 
177  std::string robotStateComponentName;
178  RobotStateComponentInterfacePrx robotStateComponentPrx;
179  VirtualRobot::RobotPtr localRobot;
180  VirtualRobot::RobotPtr pointcloudRobot;
181 
182  VirtualRobot::EndEffectorPtr activeEndEffector;
183  std::map<std::string, std::pair<VirtualRobot::RobotPtr, Eigen::Matrix4f>> robotEEFMap;
184  VirtualRobot::RobotPtr getEEFRobot(VirtualRobot::EndEffectorPtr eef) const;
185  Eigen::Matrix4f getOffsetMatrixForEEF(const VirtualRobot::EndEffectorPtr eef)
186  const; // OffsetMatrix is stored from Model to Pointcloud
187  void setOffsetMatrixForEEF(const VirtualRobot::EndEffectorPtr eef,
188  const Eigen::Matrix4f& offset);
189 
190  bool croppingActive = true;
191 
193  void taskEEFManipulationCB();
195  void taskLocalRobotUpdateCB();
196 
197  // Color Dialog
198  QColorDialog colorDialog;
199 
200  VirtualRobot::RobotNodePtr cameraNode;
201  };
202 } // namespace armarx
ManipulatorVisualization.h
armarx::PointCloudVisualization
Definition: PointCloudVisualization.h:37
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
PeriodicTask.h
PointCloudProvider.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
visionx::PointCloudProviderInfo
Definition: PointCloudProcessor.h:82
ArmarXGuiPlugin.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:177
armarx::HandEyeCalibrationWidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: HandEyeCalibrationWidgetController.h:103
PointCloudProcessor.h
PointCloudVisualization.h
IceUtil::Handle
Definition: forward_declarations.h:30
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::ManipulatorVisualization
Definition: ManipulatorVisualization.h:55
armarx::HandEyeCalibrationWidgetController
HandEyeCalibrationWidgetController brief one line description.
Definition: HandEyeCalibrationWidgetController.h:71
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
ImportExportComponent.h