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
27namespace 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
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 {
68 }
69 }
70
71 void
75
76 void
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;
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.
113 provideResultPointClouds(merged.getResultPointCloud());
114 }
115
122
123} // namespace visionx
TopicProxyType getTopicFromProperty(const std::string &propertyName)
Get a topic proxy whose name is specified by the given property.
Definition Component.h:221
void offeringTopicFromProperty(const std::string &propertyName)
Offer a topic whose name is specified by the given property.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Property definitions of LabeledPointCloudMerger.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
void enableResultPointCloudForInputProvider(const std::string &inputProviderName, const std::string &resultProviderName="")
int getPointClouds(const PointCloudPtrT &pointCloudPtr)
Poll PointClouds from provider.
MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName)
bool waitForPointClouds(int milliseconds=1000)
Wait for new PointClouds.
void provideResultPointClouds(const PointCloudPtrT &pointClouds, std::string providerName="")
sends result PointClouds for visualization
std::vector< std::string > getPointCloudProviderNames() const
Get the names of providers for which usingPointCloudProvider() has been called.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
bool isLabeled(PointContentType type)
ArmarX headers.