PointCloudVisualization.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::PointCloudVisualization
17  * @author Peter Kaiser ( peter dot kaiser at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
27 
28 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
29 
30 #include <VisionX/interface/core/PointCloudProviderInterface.h>
31 #include <VisionX/interface/core/DataTypes.h>
32 #include <VisionX/interface/components/PointCloudVisualization.h>
34 
35 #include <memory>
36 #include <mutex>
37 
38 namespace visionx
39 {
40  class PointCloudVisualization;
41 
42  // Wrapper object used to monitor one provider and call a parameterized callback in the main component
44  {
45  public:
48 
50  void stop();
51 
52  protected:
53  std::string providerName;
56  };
57 
58  using PointCloudVisualizationHandlerPtr = std::shared_ptr<PointCloudVisualizationHandler>;
59 
60 
61  /**
62  * @class PointCloudVisualizationPropertyDefinitions
63  * @brief
64  */
67  {
68  public:
71  {
72  defineOptionalProperty<std::string>("PointCloudProviders", "", "Comma-separated list of point cloud provider names");
73  defineOptionalProperty<std::string>("InitiallyDisabledVisualizations", "", "Comma-separated list of point cloud provider names, which should not be visualized by default");
74  defineOptionalProperty<std::string>("DebugDrawerTopicName", "DebugDrawerUpdates", "Name of the debug drawer topic");
75  defineOptionalProperty<std::string>("DefaultVisualizationType", "Plain", "Default point cloud visualization type.");
76  }
77  };
78 
79  using DebugDrawerPointCloudPtr = std::shared_ptr<armarx::DebugDrawer24BitColoredPointCloud>;
80  using PointCloudVisualizationCollection = std::map<visionx::PointContentType, DebugDrawerPointCloudPtr>;
81 
82  /**
83  * @defgroup Component-PointCloudVisualization PointCloudVisualization
84  * @ingroup VisionX-Components
85  * A description of the component PointCloudVisualization.
86  *
87  * @class PointCloudVisualization
88  * @ingroup Component-PointCloudVisualization
89  * @brief Brief description of class PointCloudVisualization.
90  *
91  * Detailed description of class PointCloudVisualization.
92  */
94  virtual public PointCloudVisualizationInterface,
95  virtual public PointCloudProcessor
96  {
97  public:
98  /**
99  * @see armarx::ManagedIceObject::getDefaultName()
100  */
101  std::string getDefaultName() const override
102  {
103  return "PointCloudVisualization";
104  }
105 
106  void processPointCloudProvider(const std::string& providerName);
107 
108  template<typename PointT>
109  void processPointCloud(const std::string& providerName);
110 
111  bool waitForNewPointCloud(const std::string& providerName);
112 
113  PointCloudProviderVisualizationInfoList getAvailableProviders(const Ice::Current& c = Ice::emptyCurrent) override;
114  void enablePointCloudVisualization(const std::string& providerName, visionx::PointContentType type, bool enable, const Ice::Current& c = Ice::emptyCurrent) override;
115  PointCloudVisualizationInfo getCurrentPointCloudVisualizationInfo(const std::string& providerName, const Ice::Current& c = Ice::emptyCurrent) override;
116 
117  protected:
118  /**
119  * @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
120  */
121  void onInitPointCloudProcessor() override;
122 
123  /**
124  * @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
125  */
126  void onConnectPointCloudProcessor() override;
127 
128  /**
129  * @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
130  */
131  void onDisconnectPointCloudProcessor() override;
132 
133  /**
134  * @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
135  */
136  void onExitPointCloudProcessor() override;
137 
138  /**
139  * @see visionx::PointCloudProcessor::process()
140  */
141  void process() override;
142 
143  /**
144  * @see PropertyUser::createPropertyDefinitions()
145  */
147 
148  protected:
149  void updateVisualization(const std::string& providerName);
150  void clearAllLayers();
151  std::string pointCloudTypeToText(visionx::PointContentType type);
152  visionx::PointContentType pointCloudTextToType(std::string text);
153 
154  protected:
156 
157  std::vector<std::string> providerNames;
158  std::map<std::string, visionx::MetaPointCloudFormatPtr> pointCloudFormats;
159  std::map<std::string, PointCloudVisualizationHandlerPtr> providerHandlers;
160  std::map<std::string, visionx::PointContentType> visualizationTypes;
161  std::map<std::string, bool> enabledFlags;
162 
163  std::map<std::string, PointCloudVisualizationCollection> visualizations;
164 
165  std::map<std::string, int> debugDrawerVisualizationIteration;
166 
167  std::mutex pointCloudMutex;
168  };
169 }
170 
visionx::PointCloudVisualization::visualizations
std::map< std::string, PointCloudVisualizationCollection > visualizations
Definition: PointCloudVisualization.h:163
visionx::PointCloudVisualization::processPointCloud
void processPointCloud(const std::string &providerName)
Definition: PointCloudVisualization.cpp:71
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::PointCloudVisualizationPropertyDefinitions::PointCloudVisualizationPropertyDefinitions
PointCloudVisualizationPropertyDefinitions(std::string prefix)
Definition: PointCloudVisualization.h:69
visionx::PointCloudVisualization::debugDrawerVisualizationIteration
std::map< std::string, int > debugDrawerVisualizationIteration
Definition: PointCloudVisualization.h:165
visionx::DebugDrawerPointCloudPtr
std::shared_ptr< armarx::DebugDrawer24BitColoredPointCloud > DebugDrawerPointCloudPtr
Definition: PointCloudVisualization.h:79
visionx::PointCloudVisualizationHandler::processPointCloudProvider
void processPointCloudProvider()
Definition: PointCloudVisualization.cpp:44
visionx::PointCloudVisualizationCollection
std::map< visionx::PointContentType, DebugDrawerPointCloudPtr > PointCloudVisualizationCollection
Definition: PointCloudVisualization.h:80
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::PointCloudVisualization
Brief description of class PointCloudVisualization.
Definition: PointCloudVisualization.h:93
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
visionx::PointCloudVisualization::processPointCloudProvider
void processPointCloudProvider(const std::string &providerName)
Definition: PointCloudVisualization.cpp:111
visionx::PointCloudVisualizationHandler::providerName
std::string providerName
Definition: PointCloudVisualization.h:53
RunningTask.h
visionx::PointCloudVisualization::pointCloudTypeToText
std::string pointCloudTypeToText(visionx::PointContentType type)
Definition: PointCloudVisualization.cpp:297
visionx::PointCloudVisualization::onConnectPointCloudProcessor
void onConnectPointCloudProcessor() override
Definition: PointCloudVisualization.cpp:197
visionx::PointCloudVisualization::pointCloudMutex
std::mutex pointCloudMutex
Definition: PointCloudVisualization.h:167
visionx::PointCloudVisualizationHandler::PointCloudVisualizationHandler
PointCloudVisualizationHandler(PointCloudVisualization *component, const std::string &providerName)
Definition: PointCloudVisualization.cpp:31
visionx::PointCloudVisualizationHandler::task
armarx::RunningTask< PointCloudVisualizationHandler >::pointer_type task
Definition: PointCloudVisualization.h:55
visionx::PointCloudVisualization::getAvailableProviders
PointCloudProviderVisualizationInfoList getAvailableProviders(const Ice::Current &c=Ice::emptyCurrent) override
Definition: PointCloudVisualization.cpp:142
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:186
visionx::PointCloudVisualization::pointCloudTextToType
visionx::PointContentType pointCloudTextToType(std::string text)
Definition: PointCloudVisualization.cpp:315
visionx::PointCloudVisualization::enabledFlags
std::map< std::string, bool > enabledFlags
Definition: PointCloudVisualization.h:161
visionx::PointCloudVisualizationHandlerPtr
std::shared_ptr< PointCloudVisualizationHandler > PointCloudVisualizationHandlerPtr
Definition: PointCloudVisualization.h:58
visionx::PointCloudVisualizationHandler
Definition: PointCloudVisualization.h:43
visionx::PointCloudVisualization::updateVisualization
void updateVisualization(const std::string &providerName)
Definition: PointCloudVisualization.cpp:246
visionx::PointCloudVisualization::onExitPointCloudProcessor
void onExitPointCloudProcessor() override
Definition: PointCloudVisualization.cpp:232
visionx::PointCloudVisualization::clearAllLayers
void clearAllLayers()
Definition: PointCloudVisualization.cpp:288
PointCloudProcessor.h
visionx::PointCloudVisualizationPropertyDefinitions
Definition: PointCloudVisualization.h:65
visionx::PointCloudVisualizationHandler::~PointCloudVisualizationHandler
~PointCloudVisualizationHandler()
Definition: PointCloudVisualization.cpp:39
visionx::PointCloudVisualization::onInitPointCloudProcessor
void onInitPointCloudProcessor() override
Definition: PointCloudVisualization.cpp:179
visionx::PointCloudVisualization::enablePointCloudVisualization
void enablePointCloudVisualization(const std::string &providerName, visionx::PointContentType type, bool enable, const Ice::Current &c=Ice::emptyCurrent) override
Definition: PointCloudVisualization.cpp:157
visionx::PointCloudVisualizationHandler::stop
void stop()
Definition: PointCloudVisualization.cpp:64
Component.h
visionx::PointCloudVisualization::waitForNewPointCloud
bool waitForNewPointCloud(const std::string &providerName)
Definition: PointCloudVisualization.cpp:137
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
visionx::PointCloudVisualizationHandler::component
PointCloudVisualization * component
Definition: PointCloudVisualization.h:54
visionx::PointCloudVisualization::debugDrawerTopicPrx
armarx::DebugDrawerInterfacePrx debugDrawerTopicPrx
Definition: PointCloudVisualization.h:155
IceUtil::Handle
Definition: forward_declarations.h:29
visionx::PointCloudVisualization::getCurrentPointCloudVisualizationInfo
PointCloudVisualizationInfo getCurrentPointCloudVisualizationInfo(const std::string &providerName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: PointCloudVisualization.cpp:174
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
visionx::PointCloudVisualization::providerHandlers
std::map< std::string, PointCloudVisualizationHandlerPtr > providerHandlers
Definition: PointCloudVisualization.h:159
visionx::PointCloudVisualization::pointCloudFormats
std::map< std::string, visionx::MetaPointCloudFormatPtr > pointCloudFormats
Definition: PointCloudVisualization.h:158
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
visionx::PointCloudVisualization::providerNames
std::vector< std::string > providerNames
Definition: PointCloudVisualization.h:157
visionx::PointCloudVisualization::process
void process() override
Definition: PointCloudVisualization.cpp:236
visionx::PointCloudVisualization::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PointCloudVisualization.cpp:241
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
visionx::PointCloudVisualization::visualizationTypes
std::map< std::string, visionx::PointContentType > visualizationTypes
Definition: PointCloudVisualization.h:160
visionx::PointCloudVisualization::getDefaultName
std::string getDefaultName() const override
Definition: PointCloudVisualization.h:101
visionx::PointCloudVisualization::onDisconnectPointCloudProcessor
void onDisconnectPointCloudProcessor() override
Definition: PointCloudVisualization.cpp:222