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
43namespace 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,
62 {
63 using RobotState = RobotStateComponentPluginUser;
64
65 public:
66 /// @see armarx::ManagedIceObject::getDefaultName()
67 std::string getDefaultName() const override;
68 static std::string GetDefaultName();
69
70
71 protected:
72 /// @see armarx::ManagedIceObject::onInitComponent()
73 void onInitComponent() override;
74
75 /// @see armarx::ManagedIceObject::onConnectComponent()
76 void onConnectComponent() override;
77
78 /// @see armarx::ManagedIceObject::onDisconnectComponent()
79 void onDisconnectComponent() override;
80
81 /// @see armarx::ManagedIceObject::onExitComponent()
82 void onExitComponent() override;
83
84 /// @see PropertyUser::createPropertyDefinitions()
86
87
88 void createRemoteGuiTab();
89 void RemoteGui_update() override;
90
91
92 private:
93 void run();
94 void onLocalizationResult(const Eigen::Matrix4f& markerPoseInCamera);
95 void storeCalibration();
96
97
98 private:
99 visionx::ArMarkerLocalizerInterfacePrx localizer;
100 int localizerMarkerID = -1;
101
103
104
105 // Robot
106
107 std::string robotArMarkerFileName =
108 "VisionX/external-camera-calibration/Camera_ArMarker.xml";
109
110 VirtualRobot::RobotPtr robotArMarker;
111
112 std::string robotBaseNodeName = "Camera_ArMarker_Base";
113 std::string robotArMarkerMarkerNodeName = "ArMarker_Marker";
114
115
116 // Calibration data
117 std::mutex markerPoseMutex;
118 /// The marker pose in camera frame.
119 Eigen::Matrix4f markerPoseInCamera = Eigen::Matrix4f::Identity();
120 Eigen::Matrix4f cameraPoseInRobotBase = Eigen::Matrix4f::Identity();
121 std::string calibrationFilePath = "VisionX/external-camera-calibration/calibration.json";
122
123
124 // Remote Gui
125 private:
127 {
129 };
130
131 Tab tab;
132
133
134 // Visu
135 private:
136 struct Visu
137 {
138 viz::Layer layerCamera;
139 viz::Pose markerPoseInCamera = viz::Pose("Marker_Camera");
140
141 viz::Layer layerRobotBase;
142 viz::Pose markerPoseInRobotBase = viz::Pose("Marker_RobotBase");
143 viz::Pose cameraPoseInRobotBase = viz::Pose("Camera_RobotBase");
144 viz::Pose markerModelInRobotBase = viz::Pose("MarkerModel_RobotBase");
145
146 visionx::PointCloudToArVizInterfacePrx pointCloudToArViz;
147 };
148
149 Visu vis;
150 };
151} // namespace armarx
Brief description of class ArMarkerExternalCameraCalibration.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Provides a ready-to-use ArViz client arviz as member variable.
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.