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
28
29namespace visionx
30{
31
33 std::string prefix) :
35 {
36 defineOptionalProperty<std::string>("ice.DebugObserverName",
37 "DebugObserver",
38 "Name of the topic the DebugObserver listens to.");
39
41 "ProviderWaitMs", 100, "Time to wait for each point cloud provider [ms].");
42 }
43
44 std::string
49
50 std::string
52 {
53 return "LabeledPointCloudMerger";
54 }
55
56 void
58 {
59 offeringTopicFromProperty("ice.DebugObserverName");
60 // debugDrawer.offeringTopic(*this); // Calls this->offeringTopic().
61
62 providerWaitTime =
63 IceUtil::Time::milliSeconds(getProperty<int>("ProviderWaitMs").getValue());
64 }
65
66 void
68 {
69 getTopicFromProperty(debugObserver, "ice.DebugObserverName");
70 // debugDrawer.getTopic(*this); // Calls this->getTopic().
71
72 const std::vector<std::string> providerNames = getPointCloudProviderNames();
73 if (!providerNames.empty())
74 {
76 }
77 }
78
79 void
83
84 void
88
89 void
91 {
92 // Fetch input clouds.
93 for (const auto& providerName : getPointCloudProviderNames())
94 {
95 if (waitForPointClouds(providerName,
96 static_cast<int>(providerWaitTime.toMilliSeconds())))
97 {
98 const PointContentType type = getPointCloudFormat(providerName)->type;
100 {
101 pcl::PointCloud<MergedLabeledPointCloud::PointL>::Ptr inputCloud(
102 new pcl::PointCloud<MergedLabeledPointCloud::PointL>);
103 getPointClouds(providerName, inputCloud);
104 merged.setInputPointCloud(providerName, inputCloud, true);
105 }
106 else
107 {
108 pcl::PointCloud<MergedLabeledPointCloud::PointT>::Ptr inputCloud(
109 new pcl::PointCloud<MergedLabeledPointCloud::PointT>);
110 getPointClouds(providerName, inputCloud);
111 merged.setInputPointCloud(providerName, inputCloud);
112 }
113 }
114 else
115 {
116 ARMARX_INFO << "Timeout waiting for point cloud provider " << providerName << ".";
117 }
118 }
119
120 // Publish result cloud.
121 provideResultPointClouds(merged.getResultPointCloud());
122 }
123
130
133
134} // namespace visionx
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Definition Decoupled.h:29
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.
Brief description of class 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.