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