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 
31 #include <ArmarXCore/interface/observers/ObserverInterface.h>
32 
34 
37 
38 #include <VisionX/interface/components/ArMarkerLocalizerInterface.h>
39 #include <VisionX/interface/components/PointCloudToArViz.h>
40 
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  /// @see armarx::ManagedIceObject::getDefaultName()
67  std::string getDefaultName() const override;
68 
69 
70  protected:
71  /// @see armarx::ManagedIceObject::onInitComponent()
72  void onInitComponent() override;
73 
74  /// @see armarx::ManagedIceObject::onConnectComponent()
75  void onConnectComponent() override;
76 
77  /// @see armarx::ManagedIceObject::onDisconnectComponent()
78  void onDisconnectComponent() override;
79 
80  /// @see armarx::ManagedIceObject::onExitComponent()
81  void onExitComponent() override;
82 
83  /// @see PropertyUser::createPropertyDefinitions()
85 
86 
87  void createRemoteGuiTab();
88  void RemoteGui_update() override;
89 
90 
91  private:
92  void run();
93  void onLocalizationResult(const Eigen::Matrix4f& markerPoseInCamera);
94  void storeCalibration();
95 
96 
97  private:
98  visionx::ArMarkerLocalizerInterfacePrx localizer;
99  int localizerMarkerID = -1;
100 
102 
103 
104  // Robot
105 
106  std::string robotArMarkerFileName =
107  "VisionX/external-camera-calibration/Camera_ArMarker.xml";
108 
109  VirtualRobot::RobotPtr robotArMarker;
110 
111  std::string robotBaseNodeName = "Camera_ArMarker_Base";
112  std::string robotArMarkerMarkerNodeName = "ArMarker_Marker";
113 
114 
115  // Calibration data
116  std::mutex markerPoseMutex;
117  /// The marker pose in camera frame.
118  Eigen::Matrix4f markerPoseInCamera = Eigen::Matrix4f::Identity();
119  Eigen::Matrix4f cameraPoseInRobotBase = Eigen::Matrix4f::Identity();
120  std::string calibrationFilePath = "VisionX/external-camera-calibration/calibration.json";
121 
122 
123  // Remote Gui
124  private:
125  struct Tab : armarx::RemoteGui::Client::Tab
126  {
128  };
129 
130  Tab tab;
131 
132 
133  // Visu
134  private:
135  struct Visu
136  {
137  viz::Layer layerCamera;
138  viz::Pose markerPoseInCamera = viz::Pose("Marker_Camera");
139 
140  viz::Layer layerRobotBase;
141  viz::Pose markerPoseInRobotBase = viz::Pose("Marker_RobotBase");
142  viz::Pose cameraPoseInRobotBase = viz::Pose("Camera_RobotBase");
143  viz::Pose markerModelInRobotBase = viz::Pose("MarkerModel_RobotBase");
144 
145  visionx::PointCloudToArVizInterfacePrx pointCloudToArViz;
146  };
147 
148  Visu vis;
149  };
150 } // namespace armarx
ArVizComponentPlugin.h
RobotStateComponentPlugin.h
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::ArMarkerExternalCameraCalibration
Brief description of class ArMarkerExternalCameraCalibration.
Definition: ArMarkerExternalCameraCalibration.h:57
armarx::ArMarkerExternalCameraCalibration::getDefaultName
std::string getDefaultName() const override
Definition: ArMarkerExternalCameraCalibration.cpp:67
armarx::RemoteGui::Client::Tab
Definition: Tab.h:15
armarx::ArMarkerExternalCameraCalibration::RemoteGui_update
void RemoteGui_update() override
Definition: ArMarkerExternalCameraCalibration.cpp:273
LightweightRemoteGuiComponentPlugin.h
armarx::ArMarkerExternalCameraCalibration::onExitComponent
void onExitComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:134
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:35
armarx::ArMarkerExternalCameraCalibration::createRemoteGuiTab
void createRemoteGuiTab()
Definition: ArMarkerExternalCameraCalibration.cpp:262
armarx::ArMarkerExternalCameraCalibration::onConnectComponent
void onConnectComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:93
armarx::RobotStateComponentPluginUser::RobotStateComponentPluginUser
RobotStateComponentPluginUser()
Definition: RobotStateComponentPlugin.cpp:369
armarx::viz::Pose
Definition: Elements.h:178
TaskUtil.h
armarx::LightweightRemoteGuiComponentPluginUser
Definition: LightweightRemoteGuiComponentPlugin.h:72
armarx::ArMarkerExternalCameraCalibration::onInitComponent
void onInitComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:73
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::ArMarkerExternalCameraCalibration::onDisconnectComponent
void onDisconnectComponent() override
Definition: ArMarkerExternalCameraCalibration.cpp:127
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:165
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