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 
50 namespace visionx
51 {
52 
53  /**
54  * @class PointCloudToArVizPropertyDefinitions
55  * @brief Property definitions of `PointCloudToArViz`.
56  */
59  {
60  public:
62  };
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,
79  virtual public armarx::ArVizComponentPluginUser,
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  {
169  armarx::RemoteGui::Client::FloatSpinBox pointSizeInPixels;
171  };
172 
173  RemoteGuiTab tab;
174 
175 
177  armarx::armem::robot_state::VirtualRobotReader>* virtualRobotReaderPlugin = nullptr;
178 
180  };
181 } // namespace visionx
ArVizComponentPlugin.h
armarx::armem::robot_state::VirtualRobotReader
The VirtualRobotReader class.
Definition: VirtualRobotReader.h:40
visionx::PointCloudToArViz::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PointCloudToArViz.cpp:48
visionx::PointCloudToArViz::setPointSizeInPixels
virtual void setPointSizeInPixels(float pointSizeInPixels, const Ice::Current &=Ice::emptyCurrent) override
Definition: PointCloudToArViz.cpp:183
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::PointCloudToArViz::process
void process() override
Definition: PointCloudToArViz.cpp:118
visionx::PointCloudToArVizPropertyDefinitions
Property definitions of PointCloudToArViz.
Definition: PointCloudToArViz.h:57
armarx::armem::client::plugins::ReaderWriterPlugin
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
Definition: ReaderWriterPlugin.h:44
armarx::RemoteGui::Client::Tab
Definition: Tab.h:15
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
ReaderWriterPlugin.h
visionx::PointCloudToArVizPropertyDefinitions::PointCloudToArVizPropertyDefinitions
PointCloudToArVizPropertyDefinitions(std::string prefix)
Definition: PointCloudToArViz.cpp:40
LightweightRemoteGuiComponentPlugin.h
visionx::PointCloudToArViz::PointCloudToArViz
PointCloudToArViz()
Definition: PointCloudToArViz.cpp:76
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:186
visionx::PointCloudToArViz::RemoteGui_update
void RemoteGui_update() override
Definition: PointCloudToArViz.cpp:297
VirtualRobotReader.h
visionx::PointCloudToArViz::getDefaultName
std::string getDefaultName() const override
Definition: PointCloudToArViz.cpp:82
visionx::PointCloudToArViz::onDisconnectPointCloudProcessor
void onDisconnectPointCloudProcessor() override
Definition: PointCloudToArViz.cpp:108
visionx::PointCloudProcessorPropertyDefinitions
Properties of PointCloudProcessor.
Definition: PointCloudProcessor.h:173
PointCloudProcessor.h
armarx::LightweightRemoteGuiComponentPluginUser
Definition: LightweightRemoteGuiComponentPlugin.h:73
plugins.h
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
Component.h
visionx::PointCloudToArViz::onInitPointCloudProcessor
void onInitPointCloudProcessor() override
Definition: PointCloudToArViz.cpp:88
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
visionx::PointCloudToArViz
Brief description of class PointCloudToArViz.
Definition: PointCloudToArViz.h:76
visionx::PointCloudToArViz::createRemoteGuiTab
void createRemoteGuiTab()
Definition: PointCloudToArViz.cpp:265
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:315
armarx::RemoteGui::Client::CheckBox
Definition: Widgets.h:129
visionx::PointCloudToArViz::onConnectPointCloudProcessor
void onConnectPointCloudProcessor() override
Definition: PointCloudToArViz.cpp:95
visionx::PointCloudToArViz::onExitPointCloudProcessor
void onExitPointCloudProcessor() override
Definition: PointCloudToArViz.cpp:113
armarx::RemoteGui::Client::FloatSpinBox
Definition: Widgets.h:93
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
visionx::PointCloudToArViz::setCustomTransform
virtual void setCustomTransform(const armarx::PoseBasePtr &transform, const Ice::Current &=Ice::emptyCurrent) override
Definition: PointCloudToArViz.cpp:190