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 static std::string GetDefaultName();
87 std::string getDefaultName() const override;
88
89 virtual void setPointSizeInPixels(float pointSizeInPixels,
90 const Ice::Current& = Ice::emptyCurrent) override;
91 virtual void setCustomTransform(const armarx::PoseBasePtr& transform,
92 const Ice::Current& = Ice::emptyCurrent) override;
93
94
95 protected:
96 /// @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
97 void onInitPointCloudProcessor() override;
98
99 /// @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
100 void onConnectPointCloudProcessor() override;
101
102 /// @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
103 void onDisconnectPointCloudProcessor() override;
104
105 /// @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
106 void onExitPointCloudProcessor() override;
107
108
109 /// @see visionx::PointCloudProcessor::process()
110 void process() override;
111
112
113 /// @see PropertyUser::createPropertyDefinitions()
115
116
117 // LightweightRemoteGuiComponentPluginUser interface
118 public:
119 void createRemoteGuiTab();
120 void RemoteGui_update() override;
121
122
123 private:
124 struct Parameters
125 {
126 /// Time waiting for each provider before timeout.
127 IceUtil::Time providerWaitTime = IceUtil::Time::milliSeconds(100);
128
129 /// Whether to check whether points are finite.
130 bool checkFinite = false;
131
132 /// The point size in pixels.
133 float pointSizeInPixels = 1;
134
135 /// If true and point cloud is labeled, draw colors according to labels.
136 bool labeled = false;
137
138 /// An optional custom transform to apply to the point cloud.
139 // std::optional<Eigen::Matrix4f> customTransform;
140
141 /// Show coordinate system of node in ArViz
142 bool alsoVisualizeNode = false;
143
144 /// The robot name to use
145 std::string robotName = "Armar6";
146
147 // If the point cloud header does not provide a frame id, this info is used.
148 std::string pointCloudNodeName;
149 };
150
151 std::mutex paramMutex;
152 Parameters params;
153
154 struct OriginInfo
155 {
156 std::string name;
157 Eigen::Matrix4f pose;
158 };
159
160 template <class PointT>
161 std::optional<OriginInfo> applyCustomTransform(pcl::PointCloud<PointT>& pointCloud);
162
163
164 /// Cache of constructed and allocated `viz::PointCloud` instances.
165 std::map<std::string, armarx::viz::PointCloud> cache;
166
167 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
168 {
172
173 armarx::RemoteGui::Client::ComboBox localTransformationNode;
174 std::vector<armarx::RemoteGui::Client::FloatSpinBox> transfSpinBoxes;
175 };
176
177 RemoteGuiTab tab;
178
179
181 armarx::armem::robot_state::VirtualRobotReader>* virtualRobotReaderPlugin = nullptr;
182
184
185 std::string localTransformationNodeName;
186 std::mutex robotMutex;
187 };
188} // 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
static std::string GetDefaultName()
void onInitPointCloudProcessor() override
std::string getDefaultName() const override
Retrieve default name of component.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.