LabeledPointCloudMerger.cpp
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::LabeledPointCloudMerger
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2019
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
26 
27 
28 namespace visionx
29 {
30 
33  {
34  defineOptionalProperty<std::string>("ice.DebugObserverName", "DebugObserver",
35  "Name of the topic the DebugObserver listens to.");
36 
37  defineOptionalProperty<int>("ProviderWaitMs", 100,
38  "Time to wait for each point cloud provider [ms].");
39  }
40 
41 
43  {
44  return "LabeledPointCloudMerger";
45  }
46 
47 
49  {
50  offeringTopicFromProperty("ice.DebugObserverName");
51  // debugDrawer.offeringTopic(*this); // Calls this->offeringTopic().
52 
53  providerWaitTime = IceUtil::Time::milliSeconds(getProperty<int>("ProviderWaitMs").getValue());
54  }
55 
56 
58  {
59  getTopicFromProperty(debugObserver, "ice.DebugObserverName");
60  // debugDrawer.getTopic(*this); // Calls this->getTopic().
61 
62  const std::vector<std::string> providerNames = getPointCloudProviderNames();
63  if (!providerNames.empty())
64  {
65  enableResultPointCloudForInputProvider<PointT>(providerNames.front());
66  }
67  }
68 
69 
71  {
72  }
73 
75  {
76  }
77 
78 
80  {
81  // Fetch input clouds.
82  for (const auto& providerName : getPointCloudProviderNames())
83  {
84  if (waitForPointClouds(providerName, static_cast<int>(providerWaitTime.toMilliSeconds())))
85  {
86  const PointContentType type = getPointCloudFormat(providerName)->type;
87  if (visionx::tools::isLabeled(type))
88  {
89  pcl::PointCloud<MergedLabeledPointCloud::PointL>::Ptr inputCloud(
90  new pcl::PointCloud<MergedLabeledPointCloud::PointL>);
91  getPointClouds(providerName, inputCloud);
92  merged.setInputPointCloud(providerName, inputCloud, true);
93  }
94  else
95  {
96  pcl::PointCloud<MergedLabeledPointCloud::PointT>::Ptr inputCloud(
97  new pcl::PointCloud<MergedLabeledPointCloud::PointT>);
98  getPointClouds(providerName, inputCloud);
99  merged.setInputPointCloud(providerName, inputCloud);
100  }
101  }
102  else
103  {
104  ARMARX_INFO << "Timeout waiting for point cloud provider " << providerName << ".";
105  }
106  }
107 
108  // Publish result cloud.
110  }
111 
112 
114  {
117  }
118 
119 }
visionx::PointCloudProcessor::getPointCloudFormat
MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName)
Definition: PointCloudProcessor.cpp:506
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::LabeledPointCloudMerger::onInitPointCloudProcessor
void onInitPointCloudProcessor() override
Definition: LabeledPointCloudMerger.cpp:48
LabeledPointCloudMerger.h
Pose.h
visionx::LabeledPointCloudMerger::onConnectPointCloudProcessor
void onConnectPointCloudProcessor() override
Definition: LabeledPointCloudMerger.cpp:57
armarx::Component::offeringTopicFromProperty
void offeringTopicFromProperty(const std::string &propertyName)
Offer a topic whose name is specified by the given property.
Definition: Component.cpp:154
visionx::tools::isLabeled
bool isLabeled(PointContentType type)
Definition: PointCloudConversions.cpp:108
visionx::LabeledPointCloudMerger::process
void process() override
Definition: LabeledPointCloudMerger.cpp:79
visionx::LabeledPointCloudMergerPropertyDefinitions::LabeledPointCloudMergerPropertyDefinitions
LabeledPointCloudMergerPropertyDefinitions(std::string prefix)
Definition: LabeledPointCloudMerger.cpp:31
armarx::Component::getTopicFromProperty
TopicProxyType getTopicFromProperty(const std::string &propertyName)
Get a topic proxy whose name is specified by the given property.
Definition: Component.h:218
visionx::LabeledPointCloudMerger::onDisconnectPointCloudProcessor
void onDisconnectPointCloudProcessor() override
Definition: LabeledPointCloudMerger.cpp:70
visionx::PointCloudProcessor::provideResultPointClouds
void provideResultPointClouds(const PointCloudPtrT &pointClouds, std::string providerName="")
sends result PointClouds for visualization
Definition: PointCloudProcessor.h:286
visionx::LabeledPointCloudMergerPropertyDefinitions
Property definitions of LabeledPointCloudMerger.
Definition: LabeledPointCloudMerger.h:46
visionx::MergedLabeledPointCloud::setInputPointCloud
void setInputPointCloud(const std::string &name, pcl::PointCloud< PointL >::ConstPtr inputCloud, bool isLabeled=true)
Set a (new) labeled or unlabeled input point cloud.
Definition: MergedLabeledPointCloud.cpp:40
visionx::PointCloudProcessor::waitForPointClouds
bool waitForPointClouds(int milliseconds=1000)
Wait for new PointClouds.
Definition: PointCloudProcessor.cpp:433
visionx::PointCloudProcessorPropertyDefinitions
Properties of PointCloudProcessor.
Definition: PointCloudProcessor.h:173
visionx::PointCloudProcessor::getPointClouds
int getPointClouds(const PointCloudPtrT &pointCloudPtr)
Poll PointClouds from provider.
Definition: PointCloudProcessor.h:373
visionx::LabeledPointCloudMerger::onExitPointCloudProcessor
void onExitPointCloudProcessor() override
Definition: LabeledPointCloudMerger.cpp:74
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
visionx::LabeledPointCloudMerger::getDefaultName
std::string getDefaultName() const override
Definition: LabeledPointCloudMerger.cpp:42
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::LabeledPointCloudMerger::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: LabeledPointCloudMerger.cpp:113
visionx::MergedLabeledPointCloud::getResultPointCloud
pcl::PointCloud< PointL >::Ptr getResultPointCloud()
Get the result point cloud.
Definition: MergedLabeledPointCloud.cpp:82
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
visionx::PointCloudProcessor::getPointCloudProviderNames
std::vector< std::string > getPointCloudProviderNames() const
Get the names of providers for which usingPointCloudProvider() has been called.
Definition: PointCloudProcessor.cpp:381