PointCloudToArViz.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 VisionX::ArmarXObjects::PointCloudToArViz
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 <map>
26#include <mutex>
27#include <optional>
28
29#include <VirtualRobot/VirtualRobot.h>
30
32
34
39
40// The has_member macro from
41// > simox/SimoxUtility/meta/has_member_macros/has_member.hpp
42// breaks compilation here if boost thread is not already included
43#ifdef has_member
44#undef has_member
45#endif
46
48#include <VisionX/interface/components/PointCloudToArViz.h>
49
50namespace visionx
51{
52
53 /**
54 * @class PointCloudToArVizPropertyDefinitions
55 * @brief Property definitions of `PointCloudToArViz`.
56 */
63
64 /**
65 * @defgroup Component-PointCloudToArViz PointCloudToArViz
66 * @ingroup VisionX-Components
67 *
68 * This point cloud processor draws the specified components to ArViz.
69 *
70 * @class PointCloudToArViz
71 * @ingroup Component-PointCloudToArViz
72 * @brief Brief description of class PointCloudToArViz.
73 *
74 * Detailed description of class PointCloudToArViz.
75 */
77 virtual public visionx::PointCloudToArVizInterface,
78 virtual public visionx::PointCloudProcessor,
81 {
82 public:
84
85 /// @see armarx::ManagedIceObject::getDefaultName()
86 std::string getDefaultName() const override;
87
88 virtual void setPointSizeInPixels(float pointSizeInPixels,
89 const Ice::Current& = Ice::emptyCurrent) override;
90 virtual void setCustomTransform(const armarx::PoseBasePtr& transform,
91 const Ice::Current& = Ice::emptyCurrent) override;
92
93
94 protected:
95 /// @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
96 void onInitPointCloudProcessor() override;
97
98 /// @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
99 void onConnectPointCloudProcessor() override;
100
101 /// @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
102 void onDisconnectPointCloudProcessor() override;
103
104 /// @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
105 void onExitPointCloudProcessor() override;
106
107
108 /// @see visionx::PointCloudProcessor::process()
109 void process() override;
110
111
112 /// @see PropertyUser::createPropertyDefinitions()
114
115
116 // LightweightRemoteGuiComponentPluginUser interface
117 public:
118 void createRemoteGuiTab();
119 void RemoteGui_update() override;
120
121
122 private:
123 struct Parameters
124 {
125 /// Time waiting for each provider before timeout.
126 IceUtil::Time providerWaitTime = IceUtil::Time::milliSeconds(100);
127
128 /// Whether to check whether points are finite.
129 bool checkFinite = false;
130
131 /// The point size in pixels.
132 float pointSizeInPixels = 1;
133
134 /// If true and point cloud is labeled, draw colors according to labels.
135 bool labeled = false;
136
137 /// An optional custom transform to apply to the point cloud.
138 // std::optional<Eigen::Matrix4f> customTransform;
139
140 /// Show coordinate system of node in ArViz
141 bool alsoVisualizeNode = false;
142
143 /// The robot name to use
144 std::string robotName = "Armar6";
145
146 // If the point cloud header does not provide a frame id, this info is used.
147 std::string pointCloudNodeName;
148 };
149
150 std::mutex paramMutex;
151 Parameters params;
152
153 struct OriginInfo
154 {
155 std::string name;
156 Eigen::Matrix4f pose;
157 };
158
159 template <class PointT>
160 std::optional<OriginInfo> applyCustomTransform(pcl::PointCloud<PointT>& pointCloud);
161
162
163 /// Cache of constructed and allocated `viz::PointCloud` instances.
164 std::map<std::string, armarx::viz::PointCloud> cache;
165
166 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
167 {
171
172 armarx::RemoteGui::Client::ComboBox localTransformationNode;
173 std::vector<armarx::RemoteGui::Client::FloatSpinBox> transfSpinBoxes;
174 };
175
176 RemoteGuiTab tab;
177
178
180 armarx::armem::robot_state::VirtualRobotReader>* virtualRobotReaderPlugin = nullptr;
181
183
184 std::string localTransformationNodeName;
185 std::mutex robotMutex;
186 };
187} // namespace visionx
Provides a ready-to-use ArViz client arviz as member variable.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
virtual void setPointSizeInPixels(float pointSizeInPixels, const Ice::Current &=Ice::emptyCurrent) override
virtual void setCustomTransform(const armarx::PoseBasePtr &transform, const Ice::Current &=Ice::emptyCurrent) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onExitPointCloudProcessor() override
void onConnectPointCloudProcessor() override
void onDisconnectPointCloudProcessor() override
void onInitPointCloudProcessor() override
std::string getDefaultName() const override
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.