ArMarkerExternalCameraCalibration.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 Imagine::ArmarXObjects::ArMarkerExternalCameraCalibration
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <mutex>
26 
27 #include <VirtualRobot/Robot.h>
28 
30 
32 #include <ArmarXCore/interface/observers/ObserverInterface.h>
36 
37 #include <VisionX/interface/components/ArMarkerLocalizerInterface.h>
38 #include <VisionX/interface/components/PointCloudToArViz.h>
39 
41 
42 
43 namespace armarx
44 {
45 
46  /**
47  * @defgroup Component-ArMarkerExternalCameraCalibration ArMarkerExternalCameraCalibration
48  * @ingroup VisionX-Components
49  * A description of the component ArMarkerExternalCameraCalibration.
50  *
51  * @class ArMarkerExternalCameraCalibration
52  * @ingroup Component-ArMarkerExternalCameraCalibration
53  * @brief Brief description of class ArMarkerExternalCameraCalibration.
54  *
55  * Detailed description of class ArMarkerExternalCameraCalibration.
56  */
58  virtual public armarx::Component
60  , virtual public armarx::ArVizComponentPluginUser
62  {
64 
65  public:
66 
67  /// @see armarx::ManagedIceObject::getDefaultName()
68  std::string getDefaultName() const override;
69 
70 
71  protected:
72 
73  /// @see armarx::ManagedIceObject::onInitComponent()
74  void onInitComponent() override;
75 
76  /// @see armarx::ManagedIceObject::onConnectComponent()
77  void onConnectComponent() override;
78 
79  /// @see armarx::ManagedIceObject::onDisconnectComponent()
80  void onDisconnectComponent() override;
81 
82  /// @see armarx::ManagedIceObject::onExitComponent()
83  void onExitComponent() override;
84 
85  /// @see PropertyUser::createPropertyDefinitions()
87 
88 
89  void createRemoteGuiTab();
90  void RemoteGui_update() override;
91 
92 
93  private:
94 
95  void run();
96  void onLocalizationResult(const Eigen::Matrix4f& markerPoseInCamera);
97  void storeCalibration();
98 
99 
100  private:
101 
102  visionx::ArMarkerLocalizerInterfacePrx localizer;
103  int localizerMarkerID = -1;
104 
106 
107 
108  // Robot
109 
110  std::string robotArMarkerFileName = "VisionX/external-camera-calibration/Camera_ArMarker.xml";
111 
112  VirtualRobot::RobotPtr robotArMarker;
113 
114  std::string robotBaseNodeName = "Camera_ArMarker_Base";
115  std::string robotArMarkerMarkerNodeName = "ArMarker_Marker";
116 
117 
118  // Calibration data
119  std::mutex markerPoseMutex;
120  /// The marker pose in camera frame.
121  Eigen::Matrix4f markerPoseInCamera = Eigen::Matrix4f::Identity();
122  Eigen::Matrix4f cameraPoseInRobotBase = Eigen::Matrix4f::Identity();
123  std::string calibrationFilePath = "VisionX/external-camera-calibration/calibration.json";
124 
125 
126  // Remote Gui
127  private:
128 
129  struct Tab : armarx::RemoteGui::Client::Tab
130  {
132  };
133  Tab tab;
134 
135 
136  // Visu
137  private:
138 
139  struct Visu
140  {
141  viz::Layer layerCamera;
142  viz::Pose markerPoseInCamera = viz::Pose("Marker_Camera");
143 
144  viz::Layer layerRobotBase;
145  viz::Pose markerPoseInRobotBase = viz::Pose("Marker_RobotBase");
146  viz::Pose cameraPoseInRobotBase = viz::Pose("Camera_RobotBase");
147  viz::Pose markerModelInRobotBase = viz::Pose("MarkerModel_RobotBase");
148 
149  visionx::PointCloudToArVizInterfacePrx pointCloudToArViz;
150  };
151  Visu vis;
152 
153  };
154 }
ArVizComponentPlugin.h
RobotStateComponentPlugin.h
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::ArMarkerExternalCameraCalibration
Brief description of class ArMarkerExternalCameraCalibration.
Definition: ArMarkerExternalCameraCalibration.h:57
armarx::ArMarkerExternalCameraCalibration::getDefaultName
std::string getDefaultName() const override
Definition: ArMarkerExternalCameraCalibration.cpp:59
armarx::RemoteGui::Client::Tab
Definition: Tab.h:15
armarx::ArMarkerExternalCameraCalibration::RemoteGui_update
void RemoteGui_update() override
Definition: ArMarkerExternalCameraCalibration.cpp:258
LightweightRemoteGuiComponentPlugin.h
armarx::ArMarkerExternalCameraCalibration::onExitComponent
void onExitComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:129
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
armarx::ArMarkerExternalCameraCalibration::createRemoteGuiTab
void createRemoteGuiTab()
Definition: ArMarkerExternalCameraCalibration.cpp:248
armarx::ArMarkerExternalCameraCalibration::onConnectComponent
void onConnectComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:84
armarx::RobotStateComponentPluginUser::RobotStateComponentPluginUser
RobotStateComponentPluginUser()
Definition: RobotStateComponentPlugin.cpp:303
armarx::viz::Pose
Definition: Elements.h:179
TaskUtil.h
armarx::LightweightRemoteGuiComponentPluginUser
Definition: LightweightRemoteGuiComponentPlugin.h:73
armarx::ArMarkerExternalCameraCalibration::onInitComponent
void onInitComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:65
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ArMarkerExternalCameraCalibration::onDisconnectComponent
void onDisconnectComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:122
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ArMarkerExternalCameraCalibration::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: ArMarkerExternalCameraCalibration.cpp:41
armarx::RemoteGui::Client::Button
Definition: Widgets.h:120
ExternalCameraCalibration.h
armarx::viz::Layer
Definition: Layer.h:12
armarx::RobotStateComponentPluginUser
Definition: RobotStateComponentPlugin.h:167
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