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
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:
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
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.