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 
24 #include <RobotComponents/gui-plugins/HandEyeCalibration/ui_HandEyeCalibrationWidget.h>
25 #include <Inventor/sensors/SoTimerSensor.h>
26 
32 
33 #include <RobotAPI/interface/core/RobotState.h>
34 
35 //Point Cloud Processor
37 
38 //VisionX
39 #include <VisionX/interface/core/PointCloudProviderInterface.h>
41 
42 // Qt
43 #include <QColorDialog>
44 #include <QFile>
45 
48 
49 namespace armarx
50 {
51  /**
52  \page RobotComponents-GuiPlugins-HandEyeCalibration HandEyeCalibration
53  \brief The HandEyeCalibration allows visualizing ...
54 
55  \image html HandEyeCalibration.png
56  The user can
57 
58  API Documentation \ref HandEyeCalibrationWidgetController
59 
60  \see HandEyeCalibrationGuiPlugin
61  */
62 
63  /**
64  * \class HandEyeCalibrationWidgetController
65  * \brief HandEyeCalibrationWidgetController brief one line description
66  *
67  * Detailed description
68  */
71  public armarx::ArmarXComponentWidgetControllerTemplate < HandEyeCalibrationWidgetController >,
73  {
74  Q_OBJECT
75 
76  public:
77  /**
78  * Controller Constructor
79  */
81 
82  /**
83  * Controller destructor
84  */
86 
87  /**
88  * @see ArmarXWidgetController::loadSettings()
89  */
90  void loadSettings(QSettings* settings) override;
91 
92  /**
93  * @see ArmarXWidgetController::saveSettings()
94  */
95  void saveSettings(QSettings* settings) override;
96 
97  /**
98  * Returns the Widget name displayed in the ArmarXGui to create an
99  * instance of this class.
100  */
101  static QString GetWidgetName()
102  {
103  return "RobotControl.HandEyeCalibrationGUI";
104  }
105  QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
106  void configured() override;
107 
108  // PointCloudProcessor interface
109  void onInitPointCloudProcessor() override;
110  void onConnectPointCloudProcessor() override;
111  void onDisconnectPointCloudProcessor() override;
112  void onExitPointCloudProcessor() override;
113  void process() override;
114 
115  private:
116  void setupEndEffectorSelection(VirtualRobot::RobotPtr robot);
117  void setupCameraNodeSlider(VirtualRobot::RobotPtr robot);
118  VirtualRobot::RobotPtr loadRobotFromFile() const;
119  std::string getProviderFrame() const;
120  void cropOriginalPointCloud(const pcl::PointCloud<PointT>& cloud, const VirtualRobot::EndEffectorPtr eef) const;
121  std::string formatTransformationMatrix(Eigen::Matrix4f mat, int decimalPlacesOrientation = 6, int decimalPlacesPosition = 2) const;
122  void enableGuiElements();
123  void disableGuiElements();
124  void updateManipulatorVisualization();
125  bool findStringIC(const std::string& strHaystack, const std::string& strNeedle) const;
126 
127  private slots:
128  void processPointCloud();
129  void activeEndEffectorChanged(QString endEffectorName);
130 
131  void slider_croppingRange_changed(int value);
132  void cb_croppingActive_changed(int state);
133  void cb_inverted_changed(bool checked);
134  void btn_copyToClipboard_pressed();
135  void btn_resetToModel_pressed();
136  void btn_backgroundColor_pressed();
137  void btn_pointCloudColor_pressed();
138  void sB_pointSize_changed(int value);
139 
140  void cameraNodeTransformationChanged(double value);
141 
142  void connectQt();
143  void disconnectQt();
144  void initUI();
145  void saveDatapoint();
146  void selectFile();
147 
148  signals:
149  void pointCloudUpdated();
150 
151  private:
152  QPointer<QWidget> m_widget;
153 
154  /**
155  * Widget Form
156  */
157  Ui::HandEyeCalibrationWidget widget;
158  QPointer<SimpleConfigDialog> dialog;
159 
160  std::string providerName;
161  visionx::PointCloudProviderInfo providerInfo;
162  std::string referenceFrame;
163  pcl::PointCloud<PointT>::Ptr providerBuffer;
164 
165  // PointCloudVisualization
166  PointCloudVisualization* pointCloudVisu;
167  bool showPointCloud;
168  // ManipulatorVisualization
169  ManipulatorVisualization* manipulatorVisu;
170 
171  std::string robotStateComponentName;
172  RobotStateComponentInterfacePrx robotStateComponentPrx;
173  VirtualRobot::RobotPtr localRobot;
174  VirtualRobot::RobotPtr pointcloudRobot;
175 
176  VirtualRobot::EndEffectorPtr activeEndEffector;
177  std::map<std::string, std::pair<VirtualRobot::RobotPtr, Eigen::Matrix4f>> robotEEFMap;
178  VirtualRobot::RobotPtr getEEFRobot(VirtualRobot::EndEffectorPtr eef) const;
179  Eigen::Matrix4f getOffsetMatrixForEEF(const VirtualRobot::EndEffectorPtr eef) const; // OffsetMatrix is stored from Model to Pointcloud
180  void setOffsetMatrixForEEF(const VirtualRobot::EndEffectorPtr eef, const Eigen::Matrix4f& offset);
181 
182  bool croppingActive = true;
183 
185  void taskEEFManipulationCB();
187  void taskLocalRobotUpdateCB();
188 
189  // Color Dialog
190  QColorDialog colorDialog;
191 
192  VirtualRobot::RobotNodePtr cameraNode;
193 
194  };
195 }
196 
197 
ManipulatorVisualization.h
armarx::PointCloudVisualization
Definition: PointCloudVisualization.h:37
PeriodicTask.h
PointCloudProvider.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
visionx::PointCloudProviderInfo
Definition: PointCloudProcessor.h:83
ArmarXGuiPlugin.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
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:186
armarx::HandEyeCalibrationWidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: HandEyeCalibrationWidgetController.h:101
PointCloudProcessor.h
PointCloudVisualization.h
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
IceUtil::Handle
Definition: forward_declarations.h:29
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::ManipulatorVisualization
Definition: ManipulatorVisualization.h:51
armarx::HandEyeCalibrationWidgetController
HandEyeCalibrationWidgetController brief one line description.
Definition: HandEyeCalibrationWidgetController.h:69
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ImportExportComponent.h